use of org.sonar.scanner.source.DeprecatedDefaultSymbolTable in project sonarqube by SonarSource.
the class DeprecatedDefaultSymbolTableTest method variable_length_references.
@Test
public void variable_length_references() {
Symbolizable.SymbolTableBuilder symbolTableBuilder = new DeprecatedDefaultSymbolTable.Builder(new DefaultSymbolTable(null).onFile(inputFile));
Symbol firstSymbol = symbolTableBuilder.newSymbol(10, 20);
symbolTableBuilder.newReference(firstSymbol, 32);
symbolTableBuilder.newReference(firstSymbol, 44, 47);
DeprecatedDefaultSymbolTable symbolTable = (DeprecatedDefaultSymbolTable) symbolTableBuilder.build();
assertThat(symbolTable.getWrapped().getReferencesBySymbol().keySet()).containsExactly(range(10, 20));
Set<TextRange> references = symbolTable.getWrapped().getReferencesBySymbol().get(range(10, 20));
assertThat(references).containsExactly(range(32, 42), range(44, 47));
}
use of org.sonar.scanner.source.DeprecatedDefaultSymbolTable in project sonarqube by SonarSource.
the class DeprecatedDefaultSymbolTableTest method should_order_symbol_and_references.
@Test
public void should_order_symbol_and_references() {
Symbolizable.SymbolTableBuilder symbolTableBuilder = new DeprecatedDefaultSymbolTable.Builder(new DefaultSymbolTable(null).onFile(inputFile));
Symbol firstSymbol = symbolTableBuilder.newSymbol(10, 20);
symbolTableBuilder.newReference(firstSymbol, 32);
Symbol secondSymbol = symbolTableBuilder.newSymbol(84, 92);
symbolTableBuilder.newReference(secondSymbol, 124);
Symbol thirdSymbol = symbolTableBuilder.newSymbol(55, 62);
symbolTableBuilder.newReference(thirdSymbol, 70);
DeprecatedDefaultSymbolTable symbolTable = (DeprecatedDefaultSymbolTable) symbolTableBuilder.build();
assertThat(symbolTable.getWrapped().getReferencesBySymbol().keySet()).containsExactly(range(10, 20), range(84, 92), range(55, 62));
}
Aggregations