Return error candidates from KtFirArrayAccessReference.resolveToSymbols
This commit is contained in:
@@ -48,6 +48,9 @@ private fun FirBasedSymbol<*>.isInvokeFunction() =
|
||||
fun FirFunctionCall.getCalleeSymbol(): FirBasedSymbol<*>? =
|
||||
calleeReference.getResolvedSymbolOfNameReference()
|
||||
|
||||
fun FirFunctionCall.getCandidateSymbols(): Collection<FirBasedSymbol<*>> =
|
||||
calleeReference.getCandidateSymbols()
|
||||
|
||||
fun FirReference.getResolvedSymbolOfNameReference(): FirBasedSymbol<*>? =
|
||||
(this as? FirResolvedNamedReference)?.resolvedSymbol
|
||||
|
||||
@@ -84,4 +87,4 @@ internal fun FirAnnotation.toKtAnnotationApplication(useSiteSession: FirSession)
|
||||
useSiteSession,
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -6,13 +6,13 @@
|
||||
package org.jetbrains.kotlin.idea.references
|
||||
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||
import org.jetbrains.kotlin.analysis.api.fir.getCalleeSymbol
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFirSafe
|
||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.fir.KtFirAnalysisSession
|
||||
import org.jetbrains.kotlin.analysis.api.fir.buildSymbol
|
||||
import org.jetbrains.kotlin.analysis.api.fir.getCandidateSymbols
|
||||
import org.jetbrains.kotlin.analysis.api.symbols.KtSymbol
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFirSafe
|
||||
import org.jetbrains.kotlin.fir.expressions.FirFunctionCall
|
||||
import org.jetbrains.kotlin.psi.KtArrayAccessExpression
|
||||
|
||||
class KtFirArrayAccessReference(
|
||||
@@ -21,8 +21,8 @@ class KtFirArrayAccessReference(
|
||||
override fun KtAnalysisSession.resolveToSymbols(): Collection<KtSymbol> {
|
||||
check(this is KtFirAnalysisSession)
|
||||
val fir = element.getOrBuildFirSafe<FirFunctionCall>(firResolveState) ?: return emptyList()
|
||||
return listOfNotNull(fir.getCalleeSymbol()?.fir?.buildSymbol(firSymbolBuilder))
|
||||
return fir.getCandidateSymbols().map { it.fir.buildSymbol(firSymbolBuilder) }
|
||||
}
|
||||
|
||||
override fun handleElementRename(newElementName: String): PsiElement = TODO("Not yet implemented")
|
||||
}
|
||||
}
|
||||
|
||||
+24
@@ -675,11 +675,35 @@ public class FirReferenceResolveTestGenerated extends AbstractFirReferenceResolv
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/arrayAccess/get.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("getFunction.kt")
|
||||
public void testGetFunction() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/arrayAccess/getFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("getOperator.kt")
|
||||
public void testGetOperator() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/arrayAccess/getOperator.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("set.kt")
|
||||
public void testSet() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/arrayAccess/set.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("setFunction.kt")
|
||||
public void testSetFunction() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/arrayAccess/setFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("setOperator.kt")
|
||||
public void testSetOperator() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/referenceResolve/arrayAccess/setOperator.kt");
|
||||
}
|
||||
}
|
||||
|
||||
@Nested
|
||||
|
||||
@@ -0,0 +1,5 @@
|
||||
fun Int.get(index: Int) = 42
|
||||
|
||||
fun f() {
|
||||
1<caret>[2]
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
Resolved to:
|
||||
0: (in ROOT) fun kotlin.Int.get(index: kotlin.Int): kotlin.Int
|
||||
@@ -0,0 +1,5 @@
|
||||
operator fun Int.get(index: Int) = 42
|
||||
|
||||
fun f() {
|
||||
1<caret>[2]
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
Resolved to:
|
||||
0: (in ROOT) operator fun kotlin.Int.get(index: kotlin.Int): kotlin.Int
|
||||
@@ -0,0 +1,5 @@
|
||||
fun Int.set(index: Int, value: Int) = value
|
||||
|
||||
fun f() {
|
||||
1<caret>[2] = 42
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
Resolved to:
|
||||
0: (in ROOT) fun kotlin.Int.set(index: kotlin.Int, value: kotlin.Int): kotlin.Int
|
||||
@@ -0,0 +1,5 @@
|
||||
operator fun Int.set(index: Int, value: Int) = value
|
||||
|
||||
fun f() {
|
||||
1<caret>[2] = 42
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
Resolved to:
|
||||
0: (in ROOT) operator fun kotlin.Int.set(index: kotlin.Int, value: kotlin.Int): kotlin.Int
|
||||
Reference in New Issue
Block a user