use of org.sonar.scanner.protocol.output.ScannerReport.TextRange in project sonarqube by SonarSource.
the class SymbolsLineReaderTest method newSingleLineTextRangeWithExpectedLabel.
private TextRange newSingleLineTextRangeWithExpectedLabel(int line, int startOffset, int endOffset, String rangeLabel) {
TextRange textRange = newTextRange(line, line, startOffset, endOffset);
when(rangeOffsetConverter.offsetToString(textRange, line, DEFAULT_LINE_LENGTH)).thenReturn(rangeLabel);
return textRange;
}
use of org.sonar.scanner.protocol.output.ScannerReport.TextRange in project sonarqube by SonarSource.
the class SymbolsLineReaderTest method read_symbols_defined_on_many_lines.
@Test
public void read_symbols_defined_on_many_lines() {
TextRange declaration = newTextRange(LINE_1, LINE_2, OFFSET_1, OFFSET_3);
when(rangeOffsetConverter.offsetToString(declaration, LINE_1, DEFAULT_LINE_LENGTH)).thenReturn(RANGE_LABEL_1);
when(rangeOffsetConverter.offsetToString(declaration, LINE_2, DEFAULT_LINE_LENGTH)).thenReturn(RANGE_LABEL_2);
TextRange reference = newTextRange(LINE_3, LINE_4, OFFSET_1, OFFSET_3);
when(rangeOffsetConverter.offsetToString(reference, LINE_3, DEFAULT_LINE_LENGTH)).thenReturn(RANGE_LABEL_1);
when(rangeOffsetConverter.offsetToString(reference, LINE_4, DEFAULT_LINE_LENGTH)).thenReturn(RANGE_LABEL_2);
SymbolsLineReader symbolsLineReader = newReader(newSymbol(declaration, reference));
symbolsLineReader.read(line1);
symbolsLineReader.read(line2);
symbolsLineReader.read(line3);
symbolsLineReader.read(line4);
assertThat(line1.getSymbols()).isEqualTo(RANGE_LABEL_1 + ",1");
assertThat(line2.getSymbols()).isEqualTo(RANGE_LABEL_2 + ",1");
assertThat(line3.getSymbols()).isEqualTo(RANGE_LABEL_1 + ",1");
assertThat(line4.getSymbols()).isEqualTo(RANGE_LABEL_2 + ",1");
}
use of org.sonar.scanner.protocol.output.ScannerReport.TextRange in project sonarqube by SonarSource.
the class SymbolsLineReaderTest method display_file_key_in_warning_when_range_offset_converter_throw_RangeOffsetConverterException.
@Test
public void display_file_key_in_warning_when_range_offset_converter_throw_RangeOffsetConverterException() {
TextRange declaration = newTextRange(LINE_1, LINE_1, OFFSET_1, OFFSET_3);
doThrow(RangeOffsetConverter.RangeOffsetConverterException.class).when(rangeOffsetConverter).offsetToString(declaration, LINE_1, DEFAULT_LINE_LENGTH);
SymbolsLineReader symbolsLineReader = newReader(newSymbol(declaration, newSingleLineTextRangeWithExpectedLabel(LINE_2, OFFSET_1, OFFSET_3, RANGE_LABEL_2)));
symbolsLineReader.read(line1);
assertThat(logTester.logs(WARN)).containsOnly("Inconsistency detected in Symbols data. Symbols will be ignored for file 'FILE_KEY'");
}
use of org.sonar.scanner.protocol.output.ScannerReport.TextRange in project sonarqube by SonarSource.
the class HighlightingLineReaderTest method read_highlighting_declared_on_a_whole_line.
@Test
public void read_highlighting_declared_on_a_whole_line() {
TextRange textRange = newTextRange(LINE_1, LINE_2);
when(rangeOffsetConverter.offsetToString(textRange, LINE_1, DEFAULT_LINE_LENGTH)).thenReturn(RANGE_LABEL_1);
when(rangeOffsetConverter.offsetToString(textRange, LINE_2, DEFAULT_LINE_LENGTH)).thenReturn("");
HighlightingLineReader highlightingLineReader = newReader(of(textRange, ANNOTATION));
highlightingLineReader.read(line1);
highlightingLineReader.read(line2);
highlightingLineReader.read(line3);
assertThat(line1.getHighlighting()).isEqualTo(RANGE_LABEL_1 + ",a");
// Nothing should be set on line 2
assertThat(line2.getHighlighting()).isEmpty();
assertThat(line3.getHighlighting()).isEmpty();
}
use of org.sonar.scanner.protocol.output.ScannerReport.TextRange in project sonarqube by SonarSource.
the class HighlightingLineReaderTest method keep_existing_processed_highlighting_when_range_offset_converter_throw_RangeOffsetConverterException.
@Test
public void keep_existing_processed_highlighting_when_range_offset_converter_throw_RangeOffsetConverterException() {
TextRange textRange2 = newTextRange(LINE_2, LINE_2);
doThrow(RangeOffsetConverterException.class).when(rangeOffsetConverter).offsetToString(textRange2, LINE_2, DEFAULT_LINE_LENGTH);
HighlightingLineReader highlightingLineReader = newReader(of(newSingleLineTextRangeWithExpectingLabel(LINE_1, RANGE_LABEL_1), ANNOTATION, textRange2, HIGHLIGHTING_STRING));
highlightingLineReader.read(line1);
highlightingLineReader.read(line2);
assertThat(line1.hasHighlighting()).isTrue();
assertThat(line2.hasHighlighting()).isFalse();
assertThat(logTester.logs(WARN)).isNotEmpty();
}
Aggregations