Search in sources :

Example 6 with DefaultHighlighting

use of org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting in project sonarqube by SonarSource.

the class DefaultSensorStorageTest method should_save_highlighting.

@Test
public void should_save_highlighting() {
    DefaultInputFile file = new TestInputFileBuilder("foo", "src/Foo.php").setContents("// comment").build();
    DefaultHighlighting highlighting = new DefaultHighlighting(underTest).onFile(file).highlight(1, 0, 1, 1, TypeOfText.KEYWORD);
    underTest.store(highlighting);
    assertThat(reportWriter.hasComponentData(FileStructure.Domain.SYNTAX_HIGHLIGHTINGS, file.scannerId())).isTrue();
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) DefaultHighlighting(org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting) Test(org.junit.Test)

Example 7 with DefaultHighlighting

use of org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting in project sonarqube by SonarSource.

the class DefaultSensorStorageTest method duplicateHighlighting.

@Test(expected = UnsupportedOperationException.class)
public void duplicateHighlighting() throws Exception {
    InputFile inputFile = new TestInputFileBuilder("foo", "src/Foo.java").setModuleBaseDir(temp.newFolder().toPath()).build();
    DefaultHighlighting h = new DefaultHighlighting(null).onFile(inputFile);
    underTest.store(h);
    underTest.store(h);
}
Also used : TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) DefaultHighlighting(org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) Test(org.junit.Test)

Example 8 with DefaultHighlighting

use of org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting in project sonarqube by SonarSource.

the class InMemorySensorStorage method store.

@Override
public void store(NewHighlighting newHighlighting) {
    DefaultHighlighting highlighting = (DefaultHighlighting) newHighlighting;
    String fileKey = highlighting.inputFile().key();
    // Emulate duplicate storage check
    if (highlightingByComponent.containsKey(fileKey)) {
        throw new UnsupportedOperationException("Trying to save highlighting twice for the same file is not supported: " + highlighting.inputFile());
    }
    highlightingByComponent.put(fileKey, highlighting);
}
Also used : DefaultHighlighting(org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting)

Aggregations

DefaultHighlighting (org.sonar.api.batch.sensor.highlighting.internal.DefaultHighlighting)8 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)5 Test (org.junit.Test)4 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)4 ArrayList (java.util.ArrayList)1 AnalysisMode (org.sonar.api.batch.AnalysisMode)1 InputFile (org.sonar.api.batch.fs.InputFile)1 TextRange (org.sonar.api.batch.fs.TextRange)1 DefaultTextPointer (org.sonar.api.batch.fs.internal.DefaultTextPointer)1 TypeOfText (org.sonar.api.batch.sensor.highlighting.TypeOfText)1 SyntaxHighlightingRule (org.sonar.api.batch.sensor.highlighting.internal.SyntaxHighlightingRule)1 SensorStorage (org.sonar.api.batch.sensor.internal.SensorStorage)1 ScannerReportWriter (org.sonar.scanner.protocol.output.ScannerReportWriter)1 DefaultHighlightable (org.sonar.scanner.source.DefaultHighlightable)1