[fir low level, refactoring] rename rootModule -> useSiteModule
This commit is contained in:
+5
-5
@@ -36,7 +36,7 @@ private constructor(
|
||||
private val mode: AnalysisSessionMode,
|
||||
) : KtAnalysisSession(token) {
|
||||
|
||||
override val useSiteModule: KtModule get() = firResolveState.module
|
||||
override val useSiteModule: KtModule get() = firResolveState.useSiteKtModule
|
||||
|
||||
private enum class AnalysisSessionMode {
|
||||
REGULAR,
|
||||
@@ -58,7 +58,7 @@ private constructor(
|
||||
override val scopeProviderImpl by threadLocal { KtFirScopeProvider(this, firSymbolBuilder, project, firResolveState, token) }
|
||||
|
||||
override val symbolProviderImpl =
|
||||
KtFirSymbolProvider(this, firResolveState.rootModuleSession.symbolProvider, firResolveState, firSymbolBuilder, token)
|
||||
KtFirSymbolProvider(this, firResolveState.useSiteFirSession.symbolProvider, firResolveState, firSymbolBuilder, token)
|
||||
|
||||
override val completionCandidateCheckerImpl = KtFirCompletionCandidateChecker(this, token)
|
||||
|
||||
@@ -119,9 +119,9 @@ private constructor(
|
||||
)
|
||||
}
|
||||
|
||||
val rootModuleSession: FirSession get() = firResolveState.rootModuleSession
|
||||
val firSymbolProvider: FirSymbolProvider get() = rootModuleSession.symbolProvider
|
||||
val targetPlatform: TargetPlatform get() = rootModuleSession.moduleData.platform
|
||||
val useSiteSession: FirSession get() = firResolveState.useSiteFirSession
|
||||
val firSymbolProvider: FirSymbolProvider get() = useSiteSession.symbolProvider
|
||||
val targetPlatform: TargetPlatform get() = useSiteSession.moduleData.platform
|
||||
|
||||
fun getScopeSessionFor(session: FirSession): ScopeSession = firResolveState.getScopeSessionFor(session)
|
||||
|
||||
|
||||
+2
-2
@@ -63,8 +63,8 @@ internal class KtSymbolByFirBuilder private constructor(
|
||||
) : ValidityTokenOwner {
|
||||
private val resolveState by weakRef(resolveState)
|
||||
|
||||
private val firProvider get() = resolveState.rootModuleSession.symbolProvider
|
||||
val rootSession: FirSession = resolveState.rootModuleSession
|
||||
private val firProvider get() = resolveState.useSiteFirSession.symbolProvider
|
||||
val rootSession: FirSession = resolveState.useSiteFirSession
|
||||
|
||||
val classifierBuilder = ClassifierSymbolBuilder()
|
||||
val functionLikeBuilder = FunctionLikeSymbolBuilder()
|
||||
|
||||
+3
-3
@@ -39,7 +39,7 @@ import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
internal interface KtFirAnalysisSessionComponent {
|
||||
val analysisSession: KtFirAnalysisSession
|
||||
|
||||
val rootModuleSession: FirSession get() = analysisSession.firResolveState.rootModuleSession
|
||||
val rootModuleSession: FirSession get() = analysisSession.firResolveState.useSiteFirSession
|
||||
val typeContext: ConeInferenceContext get() = rootModuleSession.typeContext
|
||||
val firSymbolBuilder get() = analysisSession.firSymbolBuilder
|
||||
val firResolveState get() = analysisSession.firResolveState
|
||||
@@ -54,7 +54,7 @@ internal interface KtFirAnalysisSessionComponent {
|
||||
qualifiedAccessSource: KtSourceElement?,
|
||||
diagnosticCache: MutableList<KtDiagnostic>
|
||||
): KtDiagnosticWithPsi<*>? {
|
||||
val firDiagnostic = toFirDiagnostics(analysisSession.rootModuleSession, source, qualifiedAccessSource).firstOrNull() ?: return null
|
||||
val firDiagnostic = toFirDiagnostics(analysisSession.useSiteSession, source, qualifiedAccessSource).firstOrNull() ?: return null
|
||||
diagnosticCache += firDiagnostic
|
||||
check(firDiagnostic is KtPsiDiagnostic)
|
||||
return firDiagnostic.asKtDiagnostic()
|
||||
@@ -76,7 +76,7 @@ internal interface KtFirAnalysisSessionComponent {
|
||||
|
||||
fun createTypeCheckerContext(): TypeCheckerState {
|
||||
// TODO use correct session here,
|
||||
return analysisSession.firResolveState.rootModuleSession.typeContext.newTypeCheckerState(
|
||||
return analysisSession.firResolveState.useSiteFirSession.typeContext.newTypeCheckerState(
|
||||
errorTypesEqualToAnything = true,
|
||||
stubTypesEqualToAnything = true
|
||||
)
|
||||
|
||||
+5
-5
@@ -69,7 +69,7 @@ internal class KtFirCallResolver(
|
||||
private val diagnosticCache = mutableListOf<KtDiagnostic>()
|
||||
|
||||
private val equalsSymbolInAny: FirNamedFunctionSymbol by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||
val session = analysisSession.rootModuleSession
|
||||
val session = analysisSession.useSiteSession
|
||||
val scope = session.declaredMemberScope(session.builtinTypes.anyType.toRegularClassSymbol(session)!!)
|
||||
lateinit var result: FirNamedFunctionSymbol
|
||||
scope.processFunctionsByName(EQUALS) {
|
||||
@@ -771,7 +771,7 @@ internal class KtFirCallResolver(
|
||||
}
|
||||
|
||||
val calleeName = originalFunctionCall.calleeOrCandidateName ?: return emptyList()
|
||||
val candidates = AllCandidatesResolver(analysisSession.rootModuleSession).getAllCandidates(
|
||||
val candidates = AllCandidatesResolver(analysisSession.useSiteSession).getAllCandidates(
|
||||
analysisSession.firResolveState,
|
||||
originalFunctionCall,
|
||||
calleeName,
|
||||
@@ -902,7 +902,7 @@ internal class KtFirCallResolver(
|
||||
FirOperation.EQ, FirOperation.NOT_EQ -> {
|
||||
val equalsSymbolInAny = equalsSymbolInAny
|
||||
val leftOperand = arguments.firstOrNull() ?: return null
|
||||
val session = analysisSession.rootModuleSession
|
||||
val session = analysisSession.useSiteSession
|
||||
val classSymbol = leftOperand.typeRef.coneType.fullyExpandedType(session).toSymbol(session) as? FirClassSymbol<*>
|
||||
val equalsSymbol = classSymbol?.getEqualsSymbol(equalsSymbolInAny) ?: equalsSymbolInAny
|
||||
val ktSignature = equalsSymbol.toKtSignature()
|
||||
@@ -926,8 +926,8 @@ internal class KtFirCallResolver(
|
||||
|
||||
private fun FirClassSymbol<*>.getEqualsSymbol(equalsSymbolInAny: FirNamedFunctionSymbol): FirNamedFunctionSymbol {
|
||||
val scope = unsubstitutedScope(
|
||||
analysisSession.rootModuleSession,
|
||||
analysisSession.getScopeSessionFor(analysisSession.rootModuleSession),
|
||||
analysisSession.useSiteSession,
|
||||
analysisSession.getScopeSessionFor(analysisSession.useSiteSession),
|
||||
false
|
||||
)
|
||||
var equalsSymbol: FirNamedFunctionSymbol? = null
|
||||
|
||||
+1
-1
@@ -62,7 +62,7 @@ internal class KtFirCompletionCandidateChecker(
|
||||
): KtExtensionApplicabilityResult {
|
||||
val file = originalFile.getOrBuildFirFile(firResolveState)
|
||||
val explicitReceiverExpression = possibleExplicitReceiver?.getMatchingFirExpressionForCallReceiver()
|
||||
val resolver = SingleCandidateResolver(firResolveState.rootModuleSession, file)
|
||||
val resolver = SingleCandidateResolver(firResolveState.useSiteFirSession, file)
|
||||
val implicitReceivers = getImplicitReceivers(originalFile, nameExpression)
|
||||
for (implicitReceiverValue in implicitReceivers) {
|
||||
val resolutionParameters = ResolutionParameters(
|
||||
|
||||
+1
-1
@@ -31,6 +31,6 @@ internal class KtFirExpressionInfoProvider(
|
||||
|
||||
override fun getWhenMissingCases(whenExpression: KtWhenExpression): List<WhenMissingCase> {
|
||||
val firWhenExpression = whenExpression.getOrBuildFirSafe<FirWhenExpression>(analysisSession.firResolveState) ?: return emptyList()
|
||||
return FirWhenExhaustivenessTransformer.computeAllMissingCases(analysisSession.firResolveState.rootModuleSession, firWhenExpression)
|
||||
return FirWhenExhaustivenessTransformer.computeAllMissingCases(analysisSession.firResolveState.useSiteFirSession, firWhenExpression)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -225,7 +225,7 @@ internal class KtFirExpressionTypeProvider(
|
||||
getDefiniteNullability(expression) == DefiniteNullability.DEFINITELY_NOT_NULL
|
||||
|
||||
private fun getDefiniteNullability(expression: KtExpression): DefiniteNullability = withValidityAssertion {
|
||||
fun FirExpression.isNotNullable() = with(analysisSession.rootModuleSession.typeContext) {
|
||||
fun FirExpression.isNotNullable() = with(analysisSession.useSiteSession.typeContext) {
|
||||
!typeRef.coneType.isNullableType()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ internal class KtFirImportOptimizer(
|
||||
private val firResolveState: LLFirModuleResolveState
|
||||
) : KtImportOptimizer() {
|
||||
private val firSession: FirSession
|
||||
get() = firResolveState.rootModuleSession
|
||||
get() = firResolveState.useSiteFirSession
|
||||
|
||||
override fun analyseImports(file: KtFile): KtImportOptimizerResult {
|
||||
assertIsValidAndAccessible()
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ internal class KtFirInheritorsProvider(
|
||||
require(classSymbol.modality == Modality.SEALED)
|
||||
require(classSymbol is KtFirNamedClassOrObjectSymbol)
|
||||
|
||||
val inheritorClassIds = classSymbol.firSymbol.fir.getSealedClassInheritors(analysisSession.rootModuleSession)
|
||||
val inheritorClassIds = classSymbol.firSymbol.fir.getSealedClassInheritors(analysisSession.useSiteSession)
|
||||
|
||||
with(analysisSession) {
|
||||
inheritorClassIds.mapNotNull { it.getCorrespondingToplevelClassOrObjectSymbol() as? KtNamedClassOrObjectSymbol }
|
||||
|
||||
+1
-1
@@ -19,6 +19,6 @@ internal class KtFirJvmTypeMapper(
|
||||
) : KtJvmTypeMapper(), KtFirAnalysisSessionComponent {
|
||||
|
||||
override fun mapTypeToJvmType(type: KtType, mode: TypeMappingMode): Type {
|
||||
return analysisSession.rootModuleSession.jvmTypeMapper.mapType(type.coneType, mode)
|
||||
return analysisSession.useSiteSession.jvmTypeMapper.mapType(type.coneType, mode)
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -167,7 +167,7 @@ private class FirShorteningContext(val analysisSession: KtFirAnalysisSession) {
|
||||
private val firResolveState = analysisSession.firResolveState
|
||||
|
||||
private val firSession: FirSession
|
||||
get() = firResolveState.rootModuleSession
|
||||
get() = firResolveState.useSiteFirSession
|
||||
|
||||
fun findFirstClassifierInScopesByName(positionScopes: List<FirScope>, targetClassName: Name): AvailableSymbol<ClassId>? {
|
||||
for (scope in positionScopes) {
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ internal class KtFirSamResolver(
|
||||
override fun getSamConstructor(ktClassLikeSymbol: KtClassLikeSymbol): KtSamConstructorSymbol? {
|
||||
val classId = ktClassLikeSymbol.classIdIfNonLocal ?: return null
|
||||
val owner = analysisSession.getClassLikeSymbol(classId) as? FirRegularClass ?: return null
|
||||
val resolver = LocalSamResolver(analysisSession, analysisSession.rootModuleSession)
|
||||
val resolver = LocalSamResolver(analysisSession, analysisSession.useSiteSession)
|
||||
return resolver.getSamConstructor(owner)?.let {
|
||||
analysisSession.firSymbolBuilder.functionLikeBuilder.buildSamConstructorSymbol(it.symbol)
|
||||
}
|
||||
|
||||
+6
-6
@@ -53,7 +53,7 @@ internal class KtFirScopeProvider(
|
||||
override val token: ValidityToken,
|
||||
) : KtScopeProvider(), ValidityTokenOwner {
|
||||
// KtFirScopeProvider is thread local, so it's okay to use the same session here
|
||||
private val scopeSession = analysisSession.getScopeSessionFor(analysisSession.rootModuleSession)
|
||||
private val scopeSession = analysisSession.getScopeSessionFor(analysisSession.useSiteSession)
|
||||
|
||||
|
||||
override val analysisSession: KtFirAnalysisSession by weakRef(analysisSession)
|
||||
@@ -89,7 +89,7 @@ internal class KtFirScopeProvider(
|
||||
override fun getMemberScope(classSymbol: KtSymbolWithMembers): KtScope = withValidityAssertion {
|
||||
memberScopeCache.getOrPut(classSymbol) {
|
||||
val firScope = classSymbol.withFirForScope { fir ->
|
||||
val firSession = analysisSession.rootModuleSession
|
||||
val firSession = analysisSession.useSiteSession
|
||||
fir.unsubstitutedScope(
|
||||
firSession,
|
||||
scopeSession,
|
||||
@@ -103,7 +103,7 @@ internal class KtFirScopeProvider(
|
||||
|
||||
override fun getStaticMemberScope(symbol: KtSymbolWithMembers): KtScope {
|
||||
val firScope = symbol.withFirForScope { fir ->
|
||||
val firSession = analysisSession.rootModuleSession
|
||||
val firSession = analysisSession.useSiteSession
|
||||
fir.scopeProvider.getStaticScope(
|
||||
fir,
|
||||
firSession,
|
||||
@@ -116,7 +116,7 @@ internal class KtFirScopeProvider(
|
||||
override fun getDeclaredMemberScope(classSymbol: KtSymbolWithMembers): KtScope = withValidityAssertion {
|
||||
declaredMemberScopeCache.getOrPut(classSymbol) {
|
||||
val firScope = classSymbol.withFirForScope {
|
||||
analysisSession.rootModuleSession.declaredMemberScope(it)
|
||||
analysisSession.useSiteSession.declaredMemberScope(it)
|
||||
} ?: return@getOrPut getEmptyScope()
|
||||
|
||||
KtFirDelegatingScope(firScope, builder, token)
|
||||
@@ -130,7 +130,7 @@ internal class KtFirScopeProvider(
|
||||
val firScope = classSymbol.withFirForScope { fir ->
|
||||
val delegateFields = fir.delegateFields
|
||||
if (delegateFields.isNotEmpty()) {
|
||||
val firSession = analysisSession.rootModuleSession
|
||||
val firSession = analysisSession.useSiteSession
|
||||
FirDelegatedMemberScope(
|
||||
firSession,
|
||||
scopeSession,
|
||||
@@ -176,7 +176,7 @@ internal class KtFirScopeProvider(
|
||||
|
||||
override fun getTypeScope(type: KtType): KtScope? {
|
||||
check(type is KtFirType) { "KtFirScopeProvider can only work with KtFirType, but ${type::class} was provided" }
|
||||
val firSession = firResolveState.rootModuleSession
|
||||
val firSession = firResolveState.useSiteFirSession
|
||||
val firTypeScope = type.coneType.scope(
|
||||
firSession,
|
||||
scopeSession,
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ internal class KtFirSymbolDeclarationRendererProvider(
|
||||
|
||||
override fun render(type: KtType, options: KtTypeRendererOptions): String {
|
||||
require(type is KtFirType)
|
||||
return ConeTypeIdeRenderer(analysisSession.firResolveState.rootModuleSession, options).renderType(type.coneType)
|
||||
return ConeTypeIdeRenderer(analysisSession.firResolveState.useSiteFirSession, options).renderType(type.coneType)
|
||||
}
|
||||
|
||||
override fun renderDeclaration(symbol: KtDeclarationSymbol, options: KtDeclarationRendererOptions): String {
|
||||
|
||||
+3
-3
@@ -25,7 +25,7 @@ internal class KtFirTypeInfoProvider(
|
||||
|
||||
override fun isFunctionalInterfaceType(type: KtType): Boolean {
|
||||
val coneType = (type as KtFirType).coneType
|
||||
val firSession = analysisSession.rootModuleSession
|
||||
val firSession = analysisSession.useSiteSession
|
||||
val samResolver = FirSamResolverImpl(
|
||||
firSession,
|
||||
analysisSession.getScopeSessionFor(firSession),
|
||||
@@ -35,14 +35,14 @@ internal class KtFirTypeInfoProvider(
|
||||
|
||||
override fun getFunctionClassKind(type: KtType): FunctionClassKind? {
|
||||
val coneType = (type as KtFirType).coneType
|
||||
return coneType.functionClassKind(analysisSession.rootModuleSession)
|
||||
return coneType.functionClassKind(analysisSession.useSiteSession)
|
||||
}
|
||||
|
||||
override fun canBeNull(type: KtType): Boolean = (type as KtFirType).coneType.canBeNull
|
||||
|
||||
override fun isDenotable(type: KtType): Boolean {
|
||||
val coneType = (type as KtFirType).coneType
|
||||
return analysisSession.rootModuleSession.typeApproximator.approximateToSuperType(
|
||||
return analysisSession.useSiteSession.typeApproximator.approximateToSuperType(
|
||||
coneType,
|
||||
PublicTypeApproximator.PublicApproximatorConfiguration(false)
|
||||
) == null
|
||||
|
||||
+4
-4
@@ -80,7 +80,7 @@ internal class KtFirTypeProvider(
|
||||
}
|
||||
|
||||
override fun commonSuperType(types: Collection<KtType>): KtType? {
|
||||
return analysisSession.rootModuleSession.typeContext
|
||||
return analysisSession.useSiteSession.typeContext
|
||||
.commonSuperTypeOrNull(types.map { it.coneType })
|
||||
?.asKtType()
|
||||
}
|
||||
@@ -115,7 +115,7 @@ internal class KtFirTypeProvider(
|
||||
}
|
||||
|
||||
override fun haveCommonSubtype(a: KtType, b: KtType): Boolean {
|
||||
return analysisSession.rootModuleSession.typeContext.isCompatible(
|
||||
return analysisSession.useSiteSession.typeContext.isCompatible(
|
||||
a.coneType,
|
||||
b.coneType
|
||||
) == ConeTypeCompatibilityChecker.Compatibility.COMPATIBLE
|
||||
@@ -136,7 +136,7 @@ internal class KtFirTypeProvider(
|
||||
// We also need to collect those on `upperBound` due to nullability.
|
||||
is ConeFlexibleType -> lowerBound.getDirectSuperTypes(shouldApproximate) + upperBound.getDirectSuperTypes(shouldApproximate)
|
||||
is ConeDefinitelyNotNullType -> original.getDirectSuperTypes(shouldApproximate).map {
|
||||
ConeDefinitelyNotNullType.create(it, analysisSession.rootModuleSession.typeContext) ?: it
|
||||
ConeDefinitelyNotNullType.create(it, analysisSession.useSiteSession.typeContext) ?: it
|
||||
}
|
||||
is ConeIntersectionType -> intersectedTypes.asSequence().flatMap { it.getDirectSuperTypes(shouldApproximate) }
|
||||
is ConeErrorType -> emptySequence()
|
||||
@@ -146,7 +146,7 @@ internal class KtFirTypeProvider(
|
||||
}
|
||||
|
||||
private fun ConeLookupTagBasedType.getSubstitutedSuperTypes(shouldApproximate: Boolean): Sequence<ConeKotlinType> {
|
||||
val session = analysisSession.firResolveState.rootModuleSession
|
||||
val session = analysisSession.firResolveState.useSiteFirSession
|
||||
val symbol = lookupTag.toSymbol(session)
|
||||
val superTypes = when (symbol) {
|
||||
is FirAnonymousObjectSymbol -> symbol.superConeTypes
|
||||
|
||||
+1
-1
@@ -189,7 +189,7 @@ internal object FirReferenceResolveHelper {
|
||||
val symbolBuilder = analysisSession.firSymbolBuilder
|
||||
val adjustedResolutionExpression = adjustResolutionExpression(expression)
|
||||
val fir = adjustedResolutionExpression.getOrBuildFir(analysisSession.firResolveState)
|
||||
val session = analysisSession.firResolveState.rootModuleSession
|
||||
val session = analysisSession.firResolveState.useSiteFirSession
|
||||
return when (fir) {
|
||||
is FirResolvedTypeRef -> getSymbolsForResolvedTypeRef(fir, expression, session, symbolBuilder)
|
||||
is FirResolvedQualifier ->
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ internal class KtFirAnonymousObjectSymbol(
|
||||
) : KtAnonymousObjectSymbol(), KtFirSymbol<FirAnonymousObjectSymbol> {
|
||||
override val psi: PsiElement? by cached { firSymbol.findPsi() }
|
||||
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.rootModuleSession, token) }
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.useSiteFirSession, token) }
|
||||
|
||||
override val superTypes: List<KtType> by cached { firSymbol.superTypesList(builder) }
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ import org.jetbrains.kotlin.name.StandardClassIds
|
||||
|
||||
object KtFirArrayOfSymbolProvider {
|
||||
internal fun KtFirAnalysisSession.arrayOfSymbol(identifier: Name): KtFirFunctionSymbol? {
|
||||
val firSymbol = firResolveState.rootModuleSession.symbolProvider.getTopLevelCallableSymbols(kotlinPackage, identifier).firstOrNull {
|
||||
val firSymbol = firResolveState.useSiteFirSession.symbolProvider.getTopLevelCallableSymbols(kotlinPackage, identifier).firstOrNull {
|
||||
/* choose (for byte array)
|
||||
* public fun byteArrayOf(vararg elements: kotlin.Byte): kotlin.ByteArray
|
||||
*/
|
||||
|
||||
+1
-1
@@ -48,7 +48,7 @@ internal class KtFirConstructorSymbol(
|
||||
|
||||
override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility }
|
||||
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.rootModuleSession, token) }
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.useSiteFirSession, token) }
|
||||
|
||||
override val containingClassIdIfNonLocal: ClassId?
|
||||
get() = withValidityAssertion { firSymbol.containingClass()?.classId?.takeUnless { it.isLocal } }
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ internal class KtFirFileSymbol(
|
||||
TODO("Creating pointers for files from library is not supported yet")
|
||||
}
|
||||
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.rootModuleSession, token) }
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.useSiteFirSession, token) }
|
||||
|
||||
override fun equals(other: Any?): Boolean = symbolEquals(other)
|
||||
override fun hashCode(): Int = symbolHashCode()
|
||||
|
||||
+1
-1
@@ -57,7 +57,7 @@ internal class KtFirFunctionSymbol(
|
||||
override val hasStableParameterNames: Boolean
|
||||
get() = withValidityAssertion { firSymbol.fir.getHasStableParameterNames(firSymbol.moduleData.session) }
|
||||
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.rootModuleSession, token) }
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.useSiteFirSession, token) }
|
||||
|
||||
override val isSuspend: Boolean get() = withValidityAssertion { firSymbol.isSuspend }
|
||||
override val isOverride: Boolean get() = withValidityAssertion { firSymbol.isOverride }
|
||||
|
||||
+1
-1
@@ -78,7 +78,7 @@ internal class KtFirKotlinPropertySymbol(
|
||||
override val modality: Modality get() = withValidityAssertion { firSymbol.modalityOrFinal }
|
||||
override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility }
|
||||
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.rootModuleSession, token) }
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.useSiteFirSession, token) }
|
||||
|
||||
override val callableIdIfNonLocal: CallableId? get() = withValidityAssertion { firSymbol.getCallableIdIfNonLocal() }
|
||||
|
||||
|
||||
+1
-1
@@ -65,7 +65,7 @@ internal class KtFirNamedClassOrObjectSymbol(
|
||||
else -> possiblyRawVisibility
|
||||
}
|
||||
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.rootModuleSession, token) }
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.useSiteFirSession, token) }
|
||||
|
||||
override val isInner: Boolean get() = withValidityAssertion { firSymbol.isInner }
|
||||
override val isData: Boolean get() = withValidityAssertion { firSymbol.isData }
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ internal class KtFirOverrideInfoProvider(
|
||||
return memberFir.symbol.getImplementationStatus(
|
||||
SessionHolderImpl(
|
||||
rootModuleSession,
|
||||
analysisSession.getScopeSessionFor(analysisSession.rootModuleSession),
|
||||
analysisSession.getScopeSessionFor(analysisSession.useSiteSession),
|
||||
),
|
||||
parentClassFir.symbol
|
||||
)
|
||||
|
||||
+1
-1
@@ -54,7 +54,7 @@ internal class KtFirPropertyGetterSymbol(
|
||||
override val returnType: KtType get() = withValidityAssertion { firSymbol.returnType(builder) }
|
||||
override val receiverType: KtType? get() = withValidityAssertion { firSymbol.receiverType(builder) }
|
||||
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.rootModuleSession, token) }
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.useSiteFirSession, token) }
|
||||
|
||||
/**
|
||||
* Returns [CallableId] of the delegated Java method if the corresponding property of this setter is a synthetic Java property.
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ internal class KtFirPropertySetterSymbol(
|
||||
override val modality: Modality get() = withValidityAssertion { firSymbol.modalityOrFinal }
|
||||
override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility }
|
||||
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.rootModuleSession, token) }
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.useSiteFirSession, token) }
|
||||
|
||||
/**
|
||||
* Returns [CallableId] of the delegated Java method if the corresponding property of this setter is a synthetic Java property.
|
||||
|
||||
+1
-1
@@ -56,7 +56,7 @@ internal class KtFirSyntheticJavaPropertySymbol(
|
||||
override val modality: Modality get() = withValidityAssertion { firSymbol.modality ?: firSymbol.invalidModalityError() }
|
||||
override val visibility: Visibility get() = withValidityAssertion { firSymbol.visibility }
|
||||
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.rootModuleSession, token) }
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.useSiteFirSession, token) }
|
||||
|
||||
override val callableIdIfNonLocal: CallableId? get() = withValidityAssertion { firSymbol.getCallableIdIfNonLocal() }
|
||||
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ internal class KtFirTypeAliasSymbol(
|
||||
override val expandedType: KtType by cached { builder.typeBuilder.buildKtType(firSymbol.resolvedExpandedTypeRef) }
|
||||
|
||||
override val annotationsList: KtAnnotationsList by cached {
|
||||
KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.rootModuleSession, token)
|
||||
KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.useSiteFirSession, token)
|
||||
}
|
||||
|
||||
override fun createPointer(): KtSymbolPointer<KtTypeAliasSymbol> {
|
||||
|
||||
+1
-1
@@ -53,7 +53,7 @@ internal class KtFirValueParameterSymbol(
|
||||
|
||||
override val hasDefaultValue: Boolean get() = withValidityAssertion { firSymbol.hasDefaultValue }
|
||||
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.rootModuleSession, token) }
|
||||
override val annotationsList by cached { KtFirAnnotationListForDeclaration.create(firSymbol, resolveState.useSiteFirSession, token) }
|
||||
|
||||
override fun createPointer(): KtSymbolPointer<KtValueParameterSymbol> {
|
||||
KtPsiBasedSymbolPointer.createForSymbolFromSource(this)?.let { return it }
|
||||
|
||||
+1
-1
@@ -24,7 +24,7 @@ internal abstract class KtFirMemberSymbolPointer<S : KtSymbol>(
|
||||
require(analysisSession is KtFirAnalysisSession)
|
||||
val owner = analysisSession.getClassLikeSymbol(ownerClassId) as? FirRegularClass
|
||||
?: return null
|
||||
val firSession = analysisSession.rootModuleSession
|
||||
val firSession = analysisSession.useSiteSession
|
||||
val scope = owner.unsubstitutedScope(
|
||||
firSession,
|
||||
analysisSession.getScopeSessionFor(firSession),
|
||||
|
||||
+1
-1
@@ -33,5 +33,5 @@ internal abstract class KtTopLevelCallableSymbolPointer<S : KtCallableSymbol>(
|
||||
}
|
||||
|
||||
private fun KtFirAnalysisSession.getCallableSymbols(callableId: CallableId) =
|
||||
firResolveState.rootModuleSession.symbolProvider.getTopLevelCallableSymbols(callableId.packageName, callableId.callableName)
|
||||
firResolveState.useSiteFirSession.symbolProvider.getTopLevelCallableSymbols(callableId.packageName, callableId.callableName)
|
||||
|
||||
|
||||
+1
-1
@@ -58,4 +58,4 @@ internal fun FirDeclaration.createSignature(): IdSignature {
|
||||
}
|
||||
|
||||
internal fun KtFirAnalysisSession.getClassLikeSymbol(classId: ClassId) =
|
||||
firResolveState.rootModuleSession.symbolProvider.getClassLikeSymbolByClassId(classId)?.fir
|
||||
firResolveState.useSiteFirSession.symbolProvider.getClassLikeSymbolByClassId(classId)?.fir
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ fun FirBasedSymbol<*>.getContainingKtModule(resolveState: LLFirModuleResolveStat
|
||||
val target = when (this) {
|
||||
is FirCallableSymbol -> {
|
||||
// callable fake overrides have use-site FirModuleData
|
||||
dispatchReceiverClassOrNull()?.toFirRegularClassSymbol(resolveState.rootModuleSession) ?: this
|
||||
dispatchReceiverClassOrNull()?.toFirRegularClassSymbol(resolveState.useSiteFirSession) ?: this
|
||||
}
|
||||
else -> this
|
||||
}
|
||||
|
||||
+2
-5
@@ -12,13 +12,10 @@ import org.jetbrains.kotlin.analysis.low.level.api.fir.api.DiagnosticCheckerFilt
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.LLFirModuleResolveState
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.FirElementBuilder
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.FirTowerContextProvider
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.file.builder.ModuleFileCache
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.file.structure.KtToFirMapping
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.state.LLFirResolvableModuleResolveState
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.state.TowerProviderForElementForState
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.LLFirScopeSessionProvider
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.containingKtFileIfAny
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.util.originalKtFile
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtModule
|
||||
import org.jetbrains.kotlin.analysis.utils.caches.*
|
||||
import org.jetbrains.kotlin.diagnostics.KtPsiDiagnostic
|
||||
@@ -40,8 +37,8 @@ internal class FirModuleResolveStateDepended(
|
||||
private val ktToFirMapping: KtToFirMapping?,
|
||||
) : LLFirModuleResolveState() {
|
||||
override val project: Project get() = originalState.project
|
||||
override val module: KtModule get() = originalState.module
|
||||
override val rootModuleSession get() = originalState.rootModuleSession
|
||||
override val useSiteKtModule: KtModule get() = originalState.useSiteKtModule
|
||||
override val useSiteFirSession get() = originalState.useSiteFirSession
|
||||
|
||||
private val scopeSessionProviderCache by softCachedValue(
|
||||
project,
|
||||
|
||||
+8
-10
@@ -10,9 +10,7 @@ import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.roots.ProjectRootModificationTracker
|
||||
import org.jetbrains.annotations.TestOnly
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.LLFirModuleResolveState
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.lazy.resolve.FirLazyDeclarationResolver
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.*
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirLibraryOrLibrarySourceResolvableModuleSession
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirSessionProviderStorage
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.state.LLFirSourceModuleResolveState
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.state.LLFirLibraryOrLibrarySourceResolvableModuleResolveState
|
||||
@@ -43,18 +41,18 @@ internal class LLFirResolveStateService(project: Project) {
|
||||
ServiceManager.getService(project, LLFirResolveStateService::class.java)
|
||||
|
||||
internal fun createResolveStateFor(
|
||||
module: KtModule,
|
||||
useSiteKtModule: KtModule,
|
||||
sessionProviderStorage: LLFirSessionProviderStorage,
|
||||
configureSession: (LLFirSession.() -> Unit)? = null,
|
||||
): LLFirResolvableModuleResolveState {
|
||||
val sessionProvider = sessionProviderStorage.getSessionProvider(module, configureSession)
|
||||
val sessionProvider = sessionProviderStorage.getSessionProvider(useSiteKtModule, configureSession)
|
||||
val useSiteSession = sessionProvider.rootModuleSession
|
||||
return when (module) {
|
||||
return when (useSiteKtModule) {
|
||||
is KtSourceModule -> {
|
||||
LLFirSourceModuleResolveState(
|
||||
useSiteSession.moduleComponents.globalResolveComponents,
|
||||
sessionProviderStorage.project,
|
||||
module,
|
||||
useSiteKtModule,
|
||||
sessionProvider,
|
||||
)
|
||||
}
|
||||
@@ -62,12 +60,12 @@ internal class LLFirResolveStateService(project: Project) {
|
||||
LLFirLibraryOrLibrarySourceResolvableModuleResolveState(
|
||||
useSiteSession.moduleComponents.globalResolveComponents,
|
||||
sessionProviderStorage.project,
|
||||
module,
|
||||
useSiteKtModule,
|
||||
sessionProvider,
|
||||
)
|
||||
}
|
||||
else -> {
|
||||
error("Unexpected $module")
|
||||
error("Unexpected $useSiteKtModule")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -77,12 +75,12 @@ internal class LLFirResolveStateService(project: Project) {
|
||||
|
||||
@TestOnly
|
||||
fun createResolveStateForNoCaching(
|
||||
module: KtModule,
|
||||
useSiteKtModule: KtModule,
|
||||
project: Project,
|
||||
configureSession: (LLFirSession.() -> Unit)? = null,
|
||||
): LLFirModuleResolveState =
|
||||
LLFirResolveStateService.createResolveStateFor(
|
||||
module = module,
|
||||
useSiteKtModule = useSiteKtModule,
|
||||
sessionProviderStorage = LLFirSessionProviderStorage(project),
|
||||
configureSession = configureSession
|
||||
)
|
||||
|
||||
+2
-9
@@ -6,14 +6,8 @@
|
||||
package org.jetbrains.kotlin.analysis.low.level.api.fir.api
|
||||
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirGlobalResolveComponents
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.element.builder.FirTowerContextProvider
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.file.builder.ModuleFileCache
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirResolvableModuleSession
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtLibraryModule
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtModule
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtSourceModule
|
||||
import org.jetbrains.kotlin.analysis.project.structure.getKtModule
|
||||
import org.jetbrains.kotlin.diagnostics.KtPsiDiagnostic
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
@@ -25,14 +19,13 @@ import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
||||
import org.jetbrains.kotlin.psi.KtDeclaration
|
||||
import org.jetbrains.kotlin.psi.KtElement
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtLambdaExpression
|
||||
|
||||
abstract class LLFirModuleResolveState {
|
||||
abstract val project: Project
|
||||
|
||||
abstract val rootModuleSession: FirSession
|
||||
abstract val useSiteFirSession: FirSession
|
||||
|
||||
abstract val module: KtModule
|
||||
abstract val useSiteKtModule: KtModule
|
||||
|
||||
internal abstract fun getSessionFor(module: KtModule): FirSession
|
||||
|
||||
|
||||
+1
-1
@@ -304,7 +304,7 @@ object LowLevelFirApiFacadeForResolveOnAir {
|
||||
val context = state.getTowerContextProvider(place.containingKtFile).getClosestAvailableParentContext(place)
|
||||
?: error("TowerContext not found for ${place.getElementTextInContext()}")
|
||||
|
||||
val session = state.rootModuleSession
|
||||
val session = state.useSiteFirSession
|
||||
val firTypeReference = buildFirUserTypeRef(
|
||||
typeReference = typeReference,
|
||||
session = session,
|
||||
|
||||
+2
-4
@@ -8,8 +8,6 @@ package org.jetbrains.kotlin.analysis.low.level.api.fir.state
|
||||
import com.intellij.openapi.project.Project
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.LLFirGlobalResolveComponents
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.api.DiagnosticCheckerFilter
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.file.builder.LLFirFileBuilder
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.lazy.resolve.FirLazyDeclarationResolver
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirSessionProvider
|
||||
import org.jetbrains.kotlin.analysis.low.level.api.fir.sessions.LLFirLibraryOrLibrarySourceResolvableModuleSession
|
||||
import org.jetbrains.kotlin.analysis.project.structure.KtModule
|
||||
@@ -21,7 +19,7 @@ import org.jetbrains.kotlin.psi.KtFile
|
||||
internal class LLFirLibraryOrLibrarySourceResolvableModuleResolveState(
|
||||
override val globalComponents: LLFirGlobalResolveComponents,
|
||||
override val project: Project,
|
||||
override val module: KtModule,
|
||||
override val useSiteKtModule: KtModule,
|
||||
sessionProvider: LLFirSessionProvider,
|
||||
) : LLFirResolvableModuleResolveState(sessionProvider) {
|
||||
override fun getDiagnostics(element: KtElement, filter: DiagnosticCheckerFilter): List<KtPsiDiagnostic> =
|
||||
@@ -33,7 +31,7 @@ internal class LLFirLibraryOrLibrarySourceResolvableModuleResolveState(
|
||||
override fun getModuleKind(module: KtModule): ModuleKind {
|
||||
LLFirLibraryOrLibrarySourceResolvableModuleSession.checkIsValidKtModule(module)
|
||||
return when {
|
||||
module == this.module -> ModuleKind.RESOLVABLE_MODULE
|
||||
module == this.useSiteKtModule -> ModuleKind.RESOLVABLE_MODULE
|
||||
else -> ModuleKind.BINARY_MODULE
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ internal abstract class LLFirResolvableModuleResolveState(
|
||||
) : LLFirModuleResolveState() {
|
||||
abstract val globalComponents: LLFirGlobalResolveComponents
|
||||
|
||||
final override val rootModuleSession = sessionProvider.rootModuleSession
|
||||
final override val useSiteFirSession = sessionProvider.rootModuleSession
|
||||
|
||||
override fun getSessionFor(module: KtModule): FirSession =
|
||||
sessionProvider.getSession(module)
|
||||
@@ -80,7 +80,7 @@ internal abstract class LLFirResolvableModuleResolveState(
|
||||
"This method will only work on compiled declarations, but this declaration is not compiled: ${ktDeclaration.getElementTextInContext()}"
|
||||
}
|
||||
|
||||
val searcher = FirDeclarationForCompiledElementSearcher(rootModuleSession.symbolProvider)
|
||||
val searcher = FirDeclarationForCompiledElementSearcher(useSiteFirSession.symbolProvider)
|
||||
val firDeclaration = searcher.findNonLocalDeclaration(ktDeclaration)
|
||||
return firDeclaration.symbol
|
||||
}
|
||||
|
||||
+1
-1
@@ -23,7 +23,7 @@ import org.jetbrains.kotlin.psi.KtFile
|
||||
internal class LLFirSourceModuleResolveState(
|
||||
override val globalComponents: LLFirGlobalResolveComponents,
|
||||
override val project: Project,
|
||||
override val module: KtModule,
|
||||
override val useSiteKtModule: KtModule,
|
||||
sessionProvider: LLFirSessionProvider,
|
||||
) : LLFirResolvableModuleResolveState(sessionProvider) {
|
||||
override fun getDiagnostics(element: KtElement, filter: DiagnosticCheckerFilter): List<KtPsiDiagnostic> {
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ abstract class AbstractFirLazyBodiesCalculatorTest : AbstractLowLevelApiSingleFi
|
||||
|
||||
override fun doTestByFileStructure(ktFile: KtFile, moduleStructure: TestModuleStructure, testServices: TestServices) {
|
||||
resolveWithClearCaches(ktFile) { resolveState ->
|
||||
val session = resolveState.rootModuleSession
|
||||
val session = resolveState.useSiteFirSession
|
||||
val provider = session.kotlinScopeProvider
|
||||
|
||||
val laziedFirFile = RawFirBuilder(
|
||||
|
||||
+1
-1
@@ -81,7 +81,7 @@ abstract class AbstractCompilerBasedTestForFir : AbstractCompilerBasedTest() {
|
||||
} else DiagnosticCheckerFilter.ONLY_COMMON_CHECKERS
|
||||
|
||||
val analyzerFacade = LowLevelFirAnalyzerFacade(resolveState, allFirFiles.toMap(), diagnosticCheckerFilter)
|
||||
return LowLevelFirOutputArtifact(resolveState.rootModuleSession, analyzerFacade)
|
||||
return LowLevelFirOutputArtifact(resolveState.useSiteFirSession, analyzerFacade)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user