From 7538efa218e5acd06ba728f7bb0fe4d8e9a89d48 Mon Sep 17 00:00:00 2001 From: Eugene Zhuravlev Date: Thu, 22 Jul 2010 15:28:24 +0400 Subject: [PATCH] corrected filter used to select files for dumb-mode reindexing: new filter acceps files from libs and lib sources --- .../util/indexing/FileBasedIndex.java | 28 +++++++++++++------ .../FileBasedIndexProjectHandler.java | 2 +- .../testFramework/LightPlatformTestCase.java | 2 +- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java index acbdcebd68ba..701ae442da7f 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndex.java @@ -21,7 +21,6 @@ import com.intellij.concurrency.JobScheduler; import com.intellij.history.LocalHistory; import com.intellij.ide.caches.CacheUpdater; import com.intellij.lang.ASTNode; -import com.intellij.openapi.application.Application; import com.intellij.openapi.application.ApplicationAdapter; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.application.PathManager; @@ -108,6 +107,7 @@ public class FileBasedIndex implements ApplicationComponent { private final ChangedFilesCollector myChangedFilesCollector; private final List myIndexableSets = ContainerUtil.createEmptyCOWList(); + private final Map myIndexableSetToProjectMap = new HashMap(); public static final int OK = 1; public static final int REQUIRES_REBUILD = 2; @@ -281,7 +281,7 @@ public class FileBasedIndex implements ApplicationComponent { myVfManager.addVirtualFileListener(myChangedFilesCollector); - registerIndexableSet(new AdditionalIndexableFileSet()); + registerIndexableSet(new AdditionalIndexableFileSet(), null); } finally { ShutDownTracker.getInstance().registerShutdownTask(new Runnable() { @@ -958,8 +958,7 @@ public class FileBasedIndex implements ApplicationComponent { } }; - final Application application = ApplicationManager.getApplication(); - if (cleanupOnly || application.isUnitTestMode()) { + if (cleanupOnly || myIsUnitTestMode) { rebuildRunnable.run(); } else { @@ -1238,10 +1237,18 @@ public class FileBasedIndex implements ApplicationComponent { } public Collection getFilesToUpdate(final Project project) { - final ProjectFileIndex projectIndex = ProjectRootManager.getInstance(project).getFileIndex(); return ContainerUtil.findAll(myChangedFilesCollector.getAllFilesToUpdate(), new Condition() { public boolean value(VirtualFile virtualFile) { - return projectIndex.isInContent(virtualFile); + for (IndexableFileSet set : myIndexableSets) { + final Project proj = myIndexableSetToProjectMap.get(set); + if (proj != null && !proj.equals(project)) { + continue; // skip this set as associated with a different project + } + if (set.isInSet(virtualFile)) { + return true; + } + } + return false; } }); } @@ -1436,8 +1443,9 @@ public class FileBasedIndex implements ApplicationComponent { } private void markDirty(final VirtualFileEvent event) { - cleanProcessedFlag(event.getFile()); - iterateIndexableFiles(event.getFile(), new Processor() { + final VirtualFile eventFile = event.getFile(); + cleanProcessedFlag(eventFile); + iterateIndexableFiles(eventFile, new Processor() { public boolean process(final VirtualFile file) { FileContent fileContent = null; // handle 'content-less' indices separately @@ -1838,13 +1846,15 @@ public class FileBasedIndex implements ApplicationComponent { return new UnindexedFilesFinder(); } - public void registerIndexableSet(IndexableFileSet set) { + public void registerIndexableSet(IndexableFileSet set, @Nullable Project project) { myIndexableSets.add(set); + myIndexableSetToProjectMap.put(set, project); } public void removeIndexableSet(IndexableFileSet set) { myChangedFilesCollector.forceUpdate(null, null, true); myIndexableSets.remove(set); + myIndexableSetToProjectMap.remove(set); } @Nullable diff --git a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java index 4dcee4416e01..73604f7878d7 100644 --- a/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java +++ b/platform/lang-impl/src/com/intellij/util/indexing/FileBasedIndexProjectHandler.java @@ -57,7 +57,7 @@ public class FileBasedIndexProjectHandler extends AbstractProjectComponent imple startupManager.registerCacheUpdater(rootsChangeUpdater); rootManager.registerRootsChangeUpdater(rootsChangeUpdater); rootManager.registerRefreshUpdater(refreshUpdater); - myIndex.registerIndexableSet(FileBasedIndexProjectHandler.this); + myIndex.registerIndexableSet(FileBasedIndexProjectHandler.this, project); projectManager.addProjectManagerListener(project, new ProjectManagerAdapter() { public void projectClosing(Project project) { rootManager.unregisterRefreshUpdater(refreshUpdater); diff --git a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java index 1a84a64c55db..7b9616400c2a 100644 --- a/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java +++ b/platform/testFramework/src/com/intellij/testFramework/LightPlatformTestCase.java @@ -225,7 +225,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da iterator.processFile(file); } } - }); + }, null); final ModuleRootManager rootManager = ModuleRootManager.getInstance(ourModule);