Commit bcf1b83f authored by Jinseong Jeon's avatar Jinseong Jeon
Browse files

FIR UAST: add support for multi resolve

parent 76a12824
Showing with 18 additions and 21 deletions
+18 -21
......@@ -185,6 +185,22 @@ interface FirKotlinUastResolveProviderService : BaseKotlinUastResolveProviderSer
return psiElement.annotations
}
override fun getReferenceVariants(ktExpression: KtExpression, nameHint: String): Sequence<PsiElement> {
analyzeForUast(ktExpression) {
return ktExpression.collectCallCandidates().asSequence().mapNotNull {
when (val candidate = it.candidate) {
is KtFunctionCall<*> -> {
toPsiMethod(candidate.partiallyAppliedSymbol.symbol, ktExpression)
}
is KtCompoundAccessCall -> {
toPsiMethod(candidate.compoundAccess.operationPartiallyAppliedSymbol.symbol, ktExpression)
}
else -> null
}
}
}
}
override fun resolveBitwiseOperators(ktBinaryExpression: KtBinaryExpression): UastBinaryOperator {
val other = UastBinaryOperator.OTHER
analyzeForUast(ktBinaryExpression) {
......
......@@ -3,14 +3,9 @@
package org.jetbrains.uast.kotlin.internal
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.uast.kotlin.FirKotlinUastResolveProviderService
class FirCliKotlinUastResolveProviderService : FirKotlinUastResolveProviderService {
// Currently, UAST CLI is used by Android Lint, i.e., everything is a JVM element.
override fun isJvmElement(psiElement: PsiElement): Boolean = true
override fun getReferenceVariants(ktExpression: KtExpression, nameHint: String): Sequence<PsiElement> {
return emptySequence() // Not supported (as per the counterpart [CliKotlinUastResolveProviderService])
}
}
......@@ -20,20 +20,12 @@ class FirUastResolveApiFixtureTest : KotlinLightCodeInsightFixtureTestCase(), Ua
KotlinWithJdkAndRuntimeLightProjectDescriptor.getInstance()
private val whitelist : Set<String> = setOf(
// TODO: multiResolve, getArgumentForParameter
"MultiResolve",
// TODO: multiResolve, getArgumentForParameter
"MultiResolveJava",
// TODO: multiResolve, getArgumentForParameter, return type for ambiguous call
// TODO: return type for ambiguous call
"MultiResolveJavaAmbiguous",
// TODO: multiResolve
"MultiResolveInClass",
// TODO: multiResolve, return type for ambiguous call
// TODO: return type for ambiguous call
"MultiConstructorResolve",
// TODO: multiResolve
"MultiInvokableObjectResolve",
// TODO: multiResolve
"MultiResolveJvmOverloads",
// TODO: resolve annotation param to annotation ctor ??
"ResolveCompiledAnnotation",
)
......
......@@ -3,14 +3,8 @@
package org.jetbrains.uast.kotlin.internal
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.uast.kotlin.FirKotlinUastResolveProviderService
class FirIdeaKotlinUastResolveProviderService : FirKotlinUastResolveProviderService {
override fun isJvmElement(psiElement: PsiElement): Boolean = psiElement.isJvmElement
override fun getReferenceVariants(ktExpression: KtExpression, nameHint: String): Sequence<PsiElement> {
// TODO("Not yet implemented")
return emptySequence()
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment