FIR IDE: Avoid resolving elvis operator, because it doesn't make sense

There are intrinsics to which elvis operator's usages are resolved;
however, we do not want to expose those intrinsics through the
high-level resolve
This commit is contained in:
Roman Golyshev
2021-12-21 16:01:07 +03:00
committed by teamcity
parent 702ab3408b
commit e3219cc5b6
17 changed files with 124 additions and 2 deletions
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.analysis.api.calls.KtCompoundAccess
import org.jetbrains.kotlin.analysis.api.calls.KtExplicitReceiverValue
import org.jetbrains.kotlin.analysis.api.components.KtCallResolver
import org.jetbrains.kotlin.analysis.api.impl.barebone.parentOfType
import org.jetbrains.kotlin.lexer.KtSingleValueToken
import org.jetbrains.kotlin.lexer.KtTokens
import org.jetbrains.kotlin.psi.*
@@ -44,6 +45,16 @@ abstract class AbstractKtCallResolver : KtCallResolver() {
}
protected companion object {
val nonCallBinaryOperator = setOf(KtTokens.ELVIS, KtTokens.EQEQEQ, KtTokens.EXCLEQEQEQ)
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
}
}
}