mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
index: add storage buffering state assertions
GitOrigin-RevId: 0a8e6824b2d56b4b24e15dd3855a2e2bba9eb53a
This commit is contained in:
committed by
intellij-monorepo-bot
parent
97c6d8313b
commit
2f483b740b
@@ -916,6 +916,8 @@ public final class FileBasedIndexImpl extends FileBasedIndexEx {
|
||||
// caller is responsible to ensure no concurrent same document processing
|
||||
void indexUnsavedDocument(@NotNull final Document document, @NotNull final ID<?, ?> requestedIndexId, final Project project,
|
||||
@NotNull final VirtualFile vFile) {
|
||||
myStorageBufferingHandler.assertTransientMode();
|
||||
|
||||
final PsiFile dominantContentFile = project == null ? null : findLatestKnownPsiForUncomittedDocument(document, project);
|
||||
|
||||
final DocumentContent content;
|
||||
@@ -1376,6 +1378,8 @@ public final class FileBasedIndexImpl extends FileBasedIndexEx {
|
||||
mapInputTime = System.nanoTime() - mapInputTime;
|
||||
}
|
||||
if (myStorageBufferingHandler.runUpdate(false, storageUpdate)) {
|
||||
myStorageBufferingHandler.assertOnTheDiskMode();
|
||||
|
||||
ConcurrencyUtil.withLock(myReadLock, () -> {
|
||||
if (currentFC != null) {
|
||||
if (!isMock(currentFC.getFile())) {
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
// Copyright 2000-2020 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.util.indexing;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.intellij.openapi.util.Computable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
|
||||
abstract class StorageBufferingHandler {
|
||||
private static final Logger LOG = Logger.getInstance(StorageBufferingHandler.class);
|
||||
|
||||
private final StorageGuard myStorageLock = new StorageGuard();
|
||||
private volatile boolean myPreviousDataBufferingState;
|
||||
private final Object myBufferingStateUpdateLock = new Object();
|
||||
@@ -37,6 +40,14 @@ abstract class StorageBufferingHandler {
|
||||
myPreviousDataBufferingState = false;
|
||||
}
|
||||
|
||||
void assertTransientMode() {
|
||||
LOG.assertTrue(myPreviousDataBufferingState);
|
||||
}
|
||||
|
||||
void assertOnTheDiskMode() {
|
||||
LOG.assertTrue(!myPreviousDataBufferingState);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected abstract Stream<UpdatableIndex<?, ? ,?>> getIndexes();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user