Search in sources :

Example 1 with TokenizerBridge

use of org.sonar.duplications.internal.pmd.TokenizerBridge in project sonarqube by SonarSource.

the class DefaultCpdBlockIndexer method populateIndex.

private void populateIndex(String languageKey, List<InputFile> sourceFiles, CpdMapping mapping) {
    TokenizerBridge bridge = new TokenizerBridge(mapping.getTokenizer(), fs.encoding().name(), getBlockSize(languageKey));
    for (InputFile inputFile : sourceFiles) {
        if (!index.isIndexed(inputFile)) {
            LOG.debug("Populating index from {}", inputFile.absolutePath());
            String resourceEffectiveKey = ((DefaultInputFile) inputFile).key();
            List<Block> blocks = bridge.chunk(resourceEffectiveKey, inputFile.file());
            index.insert(inputFile, blocks);
        }
    }
}
Also used : DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile) TokenizerBridge(org.sonar.duplications.internal.pmd.TokenizerBridge) Block(org.sonar.duplications.block.Block) InputFile(org.sonar.api.batch.fs.InputFile) DefaultInputFile(org.sonar.api.batch.fs.internal.DefaultInputFile)

Aggregations

InputFile (org.sonar.api.batch.fs.InputFile)1 DefaultInputFile (org.sonar.api.batch.fs.internal.DefaultInputFile)1 Block (org.sonar.duplications.block.Block)1 TokenizerBridge (org.sonar.duplications.internal.pmd.TokenizerBridge)1