mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
FileTrees.withExclusiveStub: more diagnostics and avoid complete reindexing (RUBY-19319)
replace assertion with RuntimeException, because AssertionErrors cause index rebuild
This commit is contained in:
@@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.util.Set;
|
||||
|
||||
/**
|
||||
* @author peter
|
||||
@@ -67,8 +68,10 @@ final class FileTrees {
|
||||
return new FileTrees(myStub, ast, true, useStrongRefs);
|
||||
}
|
||||
|
||||
FileTrees withExclusiveStub(@NotNull StubTree stub) {
|
||||
assert derefTreeElement() == null && !useStrongRefs : this;
|
||||
FileTrees withExclusiveStub(@NotNull StubTree stub, Set<PsiFileImpl> allRoots) {
|
||||
if (derefTreeElement() != null || useStrongRefs) {
|
||||
throw new RuntimeException(toString() + "; roots=" + allRoots);
|
||||
}
|
||||
return new FileTrees(new SoftReference<>(stub), null, false, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -716,7 +716,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF
|
||||
|
||||
// now stubs can be safely published
|
||||
for (PsiFileImpl eachPsiRoot : bindings.keySet()) {
|
||||
eachPsiRoot.updateTrees(eachPsiRoot.myTrees.withExclusiveStub(bindings.get(eachPsiRoot)));
|
||||
eachPsiRoot.updateTrees(eachPsiRoot.myTrees.withExclusiveStub(bindings.get(eachPsiRoot), bindings.keySet()));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user