use of org.sonar.ce.task.projectanalysis.source.linereader.ScmLineReader in project sonarqube by SonarSource.
the class LineReadersImplTest method getLatestChangeWithRevision_delegates_to_ScmLineReader_if_non_null.
@Test
public void getLatestChangeWithRevision_delegates_to_ScmLineReader_if_non_null() {
ScmLineReader scmLineReader = mock(ScmLineReader.class);
Changeset changeset = Changeset.newChangesetBuilder().setDate(0L).build();
when(scmLineReader.getLatestChangeWithRevision()).thenReturn(changeset);
SourceLineReadersFactory.LineReaders lineReaders = new SourceLineReadersFactory.LineReadersImpl(Collections.emptyList(), scmLineReader, Collections.emptyList());
assertThat(lineReaders.getLatestChangeWithRevision()).isEqualTo(changeset);
verify(scmLineReader).getLatestChangeWithRevision();
verifyNoMoreInteractions(scmLineReader);
}
use of org.sonar.ce.task.projectanalysis.source.linereader.ScmLineReader in project sonarqube by SonarSource.
the class SourceLineReadersFactory method getLineReaders.
public LineReaders getLineReaders(Component component) {
List<LineReader> readers = new ArrayList<>();
List<CloseableIterator<?>> closeables = new ArrayList<>();
ScmLineReader scmLineReader = null;
int componentRef = component.getReportAttributes().getRef();
CloseableIterator<ScannerReport.LineCoverage> coverageIt = reportReader.readComponentCoverage(componentRef);
closeables.add(coverageIt);
readers.add(new CoverageLineReader(coverageIt));
Optional<ScmInfo> scmInfoOptional = scmInfoRepository.getScmInfo(component);
if (scmInfoOptional.isPresent()) {
scmLineReader = new ScmLineReader(scmInfoOptional.get());
readers.add(scmLineReader);
}
RangeOffsetConverter rangeOffsetConverter = new RangeOffsetConverter();
CloseableIterator<ScannerReport.SyntaxHighlightingRule> highlightingIt = reportReader.readComponentSyntaxHighlighting(componentRef);
closeables.add(highlightingIt);
readers.add(new HighlightingLineReader(component, highlightingIt, rangeOffsetConverter));
CloseableIterator<ScannerReport.Symbol> symbolsIt = reportReader.readComponentSymbols(componentRef);
closeables.add(symbolsIt);
readers.add(new SymbolsLineReader(component, symbolsIt, rangeOffsetConverter));
readers.add(new DuplicationLineReader(duplicationRepository.getDuplications(component)));
readers.add(new IsNewLineReader(newLinesRepository, component));
return new LineReadersImpl(readers, scmLineReader, closeables);
}
Aggregations