private void saveLineMetrics(TreeVisitorContext context) {
    LineVisitor lineVisitor = new LineVisitor(context.getTopTree());
    int linesNumber = lineVisitor.getLinesNumber();
    Set<Integer> linesOfCode = lineVisitor.getLinesOfCode();
    projectLinesOfCode.put(inputFile, linesOfCode);

    saveMetricOnFile(CoreMetrics.NCLOC, lineVisitor.getLinesOfCodeNumber());

    CommentLineVisitor commentVisitor =
        new CommentLineVisitor(context.getTopTree(), ignoreHeaderComments);
    Set<Integer> commentLines = commentVisitor.getCommentLines();

    saveMetricOnFile(CoreMetrics.COMMENT_LINES, commentVisitor.getCommentLineNumber());
    noSonarFilter.noSonarInFile(this.inputFile, commentVisitor.noSonarLines());

    FileLinesContext fileLinesContext = fileLinesContextFactory.createFor(this.inputFile);
    for (int line = 1; line <= linesNumber; line++) {
      int isCodeLine = linesOfCode.contains(line) ? 1 : 0;
      if (saveExecutableLines) {
        fileLinesContext.setIntValue(CoreMetrics.EXECUTABLE_LINES_DATA_KEY, line, isCodeLine);
      }
      fileLinesContext.setIntValue(CoreMetrics.NCLOC_DATA_KEY, line, isCodeLine);
      fileLinesContext.setIntValue(
          CoreMetrics.COMMENT_LINES_DATA_KEY, line, commentLines.contains(line) ? 1 : 0);
    }
    fileLinesContext.save();
  }
  private void setLineAndCommentMeasures() {
    LineVisitor lineVisitor = new LineVisitor(context().tree());

    CommentLineVisitor commentVisitor = new CommentLineVisitor(context().tree());

    int linesNumber = lineVisitor.getLinesNumber();

    fileMeasures.setLinesNumber(linesNumber);
    fileMeasures.setLinesOfCodeNumber(lineVisitor.getLinesOfCodeNumber());
    fileMeasures.setCommentLinesNumber(commentVisitor.commentLineNumber());
    fileMeasures.setNoSonarLines(commentVisitor.noSonarLines());

    Set<Integer> linesOfCode = lineVisitor.getLinesOfCode();
    Set<Integer> commentLines = commentVisitor.commentLines();

    for (int line = 1; line <= linesNumber; line++) {
      fileLinesContext.setIntValue(
          CoreMetrics.NCLOC_DATA_KEY, line, linesOfCode.contains(line) ? 1 : 0);
      fileLinesContext.setIntValue(
          CoreMetrics.COMMENT_LINES_DATA_KEY, line, commentLines.contains(line) ? 1 : 0);
    }

    fileLinesContext.save();
  }