[Analysis API] add constructorSymbol to API of KtAnnotationApplicationWithArgumentsInfo
This is required for some checks on call site, and it seems that this symbol can cover all cases. One of the examples why this API was introduced is a request to distinguish which vararg parameter is missed in arguments of an annotation call from symbol light classes ^KT-62560
This commit is contained in:
committed by
Space Team
parent
3a6cdc83cf
commit
1173cc46e2
+11
-7
@@ -471,6 +471,7 @@ internal fun ConstantValue<*>.toKtAnnotationValue(analysisContext: Fe10AnalysisC
|
|||||||
useSiteTarget = null,
|
useSiteTarget = null,
|
||||||
arguments = value.getKtNamedAnnotationArguments(analysisContext),
|
arguments = value.getKtNamedAnnotationArguments(analysisContext),
|
||||||
index = null,
|
index = null,
|
||||||
|
constructorSymbolPointer = null,
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -618,13 +619,16 @@ internal fun createKtInitializerValue(
|
|||||||
internal fun AnnotationDescriptor.toKtAnnotationApplication(
|
internal fun AnnotationDescriptor.toKtAnnotationApplication(
|
||||||
analysisContext: Fe10AnalysisContext,
|
analysisContext: Fe10AnalysisContext,
|
||||||
index: Int,
|
index: Int,
|
||||||
): KtAnnotationApplicationWithArgumentsInfo = KtAnnotationApplicationWithArgumentsInfo(
|
): KtAnnotationApplicationWithArgumentsInfo {
|
||||||
classId = classIdForAnnotation,
|
return KtAnnotationApplicationWithArgumentsInfo(
|
||||||
psi = psi,
|
classId = classIdForAnnotation,
|
||||||
useSiteTarget = useSiteTarget,
|
psi = psi,
|
||||||
arguments = getKtNamedAnnotationArguments(analysisContext),
|
useSiteTarget = useSiteTarget,
|
||||||
index = index,
|
arguments = getKtNamedAnnotationArguments(analysisContext),
|
||||||
)
|
index = index,
|
||||||
|
constructorSymbolPointer = null,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
internal fun AnnotationDescriptor.toKtAnnotationInfo(index: Int): KtAnnotationApplicationInfo = KtAnnotationApplicationInfo(
|
internal fun AnnotationDescriptor.toKtAnnotationInfo(index: Int): KtAnnotationApplicationInfo = KtAnnotationApplicationInfo(
|
||||||
classId = classIdForAnnotation,
|
classId = classIdForAnnotation,
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import org.jetbrains.kotlin.fir.references.FirErrorNamedReference
|
|||||||
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
||||||
import org.jetbrains.kotlin.fir.references.FirReference
|
import org.jetbrains.kotlin.fir.references.FirReference
|
||||||
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
import org.jetbrains.kotlin.fir.references.FirResolvedNamedReference
|
||||||
|
import org.jetbrains.kotlin.fir.references.toResolvedConstructorSymbol
|
||||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeDiagnosticWithCandidates
|
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeDiagnosticWithCandidates
|
||||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeDiagnosticWithSymbol
|
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeDiagnosticWithSymbol
|
||||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeHiddenCandidateError
|
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeHiddenCandidateError
|
||||||
@@ -82,19 +83,26 @@ internal fun ConeDiagnostic.getCandidateSymbols(): Collection<FirBasedSymbol<*>>
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal fun FirAnnotation.toKtAnnotationApplication(
|
internal fun FirAnnotation.toKtAnnotationApplication(
|
||||||
useSiteSession: FirSession,
|
builder: KtSymbolByFirBuilder,
|
||||||
index: Int,
|
index: Int,
|
||||||
arguments: List<KtNamedAnnotationValue> = FirAnnotationValueConverter.toNamedConstantValue(
|
arguments: List<KtNamedAnnotationValue> = FirAnnotationValueConverter.toNamedConstantValue(
|
||||||
mapAnnotationParameters(this),
|
mapAnnotationParameters(this),
|
||||||
useSiteSession,
|
builder,
|
||||||
)
|
)
|
||||||
): KtAnnotationApplicationWithArgumentsInfo = KtAnnotationApplicationWithArgumentsInfo(
|
): KtAnnotationApplicationWithArgumentsInfo {
|
||||||
classId = toAnnotationClassId(useSiteSession),
|
val constructorSymbol = (this as? FirAnnotationCall)?.calleeReference
|
||||||
psi = psi as? KtCallElement,
|
?.toResolvedConstructorSymbol()
|
||||||
useSiteTarget = useSiteTarget,
|
?.let(builder.functionLikeBuilder::buildConstructorSymbol)
|
||||||
arguments = arguments,
|
|
||||||
index = index,
|
return KtAnnotationApplicationWithArgumentsInfo(
|
||||||
)
|
classId = toAnnotationClassId(builder.rootSession),
|
||||||
|
psi = psi as? KtCallElement,
|
||||||
|
useSiteTarget = useSiteTarget,
|
||||||
|
arguments = arguments,
|
||||||
|
index = index,
|
||||||
|
constructorSymbolPointer = with(builder.analysisSession) { constructorSymbol?.createPointer() },
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
internal fun FirAnnotation.toKtAnnotationInfo(
|
internal fun FirAnnotation.toKtAnnotationInfo(
|
||||||
useSiteSession: FirSession,
|
useSiteSession: FirSession,
|
||||||
|
|||||||
+7
-6
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -42,13 +42,14 @@ import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedSymbolError
|
|||||||
import org.jetbrains.kotlin.fir.resolve.getContainingClass
|
import org.jetbrains.kotlin.fir.resolve.getContainingClass
|
||||||
import org.jetbrains.kotlin.fir.resolve.getSymbolByLookupTag
|
import org.jetbrains.kotlin.fir.resolve.getSymbolByLookupTag
|
||||||
import org.jetbrains.kotlin.fir.resolve.inference.ConeTypeParameterBasedTypeVariable
|
import org.jetbrains.kotlin.fir.resolve.inference.ConeTypeParameterBasedTypeVariable
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.originalConstructorIfTypeAlias
|
import org.jetbrains.kotlin.fir.resolve.providers.FirSymbolProvider
|
||||||
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
import org.jetbrains.kotlin.fir.resolve.providers.symbolProvider
|
||||||
import org.jetbrains.kotlin.fir.resolve.substitution.ChainedSubstitutor
|
import org.jetbrains.kotlin.fir.resolve.substitution.ChainedSubstitutor
|
||||||
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
||||||
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutorByMap
|
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutorByMap
|
||||||
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
import org.jetbrains.kotlin.fir.resolve.toSymbol
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.importedFromObjectOrStaticData
|
import org.jetbrains.kotlin.fir.scopes.impl.importedFromObjectOrStaticData
|
||||||
|
import org.jetbrains.kotlin.fir.scopes.impl.originalConstructorIfTypeAlias
|
||||||
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
|
import org.jetbrains.kotlin.fir.scopes.impl.toConeType
|
||||||
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
import org.jetbrains.kotlin.fir.symbols.ConeClassLikeLookupTag
|
||||||
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
|
import org.jetbrains.kotlin.fir.symbols.ConeTypeParameterLookupTag
|
||||||
@@ -71,13 +72,13 @@ import kotlin.contracts.contract
|
|||||||
/**
|
/**
|
||||||
* Maps FirElement to KtSymbol & ConeType to KtType, thread safe
|
* Maps FirElement to KtSymbol & ConeType to KtType, thread safe
|
||||||
*/
|
*/
|
||||||
internal class KtSymbolByFirBuilder constructor(
|
internal class KtSymbolByFirBuilder(
|
||||||
private val project: Project,
|
private val project: Project,
|
||||||
private val analysisSession: KtFirAnalysisSession,
|
val analysisSession: KtFirAnalysisSession,
|
||||||
val token: KtLifetimeToken,
|
val token: KtLifetimeToken,
|
||||||
) {
|
) {
|
||||||
private val firResolveSession: LLFirResolveSession = analysisSession.firResolveSession
|
private val firResolveSession: LLFirResolveSession get() = analysisSession.firResolveSession
|
||||||
private val firProvider get() = firResolveSession.useSiteFirSession.symbolProvider
|
private val firProvider: FirSymbolProvider get() = rootSession.symbolProvider
|
||||||
val rootSession: FirSession = firResolveSession.useSiteFirSession
|
val rootSession: FirSession = firResolveSession.useSiteFirSession
|
||||||
|
|
||||||
private val symbolsCache = BuilderCache<FirBasedSymbol<*>, KtSymbol>()
|
private val symbolsCache = BuilderCache<FirBasedSymbol<*>, KtSymbol>()
|
||||||
|
|||||||
+11
-12
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.analysis.api.annotations.AnnotationUseSiteTargetFilt
|
|||||||
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplicationInfo
|
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplicationInfo
|
||||||
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplicationWithArgumentsInfo
|
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplicationWithArgumentsInfo
|
||||||
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.impl.base.annotations.KtEmptyAnnotationsList
|
import org.jetbrains.kotlin.analysis.api.impl.base.annotations.KtEmptyAnnotationsList
|
||||||
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
|
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
|
||||||
import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
|
import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
|
||||||
@@ -19,12 +20,14 @@ import org.jetbrains.kotlin.name.ClassId
|
|||||||
|
|
||||||
internal class KtFirAnnotationListForDeclaration private constructor(
|
internal class KtFirAnnotationListForDeclaration private constructor(
|
||||||
val firSymbol: FirBasedSymbol<*>,
|
val firSymbol: FirBasedSymbol<*>,
|
||||||
private val useSiteSession: FirSession,
|
private val builder: KtSymbolByFirBuilder,
|
||||||
override val token: KtLifetimeToken,
|
|
||||||
) : KtAnnotationsList() {
|
) : KtAnnotationsList() {
|
||||||
|
override val token: KtLifetimeToken get() = builder.token
|
||||||
|
private val useSiteSession: FirSession get() = builder.rootSession
|
||||||
|
|
||||||
override val annotations: List<KtAnnotationApplicationWithArgumentsInfo>
|
override val annotations: List<KtAnnotationApplicationWithArgumentsInfo>
|
||||||
get() = withValidityAssertion {
|
get() = withValidityAssertion {
|
||||||
annotations(firSymbol, useSiteSession)
|
annotations(firSymbol, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val annotationInfos: List<KtAnnotationApplicationInfo>
|
override val annotationInfos: List<KtAnnotationApplicationInfo>
|
||||||
@@ -40,7 +43,7 @@ internal class KtFirAnnotationListForDeclaration private constructor(
|
|||||||
classId: ClassId,
|
classId: ClassId,
|
||||||
useSiteTargetFilter: AnnotationUseSiteTargetFilter,
|
useSiteTargetFilter: AnnotationUseSiteTargetFilter,
|
||||||
): List<KtAnnotationApplicationWithArgumentsInfo> = withValidityAssertion {
|
): List<KtAnnotationApplicationWithArgumentsInfo> = withValidityAssertion {
|
||||||
annotationsByClassId(firSymbol, classId, useSiteTargetFilter, useSiteSession)
|
annotationsByClassId(firSymbol, classId, useSiteTargetFilter, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val annotationClassIds: Collection<ClassId>
|
override val annotationClassIds: Collection<ClassId>
|
||||||
@@ -49,18 +52,14 @@ internal class KtFirAnnotationListForDeclaration private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun create(
|
fun create(firSymbol: FirBasedSymbol<*>, builder: KtSymbolByFirBuilder): KtAnnotationsList {
|
||||||
firSymbol: FirBasedSymbol<*>,
|
|
||||||
useSiteSession: FirSession,
|
|
||||||
token: KtLifetimeToken,
|
|
||||||
): KtAnnotationsList {
|
|
||||||
return when {
|
return when {
|
||||||
firSymbol is FirBackingFieldSymbol && firSymbol.propertySymbol.annotations.any { it.useSiteTarget == null } ->
|
firSymbol is FirBackingFieldSymbol && firSymbol.propertySymbol.annotations.any { it.useSiteTarget == null } ->
|
||||||
KtFirAnnotationListForDeclaration(firSymbol, useSiteSession, token)
|
KtFirAnnotationListForDeclaration(firSymbol, builder)
|
||||||
firSymbol.annotations.isEmpty() ->
|
firSymbol.annotations.isEmpty() ->
|
||||||
KtEmptyAnnotationsList(token)
|
KtEmptyAnnotationsList(builder.token)
|
||||||
else ->
|
else ->
|
||||||
KtFirAnnotationListForDeclaration(firSymbol, useSiteSession, token)
|
KtFirAnnotationListForDeclaration(firSymbol, builder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-11
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.analysis.api.annotations.AnnotationUseSiteTargetFilt
|
|||||||
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplicationInfo
|
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplicationInfo
|
||||||
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplicationWithArgumentsInfo
|
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplicationWithArgumentsInfo
|
||||||
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.impl.base.annotations.KtEmptyAnnotationsList
|
import org.jetbrains.kotlin.analysis.api.impl.base.annotations.KtEmptyAnnotationsList
|
||||||
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
|
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
|
||||||
import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
|
import org.jetbrains.kotlin.analysis.api.lifetime.withValidityAssertion
|
||||||
@@ -20,12 +21,14 @@ import org.jetbrains.kotlin.name.ClassId
|
|||||||
internal class KtFirAnnotationListForReceiverParameter private constructor(
|
internal class KtFirAnnotationListForReceiverParameter private constructor(
|
||||||
private val firCallableSymbol: FirCallableSymbol<*>,
|
private val firCallableSymbol: FirCallableSymbol<*>,
|
||||||
private val receiverParameter: FirAnnotationContainer,
|
private val receiverParameter: FirAnnotationContainer,
|
||||||
private val useSiteSession: FirSession,
|
private val builder: KtSymbolByFirBuilder,
|
||||||
override val token: KtLifetimeToken,
|
|
||||||
) : KtAnnotationsList() {
|
) : KtAnnotationsList() {
|
||||||
|
private val useSiteSession: FirSession get() = builder.rootSession
|
||||||
|
override val token: KtLifetimeToken get() = builder.token
|
||||||
|
|
||||||
override val annotations: List<KtAnnotationApplicationWithArgumentsInfo>
|
override val annotations: List<KtAnnotationApplicationWithArgumentsInfo>
|
||||||
get() = withValidityAssertion {
|
get() = withValidityAssertion {
|
||||||
annotations(firCallableSymbol, useSiteSession, receiverParameter)
|
annotations(firCallableSymbol, builder, receiverParameter)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val annotationInfos: List<KtAnnotationApplicationInfo>
|
override val annotationInfos: List<KtAnnotationApplicationInfo>
|
||||||
@@ -41,7 +44,7 @@ internal class KtFirAnnotationListForReceiverParameter private constructor(
|
|||||||
classId: ClassId,
|
classId: ClassId,
|
||||||
useSiteTargetFilter: AnnotationUseSiteTargetFilter,
|
useSiteTargetFilter: AnnotationUseSiteTargetFilter,
|
||||||
): List<KtAnnotationApplicationWithArgumentsInfo> = withValidityAssertion {
|
): List<KtAnnotationApplicationWithArgumentsInfo> = withValidityAssertion {
|
||||||
annotationsByClassId(firCallableSymbol, classId, useSiteTargetFilter, useSiteSession, receiverParameter)
|
annotationsByClassId(firCallableSymbol, classId, useSiteTargetFilter, builder, receiverParameter)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val annotationClassIds: Collection<ClassId>
|
override val annotationClassIds: Collection<ClassId>
|
||||||
@@ -50,16 +53,12 @@ internal class KtFirAnnotationListForReceiverParameter private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun create(
|
fun create(firCallableSymbol: FirCallableSymbol<*>, builder: KtSymbolByFirBuilder): KtAnnotationsList {
|
||||||
firCallableSymbol: FirCallableSymbol<*>,
|
|
||||||
useSiteSession: FirSession,
|
|
||||||
token: KtLifetimeToken,
|
|
||||||
): KtAnnotationsList {
|
|
||||||
val receiverParameter = firCallableSymbol.receiverParameter
|
val receiverParameter = firCallableSymbol.receiverParameter
|
||||||
return if (receiverParameter?.annotations?.isEmpty() != false) {
|
return if (receiverParameter?.annotations?.isEmpty() != false) {
|
||||||
KtEmptyAnnotationsList(token)
|
KtEmptyAnnotationsList(builder.token)
|
||||||
} else {
|
} else {
|
||||||
KtFirAnnotationListForReceiverParameter(firCallableSymbol, receiverParameter, useSiteSession, token)
|
KtFirAnnotationListForReceiverParameter(firCallableSymbol, receiverParameter, builder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+10
-11
@@ -9,6 +9,7 @@ import org.jetbrains.kotlin.analysis.api.annotations.AnnotationUseSiteTargetFilt
|
|||||||
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplicationInfo
|
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplicationInfo
|
||||||
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplicationWithArgumentsInfo
|
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationApplicationWithArgumentsInfo
|
||||||
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.toKtAnnotationApplication
|
import org.jetbrains.kotlin.analysis.api.fir.toKtAnnotationApplication
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.toKtAnnotationInfo
|
import org.jetbrains.kotlin.analysis.api.fir.toKtAnnotationInfo
|
||||||
import org.jetbrains.kotlin.analysis.api.impl.base.annotations.KtEmptyAnnotationsList
|
import org.jetbrains.kotlin.analysis.api.impl.base.annotations.KtEmptyAnnotationsList
|
||||||
@@ -27,13 +28,15 @@ import org.jetbrains.kotlin.name.ClassId
|
|||||||
|
|
||||||
internal class KtFirAnnotationListForType private constructor(
|
internal class KtFirAnnotationListForType private constructor(
|
||||||
val coneType: ConeKotlinType,
|
val coneType: ConeKotlinType,
|
||||||
private val useSiteSession: FirSession,
|
private val builder: KtSymbolByFirBuilder,
|
||||||
override val token: KtLifetimeToken,
|
|
||||||
) : KtAnnotationsList() {
|
) : KtAnnotationsList() {
|
||||||
|
override val token: KtLifetimeToken get() = builder.token
|
||||||
|
private val useSiteSession: FirSession get() = builder.rootSession
|
||||||
|
|
||||||
override val annotations: List<KtAnnotationApplicationWithArgumentsInfo>
|
override val annotations: List<KtAnnotationApplicationWithArgumentsInfo>
|
||||||
get() = withValidityAssertion {
|
get() = withValidityAssertion {
|
||||||
coneType.customAnnotationsWithLazyResolve(FirResolvePhase.ANNOTATION_ARGUMENTS).mapIndexed { index, annotation ->
|
coneType.customAnnotationsWithLazyResolve(FirResolvePhase.ANNOTATION_ARGUMENTS).mapIndexed { index, annotation ->
|
||||||
annotation.toKtAnnotationApplication(useSiteSession, index)
|
annotation.toKtAnnotationApplication(builder, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,7 +62,7 @@ internal class KtFirAnnotationListForType private constructor(
|
|||||||
return@mapIndexedNotNull null
|
return@mapIndexedNotNull null
|
||||||
}
|
}
|
||||||
|
|
||||||
annotation.toKtAnnotationApplication(useSiteSession, index)
|
annotation.toKtAnnotationApplication(builder, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,15 +72,11 @@ internal class KtFirAnnotationListForType private constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
companion object {
|
companion object {
|
||||||
fun create(
|
fun create(coneType: ConeKotlinType, builder: KtSymbolByFirBuilder): KtAnnotationsList {
|
||||||
coneType: ConeKotlinType,
|
|
||||||
useSiteSession: FirSession,
|
|
||||||
token: KtLifetimeToken,
|
|
||||||
): KtAnnotationsList {
|
|
||||||
return if (coneType.customAnnotations.isEmpty()) {
|
return if (coneType.customAnnotations.isEmpty()) {
|
||||||
KtEmptyAnnotationsList(token)
|
KtEmptyAnnotationsList(builder.token)
|
||||||
} else {
|
} else {
|
||||||
KtFirAnnotationListForType(coneType, useSiteSession, token)
|
KtFirAnnotationListForType(coneType, builder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-16
@@ -6,6 +6,7 @@
|
|||||||
package org.jetbrains.kotlin.analysis.api.fir.annotations
|
package org.jetbrains.kotlin.analysis.api.fir.annotations
|
||||||
|
|
||||||
import org.jetbrains.kotlin.analysis.api.annotations.*
|
import org.jetbrains.kotlin.analysis.api.annotations.*
|
||||||
|
import org.jetbrains.kotlin.analysis.api.fir.KtSymbolByFirBuilder
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.toKtAnnotationApplication
|
import org.jetbrains.kotlin.analysis.api.fir.toKtAnnotationApplication
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.toKtAnnotationInfo
|
import org.jetbrains.kotlin.analysis.api.fir.toKtAnnotationInfo
|
||||||
import org.jetbrains.kotlin.analysis.utils.errors.withClassEntry
|
import org.jetbrains.kotlin.analysis.utils.errors.withClassEntry
|
||||||
@@ -44,23 +45,23 @@ internal fun annotationsByClassId(
|
|||||||
firSymbol: FirBasedSymbol<*>,
|
firSymbol: FirBasedSymbol<*>,
|
||||||
classId: ClassId,
|
classId: ClassId,
|
||||||
useSiteTargetFilter: AnnotationUseSiteTargetFilter,
|
useSiteTargetFilter: AnnotationUseSiteTargetFilter,
|
||||||
useSiteSession: FirSession,
|
builder: KtSymbolByFirBuilder,
|
||||||
annotationContainer: FirAnnotationContainer = firSymbol.fir,
|
annotationContainer: FirAnnotationContainer = firSymbol.fir,
|
||||||
): List<KtAnnotationApplicationWithArgumentsInfo> =
|
): List<KtAnnotationApplicationWithArgumentsInfo> =
|
||||||
if (classId == StandardClassIds.Annotations.Target && firSymbol.fir.resolvePhase < FirResolvePhase.ANNOTATION_ARGUMENTS) {
|
if (classId == StandardClassIds.Annotations.Target && firSymbol.fir.resolvePhase < FirResolvePhase.ANNOTATION_ARGUMENTS) {
|
||||||
annotationContainer.resolvedAnnotationsWithClassIds(firSymbol)
|
annotationContainer.resolvedAnnotationsWithClassIds(firSymbol)
|
||||||
.mapIndexedToAnnotationApplication(useSiteTargetFilter, useSiteSession, classId) { index, annotation ->
|
.mapIndexedToAnnotationApplication(useSiteTargetFilter, builder.rootSession, classId) { index, annotation ->
|
||||||
annotation.asKtAnnotationApplicationForTargetAnnotation(useSiteSession, index)
|
annotation.asKtAnnotationApplicationForTargetAnnotation(builder, index)
|
||||||
}
|
}
|
||||||
} else if (classId == JvmStandardClassIds.Annotations.Java.Target && firSymbol.fir.resolvePhase < FirResolvePhase.ANNOTATION_ARGUMENTS) {
|
} else if (classId == JvmStandardClassIds.Annotations.Java.Target && firSymbol.fir.resolvePhase < FirResolvePhase.ANNOTATION_ARGUMENTS) {
|
||||||
annotationContainer.resolvedAnnotationsWithClassIds(firSymbol)
|
annotationContainer.resolvedAnnotationsWithClassIds(firSymbol)
|
||||||
.mapIndexedToAnnotationApplication(useSiteTargetFilter, useSiteSession, classId) { index, annotation ->
|
.mapIndexedToAnnotationApplication(useSiteTargetFilter, builder.rootSession, classId) { index, annotation ->
|
||||||
annotation.asKtAnnotationApplicationForJavaTargetAnnotation(useSiteSession, index)
|
annotation.asKtAnnotationApplicationForJavaTargetAnnotation(builder, index)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
annotationContainer.resolvedAnnotationsWithArguments(firSymbol)
|
annotationContainer.resolvedAnnotationsWithArguments(firSymbol)
|
||||||
.mapIndexedToAnnotationApplication(useSiteTargetFilter, useSiteSession, classId) { index, annotation ->
|
.mapIndexedToAnnotationApplication(useSiteTargetFilter, builder.rootSession, classId) { index, annotation ->
|
||||||
annotation.toKtAnnotationApplication(useSiteSession, index)
|
annotation.toKtAnnotationApplication(builder, index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +79,7 @@ private inline fun List<FirAnnotation>.mapIndexedToAnnotationApplication(
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun FirAnnotation.asKtAnnotationApplicationForAnnotationWithEnumArgument(
|
private fun FirAnnotation.asKtAnnotationApplicationForAnnotationWithEnumArgument(
|
||||||
useSiteSession: FirSession,
|
builder: KtSymbolByFirBuilder,
|
||||||
index: Int,
|
index: Int,
|
||||||
expectedEnumClassId: ClassId,
|
expectedEnumClassId: ClassId,
|
||||||
annotationParameterName: Name,
|
annotationParameterName: Name,
|
||||||
@@ -107,14 +108,14 @@ private fun FirAnnotation.asKtAnnotationApplicationForAnnotationWithEnumArgument
|
|||||||
)
|
)
|
||||||
}.orEmpty()
|
}.orEmpty()
|
||||||
|
|
||||||
return toKtAnnotationApplication(useSiteSession, index, arguments)
|
return toKtAnnotationApplication(builder, index, arguments)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun FirAnnotation.asKtAnnotationApplicationForTargetAnnotation(
|
private fun FirAnnotation.asKtAnnotationApplicationForTargetAnnotation(
|
||||||
useSiteSession: FirSession,
|
builder: KtSymbolByFirBuilder,
|
||||||
index: Int,
|
index: Int,
|
||||||
): KtAnnotationApplicationWithArgumentsInfo = asKtAnnotationApplicationForAnnotationWithEnumArgument(
|
): KtAnnotationApplicationWithArgumentsInfo = asKtAnnotationApplicationForAnnotationWithEnumArgument(
|
||||||
useSiteSession = useSiteSession,
|
builder = builder,
|
||||||
index = index,
|
index = index,
|
||||||
expectedEnumClassId = StandardClassIds.AnnotationTarget,
|
expectedEnumClassId = StandardClassIds.AnnotationTarget,
|
||||||
annotationParameterName = StandardClassIds.Annotations.ParameterNames.targetAllowedTargets,
|
annotationParameterName = StandardClassIds.Annotations.ParameterNames.targetAllowedTargets,
|
||||||
@@ -122,14 +123,14 @@ private fun FirAnnotation.asKtAnnotationApplicationForTargetAnnotation(
|
|||||||
)
|
)
|
||||||
|
|
||||||
private fun FirAnnotation.asKtAnnotationApplicationForJavaTargetAnnotation(
|
private fun FirAnnotation.asKtAnnotationApplicationForJavaTargetAnnotation(
|
||||||
useSiteSession: FirSession,
|
builder: KtSymbolByFirBuilder,
|
||||||
index: Int,
|
index: Int,
|
||||||
): KtAnnotationApplicationWithArgumentsInfo = asKtAnnotationApplicationForAnnotationWithEnumArgument(
|
): KtAnnotationApplicationWithArgumentsInfo = asKtAnnotationApplicationForAnnotationWithEnumArgument(
|
||||||
useSiteSession = useSiteSession,
|
builder = builder,
|
||||||
index = index,
|
index = index,
|
||||||
expectedEnumClassId = JvmStandardClassIds.Annotations.Java.ElementType,
|
expectedEnumClassId = JvmStandardClassIds.Annotations.Java.ElementType,
|
||||||
annotationParameterName = StandardClassIds.Annotations.ParameterNames.value,
|
annotationParameterName = StandardClassIds.Annotations.ParameterNames.value,
|
||||||
nameMapper = { ElementType.values().firstOrNull { enumValue -> enumValue.name == it }?.name },
|
nameMapper = { ElementType.entries.firstOrNull { enumValue -> enumValue.name == it }?.name },
|
||||||
)
|
)
|
||||||
|
|
||||||
private fun <T> FirAnnotation.findFromRawArguments(expectedEnumClass: ClassId, transformer: (String) -> T?): Set<T> = buildSet {
|
private fun <T> FirAnnotation.findFromRawArguments(expectedEnumClass: ClassId, transformer: (String) -> T?): Set<T> = buildSet {
|
||||||
@@ -150,11 +151,11 @@ private fun <T> FirAnnotation.findFromRawArguments(expectedEnumClass: ClassId, t
|
|||||||
|
|
||||||
internal fun annotations(
|
internal fun annotations(
|
||||||
firSymbol: FirBasedSymbol<*>,
|
firSymbol: FirBasedSymbol<*>,
|
||||||
useSiteSession: FirSession,
|
builder: KtSymbolByFirBuilder,
|
||||||
annotationContainer: FirAnnotationContainer = firSymbol.fir,
|
annotationContainer: FirAnnotationContainer = firSymbol.fir,
|
||||||
): List<KtAnnotationApplicationWithArgumentsInfo> =
|
): List<KtAnnotationApplicationWithArgumentsInfo> =
|
||||||
annotationContainer.resolvedAnnotationsWithArguments(firSymbol).mapIndexed { index, annotation ->
|
annotationContainer.resolvedAnnotationsWithArguments(firSymbol).mapIndexed { index, annotation ->
|
||||||
annotation.toKtAnnotationApplication(useSiteSession, index)
|
annotation.toKtAnnotationApplication(builder, index)
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun annotationInfos(
|
internal fun annotationInfos(
|
||||||
|
|||||||
+2
-10
@@ -1,11 +1,10 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.components
|
package org.jetbrains.kotlin.analysis.api.fir.components
|
||||||
|
|
||||||
import org.jetbrains.kotlin.KtFakeSourceElementKind
|
|
||||||
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationValue
|
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationValue
|
||||||
import org.jetbrains.kotlin.analysis.api.base.KtConstantValue
|
import org.jetbrains.kotlin.analysis.api.base.KtConstantValue
|
||||||
import org.jetbrains.kotlin.analysis.api.components.KtCompileTimeConstantProvider
|
import org.jetbrains.kotlin.analysis.api.components.KtCompileTimeConstantProvider
|
||||||
@@ -13,19 +12,12 @@ import org.jetbrains.kotlin.analysis.api.components.KtConstantEvaluationMode
|
|||||||
import org.jetbrains.kotlin.analysis.api.fir.KtFirAnalysisSession
|
import org.jetbrains.kotlin.analysis.api.fir.KtFirAnalysisSession
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.evaluate.FirAnnotationValueConverter
|
import org.jetbrains.kotlin.analysis.api.fir.evaluate.FirAnnotationValueConverter
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.evaluate.FirCompileTimeConstantEvaluator
|
import org.jetbrains.kotlin.analysis.api.fir.evaluate.FirCompileTimeConstantEvaluator
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.utils.asKtInitializerValue
|
|
||||||
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
|
import org.jetbrains.kotlin.analysis.api.lifetime.KtLifetimeToken
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFir
|
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.getOrBuildFir
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.throwUnexpectedFirElementError
|
|
||||||
import org.jetbrains.kotlin.fir.FirElement
|
import org.jetbrains.kotlin.fir.FirElement
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirProperty
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
import org.jetbrains.kotlin.fir.expressions.FirExpression
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirPropertyAccessExpression
|
import org.jetbrains.kotlin.fir.expressions.FirPropertyAccessExpression
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirVariableAssignment
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirWhenBranch
|
|
||||||
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
||||||
import org.jetbrains.kotlin.fir.types.FirTypeRef
|
|
||||||
import org.jetbrains.kotlin.psi
|
|
||||||
import org.jetbrains.kotlin.psi.KtExpression
|
import org.jetbrains.kotlin.psi.KtExpression
|
||||||
|
|
||||||
internal class KtFirCompileTimeConstantProvider(
|
internal class KtFirCompileTimeConstantProvider(
|
||||||
@@ -42,7 +34,7 @@ internal class KtFirCompileTimeConstantProvider(
|
|||||||
|
|
||||||
override fun evaluateAsAnnotationValue(expression: KtExpression): KtAnnotationValue? =
|
override fun evaluateAsAnnotationValue(expression: KtExpression): KtAnnotationValue? =
|
||||||
(expression.getOrBuildFir(firResolveSession) as? FirExpression)?.let {
|
(expression.getOrBuildFir(firResolveSession) as? FirExpression)?.let {
|
||||||
FirAnnotationValueConverter.toConstantValue(it, firResolveSession.useSiteFirSession)
|
FirAnnotationValueConverter.toConstantValue(it, analysisSession.firSymbolBuilder)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun evaluateFir(
|
private fun evaluateFir(
|
||||||
|
|||||||
+24
-24
@@ -9,8 +9,8 @@ import org.jetbrains.kotlin.analysis.api.annotations.*
|
|||||||
import org.jetbrains.kotlin.analysis.api.base.KtConstantValue
|
import org.jetbrains.kotlin.analysis.api.base.KtConstantValue
|
||||||
import org.jetbrains.kotlin.analysis.api.base.KtConstantValueFactory
|
import org.jetbrains.kotlin.analysis.api.base.KtConstantValueFactory
|
||||||
import org.jetbrains.kotlin.analysis.api.components.KtConstantEvaluationMode
|
import org.jetbrains.kotlin.analysis.api.components.KtConstantEvaluationMode
|
||||||
|
import org.jetbrains.kotlin.analysis.api.fir.KtSymbolByFirBuilder
|
||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.fir.FirSession
|
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.getContainingClassSymbol
|
import org.jetbrains.kotlin.fir.analysis.checkers.getContainingClassSymbol
|
||||||
import org.jetbrains.kotlin.fir.declarations.FirClass
|
import org.jetbrains.kotlin.fir.declarations.FirClass
|
||||||
import org.jetbrains.kotlin.fir.declarations.fullyExpandedClass
|
import org.jetbrains.kotlin.fir.declarations.fullyExpandedClass
|
||||||
@@ -34,14 +34,13 @@ import org.jetbrains.kotlin.resolve.ArrayFqNames
|
|||||||
internal object FirAnnotationValueConverter {
|
internal object FirAnnotationValueConverter {
|
||||||
fun toNamedConstantValue(
|
fun toNamedConstantValue(
|
||||||
argumentMapping: Map<Name, FirExpression>,
|
argumentMapping: Map<Name, FirExpression>,
|
||||||
session: FirSession,
|
builder: KtSymbolByFirBuilder,
|
||||||
): List<KtNamedAnnotationValue> =
|
): List<KtNamedAnnotationValue> = argumentMapping.map { (name, expression) ->
|
||||||
argumentMapping.map { (name, expression) ->
|
KtNamedAnnotationValue(
|
||||||
KtNamedAnnotationValue(
|
name,
|
||||||
name,
|
expression.convertConstantExpression(builder) ?: KtUnsupportedAnnotationValue
|
||||||
expression.convertConstantExpression(session) ?: KtUnsupportedAnnotationValue
|
)
|
||||||
)
|
}
|
||||||
}
|
|
||||||
|
|
||||||
private fun <T> FirConstExpression<T>.convertConstantExpression(): KtConstantAnnotationValue? {
|
private fun <T> FirConstExpression<T>.convertConstantExpression(): KtConstantAnnotationValue? {
|
||||||
val expression = psi as? KtElement
|
val expression = psi as? KtElement
|
||||||
@@ -71,12 +70,12 @@ internal object FirAnnotationValueConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private fun Collection<FirExpression>.convertVarargsExpression(
|
private fun Collection<FirExpression>.convertVarargsExpression(
|
||||||
session: FirSession,
|
builder: KtSymbolByFirBuilder,
|
||||||
): Pair<Collection<KtAnnotationValue>, KtElement?> {
|
): Pair<Collection<KtAnnotationValue>, KtElement?> {
|
||||||
var representativePsi: KtElement? = null
|
var representativePsi: KtElement? = null
|
||||||
val flattenedVarargs = buildList {
|
val flattenedVarargs = buildList {
|
||||||
for (expr in this@convertVarargsExpression) {
|
for (expr in this@convertVarargsExpression) {
|
||||||
val converted = expr.convertConstantExpression(session) ?: continue
|
val converted = expr.convertConstantExpression(builder) ?: continue
|
||||||
|
|
||||||
if (expr is FirSpreadArgumentExpression || expr is FirNamedArgumentExpression) {
|
if (expr is FirSpreadArgumentExpression || expr is FirNamedArgumentExpression) {
|
||||||
addAll((converted as KtArrayAnnotationValue).values)
|
addAll((converted as KtArrayAnnotationValue).values)
|
||||||
@@ -93,40 +92,38 @@ internal object FirAnnotationValueConverter {
|
|||||||
|
|
||||||
fun toConstantValue(
|
fun toConstantValue(
|
||||||
firExpression: FirExpression,
|
firExpression: FirExpression,
|
||||||
session: FirSession,
|
builder: KtSymbolByFirBuilder,
|
||||||
): KtAnnotationValue? = firExpression.convertConstantExpression(session)
|
): KtAnnotationValue? = firExpression.convertConstantExpression(builder)
|
||||||
|
|
||||||
private fun FirExpression.convertConstantExpression(
|
private fun FirExpression.convertConstantExpression(builder: KtSymbolByFirBuilder): KtAnnotationValue? {
|
||||||
session: FirSession,
|
|
||||||
): KtAnnotationValue? {
|
|
||||||
val sourcePsi = psi as? KtElement
|
val sourcePsi = psi as? KtElement
|
||||||
return when (this) {
|
return when (this) {
|
||||||
is FirConstExpression<*> -> convertConstantExpression()
|
is FirConstExpression<*> -> convertConstantExpression()
|
||||||
is FirNamedArgumentExpression -> {
|
is FirNamedArgumentExpression -> {
|
||||||
expression.convertConstantExpression(session)
|
expression.convertConstantExpression(builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
is FirSpreadArgumentExpression -> {
|
is FirSpreadArgumentExpression -> {
|
||||||
expression.convertConstantExpression(session)
|
expression.convertConstantExpression(builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
is FirVarargArgumentsExpression -> {
|
is FirVarargArgumentsExpression -> {
|
||||||
// Vararg arguments may have multiple independent expressions associated.
|
// Vararg arguments may have multiple independent expressions associated.
|
||||||
// Choose one to be the representative PSI value for the entire assembled argument.
|
// Choose one to be the representative PSI value for the entire assembled argument.
|
||||||
val (annotationValues, representativePsi) = arguments.convertVarargsExpression(session)
|
val (annotationValues, representativePsi) = arguments.convertVarargsExpression(builder)
|
||||||
KtArrayAnnotationValue(annotationValues, representativePsi ?: sourcePsi)
|
KtArrayAnnotationValue(annotationValues, representativePsi ?: sourcePsi)
|
||||||
}
|
}
|
||||||
|
|
||||||
is FirArrayLiteral -> {
|
is FirArrayLiteral -> {
|
||||||
// Desugared collection literals.
|
// Desugared collection literals.
|
||||||
KtArrayAnnotationValue(argumentList.arguments.convertVarargsExpression(session).first, sourcePsi)
|
KtArrayAnnotationValue(argumentList.arguments.convertVarargsExpression(builder).first, sourcePsi)
|
||||||
}
|
}
|
||||||
|
|
||||||
is FirFunctionCall -> {
|
is FirFunctionCall -> {
|
||||||
val reference = calleeReference as? FirResolvedNamedReference ?: return null
|
val reference = calleeReference as? FirResolvedNamedReference ?: return null
|
||||||
when (val resolvedSymbol = reference.resolvedSymbol) {
|
when (val resolvedSymbol = reference.resolvedSymbol) {
|
||||||
is FirConstructorSymbol -> {
|
is FirConstructorSymbol -> {
|
||||||
val classSymbol = resolvedSymbol.getContainingClassSymbol(session) ?: return null
|
val classSymbol = resolvedSymbol.getContainingClassSymbol(builder.rootSession) ?: return null
|
||||||
if ((classSymbol.fir as? FirClass)?.classKind == ClassKind.ANNOTATION_CLASS) {
|
if ((classSymbol.fir as? FirClass)?.classKind == ClassKind.ANNOTATION_CLASS) {
|
||||||
val resultMap = mutableMapOf<Name, FirExpression>()
|
val resultMap = mutableMapOf<Name, FirExpression>()
|
||||||
resolvedArgumentMapping?.entries?.forEach { (arg, param) ->
|
resolvedArgumentMapping?.entries?.forEach { (arg, param) ->
|
||||||
@@ -138,8 +135,11 @@ internal object FirAnnotationValueConverter {
|
|||||||
resolvedSymbol.callableId.classId,
|
resolvedSymbol.callableId.classId,
|
||||||
psi as? KtCallElement,
|
psi as? KtCallElement,
|
||||||
useSiteTarget = null,
|
useSiteTarget = null,
|
||||||
toNamedConstantValue(resultMap, session),
|
toNamedConstantValue(resultMap, builder),
|
||||||
index = null,
|
index = null,
|
||||||
|
constructorSymbolPointer = with(builder.analysisSession) {
|
||||||
|
builder.functionLikeBuilder.buildConstructorSymbol(resolvedSymbol).createPointer()
|
||||||
|
},
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
} else null
|
} else null
|
||||||
@@ -148,7 +148,7 @@ internal object FirAnnotationValueConverter {
|
|||||||
is FirNamedFunctionSymbol -> {
|
is FirNamedFunctionSymbol -> {
|
||||||
// arrayOf call with a single vararg argument.
|
// arrayOf call with a single vararg argument.
|
||||||
if (resolvedSymbol.callableId.asSingleFqName() in ArrayFqNames.ARRAY_CALL_FQ_NAMES)
|
if (resolvedSymbol.callableId.asSingleFqName() in ArrayFqNames.ARRAY_CALL_FQ_NAMES)
|
||||||
argumentList.arguments.single().convertConstantExpression(session)
|
argumentList.arguments.single().convertConstantExpression(builder)
|
||||||
else null
|
else null
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +174,7 @@ internal object FirAnnotationValueConverter {
|
|||||||
is FirGetClassCall -> {
|
is FirGetClassCall -> {
|
||||||
var symbol = (argument as? FirResolvedQualifier)?.symbol
|
var symbol = (argument as? FirResolvedQualifier)?.symbol
|
||||||
if (symbol is FirTypeAliasSymbol) {
|
if (symbol is FirTypeAliasSymbol) {
|
||||||
symbol = symbol.fullyExpandedClass(session) ?: symbol
|
symbol = symbol.fullyExpandedClass(builder.rootSession) ?: symbol
|
||||||
}
|
}
|
||||||
when {
|
when {
|
||||||
symbol == null -> {
|
symbol == null -> {
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ internal class KtFirAnonymousFunctionSymbol(
|
|||||||
|
|
||||||
override val annotationsList: KtAnnotationsList
|
override val annotationsList: KtAnnotationsList
|
||||||
get() = withValidityAssertion {
|
get() = withValidityAssertion {
|
||||||
KtFirAnnotationListForDeclaration.create(firSymbol, analysisSession.useSiteSession, token)
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val returnType: KtType get() = withValidityAssertion { firSymbol.returnType(analysisSession.firSymbolBuilder) }
|
override val returnType: KtType get() = withValidityAssertion { firSymbol.returnType(analysisSession.firSymbolBuilder) }
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ internal open class KtFirAnonymousObjectSymbol(
|
|||||||
override val psi: PsiElement? = withValidityAssertion { firSymbol.fir.getAllowedPsi() }
|
override val psi: PsiElement? = withValidityAssertion { firSymbol.fir.getAllowedPsi() }
|
||||||
|
|
||||||
override val annotationsList by cached {
|
override val annotationsList by cached {
|
||||||
KtFirAnnotationListForDeclaration.create(firSymbol, analysisSession.useSiteSession, token)
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val superTypes: List<KtType> by cached { firSymbol.superTypesList(builder) }
|
override val superTypes: List<KtType> by cached { firSymbol.superTypesList(builder) }
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ internal class KtFirBackingFieldSymbol(
|
|||||||
|
|
||||||
override val annotationsList: KtAnnotationsList
|
override val annotationsList: KtAnnotationsList
|
||||||
get() = withValidityAssertion {
|
get() = withValidityAssertion {
|
||||||
KtFirAnnotationListForDeclaration.create(firSymbol, analysisSession.useSiteSession, token)
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val returnType: KtType get() = withValidityAssertion { firSymbol.returnType(builder) }
|
override val returnType: KtType get() = withValidityAssertion { firSymbol.returnType(builder) }
|
||||||
|
|||||||
+2
-6
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -49,11 +49,7 @@ internal class KtFirConstructorSymbol(
|
|||||||
override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility }
|
override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility }
|
||||||
|
|
||||||
override val annotationsList by cached {
|
override val annotationsList by cached {
|
||||||
KtFirAnnotationListForDeclaration.create(
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
firSymbol,
|
|
||||||
analysisSession.useSiteSession,
|
|
||||||
token,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override val containingClassIdIfNonLocal: ClassId?
|
override val containingClassIdIfNonLocal: ClassId?
|
||||||
|
|||||||
+1
-1
@@ -47,7 +47,7 @@ internal class KtFirDestructuringDeclarationSymbol(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val annotationsList: KtAnnotationsList
|
override val annotationsList: KtAnnotationsList
|
||||||
get() = withValidityAssertion { KtFirAnnotationListForDeclaration.create(firSymbol, analysisSession.useSiteSession, token) }
|
get() = withValidityAssertion { KtFirAnnotationListForDeclaration.create(firSymbol, builder) }
|
||||||
|
|
||||||
override val entries: List<KtLocalVariableSymbol>
|
override val entries: List<KtLocalVariableSymbol>
|
||||||
get() = withValidityAssertion {
|
get() = withValidityAssertion {
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ internal class KtFirEnumEntrySymbol(
|
|||||||
|
|
||||||
override val annotationsList: KtAnnotationsList
|
override val annotationsList: KtAnnotationsList
|
||||||
get() = withValidityAssertion {
|
get() = withValidityAssertion {
|
||||||
KtFirAnnotationListForDeclaration.create(firSymbol, analysisSession.useSiteSession, token)
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val name: Name get() = withValidityAssertion { firSymbol.name }
|
override val name: Name get() = withValidityAssertion { firSymbol.name }
|
||||||
|
|||||||
+2
-6
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -31,11 +31,7 @@ internal class KtFirFileSymbol(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val annotationsList by cached {
|
override val annotationsList by cached {
|
||||||
KtFirAnnotationListForDeclaration.create(
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
firSymbol,
|
|
||||||
analysisSession.useSiteSession,
|
|
||||||
token,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun equals(other: Any?): Boolean = symbolEquals(other)
|
override fun equals(other: Any?): Boolean = symbolEquals(other)
|
||||||
|
|||||||
+2
-6
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -68,11 +68,7 @@ internal class KtFirFunctionSymbol(
|
|||||||
get() = withValidityAssertion { firSymbol.fir.hasStableParameterNames }
|
get() = withValidityAssertion { firSymbol.fir.hasStableParameterNames }
|
||||||
|
|
||||||
override val annotationsList by cached {
|
override val annotationsList by cached {
|
||||||
KtFirAnnotationListForDeclaration.create(
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
firSymbol,
|
|
||||||
analysisSession.useSiteSession,
|
|
||||||
token,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override val isSuspend: Boolean get() = withValidityAssertion { firSymbol.isSuspend }
|
override val isSuspend: Boolean get() = withValidityAssertion { firSymbol.isSuspend }
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -37,7 +37,7 @@ internal class KtFirJavaFieldSymbol(
|
|||||||
|
|
||||||
override val annotationsList: KtAnnotationsList
|
override val annotationsList: KtAnnotationsList
|
||||||
get() = withValidityAssertion {
|
get() = withValidityAssertion {
|
||||||
KtFirAnnotationListForDeclaration.create(firSymbol, analysisSession.useSiteSession, token)
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val isVal: Boolean get() = withValidityAssertion { firSymbol.fir.isVal }
|
override val isVal: Boolean get() = withValidityAssertion { firSymbol.fir.isVal }
|
||||||
|
|||||||
+2
-10
@@ -21,10 +21,7 @@ import org.jetbrains.kotlin.analysis.api.symbols.markers.KtSymbolKind
|
|||||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtPsiBasedSymbolPointer
|
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtPsiBasedSymbolPointer
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
|
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.UnsupportedSymbolKind
|
import org.jetbrains.kotlin.analysis.api.symbols.pointers.UnsupportedSymbolKind
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.symbolPointerOfType
|
|
||||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.errorWithFirSpecificEntries
|
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.getContainingFile
|
|
||||||
import org.jetbrains.kotlin.descriptors.Modality
|
import org.jetbrains.kotlin.descriptors.Modality
|
||||||
import org.jetbrains.kotlin.descriptors.Visibility
|
import org.jetbrains.kotlin.descriptors.Visibility
|
||||||
import org.jetbrains.kotlin.fir.containingClassLookupTag
|
import org.jetbrains.kotlin.fir.containingClassLookupTag
|
||||||
@@ -38,7 +35,6 @@ import org.jetbrains.kotlin.fir.symbols.impl.isExtension
|
|||||||
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
||||||
import org.jetbrains.kotlin.name.CallableId
|
import org.jetbrains.kotlin.name.CallableId
|
||||||
import org.jetbrains.kotlin.name.Name
|
import org.jetbrains.kotlin.name.Name
|
||||||
import org.jetbrains.kotlin.psi.KtFile
|
|
||||||
|
|
||||||
internal class KtFirKotlinPropertySymbol(
|
internal class KtFirKotlinPropertySymbol(
|
||||||
override val firSymbol: FirPropertySymbol,
|
override val firSymbol: FirPropertySymbol,
|
||||||
@@ -64,7 +60,7 @@ internal class KtFirKotlinPropertySymbol(
|
|||||||
override val contextReceivers: List<KtContextReceiver> by cached { firSymbol.createContextReceivers(builder) }
|
override val contextReceivers: List<KtContextReceiver> by cached { firSymbol.createContextReceivers(builder) }
|
||||||
|
|
||||||
override val isExtension: Boolean get() = withValidityAssertion { firSymbol.isExtension }
|
override val isExtension: Boolean get() = withValidityAssertion { firSymbol.isExtension }
|
||||||
override val initializer: KtInitializerValue? by cached { firSymbol.getKtConstantInitializer(analysisSession.firResolveSession) }
|
override val initializer: KtInitializerValue? by cached { firSymbol.getKtConstantInitializer(builder) }
|
||||||
|
|
||||||
override val symbolKind: KtSymbolKind
|
override val symbolKind: KtSymbolKind
|
||||||
get() = withValidityAssertion {
|
get() = withValidityAssertion {
|
||||||
@@ -81,11 +77,7 @@ internal class KtFirKotlinPropertySymbol(
|
|||||||
override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility }
|
override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility }
|
||||||
|
|
||||||
override val annotationsList by cached {
|
override val annotationsList by cached {
|
||||||
KtFirAnnotationListForDeclaration.create(
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
firSymbol,
|
|
||||||
analysisSession.useSiteSession,
|
|
||||||
token
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override val callableIdIfNonLocal: CallableId? get() = withValidityAssertion { firSymbol.getCallableIdIfNonLocal() }
|
override val callableIdIfNonLocal: CallableId? get() = withValidityAssertion { firSymbol.getCallableIdIfNonLocal() }
|
||||||
|
|||||||
+1
-1
@@ -37,7 +37,7 @@ internal abstract class KtFirLocalOrErrorVariableSymbol<E : FirVariable, S : Fir
|
|||||||
|
|
||||||
override val annotationsList: KtAnnotationsList
|
override val annotationsList: KtAnnotationsList
|
||||||
get() = withValidityAssertion {
|
get() = withValidityAssertion {
|
||||||
KtFirAnnotationListForDeclaration.create(firSymbol, analysisSession.useSiteSession, token)
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val name: Name get() = withValidityAssertion { firSymbol.name }
|
override val name: Name get() = withValidityAssertion { firSymbol.name }
|
||||||
|
|||||||
+2
-6
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -59,11 +59,7 @@ internal class KtFirNamedClassOrObjectSymbol(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val annotationsList by cached {
|
override val annotationsList by cached {
|
||||||
KtFirAnnotationListForDeclaration.create(
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
firSymbol,
|
|
||||||
analysisSession.useSiteSession,
|
|
||||||
token,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override val isInner: Boolean get() = withValidityAssertion { firSymbol.isInner }
|
override val isInner: Boolean get() = withValidityAssertion { firSymbol.isInner }
|
||||||
|
|||||||
+2
-6
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -59,11 +59,7 @@ internal class KtFirPropertyGetterSymbol(
|
|||||||
override val receiverParameter: KtReceiverParameterSymbol? get() = withValidityAssertion { firSymbol.fir.propertySymbol.receiver(builder) }
|
override val receiverParameter: KtReceiverParameterSymbol? get() = withValidityAssertion { firSymbol.fir.propertySymbol.receiver(builder) }
|
||||||
|
|
||||||
override val annotationsList by cached {
|
override val annotationsList by cached {
|
||||||
KtFirAnnotationListForDeclaration.create(
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
firSymbol,
|
|
||||||
analysisSession.useSiteSession,
|
|
||||||
token,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-5
@@ -69,11 +69,7 @@ internal class KtFirPropertySetterSymbol(
|
|||||||
override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility }
|
override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility }
|
||||||
|
|
||||||
override val annotationsList by cached {
|
override val annotationsList by cached {
|
||||||
KtFirAnnotationListForDeclaration.create(
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
firSymbol,
|
|
||||||
analysisSession.useSiteSession,
|
|
||||||
token,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
+1
-1
@@ -131,7 +131,7 @@ internal class KtFirPsiJavaClassSymbol(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val annotationsList: KtAnnotationsList by cached {
|
override val annotationsList: KtAnnotationsList by cached {
|
||||||
if (hasAnnotations) KtFirAnnotationListForDeclaration.create(firSymbol, analysisSession.useSiteSession, token)
|
if (hasAnnotations) KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
else KtEmptyAnnotationsList(token)
|
else KtEmptyAnnotationsList(token)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -56,6 +56,6 @@ internal class KtFirReceiverParameterSymbol(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val annotationsList: KtAnnotationsList by cached {
|
override val annotationsList: KtAnnotationsList by cached {
|
||||||
KtFirAnnotationListForReceiverParameter.create(firSymbol, analysisSession.useSiteSession, token)
|
KtFirAnnotationListForReceiverParameter.create(firSymbol, builder = analysisSession.firSymbolBuilder)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -38,7 +38,7 @@ internal class KtFirSamConstructorSymbol(
|
|||||||
|
|
||||||
override val annotationsList: KtAnnotationsList
|
override val annotationsList: KtAnnotationsList
|
||||||
get() = withValidityAssertion {
|
get() = withValidityAssertion {
|
||||||
KtFirAnnotationListForDeclaration.create(firSymbol, analysisSession.useSiteSession, token)
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val name: Name get() = withValidityAssertion { firSymbol.name }
|
override val name: Name get() = withValidityAssertion { firSymbol.name }
|
||||||
|
|||||||
+1
-5
@@ -32,11 +32,7 @@ internal class KtFirScriptSymbol(
|
|||||||
get() = withValidityAssertion { firSymbol.fir.psi }
|
get() = withValidityAssertion { firSymbol.fir.psi }
|
||||||
|
|
||||||
override val annotationsList by cached {
|
override val annotationsList by cached {
|
||||||
KtFirAnnotationListForDeclaration.create(
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
firSymbol,
|
|
||||||
analysisSession.useSiteSession,
|
|
||||||
token,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override val typeParameters: List<KtTypeParameterSymbol>
|
override val typeParameters: List<KtTypeParameterSymbol>
|
||||||
|
|||||||
+3
-7
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -49,17 +49,13 @@ internal class KtFirSyntheticJavaPropertySymbol(
|
|||||||
|
|
||||||
override val isExtension: Boolean get() = withValidityAssertion { firSymbol.isExtension }
|
override val isExtension: Boolean get() = withValidityAssertion { firSymbol.isExtension }
|
||||||
|
|
||||||
override val initializer: KtInitializerValue? by cached { firSymbol.getKtConstantInitializer(analysisSession.firResolveSession) }
|
override val initializer: KtInitializerValue? by cached { firSymbol.getKtConstantInitializer(builder) }
|
||||||
|
|
||||||
override val modality: Modality get() = withValidityAssertion { firSymbol.modality }
|
override val modality: Modality get() = withValidityAssertion { firSymbol.modality }
|
||||||
override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility }
|
override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility }
|
||||||
|
|
||||||
override val annotationsList by cached {
|
override val annotationsList by cached {
|
||||||
KtFirAnnotationListForDeclaration.create(
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
firSymbol,
|
|
||||||
analysisSession.useSiteSession,
|
|
||||||
token
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override val callableIdIfNonLocal: CallableId? get() = withValidityAssertion { firSymbol.getCallableIdIfNonLocal() }
|
override val callableIdIfNonLocal: CallableId? get() = withValidityAssertion { firSymbol.getCallableIdIfNonLocal() }
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -51,7 +51,7 @@ internal class KtFirTypeAliasSymbol(
|
|||||||
override val expandedType: KtType by cached { builder.typeBuilder.buildKtType(firSymbol.resolvedExpandedTypeRef) }
|
override val expandedType: KtType by cached { builder.typeBuilder.buildKtType(firSymbol.resolvedExpandedTypeRef) }
|
||||||
|
|
||||||
override val annotationsList: KtAnnotationsList by cached {
|
override val annotationsList: KtAnnotationsList by cached {
|
||||||
KtFirAnnotationListForDeclaration.create(firSymbol, analysisSession.useSiteSession, token)
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val symbolKind: KtSymbolKind get() = withValidityAssertion { getSymbolKind() }
|
override val symbolKind: KtSymbolKind get() = withValidityAssertion { getSymbolKind() }
|
||||||
|
|||||||
+3
-3
@@ -16,10 +16,10 @@ import org.jetbrains.kotlin.analysis.api.symbols.KtTypeParameterSymbol
|
|||||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtPsiBasedSymbolPointer
|
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtPsiBasedSymbolPointer
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
|
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
|
||||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
|
||||||
import org.jetbrains.kotlin.fir.types.isNullableAny
|
|
||||||
import org.jetbrains.kotlin.fir.analysis.checkers.typeParameterSymbols
|
import org.jetbrains.kotlin.fir.analysis.checkers.typeParameterSymbols
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||||
import org.jetbrains.kotlin.fir.types.UnexpandedTypeCheck
|
import org.jetbrains.kotlin.fir.types.UnexpandedTypeCheck
|
||||||
|
import org.jetbrains.kotlin.fir.types.isNullableAny
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* [KtFirTypeParameterSymbolBase] provides shared implementations for [KtFirTypeParameterSymbol] and [KtFirPsiJavaTypeParameterSymbol].
|
* [KtFirTypeParameterSymbolBase] provides shared implementations for [KtFirTypeParameterSymbol] and [KtFirPsiJavaTypeParameterSymbol].
|
||||||
@@ -27,7 +27,7 @@ import org.jetbrains.kotlin.fir.types.UnexpandedTypeCheck
|
|||||||
internal sealed class KtFirTypeParameterSymbolBase : KtTypeParameterSymbol(), KtFirSymbol<FirTypeParameterSymbol> {
|
internal sealed class KtFirTypeParameterSymbolBase : KtTypeParameterSymbol(), KtFirSymbol<FirTypeParameterSymbol> {
|
||||||
override val annotationsList: KtAnnotationsList
|
override val annotationsList: KtAnnotationsList
|
||||||
get() = withValidityAssertion {
|
get() = withValidityAssertion {
|
||||||
KtFirAnnotationListForDeclaration.create(firSymbol, analysisSession.useSiteSession, token)
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(UnexpandedTypeCheck::class)
|
@OptIn(UnexpandedTypeCheck::class)
|
||||||
|
|||||||
+2
-6
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -58,11 +58,7 @@ internal class KtFirValueParameterSymbol(
|
|||||||
override val hasDefaultValue: Boolean get() = withValidityAssertion { firSymbol.hasDefaultValue }
|
override val hasDefaultValue: Boolean get() = withValidityAssertion { firSymbol.hasDefaultValue }
|
||||||
|
|
||||||
override val annotationsList by cached {
|
override val annotationsList by cached {
|
||||||
KtFirAnnotationListForDeclaration.create(
|
KtFirAnnotationListForDeclaration.create(firSymbol, builder)
|
||||||
firSymbol,
|
|
||||||
analysisSession.useSiteSession,
|
|
||||||
token,
|
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
override val generatedPrimaryConstructorProperty: KtKotlinPropertySymbol? by cached {
|
override val generatedPrimaryConstructorProperty: KtKotlinPropertySymbol? by cached {
|
||||||
|
|||||||
+7
-6
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -15,14 +15,13 @@ import org.jetbrains.kotlin.analysis.api.fir.utils.asKtInitializerValue
|
|||||||
import org.jetbrains.kotlin.analysis.api.impl.base.KtContextReceiverImpl
|
import org.jetbrains.kotlin.analysis.api.impl.base.KtContextReceiverImpl
|
||||||
import org.jetbrains.kotlin.analysis.api.symbols.KtValueParameterSymbol
|
import org.jetbrains.kotlin.analysis.api.symbols.KtValueParameterSymbol
|
||||||
import org.jetbrains.kotlin.analysis.api.types.KtType
|
import org.jetbrains.kotlin.analysis.api.types.KtType
|
||||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.LLFirResolveSession
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
import org.jetbrains.kotlin.descriptors.ClassKind
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
import org.jetbrains.kotlin.fir.declarations.*
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirPropertyAccessExpression
|
import org.jetbrains.kotlin.fir.expressions.FirPropertyAccessExpression
|
||||||
import org.jetbrains.kotlin.fir.references.impl.FirPropertyFromParameterResolvedNamedReference
|
import org.jetbrains.kotlin.fir.references.impl.FirPropertyFromParameterResolvedNamedReference
|
||||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||||
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||||
|
import org.jetbrains.kotlin.fir.symbols.lazyResolveToPhase
|
||||||
import org.jetbrains.kotlin.fir.types.ConeDynamicType
|
import org.jetbrains.kotlin.fir.types.ConeDynamicType
|
||||||
import org.jetbrains.kotlin.fir.types.create
|
import org.jetbrains.kotlin.fir.types.create
|
||||||
import org.jetbrains.kotlin.fir.types.toRegularClassSymbol
|
import org.jetbrains.kotlin.fir.types.toRegularClassSymbol
|
||||||
@@ -106,7 +105,7 @@ internal fun FirCallableSymbol<*>.dispatchReceiverType(
|
|||||||
return type?.let { builder.typeBuilder.buildKtType(it) }
|
return type?.let { builder.typeBuilder.buildKtType(it) }
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun FirVariableSymbol<*>.getKtConstantInitializer(resolveSession: LLFirResolveSession): KtInitializerValue? {
|
internal fun FirVariableSymbol<*>.getKtConstantInitializer(builder: KtSymbolByFirBuilder): KtInitializerValue? {
|
||||||
// to avoid lazy resolve
|
// to avoid lazy resolve
|
||||||
if (fir.initializer == null) return null
|
if (fir.initializer == null) return null
|
||||||
|
|
||||||
@@ -122,8 +121,10 @@ internal fun FirVariableSymbol<*>.getKtConstantInitializer(resolveSession: LLFir
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val parentIsAnnotation = dispatchReceiverType
|
val parentIsAnnotation = dispatchReceiverType
|
||||||
?.toRegularClassSymbol(resolveSession.useSiteFirSession)
|
?.toRegularClassSymbol(builder.rootSession)
|
||||||
?.classKind == ClassKind.ANNOTATION_CLASS
|
?.classKind == ClassKind.ANNOTATION_CLASS
|
||||||
return firInitializer.asKtInitializerValue(moduleData.session, parentIsAnnotation)
|
|
||||||
|
return firInitializer.asKtInitializerValue(builder, parentIsAnnotation)
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -28,7 +28,7 @@ internal class KtFirCapturedType(
|
|||||||
get() = withValidityAssertion { builder.typeBuilder.buildTypeProjection(coneType.constructor.projection) }
|
get() = withValidityAssertion { builder.typeBuilder.buildTypeProjection(coneType.constructor.projection) }
|
||||||
|
|
||||||
override val annotationsList: KtAnnotationsList by cached {
|
override val annotationsList: KtAnnotationsList by cached {
|
||||||
KtFirAnnotationListForType.create(coneType, builder.rootSession, token)
|
KtFirAnnotationListForType.create(coneType, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun asStringForDebugging(): String = withValidityAssertion { coneType.renderForDebugging() }
|
override fun asStringForDebugging(): String = withValidityAssertion { coneType.renderForDebugging() }
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ internal class KtFirClassErrorType(
|
|||||||
override val errorMessage: String get() = withValidityAssertion { coneDiagnostic.reason }
|
override val errorMessage: String get() = withValidityAssertion { coneDiagnostic.reason }
|
||||||
|
|
||||||
override val annotationsList: KtAnnotationsList by cached {
|
override val annotationsList: KtAnnotationsList by cached {
|
||||||
KtFirAnnotationListForType.create(coneType, builder.rootSession, token)
|
KtFirAnnotationListForType.create(coneType, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -23,7 +23,7 @@ internal class KtFirDefinitelyNotNullType(
|
|||||||
override val token: KtLifetimeToken get() = builder.token
|
override val token: KtLifetimeToken get() = builder.token
|
||||||
override val original: KtType = withValidityAssertion { builder.typeBuilder.buildKtType(this.coneType.original) }
|
override val original: KtType = withValidityAssertion { builder.typeBuilder.buildKtType(this.coneType.original) }
|
||||||
override val annotationsList: KtAnnotationsList by cached {
|
override val annotationsList: KtAnnotationsList by cached {
|
||||||
KtFirAnnotationListForType.create(coneType, builder.rootSession, token)
|
KtFirAnnotationListForType.create(coneType, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun asStringForDebugging(): String = withValidityAssertion { coneType.renderForDebugging() }
|
override fun asStringForDebugging(): String = withValidityAssertion { coneType.renderForDebugging() }
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ internal class KtFirDynamicType(
|
|||||||
) : KtDynamicType(), KtFirType {
|
) : KtDynamicType(), KtFirType {
|
||||||
override val token: KtLifetimeToken get() = builder.token
|
override val token: KtLifetimeToken get() = builder.token
|
||||||
override val annotationsList: KtAnnotationsList by cached {
|
override val annotationsList: KtAnnotationsList by cached {
|
||||||
KtFirAnnotationListForType.create(coneType, builder.rootSession, token)
|
KtFirAnnotationListForType.create(coneType, builder)
|
||||||
}
|
}
|
||||||
override val nullability: KtTypeNullability get() = withValidityAssertion { coneType.nullability.asKtNullability() }
|
override val nullability: KtTypeNullability get() = withValidityAssertion { coneType.nullability.asKtNullability() }
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ internal class KtFirFlexibleType(
|
|||||||
override val lowerBound: KtType get() = withValidityAssertion { builder.typeBuilder.buildKtType(coneType.lowerBound) }
|
override val lowerBound: KtType get() = withValidityAssertion { builder.typeBuilder.buildKtType(coneType.lowerBound) }
|
||||||
override val upperBound: KtType get() = withValidityAssertion { builder.typeBuilder.buildKtType(coneType.upperBound) }
|
override val upperBound: KtType get() = withValidityAssertion { builder.typeBuilder.buildKtType(coneType.upperBound) }
|
||||||
override val annotationsList: KtAnnotationsList by cached {
|
override val annotationsList: KtAnnotationsList by cached {
|
||||||
KtFirAnnotationListForType.create(coneType, builder.rootSession, token)
|
KtFirAnnotationListForType.create(coneType, builder)
|
||||||
}
|
}
|
||||||
override val nullability: KtTypeNullability get() = withValidityAssertion { coneType.nullability.asKtNullability() }
|
override val nullability: KtTypeNullability get() = withValidityAssertion { coneType.nullability.asKtNullability() }
|
||||||
|
|
||||||
|
|||||||
+2
-3
@@ -1,12 +1,11 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.types
|
package org.jetbrains.kotlin.analysis.api.fir.types
|
||||||
|
|
||||||
import org.jetbrains.kotlin.analysis.api.KtAnalysisApiInternals
|
import org.jetbrains.kotlin.analysis.api.KtAnalysisApiInternals
|
||||||
import org.jetbrains.kotlin.analysis.api.KtTypeArgumentWithVariance
|
|
||||||
import org.jetbrains.kotlin.analysis.api.KtTypeProjection
|
import org.jetbrains.kotlin.analysis.api.KtTypeProjection
|
||||||
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationsList
|
import org.jetbrains.kotlin.analysis.api.annotations.KtAnnotationsList
|
||||||
import org.jetbrains.kotlin.analysis.api.base.KtContextReceiver
|
import org.jetbrains.kotlin.analysis.api.base.KtContextReceiver
|
||||||
@@ -45,7 +44,7 @@ internal class KtFirFunctionalType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val annotationsList: KtAnnotationsList by cached {
|
override val annotationsList: KtAnnotationsList by cached {
|
||||||
KtFirAnnotationListForType.create(coneType, builder.rootSession, token)
|
KtFirAnnotationListForType.create(coneType, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val nullability: KtTypeNullability get() = withValidityAssertion { coneType.nullability.asKtNullability() }
|
override val nullability: KtTypeNullability get() = withValidityAssertion { coneType.nullability.asKtNullability() }
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -34,7 +34,7 @@ internal class KtFirIntegerLiteralType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val annotationsList: KtAnnotationsList by cached {
|
override val annotationsList: KtAnnotationsList by cached {
|
||||||
KtFirAnnotationListForType.create(coneType, builder.rootSession, token)
|
KtFirAnnotationListForType.create(coneType, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val nullability: KtTypeNullability get() = withValidityAssertion { coneType.nullability.asKtNullability() }
|
override val nullability: KtTypeNullability get() = withValidityAssertion { coneType.nullability.asKtNullability() }
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ internal class KtFirIntersectionType(
|
|||||||
coneType.intersectedTypes.map { conjunct -> builder.typeBuilder.buildKtType(conjunct) }
|
coneType.intersectedTypes.map { conjunct -> builder.typeBuilder.buildKtType(conjunct) }
|
||||||
}
|
}
|
||||||
override val annotationsList: KtAnnotationsList by cached {
|
override val annotationsList: KtAnnotationsList by cached {
|
||||||
KtFirAnnotationListForType.create(coneType, builder.rootSession, token)
|
KtFirAnnotationListForType.create(coneType, builder)
|
||||||
}
|
}
|
||||||
override val nullability: KtTypeNullability get() = withValidityAssertion { coneType.nullability.asKtNullability() }
|
override val nullability: KtTypeNullability get() = withValidityAssertion { coneType.nullability.asKtNullability() }
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -36,7 +36,7 @@ internal class KtFirTypeErrorType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val annotationsList: KtAnnotationsList by cached {
|
override val annotationsList: KtAnnotationsList by cached {
|
||||||
KtFirAnnotationListForType.create(coneType, builder.rootSession, token)
|
KtFirAnnotationListForType.create(coneType, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun asStringForDebugging(): String = withValidityAssertion { coneType.renderForDebugging() }
|
override fun asStringForDebugging(): String = withValidityAssertion { coneType.renderForDebugging() }
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -31,7 +31,7 @@ internal class KtFirTypeParameterType(
|
|||||||
}
|
}
|
||||||
|
|
||||||
override val annotationsList: KtAnnotationsList by cached {
|
override val annotationsList: KtAnnotationsList by cached {
|
||||||
KtFirAnnotationListForType.create(coneType, builder.rootSession, token)
|
KtFirAnnotationListForType.create(coneType, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val nullability: KtTypeNullability get() = withValidityAssertion { coneType.nullability.asKtNullability() }
|
override val nullability: KtTypeNullability get() = withValidityAssertion { coneType.nullability.asKtNullability() }
|
||||||
|
|||||||
+2
-2
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
@@ -40,7 +40,7 @@ internal class KtFirUsualClassType(
|
|||||||
override val ownTypeArguments: List<KtTypeProjection> get() = withValidityAssertion { qualifiers.last().typeArguments }
|
override val ownTypeArguments: List<KtTypeProjection> get() = withValidityAssertion { qualifiers.last().typeArguments }
|
||||||
|
|
||||||
override val annotationsList: KtAnnotationsList by cached {
|
override val annotationsList: KtAnnotationsList by cached {
|
||||||
KtFirAnnotationListForType.create(coneType, builder.rootSession, token)
|
KtFirAnnotationListForType.create(coneType, builder)
|
||||||
}
|
}
|
||||||
|
|
||||||
override val nullability: KtTypeNullability get() = withValidityAssertion { coneType.nullability.asKtNullability() }
|
override val nullability: KtTypeNullability get() = withValidityAssertion { coneType.nullability.asKtNullability() }
|
||||||
|
|||||||
+6
-8
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
* Copyright 2010-2023 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.utils
|
package org.jetbrains.kotlin.analysis.api.fir.utils
|
||||||
@@ -10,6 +10,7 @@ import org.jetbrains.kotlin.analysis.api.KtConstantValueForAnnotation
|
|||||||
import org.jetbrains.kotlin.analysis.api.KtInitializerValue
|
import org.jetbrains.kotlin.analysis.api.KtInitializerValue
|
||||||
import org.jetbrains.kotlin.analysis.api.KtNonConstantInitializerValue
|
import org.jetbrains.kotlin.analysis.api.KtNonConstantInitializerValue
|
||||||
import org.jetbrains.kotlin.analysis.api.components.KtConstantEvaluationMode
|
import org.jetbrains.kotlin.analysis.api.components.KtConstantEvaluationMode
|
||||||
|
import org.jetbrains.kotlin.analysis.api.fir.KtSymbolByFirBuilder
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.evaluate.FirAnnotationValueConverter
|
import org.jetbrains.kotlin.analysis.api.fir.evaluate.FirAnnotationValueConverter
|
||||||
import org.jetbrains.kotlin.analysis.api.fir.evaluate.FirCompileTimeConstantEvaluator
|
import org.jetbrains.kotlin.analysis.api.fir.evaluate.FirCompileTimeConstantEvaluator
|
||||||
import org.jetbrains.kotlin.analysis.api.types.KtTypeNullability
|
import org.jetbrains.kotlin.analysis.api.types.KtTypeNullability
|
||||||
@@ -72,16 +73,13 @@ internal fun FirCallableSymbol<*>.computeImportableName(useSiteSession: FirSessi
|
|||||||
return if (canBeImported) callableId.asSingleFqName() else null
|
return if (canBeImported) callableId.asSingleFqName() else null
|
||||||
}
|
}
|
||||||
|
|
||||||
internal fun FirExpression.asKtInitializerValue(
|
internal fun FirExpression.asKtInitializerValue(builder: KtSymbolByFirBuilder, forAnnotationDefaultValue: Boolean): KtInitializerValue {
|
||||||
session: FirSession,
|
|
||||||
forAnnotationDefaultValue: Boolean
|
|
||||||
): KtInitializerValue {
|
|
||||||
val ktExpression = psi as? KtExpression
|
val ktExpression = psi as? KtExpression
|
||||||
val evaluated =
|
val evaluated = FirCompileTimeConstantEvaluator.evaluateAsKtConstantValue(this, KtConstantEvaluationMode.CONSTANT_EXPRESSION_EVALUATION)
|
||||||
FirCompileTimeConstantEvaluator.evaluateAsKtConstantValue(this, KtConstantEvaluationMode.CONSTANT_EXPRESSION_EVALUATION)
|
|
||||||
return when (evaluated) {
|
return when (evaluated) {
|
||||||
null -> if (forAnnotationDefaultValue) {
|
null -> if (forAnnotationDefaultValue) {
|
||||||
val annotationConstantValue = FirAnnotationValueConverter.toConstantValue(this, session)
|
val annotationConstantValue = FirAnnotationValueConverter.toConstantValue(this, builder)
|
||||||
if (annotationConstantValue != null) {
|
if (annotationConstantValue != null) {
|
||||||
KtConstantValueForAnnotation(annotationConstantValue, ktExpression)
|
KtConstantValueForAnnotation(annotationConstantValue, ktExpression)
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
+7
@@ -5,6 +5,8 @@
|
|||||||
|
|
||||||
package org.jetbrains.kotlin.analysis.api.annotations
|
package org.jetbrains.kotlin.analysis.api.annotations
|
||||||
|
|
||||||
|
import org.jetbrains.kotlin.analysis.api.symbols.KtConstructorSymbol
|
||||||
|
import org.jetbrains.kotlin.analysis.api.symbols.pointers.KtSymbolPointer
|
||||||
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
import org.jetbrains.kotlin.descriptors.annotations.AnnotationUseSiteTarget
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
import org.jetbrains.kotlin.name.ClassId
|
||||||
import org.jetbrains.kotlin.psi.KtCallElement
|
import org.jetbrains.kotlin.psi.KtCallElement
|
||||||
@@ -23,6 +25,11 @@ public data class KtAnnotationApplicationWithArgumentsInfo(
|
|||||||
*/
|
*/
|
||||||
public val arguments: List<KtNamedAnnotationValue>,
|
public val arguments: List<KtNamedAnnotationValue>,
|
||||||
override val index: Int?,
|
override val index: Int?,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor symbol into which this annotation resolves if the annotation is correctly resolved
|
||||||
|
*/
|
||||||
|
public val constructorSymbolPointer: KtSymbolPointer<KtConstructorSymbol>?,
|
||||||
) : KtAnnotationApplication {
|
) : KtAnnotationApplication {
|
||||||
override val isCallWithArguments: Boolean get() = arguments.isNotEmpty()
|
override val isCallWithArguments: Boolean get() = arguments.isNotEmpty()
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user