Search in sources :

Example 6 with DefaultSymbolTable

use of org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable 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

DefaultSymbolTable (org.sonar.api.batch.sensor.symbol.internal.DefaultSymbolTable)6 Test (org.junit.Test)5 TestInputFileBuilder (org.sonar.api.batch.fs.internal.TestInputFileBuilder)5 Symbol (org.sonar.api.source.Symbol)4 Symbolizable (org.sonar.api.source.Symbolizable)4 DeprecatedDefaultSymbolTable (org.sonar.scanner.source.DeprecatedDefaultSymbolTable)3 TextRange (org.sonar.api.batch.fs.TextRange)2 ImmutableMap (com.google.common.collect.ImmutableMap)1 Map (java.util.Map)1 Set (java.util.Set)1 CheckForNull (javax.annotation.CheckForNull)1 AnalysisMode (org.sonar.api.batch.AnalysisMode)1 InputFile (org.sonar.api.batch.fs.InputFile)1 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)1 DefaultTextPointer (org.sonar.api.batch.fs.internal.DefaultTextPointer)1 DefaultSensorStorage (org.sonar.scanner.sensor.DefaultSensorStorage)1 DefaultSymbolizable (org.sonar.scanner.source.DefaultSymbolizable)1