mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
fix "stub in non-stub file" assertion in tests;
added details to assertion message
This commit is contained in:
@@ -60,6 +60,7 @@ import com.intellij.util.PatchedSoftReference;
|
||||
import com.intellij.util.PatchedWeakReference;
|
||||
import com.intellij.util.containers.ContainerUtil;
|
||||
import com.intellij.util.indexing.FileBasedIndex;
|
||||
import com.intellij.util.indexing.IndexingStamp;
|
||||
import com.intellij.util.text.CharArrayUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
@@ -605,7 +606,8 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
final IElementType contentElementType = getContentElementType();
|
||||
if (!(contentElementType instanceof IStubFileElementType)) {
|
||||
final FileViewProvider viewProvider = getViewProvider();
|
||||
throw new AssertionError("A stub in a non-stub file '" + vFile +"'; isValid()=" + vFile.isValid() +
|
||||
throw new AssertionError("A stub in a non-stub file '" + vFile +"'; isValid()=" + vFile.isValid() +
|
||||
"; IndexStamp="+ IndexingStamp.getIndexStamp(vFile, StubUpdatingIndex.INDEX_ID) +
|
||||
"; Type: " + contentElementType + "; " +
|
||||
"Psi roots: " + viewProvider.getAllFiles() + "; " +
|
||||
" StubUpdatingIndex.canHaveStub(vFile)=" + StubUpdatingIndex.canHaveStub(vFile) +
|
||||
|
||||
@@ -1573,16 +1573,12 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
ApplicationManager.getApplication().runReadAction(new Runnable() {
|
||||
public void run() {
|
||||
for (ID<?, ?> indexId : affectedIndices) {
|
||||
IndexingStamp.update(file, indexId, -1L);
|
||||
IndexingStamp.update(file, indexId, -2L);
|
||||
}
|
||||
}
|
||||
});
|
||||
iterateIndexableFiles(file, new Processor<VirtualFile>() {
|
||||
public boolean process(final VirtualFile file) {
|
||||
scheduleForUpdate(file);
|
||||
return true;
|
||||
}
|
||||
});
|
||||
// the file is for sure not a dir and it was previously indexed by at least one index
|
||||
scheduleForUpdate(file);
|
||||
}
|
||||
else {
|
||||
final InvalidationTask invalidator = new InvalidationTask(file) {
|
||||
@@ -1631,7 +1627,9 @@ public class FileBasedIndex implements ApplicationComponent {
|
||||
|
||||
public void ensureAllInvalidateTasksCompleted() {
|
||||
final int size = getNumberOfPendingInvalidations();
|
||||
if (size == 0) return;
|
||||
if (size == 0) {
|
||||
return;
|
||||
}
|
||||
final ProgressIndicator current = ProgressManager.getInstance().getProgressIndicator();
|
||||
final ProgressIndicator indicator = current != null ? current : new EmptyProgressIndicator();
|
||||
indicator.setText("");
|
||||
|
||||
@@ -142,11 +142,7 @@ public class IndexingStamp {
|
||||
|
||||
public static boolean isFileIndexed(VirtualFile file, ID<?, ?> indexName, final long indexCreationStamp) {
|
||||
try {
|
||||
if (file instanceof NewVirtualFile && file.isValid()) {
|
||||
synchronized (myTimestampsCache) {
|
||||
return myTimestampsCache.get(file).get(indexName) == indexCreationStamp;
|
||||
}
|
||||
}
|
||||
return getIndexStamp(file, indexName) == indexCreationStamp;
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
final Throwable cause = e.getCause();
|
||||
@@ -158,6 +154,15 @@ public class IndexingStamp {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static long getIndexStamp(VirtualFile file, ID<?, ?> indexName) {
|
||||
if (file instanceof NewVirtualFile && file.isValid()) {
|
||||
synchronized (myTimestampsCache) {
|
||||
return myTimestampsCache.get(file).get(indexName);
|
||||
}
|
||||
}
|
||||
return 0L;
|
||||
}
|
||||
|
||||
public static void update(final VirtualFile file, final ID<?, ?> indexName, final long indexCreationStamp) {
|
||||
try {
|
||||
if (file instanceof NewVirtualFile && file.isValid()) {
|
||||
|
||||
Reference in New Issue
Block a user