Search in sources :

Example 1 with DeprecatedDefaultSymbolTable

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));
}
Also used : Symbol(org.sonar.api.source.Symbol) DeprecatedDefaultSymbolTable(org.sonar.scanner.source.DeprecatedDefaultSymbolTable) TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) TextRange(org.sonar.api.batch.fs.TextRange) DeprecatedDefaultSymbolTable(org.sonar.scanner.source.DeprecatedDefaultSymbolTable) DefaultSymbolTable(org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable) Symbolizable(org.sonar.api.source.Symbolizable) Test(org.junit.Test)

Example 2 with DeprecatedDefaultSymbolTable

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));
}
Also used : Symbol(org.sonar.api.source.Symbol) DeprecatedDefaultSymbolTable(org.sonar.scanner.source.DeprecatedDefaultSymbolTable) TestInputFileBuilder(org.sonar.api.batch.fs.internal.TestInputFileBuilder) DeprecatedDefaultSymbolTable(org.sonar.scanner.source.DeprecatedDefaultSymbolTable) DefaultSymbolTable(org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable) Symbolizable(org.sonar.api.source.Symbolizable) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)2 DefaultSymbolTable (org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable)2 Symbol (org.sonar.api.source.Symbol)2 Symbolizable (org.sonar.api.source.Symbolizable)2 DeprecatedDefaultSymbolTable (org.sonar.scanner.source.DeprecatedDefaultSymbolTable)2 TextRange (org.sonar.api.batch.fs.TextRange)1