static ImmutableSet splitGlobs()

in java/com/google/gerrit/plugins/codeowners/backend/findowners/FindOwnersCodeOwnerConfigParser.java [323:358]


    static ImmutableSet<String> splitGlobs(String commaSeparatedGlobs) {
      ImmutableSet.Builder<String> globList = ImmutableSet.builder();
      StringBuilder nextGlob = new StringBuilder();
      int curlyBracesIndentionLevel = 0;
      int squareBracesIndentionLevel = 0;
      for (int i = 0; i < commaSeparatedGlobs.length(); i++) {
        char c = commaSeparatedGlobs.charAt(i);
        if (c == ',') {
          if (curlyBracesIndentionLevel == 0 && squareBracesIndentionLevel == 0) {
            globList.add(nextGlob.toString());
            nextGlob = new StringBuilder();
          } else {
            nextGlob.append(c);
          }
        } else {
          nextGlob.append(c);
          if (c == '{') {
            curlyBracesIndentionLevel++;
          } else if (c == '}') {
            if (curlyBracesIndentionLevel > 0) {
              curlyBracesIndentionLevel--;
            }
          } else if (c == '[') {
            squareBracesIndentionLevel++;
          } else if (c == ']') {
            if (squareBracesIndentionLevel > 0) {
              squareBracesIndentionLevel--;
            }
          }
        }
      }
      if (nextGlob.length() > 0) {
        globList.add(nextGlob.toString());
      }
      return globList.build();
    }