mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Separate methods of indexable set contributor to test-cacheable (project-independent) and non-cacheable (project) sets of files [r=peter]
This commit is contained in:
+7
-8
@@ -25,6 +25,7 @@ import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.util.indexing.IndexableSetContributor;
|
||||
import gnu.trove.THashSet;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Set;
|
||||
@@ -34,15 +35,13 @@ import java.util.Set;
|
||||
*/
|
||||
public abstract class ScriptingIndexableSetContributor extends IndexableSetContributor {
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
public Set<VirtualFile> getAdditionalRootsToIndex(@Nullable Project project) {
|
||||
final Set<VirtualFile> predefinedFiles = getPredefinedFilesToIndex();
|
||||
final THashSet<VirtualFile> filesToIndex = new THashSet<VirtualFile>();
|
||||
filesToIndex.addAll(predefinedFiles);
|
||||
filesToIndex.addAll(getLibraryFiles(project));
|
||||
return filesToIndex;
|
||||
public Set<VirtualFile> getAdditionalProjectRootsToIndex(@Nullable Project project) {
|
||||
return getLibraryFiles(project);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<VirtualFile> getLibraryFiles(Project project) {
|
||||
final THashSet<VirtualFile> libFiles = new THashSet<VirtualFile>();
|
||||
LibraryType libType = getLibraryType();
|
||||
@@ -67,8 +66,8 @@ public abstract class ScriptingIndexableSetContributor extends IndexableSetContr
|
||||
}
|
||||
|
||||
@Override
|
||||
public Set<VirtualFile> getAdditionalRootsToIndex() {
|
||||
return getAdditionalRootsToIndex(null);
|
||||
public final Set<VirtualFile> getAdditionalRootsToIndex() {
|
||||
return getPredefinedFilesToIndex();
|
||||
}
|
||||
|
||||
public abstract Set<VirtualFile> getPredefinedFilesToIndex();
|
||||
|
||||
@@ -1912,7 +1912,12 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
if (project.isDisposed()) {
|
||||
return;
|
||||
}
|
||||
for (VirtualFile root : IndexableSetContributor.getRootsToIndex(provider, project)) {
|
||||
for (VirtualFile root : IndexableSetContributor.getRootsToIndex(provider)) {
|
||||
if (visitedRoots.add(root)) {
|
||||
iterateRecursively(root, processor, indicator);
|
||||
}
|
||||
}
|
||||
for (VirtualFile root : IndexableSetContributor.getProjectRootsToIndex(provider, project)) {
|
||||
if (visitedRoots.add(root)) {
|
||||
iterateRecursively(root, processor, indicator);
|
||||
}
|
||||
|
||||
@@ -5,9 +5,11 @@ import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.openapi.vfs.VirtualFileManager;
|
||||
import com.intellij.util.NotNullFunction;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import org.apache.commons.collections.SetUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -15,6 +17,9 @@ import java.util.Set;
|
||||
* @author peter
|
||||
*/
|
||||
public abstract class IndexableSetContributor implements IndexedRootsProvider {
|
||||
|
||||
protected static final Set<VirtualFile> EMPTY_FILE_SET = Collections.unmodifiableSet(new HashSet<VirtualFile>());
|
||||
|
||||
@Override
|
||||
public final Set<String> getRootsToIndex() {
|
||||
return ContainerUtil.map2Set(getAdditionalRootsToIndex(), new NotNullFunction<VirtualFile, String>() {
|
||||
@@ -26,13 +31,17 @@ public abstract class IndexableSetContributor implements IndexedRootsProvider {
|
||||
});
|
||||
}
|
||||
|
||||
public static Set<VirtualFile> getRootsToIndex(IndexedRootsProvider provider) {
|
||||
return getRootsToIndex(provider, null);
|
||||
@NotNull
|
||||
public static Set<VirtualFile> getProjectRootsToIndex(IndexedRootsProvider provider, Project project) {
|
||||
if (provider instanceof IndexableSetContributor) {
|
||||
return ((IndexableSetContributor)provider).getAdditionalProjectRootsToIndex(project);
|
||||
}
|
||||
return EMPTY_FILE_SET;
|
||||
}
|
||||
|
||||
public static Set<VirtualFile> getRootsToIndex(IndexedRootsProvider provider, @Nullable Project project) {
|
||||
public static Set<VirtualFile> getRootsToIndex(IndexedRootsProvider provider) {
|
||||
if (provider instanceof IndexableSetContributor) {
|
||||
return ((IndexableSetContributor)provider).getAdditionalRootsToIndex(project);
|
||||
return ((IndexableSetContributor)provider).getAdditionalRootsToIndex();
|
||||
}
|
||||
|
||||
final HashSet<VirtualFile> result = new HashSet<VirtualFile>();
|
||||
@@ -43,8 +52,9 @@ public abstract class IndexableSetContributor implements IndexedRootsProvider {
|
||||
return result;
|
||||
}
|
||||
|
||||
public Set<VirtualFile> getAdditionalRootsToIndex(@Nullable Project project) {
|
||||
return getAdditionalRootsToIndex();
|
||||
@NotNull
|
||||
public Set<VirtualFile> getAdditionalProjectRootsToIndex(@Nullable Project project) {
|
||||
return EMPTY_FILE_SET;
|
||||
}
|
||||
|
||||
public abstract Set<VirtualFile> getAdditionalRootsToIndex();
|
||||
|
||||
Reference in New Issue
Block a user