Package net.sourceforge.pmd.cpd

Examples of net.sourceforge.pmd.cpd.TokenEntry


  @Before
  public void setUp() {
    Tokenizer tokenizer = new Tokenizer() {
      public void tokenize(SourceCode tokens, Tokens tokenEntries) throws IOException {
        tokenEntries.add(new TokenEntry("t1", "src", 1));
        tokenEntries.add(new TokenEntry("t2", "src", 1));
        tokenEntries.add(new TokenEntry("t3", "src", 2));
        tokenEntries.add(new TokenEntry("t1", "src", 4));
        tokenEntries.add(new TokenEntry("t3", "src", 4));
        tokenEntries.add(new TokenEntry("t3", "src", 4));
        tokenEntries.add(TokenEntry.getEOF());
      }
    };
    bridge = new TokenizerBridge(tokenizer, "UTF-8", 10);
  }
View Full Code Here


  }

  @Test
  public void shouldClearCacheInTokenEntry() {
    bridge.chunk(null);
    TokenEntry token = new TokenEntry("image", "srcId", 0);
    assertThat(token.getIndex(), is(0));
    assertThat(token.getIdentifier(), is(1));
  }
View Full Code Here

  @Override
  public DefaultTokenBuilder addToken(int line, String image) {
    Preconditions.checkState(!done, "done() already called");
    Preconditions.checkState(line >= previousLine, "Token should be created in order. Previous line was " + previousLine + " and you tried to create a token at line " + line);
    TokenEntry cpdToken = new TokenEntry(image, inputFile.absolutePath(), line);
    tokens.add(cpdToken);
    previousLine = line;
    return this;
  }
View Full Code Here

            // Iterating on every token entry
            for ( Iterator<TokenEntry> occurrences = match.iterator(); occurrences.hasNext(); )
            {

                TokenEntry mark = occurrences.next();
                generateFileLine( mark );
            }

            // Source snippet
            sink.tableRow();
View Full Code Here

        File testPom = new File( getBasedir(),
                                 "src/test/resources/unit/default-configuration/cpd-default-configuration-plugin-config.xml" );
        CpdReport mojo = (CpdReport) lookupMojo( "cpd", testPom );
        assertNotNull( mojo );

        TokenEntry tFirstEntry = new TokenEntry( "public java", "MyClass.java", 34 );
        TokenEntry tSecondEntry = new TokenEntry( "public java", "MyClass3.java", 55 );
        List<Match> tList = new ArrayList<Match>();
        Match tMatch = new Match( 2, tFirstEntry, tSecondEntry );
        tMatch.setSourceCodeSlice( "// ----- ACCESSEURS  avec �l�ments -----" );
        tList.add( tMatch );
View Full Code Here

    public void tokenize(SourceCode source, Tokens cpdTokens) throws IOException {
        Lexer lexer = ObjectiveCLexer.create(new ObjectiveCConfiguration(charset));
        String fileName = source.getFileName();
        List<Token> tokens = lexer.lex(new File(fileName));
        for (Token token : tokens) {
            TokenEntry cpdToken = new TokenEntry(getTokenImage(token), fileName, token.getLine());
            cpdTokens.add(cpdToken);
        }
        cpdTokens.add(TokenEntry.getEOF());
    }
View Full Code Here

TOP

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

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.