Package org.sonar.api.batch.sensor.symbol

Examples of org.sonar.api.batch.sensor.symbol.SymbolTableBuilder


    if (symbolFile.exists()) {
      LOG.debug("Processing " + symbolFile.getAbsolutePath());
      try {
        List<String> lines = FileUtils.readLines(symbolFile, context.fileSystem().encoding().name());
        int lineNumber = 0;
        SymbolTableBuilder symbolTableBuilder = context.symbolTableBuilder(inputFile);
        for (String line : lines) {
          lineNumber++;
          if (StringUtils.isBlank(line) || line.startsWith("#")) {
            continue;
          }
          processLine(symbolFile, lineNumber, symbolTableBuilder, line);
        }
        symbolTableBuilder.done();
      } catch (IOException e) {
        throw new IllegalStateException(e);
      }
    }
  }
View Full Code Here


  public void testExecution() throws IOException {
    File symbol = new File(baseDir, "src/foo.xoo.symbol");
    FileUtils.write(symbol, "1,4,7\n12,15,23\n\n#comment");
    DefaultInputFile inputFile = new DefaultInputFile("foo", "src/foo.xoo").setAbsolutePath(new File(baseDir, "src/foo.xoo").getAbsolutePath()).setLanguage("xoo");
    fileSystem.add(inputFile);
    SymbolTableBuilder symbolTableBuilder = mock(SymbolTableBuilder.class);
    when(context.symbolTableBuilder(inputFile)).thenReturn(symbolTableBuilder);

    Symbol symbol1 = mock(Symbol.class);
    when(symbolTableBuilder.newSymbol(1, 4)).thenReturn(symbol1);
    Symbol symbol2 = mock(Symbol.class);
    when(symbolTableBuilder.newSymbol(12, 15)).thenReturn(symbol2);

    sensor.execute(context);

    verify(symbolTableBuilder).newSymbol(1, 4);
    verify(symbolTableBuilder).newReference(symbol1, 7);
View Full Code Here

  public ExpectedException throwable = ExpectedException.none();

  @Test
  public void should_order_symbol_and_references() throws Exception {
    ComponentDataCache componentDataCache = mock(ComponentDataCache.class);
    SymbolTableBuilder symbolTableBuilder = new DefaultSymbolTableBuilder("foo", componentDataCache);
    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);
    symbolTableBuilder.done();

    ArgumentCaptor<SymbolData> argCaptor = ArgumentCaptor.forClass(SymbolData.class);
    verify(componentDataCache).setData(eq("foo"), eq(SnapshotDataTypes.SYMBOL_HIGHLIGHTING), argCaptor.capture());

    SortedSetMultimap<Symbol, Integer> referencesBySymbol = argCaptor.getValue().referencesBySymbol();
View Full Code Here

  @Test
  public void should_serialize_unused_symbol() throws Exception {

    ComponentDataCache componentDataCache = mock(ComponentDataCache.class);
    SymbolTableBuilder symbolTableBuilder = new DefaultSymbolTableBuilder("foo", componentDataCache);
    symbolTableBuilder.newSymbol(10, 20);
    symbolTableBuilder.done();

    ArgumentCaptor<SymbolData> argCaptor = ArgumentCaptor.forClass(SymbolData.class);
    verify(componentDataCache).setData(eq("foo"), eq(SnapshotDataTypes.SYMBOL_HIGHLIGHTING), argCaptor.capture());

    assertThat(argCaptor.getValue().writeString()).isEqualTo("10,20,10;");
View Full Code Here

  @Test
  public void should_reject_reference_conflicting_with_declaration() throws Exception {
    throwable.expect(UnsupportedOperationException.class);

    ComponentDataCache componentDataCache = mock(ComponentDataCache.class);
    SymbolTableBuilder symbolTableBuilder = new DefaultSymbolTableBuilder("foo", componentDataCache);
    Symbol symbol = symbolTableBuilder.newSymbol(10, 20);
    symbolTableBuilder.newReference(symbol, 15);
  }
View Full Code Here

  @Test
  public void should_reject_reference_from_another_file() throws Exception {
    throwable.expect(UnsupportedOperationException.class);

    ComponentDataCache componentDataCache = mock(ComponentDataCache.class);
    SymbolTableBuilder symbolTableBuilder = new DefaultSymbolTableBuilder("foo", componentDataCache);
    Symbol symbol = symbolTableBuilder.newSymbol(10, 20);

    SymbolTableBuilder symbolTableBuilder2 = new DefaultSymbolTableBuilder("foo2", componentDataCache);
    Symbol symbol2 = symbolTableBuilder2.newSymbol(30, 40);

    symbolTableBuilder.newReference(symbol2, 15);
  }
View Full Code Here

TOP

Related Classes of org.sonar.api.batch.sensor.symbol.SymbolTableBuilder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.