Search in sources :

Example 1 with ScmLineReader

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);
}
Also used : ScmLineReader(org.sonar.ce.task.projectanalysis.source.linereader.ScmLineReader) Changeset(org.sonar.ce.task.projectanalysis.scm.Changeset) Test(org.junit.Test)

Example 2 with 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);
}
Also used : CoverageLineReader(org.sonar.ce.task.projectanalysis.source.linereader.CoverageLineReader) CloseableIterator(org.sonar.core.util.CloseableIterator) SymbolsLineReader(org.sonar.ce.task.projectanalysis.source.linereader.SymbolsLineReader) ArrayList(java.util.ArrayList) IsNewLineReader(org.sonar.ce.task.projectanalysis.source.linereader.IsNewLineReader) HighlightingLineReader(org.sonar.ce.task.projectanalysis.source.linereader.HighlightingLineReader) DuplicationLineReader(org.sonar.ce.task.projectanalysis.source.linereader.DuplicationLineReader) DuplicationLineReader(org.sonar.ce.task.projectanalysis.source.linereader.DuplicationLineReader) ScmLineReader(org.sonar.ce.task.projectanalysis.source.linereader.ScmLineReader) LineReader(org.sonar.ce.task.projectanalysis.source.linereader.LineReader) SymbolsLineReader(org.sonar.ce.task.projectanalysis.source.linereader.SymbolsLineReader) IsNewLineReader(org.sonar.ce.task.projectanalysis.source.linereader.IsNewLineReader) CoverageLineReader(org.sonar.ce.task.projectanalysis.source.linereader.CoverageLineReader) HighlightingLineReader(org.sonar.ce.task.projectanalysis.source.linereader.HighlightingLineReader) ScmLineReader(org.sonar.ce.task.projectanalysis.source.linereader.ScmLineReader) RangeOffsetConverter(org.sonar.ce.task.projectanalysis.source.linereader.RangeOffsetConverter) ScmInfo(org.sonar.ce.task.projectanalysis.scm.ScmInfo)

Aggregations

ScmLineReader (org.sonar.ce.task.projectanalysis.source.linereader.ScmLineReader)2 ArrayList (java.util.ArrayList)1 Test (org.junit.Test)1 Changeset (org.sonar.ce.task.projectanalysis.scm.Changeset)1 ScmInfo (org.sonar.ce.task.projectanalysis.scm.ScmInfo)1 CoverageLineReader (org.sonar.ce.task.projectanalysis.source.linereader.CoverageLineReader)1 DuplicationLineReader (org.sonar.ce.task.projectanalysis.source.linereader.DuplicationLineReader)1 HighlightingLineReader (org.sonar.ce.task.projectanalysis.source.linereader.HighlightingLineReader)1 IsNewLineReader (org.sonar.ce.task.projectanalysis.source.linereader.IsNewLineReader)1 LineReader (org.sonar.ce.task.projectanalysis.source.linereader.LineReader)1 RangeOffsetConverter (org.sonar.ce.task.projectanalysis.source.linereader.RangeOffsetConverter)1 SymbolsLineReader (org.sonar.ce.task.projectanalysis.source.linereader.SymbolsLineReader)1 CloseableIterator (org.sonar.core.util.CloseableIterator)1