duplicateindex should process java files only in source roots

This commit is contained in:
Maxim.Mossienko
2016-11-28 14:05:24 +01:00
parent aea83b1e60
commit db9c2e18cc
2 changed files with 13 additions and 5 deletions
@@ -17,6 +17,7 @@ package com.intellij.dupLocator;
import com.intellij.lang.LighterAST;
import com.intellij.lang.LighterASTNode;
import com.intellij.openapi.vfs.VirtualFile;
import org.jetbrains.annotations.NotNull;
/**
@@ -24,6 +25,7 @@ import org.jetbrains.annotations.NotNull;
*/
public interface LightDuplicateProfile {
void process(@NotNull LighterAST ast, @NotNull Callback callback);
boolean acceptsFile(@NotNull VirtualFile file);
interface Callback {
void process(int hash, int hash2, @NotNull LighterAST ast, @NotNull LighterASTNode... nodes);
@@ -61,10 +61,16 @@ public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayL
private final FileBasedIndex.InputFilter myInputFilter = new FileBasedIndex.InputFilter() {
@Override
public boolean acceptInput(@NotNull final VirtualFile file) {
return ourEnabled &&
findDuplicatesProfile(file.getFileType()) != null &&
file.isInLocalFileSystem() // skip library sources
;
if (!ourEnabled ||
!file.isInLocalFileSystem() // skip library sources
) {
return false;
}
DuplicatesProfile duplicatesProfile = findDuplicatesProfile(file.getFileType());
if (duplicatesProfile instanceof LightDuplicateProfile) {
return ((LightDuplicateProfile)duplicatesProfile).acceptsFile(file);
}
return duplicatesProfile != null;
}
};
@@ -163,7 +169,7 @@ public class DuplicatesIndex extends FileBasedIndexExtension<Integer, TIntArrayL
@Override
public int getVersion() {
return myBaseVersion + (ourEnabled ? 0xFF : 0) + (ourEnabledLightProfiles ? 0x7F : 0) + (ourEnabledOldProfiles ? 0x21 : 0);
return myBaseVersion + (ourEnabled ? 0xFF : 0) + (ourEnabledLightProfiles ? 0x80 : 0) + (ourEnabledOldProfiles ? 0x21 : 0);
}
@Override