[FIR IDE] Properly support loop variables in KtFirSymbolProvider
This commit is contained in:
committed by
TeamCityServer
parent
58831eacca
commit
9113ccb8fc
+13
-6
@@ -35,12 +35,19 @@ internal class KtFirSymbolProvider(
|
||||
) : KtSymbolProvider(), ValidityTokenOwner {
|
||||
private val firSymbolProvider by weakRef(firSymbolProvider)
|
||||
|
||||
override fun getParameterSymbol(psi: KtParameter): KtValueParameterSymbol = withValidityAssertion {
|
||||
if (psi.isFunctionTypeParameter) {
|
||||
error("Creating KtValueParameterSymbol for function type parameter is not possible. Please see the KDoc of getParameterSymbol")
|
||||
}
|
||||
psi.withFirDeclarationOfType<FirValueParameter, KtValueParameterSymbol>(resolveState) {
|
||||
firSymbolBuilder.variableLikeBuilder.buildValueParameterSymbol(it)
|
||||
override fun getParameterSymbol(psi: KtParameter): KtVariableLikeSymbol = withValidityAssertion {
|
||||
when {
|
||||
psi.isFunctionTypeParameter -> error(
|
||||
"Creating KtValueParameterSymbol for function type parameter is not possible. Please see the KDoc of getParameterSymbol"
|
||||
)
|
||||
|
||||
psi.isLoopParameter -> psi.withFirDeclarationOfType<FirProperty, KtLocalVariableSymbol>(resolveState) {
|
||||
firSymbolBuilder.variableLikeBuilder.buildLocalVariableSymbol(it)
|
||||
}
|
||||
|
||||
else -> psi.withFirDeclarationOfType<FirValueParameter, KtValueParameterSymbol>(resolveState) {
|
||||
firSymbolBuilder.variableLikeBuilder.buildValueParameterSymbol(it)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+6
@@ -102,6 +102,12 @@ public class SymbolByPsiTestGenerated extends AbstractSymbolByPsiTest {
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/extensionFunction.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("forLoopVariable.kt")
|
||||
public void testForLoopVariable() throws Exception {
|
||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/forLoopVariable.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("function.kt")
|
||||
public void testFunction() throws Exception {
|
||||
|
||||
Reference in New Issue
Block a user