From bcb6a0ede746b44a5eac960e36956c7356ceae71 Mon Sep 17 00:00:00 2001 From: peter Date: Mon, 4 Jun 2018 12:20:41 +0200 Subject: [PATCH] make PsiFileImpl myLoadingAst volatile (IDEA-CR-33043) --- .../src/com/intellij/psi/impl/source/PsiFileImpl.java | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java b/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java index e96fc8a883b4..134b0799d18d 100644 --- a/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java +++ b/platform/core-impl/src/com/intellij/psi/impl/source/PsiFileImpl.java @@ -69,7 +69,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF protected final PsiManagerEx myManager; public static final Key BUILDING_STUB = new Key<>("Don't use stubs mark!"); private final PsiLock myPsiLock; - private final ThreadLocal myLoadingAst = new ThreadLocal<>(); + private volatile boolean myLoadingAst; protected PsiFileImpl(@NotNull IElementType elementType, IElementType contentElementType, @NotNull FileViewProvider provider) { this(provider); @@ -209,12 +209,12 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF treeElement = createFileElement(viewProvider.getContents()); treeElement.setPsi(this); - myLoadingAst.set(true); + myLoadingAst = true; try { updateTrees(myTrees.withAst(createTreeElementPointer(treeElement))); } finally { - myLoadingAst.remove(); + myLoadingAst = false; } if (LOG.isDebugEnabled() && viewProvider.isPhysical()) { @@ -593,9 +593,7 @@ public abstract class PsiFileImpl extends ElementBase implements PsiFileEx, PsiF final StubTree derefd = derefStub(); if (derefd != null) return derefd; - if (Boolean.TRUE.equals(getUserData(BUILDING_STUB)) || - Boolean.TRUE.equals(myLoadingAst.get()) || - getElementTypeForStubBuilder() == null) { + if (Boolean.TRUE.equals(getUserData(BUILDING_STUB)) || myLoadingAst || getElementTypeForStubBuilder() == null) { return null; }