Search in sources :

Example 1 with MemoryCloneIndex

use of org.sonar.duplications.index.MemoryCloneIndex in project sonarqube by SonarSource.

the class JavaDuplicationsFunctionalTest method detect.

private List<CloneGroup> detect(String... lines) {
    String sourceCode = Arrays.stream(lines).collect(joining("\n"));
    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);
}
Also used : Statement(org.sonar.duplications.statement.Statement) Block(org.sonar.duplications.block.Block) MemoryCloneIndex(org.sonar.duplications.index.MemoryCloneIndex)

Aggregations

Block (org.sonar.duplications.block.Block)1 MemoryCloneIndex (org.sonar.duplications.index.MemoryCloneIndex)1 Statement (org.sonar.duplications.statement.Statement)1