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 saveComplexityMetrics(TreeVisitorContext context) {
    int fileComplexity = new ComplexityVisitor(true).getComplexity(context.getTopTree());

    saveMetricOnFile(CoreMetrics.COMPLEXITY, fileComplexity);
    saveMetricOnFile(CoreMetrics.COMPLEXITY_IN_CLASSES, classComplexity);
    saveMetricOnFile(CoreMetrics.COMPLEXITY_IN_FUNCTIONS, functionComplexity);

    sensorContext
        .<String>newMeasure()
        .on(inputFile)
        .forMetric(CoreMetrics.FUNCTION_COMPLEXITY_DISTRIBUTION)
        .withValue(functionComplexityDistribution.build())
        .save();

    fileComplexityDistribution.add(fileComplexity);

    sensorContext
        .<String>newMeasure()
        .on(inputFile)
        .forMetric(CoreMetrics.FILE_COMPLEXITY_DISTRIBUTION)
        .withValue(fileComplexityDistribution.build())
        .save();
  }
 private void saveCounterMetrics(TreeVisitorContext context) {
   CounterVisitor counter = new CounterVisitor(context.getTopTree());
   saveMetricOnFile(CoreMetrics.FUNCTIONS, counter.getFunctionNumber());
   saveMetricOnFile(CoreMetrics.STATEMENTS, counter.getStatementsNumber());
   saveMetricOnFile(CoreMetrics.CLASSES, counter.getClassNumber());
 }