corrected filter used to select files for dumb-mode reindexing: new filter acceps files from libs and lib sources

This commit is contained in:
Eugene Zhuravlev
2010-07-22 15:29:00 +04:00
parent fd3055d28a
commit 7538efa218
3 changed files with 21 additions and 11 deletions
@@ -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<IndexableFileSet> myIndexableSets = ContainerUtil.createEmptyCOWList();
private final Map<IndexableFileSet, Project> myIndexableSetToProjectMap = new HashMap<IndexableFileSet, Project>();
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<VirtualFile> getFilesToUpdate(final Project project) {
final ProjectFileIndex projectIndex = ProjectRootManager.getInstance(project).getFileIndex();
return ContainerUtil.findAll(myChangedFilesCollector.getAllFilesToUpdate(), new Condition<VirtualFile>() {
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<VirtualFile>() {
final VirtualFile eventFile = event.getFile();
cleanProcessedFlag(eventFile);
iterateIndexableFiles(eventFile, new Processor<VirtualFile>() {
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
@@ -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);
@@ -225,7 +225,7 @@ public abstract class LightPlatformTestCase extends UsefulTestCase implements Da
iterator.processFile(file);
}
}
});
}, null);
final ModuleRootManager rootManager = ModuleRootManager.getInstance(ourModule);