mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
another attempt to enable stale index recovery IDEA-260427
GitOrigin-RevId: a1dd9e081502ecd9bbd28c4543d3d65302324ca8
This commit is contained in:
committed by
intellij-monorepo-bot
parent
33e513bb83
commit
d3443e5f2b
+1
-3
@@ -153,12 +153,10 @@ class FileBasedIndexDataInitialization extends IndexDataInitializer<IndexConfigu
|
||||
}
|
||||
}
|
||||
|
||||
//StaleIndexesChecker.clearStaleIndexes(myStaleIds);
|
||||
|
||||
return myState;
|
||||
}
|
||||
finally {
|
||||
|
||||
myFileBasedIndex.addStaleIds(myStaleIds);
|
||||
myFileBasedIndex.setUpFlusher();
|
||||
myRegisteredIndexes.ensureLoadedIndexesUpToDate();
|
||||
myRegisteredIndexes.markInitialized(); // this will ensure that all changes to component's state will be visible to other threads
|
||||
|
||||
@@ -60,9 +60,7 @@ import com.intellij.util.indexing.snapshot.SnapshotHashEnumeratorService;
|
||||
import com.intellij.util.indexing.snapshot.SnapshotInputMappings;
|
||||
import com.intellij.util.io.storage.HeavyProcessLatch;
|
||||
import com.intellij.util.messages.SimpleMessageBusConnection;
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import it.unimi.dsi.fastutil.ints.IntSet;
|
||||
import it.unimi.dsi.fastutil.ints.*;
|
||||
import org.jetbrains.annotations.ApiStatus;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -117,6 +115,7 @@ public final class FileBasedIndexImpl extends FileBasedIndexEx {
|
||||
private final AtomicInteger myLocalModCount = new AtomicInteger();
|
||||
private final AtomicInteger myFilesModCount = new AtomicInteger();
|
||||
private final Set<Project> myProjectsBeingUpdated = ContainerUtil.newConcurrentSet();
|
||||
private final IntSet myStaleIds = new IntOpenHashSet();
|
||||
|
||||
private final Lock myReadLock;
|
||||
public final Lock myWriteLock;
|
||||
@@ -310,6 +309,12 @@ public final class FileBasedIndexImpl extends FileBasedIndexEx {
|
||||
}
|
||||
}
|
||||
|
||||
void addStaleIds(@NotNull IntSet staleIds) {
|
||||
synchronized (myStaleIds) {
|
||||
myStaleIds.addAll(staleIds);
|
||||
}
|
||||
}
|
||||
|
||||
static class MyShutDownTask implements Runnable {
|
||||
@Override
|
||||
public void run() {
|
||||
@@ -748,11 +753,28 @@ public final class FileBasedIndexImpl extends FileBasedIndexEx {
|
||||
}
|
||||
|
||||
void filesUpdateStarted(Project project) {
|
||||
ensureStaleIdsDeleted();
|
||||
getChangedFilesCollector().ensureUpToDate();
|
||||
myProjectsBeingUpdated.add(project);
|
||||
incrementFilesModCount();
|
||||
}
|
||||
|
||||
void ensureStaleIdsDeleted() {
|
||||
waitUntilIndicesAreInitialized();
|
||||
synchronized (myStaleIds) {
|
||||
if (myStaleIds.isEmpty()) return;
|
||||
try {
|
||||
StaleIndexesChecker.clearStaleIndexes(myStaleIds);
|
||||
}
|
||||
catch (Exception e) {
|
||||
LOG.error(e);
|
||||
}
|
||||
finally {
|
||||
myStaleIds.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void filesUpdateFinished(@NotNull Project project) {
|
||||
myProjectsBeingUpdated.remove(project);
|
||||
incrementFilesModCount();
|
||||
|
||||
@@ -104,6 +104,7 @@ public final class RegisteredIndexes {
|
||||
void ensureLoadedIndexesUpToDate() {
|
||||
myAllIndicesInitializedFuture = IndexDataInitializer.submitGenesisTask(() -> {
|
||||
if (!myShutdownPerformed.get()) {
|
||||
myFileBasedIndex.ensureStaleIdsDeleted();
|
||||
myFileBasedIndex.getChangedFilesCollector().ensureUpToDateAsync();
|
||||
}
|
||||
return null;
|
||||
|
||||
Reference in New Issue
Block a user