xml / js / editorconfig / json: more forceAllowTreeLoading places

This commit is contained in:
anstarovoyt
2018-10-15 18:35:55 +03:00
parent f6a1a0fe2b
commit 228ca4680d
4 changed files with 11 additions and 3 deletions
@@ -120,7 +120,8 @@ public class JsonCachedValues {
@Nullable
static String fetchSchemaId(@NotNull PsiFile psiFile) {
final JsonObject topLevelValue = ObjectUtils.tryCast(((JsonFile)psiFile).getTopLevelValue(), JsonObject.class);
final JsonObject topLevelValue = AstLoadingFilter
.forceAllowTreeLoading(psiFile, () ->ObjectUtils.tryCast(((JsonFile)psiFile).getTopLevelValue(), JsonObject.class));
return topLevelValue == null ? null : readId(topLevelValue);
}
@@ -1,6 +1,7 @@
// Copyright 2000-2018 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 org.editorconfig.language.util.headers
import com.intellij.util.AstLoadingFilter
import org.editorconfig.language.psi.EditorConfigHeader
import org.editorconfig.language.psi.EditorConfigPsiFile
import org.editorconfig.language.psi.EditorConfigSection
@@ -27,7 +28,7 @@ abstract class EditorConfigHeaderOverrideSearcherBase {
val currentFile = EditorConfigPsiTreeUtil.getOriginalFile(header.containingFile) as? EditorConfigPsiFile ?: return emptySequence()
return findRelevantPsiFiles(currentFile)
.map(EditorConfigPsiFile::sections)
.map { AstLoadingFilter.forceAllowTreeLoading<List<EditorConfigSection>, RuntimeException>(it) { it.sections } }
.flatMap(List<EditorConfigSection>::asSequence)
.map(EditorConfigSection::getHeader)
.filter(EditorConfigHeader::isValidGlob)
@@ -28,6 +28,7 @@ import com.intellij.psi.util.*;
import com.intellij.psi.xml.XmlAttribute;
import com.intellij.psi.xml.XmlTag;
import com.intellij.util.ArrayUtil;
import com.intellij.util.AstLoadingFilter;
import com.intellij.xml.XmlAttributeDescriptor;
import com.intellij.xml.XmlElementDescriptor;
import com.intellij.xml.XmlElementsGroup;
@@ -271,6 +272,11 @@ public class RngElementDescriptor implements XmlElementDescriptor {
return decl;
}
return AstLoadingFilter.forceAllowTreeLoading(file, () -> getDeclarationImpl(project, decl, location, file));
}
@Nullable
private static PsiElement getDeclarationImpl(@NotNull Project project, PsiElement decl, Locator location, PsiFile file) {
final int column = location.getColumnNumber();
final int line = location.getLineNumber();
@@ -462,7 +462,7 @@ public class XmlTagImpl extends XmlElementImpl implements XmlTag, HintedReferenc
if (file == null) {
return namespace.equals(XmlUtil.getTargetSchemaNsFromTag(this)) ? this : null;
}
return file.getDocument();
return AstLoadingFilter.forceAllowTreeLoading(file, () -> file.getDocument());
}
@Override