[AA FIR] implement FirCallableSignature to simplify search by signature
^KT-54826 Fixed
This commit is contained in:
committed by
Space Team
parent
48e2e5cc87
commit
2155a23e4e
+12
@@ -244,6 +244,12 @@ public class Fe10IdeNormalAnalysisSourceModuleSymbolByPsiTestGenerated extends A
|
|||||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/outerAndInnerTypeAlias.kt");
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/outerAndInnerTypeAlias.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("similarGenericSignature.kt")
|
||||||
|
public void testSimilarGenericSignature() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/similarGenericSignature.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("topLevelFunctions.kt")
|
@TestMetadata("topLevelFunctions.kt")
|
||||||
public void testTopLevelFunctions() throws Exception {
|
public void testTopLevelFunctions() throws Exception {
|
||||||
@@ -306,6 +312,12 @@ public class Fe10IdeNormalAnalysisSourceModuleSymbolByPsiTestGenerated extends A
|
|||||||
public void testContextReceiversOnProperty() throws Exception {
|
public void testContextReceiversOnProperty() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/contextReceivers/contextReceiversOnProperty.kt");
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/contextReceivers/contextReceiversOnProperty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("similarSignatures.kt")
|
||||||
|
public void testSimilarSignatures() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/contextReceivers/similarSignatures.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+9
-3
@@ -9,8 +9,8 @@ import com.intellij.psi.PsiElement
|
|||||||
import org.jetbrains.kotlin.analysis.api.fir.KtSymbolByFirBuilder
|
import org.jetbrains.kotlin.analysis.api.fir.KtSymbolByFirBuilder
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.annotations.KtFirAnnotationListForDeclaration
|
import org.jetbrains.kotlin.analysis.api.fir.annotations.KtFirAnnotationListForDeclaration
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.findPsi
|
import org.jetbrains.kotlin.analysis.api.fir.findPsi
|
||||||
|
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.FirCallableSignature
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.KtFirConstructorSymbolPointer
|
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.KtFirConstructorSymbolPointer
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.createSignature
|
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.requireOwnerPointer
|
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.requireOwnerPointer
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.utils.cached
|
import org.jetbrains.kotlin.analysis.api.fir.utils.cached
|
||||||
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
|
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
|
||||||
@@ -49,7 +49,13 @@ internal class KtFirConstructorSymbol(
|
|||||||
|
|
||||||
override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility }
|
override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility }
|
||||||
|
|
||||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, firResolveSession.useSiteFirSession, token) }
|
override val annotationsList by cached {
|
||||||
|
KtFirAnnotationListForDeclaration.create(
|
||||||
|
firSymbol,
|
||||||
|
firResolveSession.useSiteFirSession,
|
||||||
|
token,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
override val containingClassIdIfNonLocal: ClassId?
|
override val containingClassIdIfNonLocal: ClassId?
|
||||||
get() = withValidityAssertion { firSymbol.containingClassLookupTag()?.classId?.takeUnless { it.isLocal } }
|
get() = withValidityAssertion { firSymbol.containingClassLookupTag()?.classId?.takeUnless { it.isLocal } }
|
||||||
@@ -65,7 +71,7 @@ internal class KtFirConstructorSymbol(
|
|||||||
throw CanNotCreateSymbolPointerForLocalLibraryDeclarationException("constructor")
|
throw CanNotCreateSymbolPointerForLocalLibraryDeclarationException("constructor")
|
||||||
}
|
}
|
||||||
|
|
||||||
KtFirConstructorSymbolPointer(requireOwnerPointer(), isPrimary, firSymbol.createSignature())
|
KtFirConstructorSymbolPointer(requireOwnerPointer(), isPrimary, FirCallableSignature.createSignature(firSymbol))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = symbolEquals(other)
|
override fun equals(other: Any?): Boolean = symbolEquals(other)
|
||||||
|
|||||||
+7
-3
@@ -10,9 +10,9 @@ import org.jetbrains.kotlin.analysis.api.base.KtContextReceiver
|
|||||||
import org.jetbrains.kotlin.analysis.api.fir.KtSymbolByFirBuilder
|
import org.jetbrains.kotlin.analysis.api.fir.KtSymbolByFirBuilder
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.annotations.KtFirAnnotationListForDeclaration
|
import org.jetbrains.kotlin.analysis.api.fir.annotations.KtFirAnnotationListForDeclaration
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.findPsi
|
import org.jetbrains.kotlin.analysis.api.fir.findPsi
|
||||||
|
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.FirCallableSignature
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.KtFirMemberFunctionSymbolPointer
|
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.KtFirMemberFunctionSymbolPointer
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.KtFirTopLevelFunctionSymbolPointer
|
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.KtFirTopLevelFunctionSymbolPointer
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.createSignature
|
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.requireOwnerPointer
|
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.requireOwnerPointer
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.utils.cached
|
import org.jetbrains.kotlin.analysis.api.fir.utils.cached
|
||||||
import org.jetbrains.kotlin.analysis.api.impl.base.util.kotlinFunctionInvokeCallableIds
|
import org.jetbrains.kotlin.analysis.api.impl.base.util.kotlinFunctionInvokeCallableIds
|
||||||
@@ -96,11 +96,15 @@ internal class KtFirFunctionSymbol(
|
|||||||
KtPsiBasedSymbolPointer.createForSymbolFromSource<KtFunctionSymbol>(this)?.let { return it }
|
KtPsiBasedSymbolPointer.createForSymbolFromSource<KtFunctionSymbol>(this)?.let { return it }
|
||||||
|
|
||||||
return when (val kind = symbolKind) {
|
return when (val kind = symbolKind) {
|
||||||
KtSymbolKind.TOP_LEVEL -> KtFirTopLevelFunctionSymbolPointer(firSymbol.callableId, firSymbol.createSignature())
|
KtSymbolKind.TOP_LEVEL -> KtFirTopLevelFunctionSymbolPointer(
|
||||||
|
firSymbol.callableId,
|
||||||
|
FirCallableSignature.createSignature(firSymbol),
|
||||||
|
)
|
||||||
|
|
||||||
KtSymbolKind.CLASS_MEMBER -> KtFirMemberFunctionSymbolPointer(
|
KtSymbolKind.CLASS_MEMBER -> KtFirMemberFunctionSymbolPointer(
|
||||||
requireOwnerPointer(),
|
requireOwnerPointer(),
|
||||||
firSymbol.name,
|
firSymbol.name,
|
||||||
firSymbol.createSignature(),
|
FirCallableSignature.createSignature(firSymbol),
|
||||||
)
|
)
|
||||||
|
|
||||||
KtSymbolKind.LOCAL -> throw CanNotCreateSymbolPointerForLocalLibraryDeclarationException(
|
KtSymbolKind.LOCAL -> throw CanNotCreateSymbolPointerForLocalLibraryDeclarationException(
|
||||||
|
|||||||
+7
-3
@@ -12,9 +12,9 @@ import org.jetbrains.kotlin.analysis.api.base.KtContextReceiver
|
|||||||
import org.jetbrains.kotlin.analysis.api.fir.KtSymbolByFirBuilder
|
import org.jetbrains.kotlin.analysis.api.fir.KtSymbolByFirBuilder
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.annotations.KtFirAnnotationListForDeclaration
|
import org.jetbrains.kotlin.analysis.api.fir.annotations.KtFirAnnotationListForDeclaration
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.findPsi
|
import org.jetbrains.kotlin.analysis.api.fir.findPsi
|
||||||
|
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.FirCallableSignature
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.KtFirMemberPropertySymbolPointer
|
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.KtFirMemberPropertySymbolPointer
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.KtFirTopLevelPropertySymbolPointer
|
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.KtFirTopLevelPropertySymbolPointer
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.createSignature
|
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.requireOwnerPointer
|
import org.jetbrains.kotlin.analysis.api.fir.symbols.pointers.requireOwnerPointer
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.utils.cached
|
import org.jetbrains.kotlin.analysis.api.fir.utils.cached
|
||||||
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
|
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
|
||||||
@@ -136,12 +136,16 @@ internal class KtFirKotlinPropertySymbol(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return when (val kind = symbolKind) {
|
return when (val kind = symbolKind) {
|
||||||
KtSymbolKind.TOP_LEVEL -> KtFirTopLevelPropertySymbolPointer(firSymbol.callableId, firSymbol.createSignature())
|
KtSymbolKind.TOP_LEVEL -> KtFirTopLevelPropertySymbolPointer(
|
||||||
|
firSymbol.callableId,
|
||||||
|
FirCallableSignature.createSignature(firSymbol),
|
||||||
|
)
|
||||||
|
|
||||||
KtSymbolKind.CLASS_MEMBER ->
|
KtSymbolKind.CLASS_MEMBER ->
|
||||||
KtFirMemberPropertySymbolPointer(
|
KtFirMemberPropertySymbolPointer(
|
||||||
requireOwnerPointer(),
|
requireOwnerPointer(),
|
||||||
firSymbol.name,
|
firSymbol.name,
|
||||||
firSymbol.createSignature(),
|
FirCallableSignature.createSignature(firSymbol),
|
||||||
)
|
)
|
||||||
|
|
||||||
else -> throw UnsupportedSymbolKind(this::class, kind)
|
else -> throw UnsupportedSymbolKind(this::class, kind)
|
||||||
|
|||||||
+2
-1
@@ -1,11 +1,12 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.jetbrains.kotlin.analysis.api.fir.symbols
|
package org.jetbrains.kotlin.analysis.api.fir.symbols
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
import com.intellij.psi.PsiElement
|
||||||
|
import org.jetbrains.kotlin.analysis.api.analyze
|
||||||
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationsList
|
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationsList
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.KtSymbolByFirBuilder
|
import org.jetbrains.kotlin.analysis.api.fir.KtSymbolByFirBuilder
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.annotations.KtFirAnnotationListForDeclaration
|
import org.jetbrains.kotlin.analysis.api.fir.annotations.KtFirAnnotationListForDeclaration
|
||||||
|
|||||||
+98
-15
@@ -5,26 +5,109 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.analysis.api.fir.symbols.pointers
|
package org.jetbrains.kotlin.analysis.api.fir.symbols.pointers
|
||||||
|
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.ideSessionComponents
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
|
import org.jetbrains.kotlin.fir.declarations.FirCallableDeclaration
|
||||||
|
import org.jetbrains.kotlin.fir.declarations.FirFunction
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||||
import org.jetbrains.kotlin.fir.renderWithType
|
import org.jetbrains.kotlin.fir.renderer.ConeIdFullRenderer
|
||||||
|
import org.jetbrains.kotlin.fir.renderer.ConeTypeRenderer
|
||||||
|
import org.jetbrains.kotlin.fir.renderer.FirRenderer
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
||||||
import org.jetbrains.kotlin.ir.util.IdSignature
|
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
||||||
|
|
||||||
internal data class FirCallableSignature(private val idSignature: IdSignature) {
|
/**
|
||||||
fun sameSignature(declaration: FirCallableDeclaration): Boolean = this == declaration.createSignature()
|
* **Note**: the signature doesn't contain a name. This check should be done externally.
|
||||||
|
*/
|
||||||
|
internal class FirCallableSignature private constructor(
|
||||||
|
private val receiverType: String?,
|
||||||
|
private val contextReceiverTypes: List<String>,
|
||||||
|
private val parameters: List<String>?,
|
||||||
|
private val typeParametersCount: Int,
|
||||||
|
private val returnType: String,
|
||||||
|
) {
|
||||||
fun sameSignature(declaration: FirCallableSymbol<*>): Boolean = sameSignature(declaration.fir)
|
fun sameSignature(declaration: FirCallableSymbol<*>): Boolean = sameSignature(declaration.fir)
|
||||||
|
|
||||||
|
fun sameSignature(declaration: FirCallableDeclaration): Boolean {
|
||||||
|
if ((receiverType == null) != (declaration.receiverParameter == null)) return false
|
||||||
|
if (contextReceiverTypes.size != declaration.contextReceivers.size) return false
|
||||||
|
if (typeParametersCount != declaration.typeParameters.size) return false
|
||||||
|
if (parameters?.size != (declaration as? FirFunction)?.valueParameters?.size) return false
|
||||||
|
|
||||||
|
declaration.lazyResolveToPhase(FirResolvePhase.TYPES)
|
||||||
|
if (receiverType != declaration.receiverParameter?.typeRef?.renderType()) return false
|
||||||
|
|
||||||
|
val receivers = declaration.contextReceivers
|
||||||
|
for ((index, parameter) in contextReceiverTypes.withIndex()) {
|
||||||
|
if (receivers[index].typeRef.renderType() != parameter) return false
|
||||||
|
}
|
||||||
|
|
||||||
|
if (declaration is FirFunction) {
|
||||||
|
requireNotNull(parameters)
|
||||||
|
for ((index, parameter) in declaration.valueParameters.withIndex()) {
|
||||||
|
if (parameters[index] != parameter.returnTypeRef.renderType()) return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
declaration.lazyResolveToPhase(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE)
|
||||||
|
|
||||||
|
return returnType == declaration.returnTypeRef.renderType()
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun equals(other: Any?): Boolean {
|
||||||
|
if (this === other) return true
|
||||||
|
if (other !is FirCallableSignature) return false
|
||||||
|
|
||||||
|
if (receiverType != other.receiverType) return false
|
||||||
|
if (contextReceiverTypes != other.contextReceiverTypes) return false
|
||||||
|
if (parameters != other.parameters) return false
|
||||||
|
if (typeParametersCount != other.typeParametersCount) return false
|
||||||
|
return returnType == other.returnType
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
var result = receiverType?.hashCode() ?: 0
|
||||||
|
result = 31 * result + contextReceiverTypes.hashCode()
|
||||||
|
result = 31 * result + parameters.hashCode()
|
||||||
|
result = 31 * result + typeParametersCount.hashCode()
|
||||||
|
result = 31 * result + returnType.hashCode()
|
||||||
|
return result
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun createSignature(callableSymbol: FirCallableSymbol<*>): FirCallableSignature = createSignature(callableSymbol.fir)
|
||||||
|
|
||||||
|
fun createSignature(callableDeclaration: FirCallableDeclaration): FirCallableSignature {
|
||||||
|
callableDeclaration.lazyResolveToPhase(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE)
|
||||||
|
|
||||||
|
return FirCallableSignature(
|
||||||
|
receiverType = callableDeclaration.receiverParameter?.typeRef?.renderType(),
|
||||||
|
contextReceiverTypes = callableDeclaration.contextReceivers.map { it.typeRef.renderType() },
|
||||||
|
parameters = if (callableDeclaration is FirFunction) {
|
||||||
|
callableDeclaration.valueParameters.map { it.returnTypeRef.renderType() }
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
},
|
||||||
|
typeParametersCount = callableDeclaration.typeParameters.size,
|
||||||
|
returnType = callableDeclaration.returnTypeRef.renderType(),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun FirCallableSymbol<*>.createSignature(): FirCallableSignature = fir.createSignature()
|
private fun FirTypeRef.renderType(): String = FirRenderer(
|
||||||
|
annotationRenderer = null,
|
||||||
internal fun FirCallableDeclaration.createSignature(): FirCallableSignature {
|
bodyRenderer = null,
|
||||||
lazyResolveToPhase(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE)
|
callArgumentsRenderer = null,
|
||||||
val signatureComposer = moduleData.session.ideSessionComponents.signatureComposer
|
classMemberRenderer = null,
|
||||||
return FirCallableSignature(
|
contractRenderer = null,
|
||||||
signatureComposer.composeSignature(this, allowLocalClasses = true)
|
declarationRenderer = null,
|
||||||
?: error("Could not compose signature for ${this.renderWithType()}, looks like it is private or local")
|
idRenderer = ConeIdFullRenderer(),
|
||||||
)
|
modifierRenderer = null,
|
||||||
}
|
packageDirectiveRenderer = null,
|
||||||
|
propertyAccessorRenderer = null,
|
||||||
|
resolvePhaseRenderer = null,
|
||||||
|
typeRenderer = ConeTypeRenderer(),
|
||||||
|
valueParameterRenderer = null,
|
||||||
|
errorExpressionRenderer = null,
|
||||||
|
).renderElementAsString(this)
|
||||||
|
|||||||
+12
@@ -244,6 +244,12 @@ public class FirIdeNormalAnalysisSourceModuleSymbolByPsiTestGenerated extends Ab
|
|||||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/outerAndInnerTypeAlias.kt");
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/outerAndInnerTypeAlias.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("similarGenericSignature.kt")
|
||||||
|
public void testSimilarGenericSignature() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/similarGenericSignature.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("topLevelFunctions.kt")
|
@TestMetadata("topLevelFunctions.kt")
|
||||||
public void testTopLevelFunctions() throws Exception {
|
public void testTopLevelFunctions() throws Exception {
|
||||||
@@ -306,6 +312,12 @@ public class FirIdeNormalAnalysisSourceModuleSymbolByPsiTestGenerated extends Ab
|
|||||||
public void testContextReceiversOnProperty() throws Exception {
|
public void testContextReceiversOnProperty() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/contextReceivers/contextReceiversOnProperty.kt");
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/contextReceivers/contextReceiversOnProperty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("similarSignatures.kt")
|
||||||
|
public void testSimilarSignatures() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/contextReceivers/similarSignatures.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+12
@@ -244,6 +244,12 @@ public class FirStandaloneNormalAnalysisSourceModuleSymbolByPsiTestGenerated ext
|
|||||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/outerAndInnerTypeAlias.kt");
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/outerAndInnerTypeAlias.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("similarGenericSignature.kt")
|
||||||
|
public void testSimilarGenericSignature() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/similarGenericSignature.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@TestMetadata("topLevelFunctions.kt")
|
@TestMetadata("topLevelFunctions.kt")
|
||||||
public void testTopLevelFunctions() throws Exception {
|
public void testTopLevelFunctions() throws Exception {
|
||||||
@@ -306,6 +312,12 @@ public class FirStandaloneNormalAnalysisSourceModuleSymbolByPsiTestGenerated ext
|
|||||||
public void testContextReceiversOnProperty() throws Exception {
|
public void testContextReceiversOnProperty() throws Exception {
|
||||||
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/contextReceivers/contextReceiversOnProperty.kt");
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/contextReceivers/contextReceiversOnProperty.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
@TestMetadata("similarSignatures.kt")
|
||||||
|
public void testSimilarSignatures() throws Exception {
|
||||||
|
runTest("analysis/analysis-api/testData/symbols/symbolByPsi/contextReceivers/similarSignatures.kt");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nested
|
@Nested
|
||||||
|
|||||||
+1
-1
@@ -1,5 +1,5 @@
|
|||||||
// DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE
|
// DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE
|
||||||
// DO_NOT_CHECK_SYMBOL_RESTORE
|
// DO_NOT_CHECK_SYMBOL_RESTORE_K1
|
||||||
package test
|
package test
|
||||||
|
|
||||||
class SomeClass
|
class SomeClass
|
||||||
|
|||||||
+1
@@ -1,4 +1,5 @@
|
|||||||
// DO_NOT_CHECK_SYMBOL_RESTORE_K2
|
// DO_NOT_CHECK_SYMBOL_RESTORE_K2
|
||||||
|
// KT-55095
|
||||||
|
|
||||||
package test
|
package test
|
||||||
|
|
||||||
|
|||||||
+16
@@ -0,0 +1,16 @@
|
|||||||
|
// DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE_K1
|
||||||
|
|
||||||
|
class A
|
||||||
|
class B
|
||||||
|
|
||||||
|
context(A)
|
||||||
|
fun tooo() = Unit
|
||||||
|
|
||||||
|
context(B)
|
||||||
|
fun tooo() = Unit
|
||||||
|
|
||||||
|
context(A, B)
|
||||||
|
fun tooo() = Unit
|
||||||
|
|
||||||
|
context(B, A)
|
||||||
|
fun tooo() = Unit
|
||||||
Vendored
+11
@@ -0,0 +1,11 @@
|
|||||||
|
fun tooo()
|
||||||
|
|
||||||
|
fun tooo()
|
||||||
|
|
||||||
|
fun tooo()
|
||||||
|
|
||||||
|
fun tooo()
|
||||||
|
|
||||||
|
class A
|
||||||
|
|
||||||
|
class B
|
||||||
+159
@@ -0,0 +1,159 @@
|
|||||||
|
KtNamedClassOrObjectSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
classIdIfNonLocal: A
|
||||||
|
classKind: CLASS
|
||||||
|
companionObject: null
|
||||||
|
contextReceivers: []
|
||||||
|
isData: false
|
||||||
|
isExternal: false
|
||||||
|
isFun: false
|
||||||
|
isInline: false
|
||||||
|
isInner: false
|
||||||
|
modality: FINAL
|
||||||
|
name: A
|
||||||
|
origin: SOURCE
|
||||||
|
superTypes: [
|
||||||
|
kotlin/Any
|
||||||
|
]
|
||||||
|
symbolKind: TOP_LEVEL
|
||||||
|
typeParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtNamedClassOrObjectSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
classIdIfNonLocal: B
|
||||||
|
classKind: CLASS
|
||||||
|
companionObject: null
|
||||||
|
contextReceivers: []
|
||||||
|
isData: false
|
||||||
|
isExternal: false
|
||||||
|
isFun: false
|
||||||
|
isInline: false
|
||||||
|
isInner: false
|
||||||
|
modality: FINAL
|
||||||
|
name: B
|
||||||
|
origin: SOURCE
|
||||||
|
superTypes: [
|
||||||
|
kotlin/Any
|
||||||
|
]
|
||||||
|
symbolKind: TOP_LEVEL
|
||||||
|
typeParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: /tooo
|
||||||
|
contextReceivers: [
|
||||||
|
ContextReceiver(A)
|
||||||
|
]
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: FINAL
|
||||||
|
name: tooo
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: kotlin/Unit
|
||||||
|
symbolKind: TOP_LEVEL
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: /tooo
|
||||||
|
contextReceivers: [
|
||||||
|
ContextReceiver(B)
|
||||||
|
]
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: FINAL
|
||||||
|
name: tooo
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: kotlin/Unit
|
||||||
|
symbolKind: TOP_LEVEL
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: /tooo
|
||||||
|
contextReceivers: [
|
||||||
|
ContextReceiver(A)
|
||||||
|
ContextReceiver(B)
|
||||||
|
]
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: FINAL
|
||||||
|
name: tooo
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: kotlin/Unit
|
||||||
|
symbolKind: TOP_LEVEL
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: /tooo
|
||||||
|
contextReceivers: [
|
||||||
|
ContextReceiver(B)
|
||||||
|
ContextReceiver(A)
|
||||||
|
]
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: FINAL
|
||||||
|
name: tooo
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: kotlin/Unit
|
||||||
|
symbolKind: TOP_LEVEL
|
||||||
|
typeParameters: []
|
||||||
|
valueParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// DO_NOT_CHECK_NON_PSI_SYMBOL_RESTORE_K1
|
||||||
|
|
||||||
|
open class A
|
||||||
|
|
||||||
|
fun <J : A> foo(j: J): J = j
|
||||||
|
fun <T> foo(j: T): T = j
|
||||||
+5
@@ -0,0 +1,5 @@
|
|||||||
|
fun <J : A> foo(j: J): J
|
||||||
|
|
||||||
|
fun <T> foo(j: T): T
|
||||||
|
|
||||||
|
open class A
|
||||||
+142
@@ -0,0 +1,142 @@
|
|||||||
|
KtNamedClassOrObjectSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
classIdIfNonLocal: A
|
||||||
|
classKind: CLASS
|
||||||
|
companionObject: null
|
||||||
|
contextReceivers: []
|
||||||
|
isData: false
|
||||||
|
isExternal: false
|
||||||
|
isFun: false
|
||||||
|
isInline: false
|
||||||
|
isInner: false
|
||||||
|
modality: OPEN
|
||||||
|
name: A
|
||||||
|
origin: SOURCE
|
||||||
|
superTypes: [
|
||||||
|
kotlin/Any
|
||||||
|
]
|
||||||
|
symbolKind: TOP_LEVEL
|
||||||
|
typeParameters: []
|
||||||
|
visibility: Public
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtTypeParameterSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
isReified: false
|
||||||
|
name: J
|
||||||
|
origin: SOURCE
|
||||||
|
typeParameters: []
|
||||||
|
upperBounds: [
|
||||||
|
A
|
||||||
|
]
|
||||||
|
variance: INVARIANT
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: /foo
|
||||||
|
contextReceivers: []
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: FINAL
|
||||||
|
name: foo
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: J
|
||||||
|
symbolKind: TOP_LEVEL
|
||||||
|
typeParameters: [
|
||||||
|
KtTypeParameterSymbol(J)
|
||||||
|
]
|
||||||
|
valueParameters: [
|
||||||
|
KtValueParameterSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: null
|
||||||
|
contextReceivers: []
|
||||||
|
generatedPrimaryConstructorProperty: null
|
||||||
|
hasDefaultValue: false
|
||||||
|
isCrossinline: false
|
||||||
|
isExtension: false
|
||||||
|
isImplicitLambdaParameter: false
|
||||||
|
isNoinline: false
|
||||||
|
isVararg: false
|
||||||
|
name: j
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: J
|
||||||
|
symbolKind: LOCAL
|
||||||
|
typeParameters: []
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
]
|
||||||
|
visibility: Public
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtTypeParameterSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
isReified: false
|
||||||
|
name: T
|
||||||
|
origin: SOURCE
|
||||||
|
typeParameters: []
|
||||||
|
upperBounds: []
|
||||||
|
variance: INVARIANT
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
|
||||||
|
KtFunctionSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: /foo
|
||||||
|
contextReceivers: []
|
||||||
|
hasStableParameterNames: true
|
||||||
|
isBuiltinFunctionInvoke: false
|
||||||
|
isExtension: false
|
||||||
|
isExternal: false
|
||||||
|
isInfix: false
|
||||||
|
isInline: false
|
||||||
|
isOperator: false
|
||||||
|
isOverride: false
|
||||||
|
isStatic: false
|
||||||
|
isSuspend: false
|
||||||
|
modality: FINAL
|
||||||
|
name: foo
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: T
|
||||||
|
symbolKind: TOP_LEVEL
|
||||||
|
typeParameters: [
|
||||||
|
KtTypeParameterSymbol(T)
|
||||||
|
]
|
||||||
|
valueParameters: [
|
||||||
|
KtValueParameterSymbol:
|
||||||
|
annotationsList: []
|
||||||
|
callableIdIfNonLocal: null
|
||||||
|
contextReceivers: []
|
||||||
|
generatedPrimaryConstructorProperty: null
|
||||||
|
hasDefaultValue: false
|
||||||
|
isCrossinline: false
|
||||||
|
isExtension: false
|
||||||
|
isImplicitLambdaParameter: false
|
||||||
|
isNoinline: false
|
||||||
|
isVararg: false
|
||||||
|
name: j
|
||||||
|
origin: SOURCE
|
||||||
|
receiverParameter: null
|
||||||
|
returnType: T
|
||||||
|
symbolKind: LOCAL
|
||||||
|
typeParameters: []
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
|
]
|
||||||
|
visibility: Public
|
||||||
|
getContainingModule: KtSourceModule "Sources of main"
|
||||||
|
deprecationStatus: null
|
||||||
@@ -18,7 +18,6 @@ interface Fir2IrSignatureComposer {
|
|||||||
declaration: FirDeclaration,
|
declaration: FirDeclaration,
|
||||||
containingClass: ConeClassLikeLookupTag? = null,
|
containingClass: ConeClassLikeLookupTag? = null,
|
||||||
forceTopLevelPrivate: Boolean = false,
|
forceTopLevelPrivate: Boolean = false,
|
||||||
allowLocalClasses: Boolean = false,
|
|
||||||
): IdSignature?
|
): IdSignature?
|
||||||
|
|
||||||
fun composeAccessorSignature(
|
fun composeAccessorSignature(
|
||||||
|
|||||||
+1
-2
@@ -85,13 +85,12 @@ class FirBasedSignatureComposer(override val mangler: FirMangler) : Fir2IrSignat
|
|||||||
declaration: FirDeclaration,
|
declaration: FirDeclaration,
|
||||||
containingClass: ConeClassLikeLookupTag?,
|
containingClass: ConeClassLikeLookupTag?,
|
||||||
forceTopLevelPrivate: Boolean,
|
forceTopLevelPrivate: Boolean,
|
||||||
allowLocalClasses: Boolean,
|
|
||||||
): IdSignature? {
|
): IdSignature? {
|
||||||
if (declaration is FirAnonymousObject || declaration is FirAnonymousFunction) return null
|
if (declaration is FirAnonymousObject || declaration is FirAnonymousFunction) return null
|
||||||
if (declaration is FirRegularClass && declaration.classId.isLocal) return null
|
if (declaration is FirRegularClass && declaration.classId.isLocal) return null
|
||||||
if (declaration is FirCallableDeclaration) {
|
if (declaration is FirCallableDeclaration) {
|
||||||
if (declaration.visibility == Visibilities.Local) return null
|
if (declaration.visibility == Visibilities.Local) return null
|
||||||
if (!allowLocalClasses && (declaration.dispatchReceiverClassLookupTagOrNull()?.classId?.isLocal == true || containingClass?.classId?.isLocal == true)) return null
|
if (declaration.dispatchReceiverClassLookupTagOrNull()?.classId?.isLocal == true || containingClass?.classId?.isLocal == true) return null
|
||||||
}
|
}
|
||||||
|
|
||||||
val declarationWithParentId = FirDeclarationWithParentId(declaration, containingClass?.classId)
|
val declarationWithParentId = FirDeclarationWithParentId(declaration, containingClass?.classId)
|
||||||
|
|||||||
@@ -39,11 +39,12 @@ open class FirAnnotationRenderer {
|
|||||||
annotation.annotationTypeRef.accept(visitor)
|
annotation.annotationTypeRef.accept(visitor)
|
||||||
when (annotation) {
|
when (annotation) {
|
||||||
is FirAnnotationCall -> if (annotation.calleeReference.let { it is FirResolvedNamedReference || it is FirErrorNamedReference }) {
|
is FirAnnotationCall -> if (annotation.calleeReference.let { it is FirResolvedNamedReference || it is FirErrorNamedReference }) {
|
||||||
callArgumentsRenderer.renderArgumentMapping(annotation.argumentMapping)
|
callArgumentsRenderer?.renderArgumentMapping(annotation.argumentMapping)
|
||||||
} else {
|
} else {
|
||||||
visitor.visitCall(annotation)
|
visitor.visitCall(annotation)
|
||||||
}
|
}
|
||||||
else -> callArgumentsRenderer.renderArgumentMapping(annotation.argumentMapping)
|
|
||||||
|
else -> callArgumentsRenderer?.renderArgumentMapping(annotation.argumentMapping)
|
||||||
|
|
||||||
}
|
}
|
||||||
if (annotation.useSiteTarget == AnnotationUseSiteTarget.FILE) {
|
if (annotation.useSiteTarget == AnnotationUseSiteTarget.FILE) {
|
||||||
|
|||||||
@@ -31,18 +31,18 @@ class FirRenderer(
|
|||||||
builder: StringBuilder = StringBuilder(),
|
builder: StringBuilder = StringBuilder(),
|
||||||
override val annotationRenderer: FirAnnotationRenderer? = FirAnnotationRenderer(),
|
override val annotationRenderer: FirAnnotationRenderer? = FirAnnotationRenderer(),
|
||||||
override val bodyRenderer: FirBodyRenderer? = FirBodyRenderer(),
|
override val bodyRenderer: FirBodyRenderer? = FirBodyRenderer(),
|
||||||
override val callArgumentsRenderer: FirCallArgumentsRenderer = FirCallArgumentsRenderer(),
|
override val callArgumentsRenderer: FirCallArgumentsRenderer? = FirCallArgumentsRenderer(),
|
||||||
override val classMemberRenderer: FirClassMemberRenderer = FirClassMemberRenderer(),
|
override val classMemberRenderer: FirClassMemberRenderer? = FirClassMemberRenderer(),
|
||||||
override val contractRenderer: ConeContractRenderer? = ConeContractRenderer(),
|
override val contractRenderer: ConeContractRenderer? = ConeContractRenderer(),
|
||||||
override val declarationRenderer: FirDeclarationRenderer = FirDeclarationRenderer(),
|
override val declarationRenderer: FirDeclarationRenderer? = FirDeclarationRenderer(),
|
||||||
override val idRenderer: ConeIdRenderer = ConeIdRendererForDebugging(),
|
override val idRenderer: ConeIdRenderer = ConeIdRendererForDebugging(),
|
||||||
override val modifierRenderer: FirModifierRenderer = FirAllModifierRenderer(),
|
override val modifierRenderer: FirModifierRenderer? = FirAllModifierRenderer(),
|
||||||
override val packageDirectiveRenderer: FirPackageDirectiveRenderer? = null,
|
override val packageDirectiveRenderer: FirPackageDirectiveRenderer? = null,
|
||||||
override val propertyAccessorRenderer: FirPropertyAccessorRenderer? = FirPropertyAccessorRenderer(),
|
override val propertyAccessorRenderer: FirPropertyAccessorRenderer? = FirPropertyAccessorRenderer(),
|
||||||
override val resolvePhaseRenderer: FirResolvePhaseRenderer? = null,
|
override val resolvePhaseRenderer: FirResolvePhaseRenderer? = null,
|
||||||
override val typeRenderer: ConeTypeRenderer = ConeTypeRendererForDebugging(),
|
override val typeRenderer: ConeTypeRenderer = ConeTypeRendererForDebugging(),
|
||||||
override val valueParameterRenderer: FirValueParameterRenderer = FirValueParameterRenderer(),
|
override val valueParameterRenderer: FirValueParameterRenderer? = FirValueParameterRenderer(),
|
||||||
override val errorExpressionRenderer: FirErrorExpressionRenderer = FirErrorExpressionOnlyErrorRenderer(),
|
override val errorExpressionRenderer: FirErrorExpressionRenderer? = FirErrorExpressionOnlyErrorRenderer(),
|
||||||
) : FirRendererComponents {
|
) : FirRendererComponents {
|
||||||
|
|
||||||
override val visitor = Visitor()
|
override val visitor = Visitor()
|
||||||
@@ -65,19 +65,19 @@ class FirRenderer(
|
|||||||
init {
|
init {
|
||||||
annotationRenderer?.components = this
|
annotationRenderer?.components = this
|
||||||
bodyRenderer?.components = this
|
bodyRenderer?.components = this
|
||||||
callArgumentsRenderer.components = this
|
callArgumentsRenderer?.components = this
|
||||||
classMemberRenderer.components = this
|
classMemberRenderer?.components = this
|
||||||
contractRenderer?.components = this
|
contractRenderer?.components = this
|
||||||
declarationRenderer.components = this
|
declarationRenderer?.components = this
|
||||||
idRenderer.builder = builder
|
idRenderer.builder = builder
|
||||||
modifierRenderer.components = this
|
modifierRenderer?.components = this
|
||||||
packageDirectiveRenderer?.components = this
|
packageDirectiveRenderer?.components = this
|
||||||
propertyAccessorRenderer?.components = this
|
propertyAccessorRenderer?.components = this
|
||||||
resolvePhaseRenderer?.components = this
|
resolvePhaseRenderer?.components = this
|
||||||
typeRenderer.builder = builder
|
typeRenderer.builder = builder
|
||||||
typeRenderer.idRenderer = idRenderer
|
typeRenderer.idRenderer = idRenderer
|
||||||
valueParameterRenderer.components = this
|
valueParameterRenderer?.components = this
|
||||||
errorExpressionRenderer.components = this
|
errorExpressionRenderer?.components = this
|
||||||
}
|
}
|
||||||
|
|
||||||
fun renderElementAsString(element: FirElement): String {
|
fun renderElementAsString(element: FirElement): String {
|
||||||
@@ -200,7 +200,7 @@ class FirRenderer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (callableDeclaration is FirFunction) {
|
if (callableDeclaration is FirFunction) {
|
||||||
valueParameterRenderer.renderParameters(callableDeclaration.valueParameters)
|
valueParameterRenderer?.renderParameters(callableDeclaration.valueParameters)
|
||||||
}
|
}
|
||||||
print(": ")
|
print(": ")
|
||||||
callableDeclaration.returnTypeRef.accept(this)
|
callableDeclaration.returnTypeRef.accept(this)
|
||||||
@@ -220,8 +220,8 @@ class FirRenderer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitMemberDeclaration(memberDeclaration: FirMemberDeclaration) {
|
override fun visitMemberDeclaration(memberDeclaration: FirMemberDeclaration) {
|
||||||
modifierRenderer.renderModifiers(memberDeclaration)
|
modifierRenderer?.renderModifiers(memberDeclaration)
|
||||||
declarationRenderer.render(memberDeclaration)
|
declarationRenderer?.render(memberDeclaration)
|
||||||
when (memberDeclaration) {
|
when (memberDeclaration) {
|
||||||
is FirClassLikeDeclaration -> {
|
is FirClassLikeDeclaration -> {
|
||||||
if (memberDeclaration is FirRegularClass) {
|
if (memberDeclaration is FirRegularClass) {
|
||||||
@@ -247,7 +247,7 @@ class FirRenderer(
|
|||||||
annotationRenderer?.render(regularClass)
|
annotationRenderer?.render(regularClass)
|
||||||
visitMemberDeclaration(regularClass)
|
visitMemberDeclaration(regularClass)
|
||||||
renderSupertypes(regularClass)
|
renderSupertypes(regularClass)
|
||||||
classMemberRenderer.render(regularClass)
|
classMemberRenderer?.render(regularClass)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitEnumEntry(enumEntry: FirEnumEntry) {
|
override fun visitEnumEntry(enumEntry: FirEnumEntry) {
|
||||||
@@ -266,7 +266,7 @@ class FirRenderer(
|
|||||||
annotationRenderer?.render(anonymousObject)
|
annotationRenderer?.render(anonymousObject)
|
||||||
print("object : ")
|
print("object : ")
|
||||||
renderSeparated(anonymousObject.superTypeRefs, visitor)
|
renderSeparated(anonymousObject.superTypeRefs, visitor)
|
||||||
classMemberRenderer.render(anonymousObject.declarations)
|
classMemberRenderer?.render(anonymousObject.declarations)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitVariable(variable: FirVariable) {
|
override fun visitVariable(variable: FirVariable) {
|
||||||
@@ -293,7 +293,7 @@ class FirRenderer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitBackingField(backingField: FirBackingField) {
|
override fun visitBackingField(backingField: FirBackingField) {
|
||||||
modifierRenderer.renderModifiers(backingField)
|
modifierRenderer?.renderModifiers(backingField)
|
||||||
print("<explicit backing field>: ")
|
print("<explicit backing field>: ")
|
||||||
backingField.returnTypeRef.accept(this)
|
backingField.returnTypeRef.accept(this)
|
||||||
|
|
||||||
@@ -319,11 +319,11 @@ class FirRenderer(
|
|||||||
|
|
||||||
override fun visitConstructor(constructor: FirConstructor) {
|
override fun visitConstructor(constructor: FirConstructor) {
|
||||||
annotationRenderer?.render(constructor)
|
annotationRenderer?.render(constructor)
|
||||||
modifierRenderer.renderModifiers(constructor)
|
modifierRenderer?.renderModifiers(constructor)
|
||||||
declarationRenderer.render(constructor)
|
declarationRenderer?.render(constructor)
|
||||||
|
|
||||||
constructor.typeParameters.renderTypeParameters()
|
constructor.typeParameters.renderTypeParameters()
|
||||||
valueParameterRenderer.renderParameters(constructor.valueParameters)
|
valueParameterRenderer?.renderParameters(constructor.valueParameters)
|
||||||
print(": ")
|
print(": ")
|
||||||
constructor.returnTypeRef.accept(this)
|
constructor.returnTypeRef.accept(this)
|
||||||
val body = constructor.body
|
val body = constructor.body
|
||||||
@@ -336,9 +336,9 @@ class FirRenderer(
|
|||||||
|
|
||||||
override fun visitPropertyAccessor(propertyAccessor: FirPropertyAccessor) {
|
override fun visitPropertyAccessor(propertyAccessor: FirPropertyAccessor) {
|
||||||
annotationRenderer?.render(propertyAccessor)
|
annotationRenderer?.render(propertyAccessor)
|
||||||
modifierRenderer.renderModifiers(propertyAccessor)
|
modifierRenderer?.renderModifiers(propertyAccessor)
|
||||||
declarationRenderer.render(propertyAccessor)
|
declarationRenderer?.render(propertyAccessor)
|
||||||
valueParameterRenderer.renderParameters(propertyAccessor.valueParameters)
|
valueParameterRenderer?.renderParameters(propertyAccessor.valueParameters)
|
||||||
print(": ")
|
print(": ")
|
||||||
propertyAccessor.returnTypeRef.accept(this)
|
propertyAccessor.returnTypeRef.accept(this)
|
||||||
contractRenderer?.render(propertyAccessor)
|
contractRenderer?.render(propertyAccessor)
|
||||||
@@ -351,7 +351,7 @@ class FirRenderer(
|
|||||||
|
|
||||||
override fun visitAnonymousFunction(anonymousFunction: FirAnonymousFunction) {
|
override fun visitAnonymousFunction(anonymousFunction: FirAnonymousFunction) {
|
||||||
annotationRenderer?.render(anonymousFunction)
|
annotationRenderer?.render(anonymousFunction)
|
||||||
declarationRenderer.render(anonymousFunction)
|
declarationRenderer?.render(anonymousFunction)
|
||||||
print(" ")
|
print(" ")
|
||||||
val receiverParameter = anonymousFunction.receiverParameter
|
val receiverParameter = anonymousFunction.receiverParameter
|
||||||
if (receiverParameter != null) {
|
if (receiverParameter != null) {
|
||||||
@@ -365,7 +365,7 @@ class FirRenderer(
|
|||||||
) {
|
) {
|
||||||
print("(<no-parameters>)")
|
print("(<no-parameters>)")
|
||||||
}
|
}
|
||||||
valueParameterRenderer.renderParameters(anonymousFunction.valueParameters)
|
valueParameterRenderer?.renderParameters(anonymousFunction.valueParameters)
|
||||||
print(": ")
|
print(": ")
|
||||||
anonymousFunction.returnTypeRef.accept(this)
|
anonymousFunction.returnTypeRef.accept(this)
|
||||||
print(" <inline=${anonymousFunction.inlineStatus}")
|
print(" <inline=${anonymousFunction.inlineStatus}")
|
||||||
@@ -377,8 +377,8 @@ class FirRenderer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitFunction(function: FirFunction) {
|
override fun visitFunction(function: FirFunction) {
|
||||||
valueParameterRenderer.renderParameters(function.valueParameters)
|
valueParameterRenderer?.renderParameters(function.valueParameters)
|
||||||
declarationRenderer.render(function)
|
declarationRenderer?.render(function)
|
||||||
bodyRenderer?.render(function)
|
bodyRenderer?.render(function)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -401,7 +401,7 @@ class FirRenderer(
|
|||||||
|
|
||||||
override fun visitTypeParameter(typeParameter: FirTypeParameter) {
|
override fun visitTypeParameter(typeParameter: FirTypeParameter) {
|
||||||
annotationRenderer?.render(typeParameter)
|
annotationRenderer?.render(typeParameter)
|
||||||
modifierRenderer.renderModifiers(typeParameter)
|
modifierRenderer?.renderModifiers(typeParameter)
|
||||||
resolvePhaseRenderer?.render(typeParameter)
|
resolvePhaseRenderer?.render(typeParameter)
|
||||||
typeParameter.variance.renderVariance()
|
typeParameter.variance.renderVariance()
|
||||||
print(typeParameter.name)
|
print(typeParameter.name)
|
||||||
@@ -431,7 +431,7 @@ class FirRenderer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitValueParameter(valueParameter: FirValueParameter) {
|
override fun visitValueParameter(valueParameter: FirValueParameter) {
|
||||||
valueParameterRenderer.renderParameter(valueParameter)
|
valueParameterRenderer?.renderParameter(valueParameter)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitImport(import: FirImport) {
|
override fun visitImport(import: FirImport) {
|
||||||
@@ -635,7 +635,7 @@ class FirRenderer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitCall(call: FirCall) {
|
override fun visitCall(call: FirCall) {
|
||||||
callArgumentsRenderer.renderArguments(call.arguments)
|
callArgumentsRenderer?.renderArguments(call.arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitStringConcatenationCall(stringConcatenationCall: FirStringConcatenationCall) {
|
override fun visitStringConcatenationCall(stringConcatenationCall: FirStringConcatenationCall) {
|
||||||
@@ -704,7 +704,7 @@ class FirRenderer(
|
|||||||
|
|
||||||
annotationRenderer?.renderAnnotations(functionTypeRef.annotations.dropExtensionFunctionAnnotation())
|
annotationRenderer?.renderAnnotations(functionTypeRef.annotations.dropExtensionFunctionAnnotation())
|
||||||
print("( ")
|
print("( ")
|
||||||
modifierRenderer.renderModifiers(functionTypeRef)
|
modifierRenderer?.renderModifiers(functionTypeRef)
|
||||||
functionTypeRef.receiverTypeRef?.let {
|
functionTypeRef.receiverTypeRef?.let {
|
||||||
it.accept(this)
|
it.accept(this)
|
||||||
print(".")
|
print(".")
|
||||||
@@ -1025,7 +1025,7 @@ class FirRenderer(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun visitErrorExpression(errorExpression: FirErrorExpression) {
|
override fun visitErrorExpression(errorExpression: FirErrorExpression) {
|
||||||
errorExpressionRenderer.renderErrorExpression(errorExpression)
|
errorExpressionRenderer?.renderErrorExpression(errorExpression)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) {
|
override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier) {
|
||||||
|
|||||||
@@ -10,18 +10,18 @@ import org.jetbrains.kotlin.fir.contracts.description.ConeContractRenderer
|
|||||||
internal interface FirRendererComponents {
|
internal interface FirRendererComponents {
|
||||||
val visitor: FirRenderer.Visitor
|
val visitor: FirRenderer.Visitor
|
||||||
val printer: FirPrinter
|
val printer: FirPrinter
|
||||||
val declarationRenderer: FirDeclarationRenderer
|
val declarationRenderer: FirDeclarationRenderer?
|
||||||
val annotationRenderer: FirAnnotationRenderer?
|
val annotationRenderer: FirAnnotationRenderer?
|
||||||
val bodyRenderer: FirBodyRenderer?
|
val bodyRenderer: FirBodyRenderer?
|
||||||
val callArgumentsRenderer: FirCallArgumentsRenderer
|
val callArgumentsRenderer: FirCallArgumentsRenderer?
|
||||||
val classMemberRenderer: FirClassMemberRenderer
|
val classMemberRenderer: FirClassMemberRenderer?
|
||||||
val contractRenderer: ConeContractRenderer?
|
val contractRenderer: ConeContractRenderer?
|
||||||
val idRenderer: ConeIdRenderer
|
val idRenderer: ConeIdRenderer
|
||||||
val modifierRenderer: FirModifierRenderer
|
val modifierRenderer: FirModifierRenderer?
|
||||||
val packageDirectiveRenderer: FirPackageDirectiveRenderer?
|
val packageDirectiveRenderer: FirPackageDirectiveRenderer?
|
||||||
val propertyAccessorRenderer: FirPropertyAccessorRenderer?
|
val propertyAccessorRenderer: FirPropertyAccessorRenderer?
|
||||||
val resolvePhaseRenderer: FirResolvePhaseRenderer?
|
val resolvePhaseRenderer: FirResolvePhaseRenderer?
|
||||||
val typeRenderer: ConeTypeRenderer
|
val typeRenderer: ConeTypeRenderer
|
||||||
val valueParameterRenderer: FirValueParameterRenderer
|
val valueParameterRenderer: FirValueParameterRenderer?
|
||||||
val errorExpressionRenderer: FirErrorExpressionRenderer
|
val errorExpressionRenderer: FirErrorExpressionRenderer?
|
||||||
}
|
}
|
||||||
+2
-2
@@ -28,9 +28,9 @@ open class FirValueParameterRenderer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun renderParameter(valueParameter: FirValueParameter) {
|
fun renderParameter(valueParameter: FirValueParameter) {
|
||||||
declarationRenderer.renderPhaseAndAttributes(valueParameter)
|
declarationRenderer?.renderPhaseAndAttributes(valueParameter)
|
||||||
annotationRenderer?.render(valueParameter)
|
annotationRenderer?.render(valueParameter)
|
||||||
modifierRenderer.renderModifiers(valueParameter)
|
modifierRenderer?.renderModifiers(valueParameter)
|
||||||
if (valueParameter.name != SpecialNames.NO_NAME_PROVIDED) {
|
if (valueParameter.name != SpecialNames.NO_NAME_PROVIDED) {
|
||||||
printer.print(valueParameter.name.toString() + ": ")
|
printer.print(valueParameter.name.toString() + ": ")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user