fixed regress introduced by c5819e4 :

remove stale index data for removed files that were scheduled to update lazily
This commit is contained in:
Maxim.Mossienko
2014-03-05 18:36:26 +01:00
parent 61d11c82e3
commit 1b0bc5f5ff
@@ -2117,7 +2117,11 @@ public class FileBasedIndexImpl extends FileBasedIndex {
}
}
else {
myFilesToUpdate.remove(file);
boolean removed = myFilesToUpdate.remove(file);
if (removed) {
// file was scheduled for update, it might mean we have data in indices which would have been lazily updated
indexedIdsToUpdate.addAll(calculateAffectedContentIndices(file));
}
if (!indexedIdsToUpdate.isEmpty()) {
myFutureInvalidations.offer(new InvalidationTask(file) {
@@ -2304,13 +2308,7 @@ public class FileBasedIndexImpl extends FileBasedIndex {
try {
if (onlyRemoveOutdatedData || isTooLarge(file)) {
// on shutdown there is no need to re-index the file, just remove outdated data from indices
final List<ID<?, ?>> affected = new ArrayList<ID<?, ?>>();
for (final ID<?, ?> indexId : getAffectedIndexCandidates(file)) { // non requiring content indices should be flushed
if (needsFileContentLoading(indexId) && getInputFilter(indexId).acceptInput(file)) {
affected.add(indexId);
}
}
removeFileDataFromIndices(affected, file);
removeFileDataFromIndices(calculateAffectedContentIndices(file), file);
if (onlyRemoveOutdatedData && file instanceof VirtualFileSystemEntry) {
((VirtualFileSystemEntry)file).setFileIndexed(false); // we should be able index this file via UnindexedFileFinder later
}
@@ -2355,6 +2353,16 @@ public class FileBasedIndexImpl extends FileBasedIndex {
}
}
private List<ID<?, ?>> calculateAffectedContentIndices(VirtualFile file) {
final List<ID<?, ?>> affected = new ArrayList<ID<?, ?>>();
for (final ID<?, ?> indexId : getAffectedIndexCandidates(file)) { // non requiring content indices should be flushed
if (needsFileContentLoading(indexId) && getInputFilter(indexId).acceptInput(file)) {
affected.add(indexId);
}
}
return affected;
}
private class UnindexedFilesFinder implements CollectingContentIterator {
private final List<VirtualFile> myFiles = new ArrayList<VirtualFile>();
@Nullable