unify thread-dependence xi:include processing policy (hopefully EA-137673 - assert: IdempotenceChecker.checkEquivalence)

This commit is contained in:
peter
2019-03-01 19:36:21 +01:00
parent 0c1aaccc3c
commit 120461a0d0
2 changed files with 8 additions and 3 deletions
@@ -666,14 +666,18 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag, HintedReferenc
@Override
@NotNull
public XmlTag[] getSubTags() {
boolean processIncludes = FileBasedIndex.getInstance().getFileBeingCurrentlyIndexed() == null &&
!XmlUtil.isStubBuilding(); // todo the first condition should be enough
boolean processIncludes = shouldProcessIncludesNow();
Key<CachedValue<XmlTag[]>> key = processIncludes ? SUBTAGS_WITH_INCLUDES_KEY : SUBTAGS_WITHOUT_INCLUDES_KEY;
XmlTag[] cached = CachedValuesManager.getCachedValue(this, key, () ->
Result.create(calcSubTags(processIncludes), PsiModificationTracker.MODIFICATION_COUNT));
return cached.clone();
}
public static boolean shouldProcessIncludesNow() {
return FileBasedIndex.getInstance().getFileBeingCurrentlyIndexed() == null &&
!XmlUtil.isStubBuilding(); // todo the first condition should be enough
}
@NotNull
protected XmlTag[] calcSubTags(boolean processIncludes) {
List<XmlTag> result = new ArrayList<>();
@@ -18,6 +18,7 @@ package com.intellij.xml.util;
import com.intellij.openapi.util.NullableComputable;
import com.intellij.openapi.util.RecursionManager;
import com.intellij.psi.PsiElement;
import com.intellij.psi.impl.source.xml.XmlTagImpl;
import com.intellij.psi.util.CachedValueProvider;
import com.intellij.psi.util.CachedValuesManager;
import com.intellij.psi.util.PsiModificationTracker;
@@ -42,7 +43,7 @@ class InclusionProvider implements CachedValueProvider<PsiElement[]> {
@NotNull
public static PsiElement[] getIncludedTags(XmlTag xincludeTag) {
if (XmlUtil.isStubBuilding()) return PsiElement.EMPTY_ARRAY;
if (!XmlTagImpl.shouldProcessIncludesNow()) return PsiElement.EMPTY_ARRAY;
return CachedValuesManager.getCachedValue(xincludeTag, new InclusionProvider(xincludeTag));
}