Package org.sonar.duplications.index

Examples of org.sonar.duplications.index.MemoryCloneIndex


  private String source(String... lines) {
    return Joiner.on('\n').join(lines);
  }

  private static List<CloneGroup> detect2(String... fragments) {
    MemoryCloneIndex index = new MemoryCloneIndex();
    for (int i = 0; i < fragments.length; i++) {
      addToIndex(index, "fragment" + i, fragments[i]);
    }
    return detect(index, index.getByResourceId("fragment0"));
  }
View Full Code Here


  private static StatementChunker STATEMENT_CHUNKER = JavaStatementBuilder.build();
  private static BlockChunker BLOCK_CHUNKER = new BlockChunker(BLOCK_SIZE);

  private List<CloneGroup> detect(String... lines) {
    String sourceCode = Joiner.on('\n').join(lines);
    MemoryCloneIndex index = new MemoryCloneIndex();
    List<Statement> statements = STATEMENT_CHUNKER.chunk(TOKEN_CHUNKER.chunk(sourceCode));
    List<Block> blocks = BLOCK_CHUNKER.chunk("resourceId", statements);
    for (Block block : blocks) {
      index.insert(block);
    }
    return detect(index, blocks);
  }
View Full Code Here

    }
    return result.toArray(new Block[result.size()]);
  }

  protected static CloneIndex createIndex(Block[]... blocks) {
    CloneIndex cloneIndex = new MemoryCloneIndex();
    for (Block[] b : blocks) {
      for (Block block : b) {
        cloneIndex.insert(block);
      }
    }
    return cloneIndex;
  }
View Full Code Here

TOP

Related Classes of org.sonar.duplications.index.MemoryCloneIndex

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.