void parseLine()

in src/main/java/com/googlesource/gerrit/plugins/findowners/Parser.java [328:376]


  void parseLine(Result result, String dir, String line, int num) {
    String email;
    String[] globsAndOwners;
    String[] parsedKPF; // parsed keyword, projectName, filePath
    if (isNoParent(line)) {
      result.stopLooking = true;
    } else if (isComment(line)) {
      // ignore comment and empty lines.
    } else if ((email = parseEmail(line)) != null) {
      Util.addToMap(result.owner2paths, email, dir); // here dir is not a glob
    } else if ((globsAndOwners = parsePerFile(line)) != null) {
      String[] dirGlobs = globsAndOwners[0].split(COMMA, -1);
      String directive = globsAndOwners[1];
      if (directive.equals(Parser.TOK_SET_NOPARENT)) {
        // per-file globs = set noparent
        for (String glob : dirGlobs) {
          result.noParentGlobs.add(dir + glob);
        }
      } else {
        List<String> ownerEmails;
        if ((parsedKPF = parseInclude(stack.currentProject(), directive)) == null) {
          // per-file globs = ownerEmails
          ownerEmails = Arrays.asList(directive.split(COMMA, -1));
        } else {
          // per-file globs = file: projectFile
          ownerEmails = new ArrayList<>();
          Result r = new Result();
          includeFile(r, "", num, parsedKPF, false);
          for (String key : r.owner2paths.keySet()) {
            for (String path : r.owner2paths.get(key)) {
              if (path.isEmpty()) {
                ownerEmails.add(key);
                break;
              }
            }
          }
        }
        for (String glob : dirGlobs) {
          for (String owner : ownerEmails) {
            Util.addToMap(result.owner2paths, owner, dir + glob);
          }
        }
      }
    } else if ((parsedKPF = parseInclude(stack.currentProject(), line)) != null) {
      includeFile(result, dir, num, parsedKPF, parsedKPF[0].equals("include"));
    } else {
      result.errors.add(errorMsg(stack.currentFile(), num, "ignored unknown line", line));
    }
  }