FIR IDE: avoid finding symbol for function type parameter

This commit is contained in:
Jinseong Jeon
2021-07-13 12:07:43 -07:00
committed by Ilya Kirillov
parent 2e502bd01e
commit 9ec4d19a3f
6 changed files with 173 additions and 5 deletions
@@ -140,8 +140,39 @@ public class KtParameter extends KtNamedDeclarationStub<KotlinParameterStub> imp
return getParent() instanceof KtForExpression;
}
private <T extends PsiElement> boolean checkParentOfParentType(Class<T> klass) {
// `parent` is supposed to be [KtParameterList]
PsiElement parent = getParent();
if (parent == null) {
return false;
}
return klass.isInstance(parent.getParent());
}
public boolean isCatchParameter() {
return getParent().getParent() instanceof KtCatchClause;
return checkParentOfParentType(KtCatchClause.class);
}
/**
* For example,
* lambdaConsumer { lambdaParameter ->
* ...
* }
*
* @return [true] if this [KtParameter] is a parameter of a lambda.
*/
public boolean isLambdaParameter() {
return checkParentOfParentType(KtFunctionLiteral.class);
}
/**
* For example,
* fun foo(lambdaArgument: (functionTypeParameter: T, ...) -> R) { ... }
*
* @return [true] if this [KtParameter] is a parameter of a function type.
*/
public boolean isFunctionTypeParameter() {
return checkParentOfParentType(KtFunctionType.class);
}
@Nullable