use of org.sonar.api.measures.FileLinesContext in project sonarqube by SonarSource.
the class LineMeasureSensor method processFileMeasures.
private void processFileMeasures(InputFile inputFile, SensorContext context) {
File ioFile = inputFile.file();
File measureFile = new File(ioFile.getParentFile(), ioFile.getName() + MEASURES_EXTENSION);
if (measureFile.exists()) {
LOG.debug("Processing " + measureFile.getAbsolutePath());
try {
FileLinesContext linesContext = contextFactory.createFor(inputFile);
List<String> lines = FileUtils.readLines(measureFile, context.fileSystem().encoding().name());
int lineNumber = 0;
for (String line : lines) {
lineNumber++;
if (StringUtils.isBlank(line) || line.startsWith("#")) {
continue;
}
processMeasure(inputFile, linesContext, measureFile, lineNumber, line);
}
linesContext.save();
} catch (IOException e) {
throw new IllegalStateException(e);
}
}
}
Aggregations