[Analysis API FIR] fix call resolution of non-resolvable elements

This commit is contained in:
Ilya Kirillov
2022-10-01 10:36:02 +02:00
parent ccdb6fc599
commit ab3f916f3f
13 changed files with 124 additions and 24 deletions
@@ -45,17 +45,19 @@ abstract class AbstractKtCallResolver : KtCallResolver() {
return KtPsiUtil.deparenthesize(safeQualifiedExpression.receiverExpression) == KtPsiUtil.deparenthesize(this)
}
protected fun canBeResolvedAsCall(ktElement: KtElement): Boolean = when (ktElement) {
is KtBinaryExpression -> ktElement.operationToken !in nonCallBinaryOperator
is KtOperationReferenceExpression -> ktElement.operationSignTokenType !in nonCallBinaryOperator
is KtCallElement -> true
is KtConstructorCalleeExpression -> true
is KtDotQualifiedExpression -> true
is KtNameReferenceExpression -> true
is KtOperationExpression -> true
is KtArrayAccessExpression -> true
else -> false
}
protected companion object {
private val nonCallBinaryOperator: Set<KtSingleValueToken> = setOf(KtTokens.ELVIS, KtTokens.EQEQEQ, KtTokens.EXCLEQEQEQ)
/**
* We don't want to resolve the operators from the [AbstractKtCallResolver.nonCallBinaryOperator] list, because it's either
* not possible or not desirable.
*/
fun KtElement.isNotResolvable(): Boolean {
return this is KtBinaryExpression && operationToken in nonCallBinaryOperator ||
this is KtOperationReferenceExpression && operationSignTokenType in nonCallBinaryOperator
}
}
}