Analysis API: Rename resolveCandidates to collectCallCandidates.
Didn't bother to rename the directory in the test data.
This commit is contained in:
committed by
Ilya Kirillov
parent
58c6c25fe9
commit
7a1ef25333
+1
-1
@@ -147,7 +147,7 @@ internal class KtFe10CallResolver(
|
||||
}
|
||||
|
||||
// TODO: See Call.resolveCandidates() in plugins/kotlin/core/src/org/jetbrains/kotlin/idea/core/Utils.kt
|
||||
override fun resolveCandidates(psi: KtElement): List<KtCallInfo> = TODO()
|
||||
override fun collectCallCandidates(psi: KtElement): List<KtCallInfo> = TODO()
|
||||
|
||||
private fun handleAsCompoundAssignment(context: BindingContext, binaryExpression: KtBinaryExpression): KtCallInfo? {
|
||||
val left = binaryExpression.left ?: return null
|
||||
|
||||
+5
-5
@@ -698,9 +698,9 @@ internal class KtFirCallResolver(
|
||||
private fun FirValueParameterSymbol.toKtSymbol(): KtValueParameterSymbol =
|
||||
firSymbolBuilder.variableLikeBuilder.buildValueParameterSymbol(this)
|
||||
|
||||
override fun resolveCandidates(psi: KtElement): List<KtCallInfo> = withValidityAssertion {
|
||||
override fun collectCallCandidates(psi: KtElement): List<KtCallInfo> = withValidityAssertion {
|
||||
getKtCallInfos(psi) { psiToResolve, resolveCalleeExpressionOfFunctionCall, resolveFragmentOfCall ->
|
||||
resolveCandidates(
|
||||
collectCallCandidates(
|
||||
psiToResolve,
|
||||
resolveCalleeExpressionOfFunctionCall,
|
||||
resolveFragmentOfCall
|
||||
@@ -709,7 +709,7 @@ internal class KtFirCallResolver(
|
||||
}
|
||||
|
||||
// TODO: Refactor common code with FirElement.toKtCallInfo() when other FirResolvables are handled
|
||||
private fun FirElement.resolveCandidates(
|
||||
private fun FirElement.collectCallCandidates(
|
||||
psi: KtElement,
|
||||
resolveCalleeExpressionOfFunctionCall: Boolean,
|
||||
resolveFragmentOfCall: Boolean,
|
||||
@@ -725,7 +725,7 @@ internal class KtFirCallResolver(
|
||||
// // This way `f` is also the explicit receiver of this implicit `invoke` call
|
||||
// }
|
||||
// ```
|
||||
return explicitReceiver?.resolveCandidates(
|
||||
return explicitReceiver?.collectCallCandidates(
|
||||
psi,
|
||||
resolveCalleeExpressionOfFunctionCall = false,
|
||||
resolveFragmentOfCall = resolveFragmentOfCall
|
||||
@@ -736,7 +736,7 @@ internal class KtFirCallResolver(
|
||||
val firFile = psi.containingKtFile.getOrBuildFirFile(firResolveState)
|
||||
AllCandidatesResolver(analysisSession.rootModuleSession, firFile).getAllCandidates(this, psi, resolveFragmentOfCall)
|
||||
}
|
||||
is FirSafeCallExpression -> selector.resolveCandidates(
|
||||
is FirSafeCallExpression -> selector.collectCallCandidates(
|
||||
psi,
|
||||
resolveCalleeExpressionOfFunctionCall,
|
||||
resolveFragmentOfCall
|
||||
|
||||
+6
-8
@@ -7,9 +7,7 @@ package org.jetbrains.kotlin.analysis.api.impl.base.test.components
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.calls.KtCall
|
||||
import org.jetbrains.kotlin.analysis.api.calls.KtCallInfo
|
||||
import org.jetbrains.kotlin.analysis.api.impl.barebone.test.FrontendApiTestConfiguratorService
|
||||
import org.jetbrains.kotlin.analysis.api.impl.barebone.test.expressionMarkerProvider
|
||||
import org.jetbrains.kotlin.analysis.api.impl.base.test.test.framework.AbstractHLApiSingleModuleTest
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
@@ -24,7 +22,7 @@ abstract class AbstractResolveCandidatesTest : AbstractHLApiSingleModuleTest() {
|
||||
|
||||
val actual = executeOnPooledThreadInReadAction {
|
||||
analyseForTest(expression) {
|
||||
val candidates = resolveCandidates(expression)
|
||||
val candidates = collectCallCandidates(expression)
|
||||
if (candidates.isEmpty()) {
|
||||
"NO_CANDIDATES"
|
||||
} else {
|
||||
@@ -35,19 +33,19 @@ abstract class AbstractResolveCandidatesTest : AbstractHLApiSingleModuleTest() {
|
||||
testServices.assertions.assertEqualsToTestDataFileSibling(actual)
|
||||
}
|
||||
|
||||
private fun KtAnalysisSession.resolveCandidates(element: PsiElement): List<KtCallInfo> = when (element) {
|
||||
is KtValueArgument -> resolveCandidates(element.getArgumentExpression()!!)
|
||||
private fun KtAnalysisSession.collectCallCandidates(element: PsiElement): List<KtCallInfo> = when (element) {
|
||||
is KtValueArgument -> this@collectCallCandidates.collectCallCandidates(element.getArgumentExpression()!!)
|
||||
is KtDeclarationModifierList -> {
|
||||
val annotationEntry = element.annotationEntries.singleOrNull()
|
||||
?: error("Only single annotation entry is supported for now")
|
||||
annotationEntry.resolveCandidates()
|
||||
annotationEntry.collectCallCandidates()
|
||||
}
|
||||
is KtFileAnnotationList -> {
|
||||
val annotationEntry = element.annotationEntries.singleOrNull()
|
||||
?: error("Only single annotation entry is supported for now")
|
||||
annotationEntry.resolveCandidates()
|
||||
annotationEntry.collectCallCandidates()
|
||||
}
|
||||
is KtElement -> element.resolveCandidates()
|
||||
is KtElement -> element.collectCallCandidates()
|
||||
else -> error("Selected element type (${element::class.simpleName}) is not supported for resolveCandidates()")
|
||||
}
|
||||
|
||||
|
||||
+10
-3
@@ -13,7 +13,7 @@ import org.jetbrains.kotlin.psi.KtUnaryExpression
|
||||
|
||||
public abstract class KtCallResolver : KtAnalysisSessionComponent() {
|
||||
public abstract fun resolveCall(psi: KtElement): KtCallInfo?
|
||||
public abstract fun resolveCandidates(psi: KtElement): List<KtCallInfo>
|
||||
public abstract fun collectCallCandidates(psi: KtElement): List<KtCallInfo>
|
||||
}
|
||||
|
||||
public interface KtCallResolverMixIn : KtAnalysisSessionMixIn {
|
||||
@@ -31,6 +31,13 @@ public interface KtCallResolverMixIn : KtAnalysisSessionMixIn {
|
||||
public fun KtArrayAccessExpression.resolveCall(): KtCallInfo =
|
||||
analysisSession.callResolver.resolveCall(this) ?: error("KtArrayAccessExpression should always resolve to a KtCallInfo")
|
||||
|
||||
public fun KtElement.resolveCandidates(): List<KtCallInfo> =
|
||||
analysisSession.callResolver.resolveCandidates(this)
|
||||
/**
|
||||
* Returns all the candidates considered during [overload resolution](https://kotlinlang.org/spec/overload-resolution.html) for the call
|
||||
* corresponding to this [KtElement].
|
||||
*
|
||||
* [resolveCall] only returns the final result of overload resolution, i.e., the selected callable after considering candidate
|
||||
* applicability and choosing the most specific candidate.
|
||||
*/
|
||||
public fun KtElement.collectCallCandidates(): List<KtCallInfo> =
|
||||
analysisSession.callResolver.collectCallCandidates(this)
|
||||
}
|
||||
Reference in New Issue
Block a user