Package net.sourceforge.pmd.cpd

Examples of net.sourceforge.pmd.cpd.Tokens


  @Test
  public void shouldWorkOnValidInput() throws URISyntaxException {
    File file = new File(getClass().getResource("codechunks-project/code_chunks.cc").toURI());
    SourceCode source = new SourceCode(new SourceCode.FileCodeLoader(file, "key"));
    Tokens cpdTokens = new Tokens();
    CxxTokenizer tokenizer = new CxxTokenizer(Charset.forName("UTF-8"));
    tokenizer.tokenize(source, cpdTokens);
    List<TokenEntry> list = cpdTokens.getTokens();
    assertThat(list.size()).isEqualTo(371);
  }
View Full Code Here


  @Test
  public void test() {
    JavaScriptTokenizer tokenizer = new JavaScriptTokenizer(Charset.forName("UTF-8"));
    SourceCode source = mock(SourceCode.class);
    when(source.getFileName()).thenReturn(new File("src/test/resources/cpd/Person.js").getAbsolutePath());
    Tokens tokens = new Tokens();
    tokenizer.tokenize(source, tokens);
    assertThat(tokens.getTokens().size()).isGreaterThan(1);
    assertThat(tokens.getTokens().get(tokens.size() - 1)).isEqualTo(TokenEntry.getEOF());
  }
View Full Code Here

    return blockBuilder.chunk(resourceId, chunk(file));
  }

  public List<TokensLine> chunk(File file) {
    SourceCode sourceCode = new SourceCode(new FileCodeLoaderWithoutCache(file, encoding));
    Tokens tokens = new Tokens();
    TokenEntry.clearImages();
    try {
      tokenizer.tokenize(sourceCode, tokens);
    } catch (IOException e) {
      throw Throwables.propagate(e);
    }
    TokenEntry.clearImages();
    return convert(tokens.getTokens());
  }
View Full Code Here

TOP

Related Classes of net.sourceforge.pmd.cpd.Tokens

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.