[psi] don't decompile to detect invalid code

in compiled code no error elements are possible

Merge-request: KT-MR-10407
Merged-by: Anna Kozlova <Anna.Kozlova@jetbrains.com>
This commit is contained in:
Anna Kozlova
2023-06-05 10:17:40 +00:00
committed by Space Team
parent f2520a9cb7
commit cc76bbd09d
@@ -154,10 +154,18 @@ public class KtParameter extends KtNamedDeclarationStub<KotlinParameterStub> imp
private <T extends PsiElement> boolean checkParentOfParentType(Class<T> klass) {
// `parent` is supposed to be [KtParameterList]
PsiElement parent = getParent();
if (parent == null || parent.getNextSibling() instanceof PsiErrorElement) {
if (parent == null) {
return false;
}
return klass.isInstance(parent.getParent());
if (klass.isInstance(parent.getParent())) {
//don't check ast if the tree structure is different; skip for compiled code
if (!getContainingKtFile().isCompiled() &&
parent.getNextSibling() instanceof PsiErrorElement) {
return false;
}
return true;
}
return false;
}
public boolean isCatchParameter() {