}
// Create index
- SonarDuplicationsIndex index = indexFactory.create(project);
+ SonarDuplicationsIndex index = indexFactory.create(project, languageKey);
TokenizerBridge bridge = new TokenizerBridge(mapping.getTokenizer(), fs.encoding().name(), getBlockSize(project, languageKey));
for (InputFile inputFile : sourceFiles) {
if (sourceFiles.isEmpty()) {
return;
}
- SonarDuplicationsIndex index = createIndex(project, sourceFiles);
+ SonarDuplicationsIndex index = createIndex(project, languageKey, sourceFiles);
detect(index, context, sourceFiles);
}
- private SonarDuplicationsIndex createIndex(Project project, Iterable<InputFile> sourceFiles) {
- final SonarDuplicationsIndex index = indexFactory.create(project);
+ private SonarDuplicationsIndex createIndex(Project project, String language, Iterable<InputFile> sourceFiles) {
+ final SonarDuplicationsIndex index = indexFactory.create(project, language);
TokenChunker tokenChunker = JavaTokenProducer.build();
StatementChunker statementChunker = JavaStatementBuilder.build();
private DuplicationDao dao;
- public DbDuplicationsIndex(ResourcePersister resourcePersister, Project currentProject, DuplicationDao dao) {
+ public DbDuplicationsIndex(ResourcePersister resourcePersister, Project currentProject, DuplicationDao dao,
+ String language) {
this.dao = dao;
this.resourcePersister = resourcePersister;
Snapshot currentSnapshot = resourcePersister.getSnapshotOrFail(currentProject);
Snapshot lastSnapshot = resourcePersister.getLastSnapshot(currentSnapshot, false);
this.currentProjectSnapshotId = currentSnapshot.getId();
this.lastSnapshotId = lastSnapshot == null ? null : lastSnapshot.getId();
- this.languageKey = currentProject.getLanguageKey();
+ this.languageKey = language;
}
int getSnapshotIdFor(InputFile inputFile) {
this.dao = dao;
}
- public SonarDuplicationsIndex create(Project project) {
+ public SonarDuplicationsIndex create(Project project, String languageKey) {
if (verifyCrossProject(project, LOG)) {
- return new SonarDuplicationsIndex(new DbDuplicationsIndex(resourcePersister, project, dao));
+ return new SonarDuplicationsIndex(new DbDuplicationsIndex(resourcePersister, project, dao, languageKey));
}
return new SonarDuplicationsIndex();
}