mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
don't even try to instantiate UAST for leaf elements where it surely won't exist or be needed
This commit is contained in:
+2
-1
@@ -9,6 +9,7 @@ import com.intellij.openapi.roots.ProjectFileIndex;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.VirtualFile;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.source.tree.LeafPsiElement;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import com.intellij.psi.util.PsiUtilCore;
|
||||
@@ -57,7 +58,7 @@ public abstract class AnnotatedElementInspectionBase extends LocalInspectionTool
|
||||
@Override
|
||||
public void visitElement(PsiElement element) {
|
||||
super.visitElement(element);
|
||||
if (element instanceof PsiLanguageInjectionHost) {
|
||||
if (element instanceof PsiLanguageInjectionHost || element instanceof LeafPsiElement) {
|
||||
return; // better performance
|
||||
}
|
||||
|
||||
|
||||
@@ -61,6 +61,10 @@ class UastContext(val project: Project) : UastLanguagePlugin {
|
||||
}
|
||||
|
||||
override fun convertElementWithParent(element: PsiElement, requiredType: Class<out UElement>?): UElement? {
|
||||
if (element is PsiWhiteSpace) {
|
||||
return null
|
||||
}
|
||||
|
||||
val cachedElement = element.getUserData(CACHED_UELEMENT_KEY)?.get()
|
||||
if (cachedElement != null) {
|
||||
return if (requiredType == null || requiredType.isInstance(cachedElement)) cachedElement else null
|
||||
|
||||
Reference in New Issue
Block a user