[FIR] Rename FirDeclaration.session to declarationSiteSession
This commit is contained in:
committed by
TeamCityServer
parent
46f5c2073d
commit
c3b1be1a39
+4
-4
@@ -115,7 +115,7 @@ internal class FirModuleResolveStateImpl(
|
||||
sessionProvider.getModuleCache(ktDeclaration.getModuleInfo() as ModuleSourceInfo)
|
||||
)
|
||||
if (container.resolvePhase < FirResolvePhase.BODY_RESOLVE) {
|
||||
val cache = (container.session as FirIdeSourcesSession).cache
|
||||
val cache = (container.declarationSiteSession as FirIdeSourcesSession).cache
|
||||
firLazyDeclarationResolver.lazyResolveDeclaration(
|
||||
container,
|
||||
cache,
|
||||
@@ -142,7 +142,7 @@ internal class FirModuleResolveStateImpl(
|
||||
}
|
||||
|
||||
override fun <D : FirDeclaration> resolvedFirToPhase(declaration: D, toPhase: FirResolvePhase): D {
|
||||
val fileCache = when (val session = declaration.session) {
|
||||
val fileCache = when (val session = declaration.declarationSiteSession) {
|
||||
is FirIdeSourcesSession -> session.cache
|
||||
else -> return declaration
|
||||
}
|
||||
@@ -165,7 +165,7 @@ internal class FirModuleResolveStateImpl(
|
||||
firDeclaration,
|
||||
rootModuleSession.cache,
|
||||
containerFirFile,
|
||||
containerFirFile.session.firIdeProvider,
|
||||
containerFirFile.declarationSiteSession.firIdeProvider,
|
||||
fromPhase = firDeclaration.resolvePhase,
|
||||
toPhase = FirResolvePhase.BODY_RESOLVE,
|
||||
towerDataContextCollector = collector,
|
||||
@@ -180,4 +180,4 @@ internal class FirModuleResolveStateImpl(
|
||||
override fun getTowerDataContextForElement(element: KtElement): FirTowerDataContext? {
|
||||
return collector.getClosestAvailableParentContext(element)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -63,7 +63,7 @@ internal class FirPhaseRunner {
|
||||
}
|
||||
|
||||
private fun runPhaseWithoutLock(firFile: FirFile, phase: FirResolvePhase, scopeSession: ScopeSession) {
|
||||
val phaseProcessor = phase.createTransformerBasedProcessorByPhase(firFile.session, scopeSession)
|
||||
val phaseProcessor = phase.createTransformerBasedProcessorByPhase(firFile.declarationSiteSession, scopeSession)
|
||||
executeWithoutPCE {
|
||||
FirLazyBodiesCalculator.calculateLazyBodiesIfPhaseRequires(firFile, phase)
|
||||
phaseProcessor.processFile(firFile)
|
||||
@@ -91,4 +91,4 @@ internal fun FirResolvePhase.createTransformerBasedProcessorByPhase(
|
||||
FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE -> FirImplicitTypeBodyResolveProcessor(session, scopeSession)
|
||||
FirResolvePhase.BODY_RESOLVE -> FirBodyResolveProcessor(session, scopeSession)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -28,7 +28,7 @@ internal class IdeFirPhaseManager(
|
||||
try {
|
||||
lazyDeclarationResolver.lazyResolveDeclaration(fir, cache, requiredPhase, checkPCE = true)
|
||||
} catch (e: Throwable) {
|
||||
sessionInvalidator.invalidate(fir.session)
|
||||
sessionInvalidator.invalidate(fir.declarationSiteSession)
|
||||
throw e
|
||||
}
|
||||
}
|
||||
|
||||
+5
-5
@@ -28,10 +28,10 @@ class FirDeclarationDesignation(
|
||||
|
||||
object DeclarationDesignationCollector {
|
||||
fun collectDesignation(declaration: FirDeclaration): FirDeclarationDesignation {
|
||||
val firProvider = declaration.session.firProvider
|
||||
val firProvider = declaration.declarationSiteSession.firProvider
|
||||
|
||||
val containingClass = when (declaration) {
|
||||
is FirCallableDeclaration<*> -> declaration.containingClass()?.toFirRegularClass(declaration.session)
|
||||
is FirCallableDeclaration<*> -> declaration.containingClass()?.toFirRegularClass(declaration.declarationSiteSession)
|
||||
is FirClassLikeDeclaration<*> -> declaration.symbol.classId.outerClassId?.let(firProvider::getFirClassifierByFqName)
|
||||
else -> error("Invalid declaration ${declaration.renderWithType()}")
|
||||
} ?: return FirDeclarationDesignation(emptyList(), declaration, isLocalDesignation = false)
|
||||
@@ -54,7 +54,7 @@ object DeclarationDesignationCollector {
|
||||
|
||||
private fun FirRegularClass.collectForNonLocal(): List<FirClassLikeDeclaration<*>> {
|
||||
require(!isLocal)
|
||||
val firProvider = session.firProvider
|
||||
val firProvider = declarationSiteSession.firProvider
|
||||
var containingClassId = classId.outerClassId
|
||||
val designation = mutableListOf<FirClassLikeDeclaration<*>>(this)
|
||||
while (containingClassId != null) {
|
||||
@@ -70,7 +70,7 @@ object DeclarationDesignationCollector {
|
||||
var containingClassLookUp = containingClassForLocal()
|
||||
val designation = mutableListOf<FirClassLikeDeclaration<*>>(this)
|
||||
while (containingClassLookUp != null && containingClassLookUp.classId.isLocal) {
|
||||
val currentClass = containingClassLookUp.toFirRegularClass(session) ?: break
|
||||
val currentClass = containingClassLookUp.toFirRegularClass(declarationSiteSession) ?: break
|
||||
designation.add(currentClass)
|
||||
containingClassLookUp = currentClass.containingClassForLocal()
|
||||
}
|
||||
@@ -80,4 +80,4 @@ object DeclarationDesignationCollector {
|
||||
|
||||
|
||||
fun FirDeclaration.collectDesignation(): FirDeclarationDesignation =
|
||||
DeclarationDesignationCollector.collectDesignation(this)
|
||||
DeclarationDesignationCollector.collectDesignation(this)
|
||||
|
||||
+2
-2
@@ -43,7 +43,7 @@ abstract class FirModuleResolveState {
|
||||
|
||||
internal inline fun <D : FirDeclaration, R> withLock(declaration: D, declarationLockType: DeclarationLockType, action: (D) -> R): R {
|
||||
val originalDeclaration = (declaration as? FirCallableDeclaration<*>)?.unwrapFakeOverrides() ?: declaration
|
||||
val session = originalDeclaration.session
|
||||
val session = originalDeclaration.declarationSiteSession
|
||||
return when {
|
||||
originalDeclaration.origin == FirDeclarationOrigin.Source
|
||||
&& session is FirIdeSourcesSession
|
||||
@@ -93,4 +93,4 @@ abstract class FirModuleResolveState {
|
||||
}
|
||||
|
||||
fun FirModuleResolveState.getTowerDataContextUnsafe(element: KtElement): FirTowerDataContext =
|
||||
getTowerDataContextForElement(element) ?: error("No context for ${element.getElementTextInContext()}")
|
||||
getTowerDataContextForElement(element) ?: error("No context for ${element.getElementTextInContext()}")
|
||||
|
||||
+3
-3
@@ -31,7 +31,7 @@ internal class SingleNonLocalDeclarationDiagnosticRetriever(
|
||||
collector: FileStructureElementDiagnosticsCollector,
|
||||
lockProvider: LockProvider<FirFile>
|
||||
): FileStructureElementDiagnosticList {
|
||||
val sessionHolder = SessionHolderImpl.createWithEmptyScopeSession(firFile.session)
|
||||
val sessionHolder = SessionHolderImpl.createWithEmptyScopeSession(firFile.declarationSiteSession)
|
||||
val context = lockProvider.withReadLock(firFile) {
|
||||
PersistenceContextCollector.collectContext(sessionHolder, firFile, structureElementDeclaration)
|
||||
}
|
||||
@@ -105,7 +105,7 @@ internal object FileDiagnosticRetriever : FileStructureElementDiagnosticRetrieve
|
||||
firFile: FirFile,
|
||||
components: List<AbstractDiagnosticCollectorComponent>
|
||||
) : FirIdeDiagnosticVisitor(
|
||||
PersistentCheckerContextFactory.createEmptyPersistenceCheckerContext(SessionHolderImpl.createWithEmptyScopeSession(firFile.session)),
|
||||
PersistentCheckerContextFactory.createEmptyPersistenceCheckerContext(SessionHolderImpl.createWithEmptyScopeSession(firFile.declarationSiteSession)),
|
||||
components,
|
||||
) {
|
||||
override fun visitFile(file: FirFile, data: Nothing?) {
|
||||
@@ -118,4 +118,4 @@ internal object FileDiagnosticRetriever : FileStructureElementDiagnosticRetrieve
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -21,11 +21,11 @@ internal class FileStructureElementDiagnosticsCollector private constructor(priv
|
||||
createVisitor: (components: List<AbstractDiagnosticCollectorComponent>) -> CheckerRunningDiagnosticCollectorVisitor,
|
||||
): FileStructureElementDiagnosticList =
|
||||
FirIdeStructureElementDiagnosticsCollector(
|
||||
firDeclaration.session,
|
||||
firDeclaration.declarationSiteSession,
|
||||
createVisitor,
|
||||
useExtendedCheckers,
|
||||
).let { collector ->
|
||||
collector.collectDiagnostics(firDeclaration)
|
||||
FileStructureElementDiagnosticList(collector.result)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ internal class FileStructure(
|
||||
private val moduleFileCache: ModuleFileCache,
|
||||
private val collector: FirTowerDataContextCollector
|
||||
) {
|
||||
private val firIdeProvider = firFile.session.firIdeProvider
|
||||
private val firIdeProvider = firFile.declarationSiteSession.firIdeProvider
|
||||
|
||||
private val structureElements = ConcurrentHashMap<KtAnnotated, FileStructureElement>()
|
||||
|
||||
|
||||
+2
-2
@@ -31,7 +31,7 @@ internal object FileStructureUtil {
|
||||
} else {
|
||||
val classLikeLookupTag = from.containingClass()
|
||||
?: error("Class name should not be null for non-top-level & non-local declarations, but was null for\n${from.render()}")
|
||||
val containingClass = classLikeLookupTag.toSymbol(firFile.session)?.fir as FirRegularClass
|
||||
val containingClass = classLikeLookupTag.toSymbol(firFile.declarationSiteSession)?.fir as FirRegularClass
|
||||
containingClass.declarations as MutableList<FirDeclaration>
|
||||
}
|
||||
declarations.replaceFirst(from, to)
|
||||
@@ -52,4 +52,4 @@ internal object FileStructureUtil {
|
||||
throw e
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+6
-6
@@ -30,8 +30,8 @@ internal object FirLazyBodiesCalculator {
|
||||
fun calculateLazyBodiesForFunction(simpleFunction: FirSimpleFunction, designation: List<FirDeclaration>) {
|
||||
if (simpleFunction.body !is FirLazyBlock) return
|
||||
val newFunction = RawFirFragmentForLazyBodiesBuilder.build(
|
||||
session = simpleFunction.session,
|
||||
baseScopeProvider = simpleFunction.session.firIdeProvider.kotlinScopeProvider,
|
||||
session = simpleFunction.declarationSiteSession,
|
||||
baseScopeProvider = simpleFunction.declarationSiteSession.firIdeProvider.kotlinScopeProvider,
|
||||
designation = designation,
|
||||
declaration = simpleFunction.psi as KtNamedFunction
|
||||
) as FirSimpleFunction
|
||||
@@ -46,8 +46,8 @@ internal object FirLazyBodiesCalculator {
|
||||
if (secondaryConstructor.body !is FirLazyBlock) return
|
||||
|
||||
val newFunction = RawFirFragmentForLazyBodiesBuilder.build(
|
||||
session = secondaryConstructor.session,
|
||||
baseScopeProvider = secondaryConstructor.session.firIdeProvider.kotlinScopeProvider,
|
||||
session = secondaryConstructor.declarationSiteSession,
|
||||
baseScopeProvider = secondaryConstructor.declarationSiteSession.firIdeProvider.kotlinScopeProvider,
|
||||
designation = designation,
|
||||
declaration = secondaryConstructor.psi as KtSecondaryConstructor
|
||||
) as FirSimpleFunction
|
||||
@@ -61,8 +61,8 @@ internal object FirLazyBodiesCalculator {
|
||||
if (!needCalculatingLazyBodyForProperty(firProperty)) return
|
||||
|
||||
val newProperty = RawFirFragmentForLazyBodiesBuilder.build(
|
||||
session = firProperty.session,
|
||||
baseScopeProvider = firProperty.session.firIdeProvider.kotlinScopeProvider,
|
||||
session = firProperty.declarationSiteSession,
|
||||
baseScopeProvider = firProperty.declarationSiteSession.firIdeProvider.kotlinScopeProvider,
|
||||
designation = designation,
|
||||
declaration = firProperty.psi as KtProperty
|
||||
) as FirProperty
|
||||
|
||||
+6
-6
@@ -34,7 +34,7 @@ internal class FirLazyDeclarationResolver(
|
||||
scopeSession: ScopeSession,
|
||||
) {
|
||||
firFileBuilder.runCustomResolveUnderLock(firFile, moduleFileCache) {
|
||||
val transformer = FirFileAnnotationsResolveTransformer(firFile.session, scopeSession)
|
||||
val transformer = FirFileAnnotationsResolveTransformer(firFile.declarationSiteSession, scopeSession)
|
||||
firFile.accept(transformer, ResolutionMode.ContextDependent)
|
||||
}
|
||||
}
|
||||
@@ -58,13 +58,13 @@ internal class FirLazyDeclarationResolver(
|
||||
else -> error("Invalid source of property accessor ${ktDeclaration::class}")
|
||||
}
|
||||
val containingProperty = ktContainingResolvableDeclaration
|
||||
.findSourceNonLocalFirDeclaration(firFileBuilder, declaration.session.symbolProvider, moduleFileCache)
|
||||
.findSourceNonLocalFirDeclaration(firFileBuilder, declaration.declarationSiteSession.symbolProvider, moduleFileCache)
|
||||
return lazyResolveDeclaration(containingProperty, moduleFileCache, toPhase, towerDataContextCollector)
|
||||
}
|
||||
|
||||
val firFile = declaration.getContainingFile()
|
||||
?: error("FirFile was not found for\n${declaration.render()}")
|
||||
val provider = firFile.session.firIdeProvider
|
||||
val provider = firFile.declarationSiteSession.firIdeProvider
|
||||
// Lazy since we want to read the resolve phase inside the lock. Otherwise, we may run the same resolve phase multiple times. See
|
||||
// KT-45121
|
||||
val fromPhase: FirResolvePhase by lazy(LazyThreadSafetyMode.NONE) {
|
||||
@@ -186,18 +186,18 @@ internal class FirLazyDeclarationResolver(
|
||||
) = when (this) {
|
||||
FirResolvePhase.CONTRACTS -> FirDesignatedContractsResolveTransformerForIDE(
|
||||
FirDesignation(designation),
|
||||
containerFirFile.session,
|
||||
containerFirFile.declarationSiteSession,
|
||||
scopeSession,
|
||||
)
|
||||
FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE -> FirDesignatedImplicitTypesTransformerForIDE(
|
||||
FirDesignation(designation),
|
||||
containerFirFile.session,
|
||||
containerFirFile.declarationSiteSession,
|
||||
scopeSession,
|
||||
towerDataContextCollector,
|
||||
)
|
||||
FirResolvePhase.BODY_RESOLVE -> FirDesignatedBodyResolveTransformerForIDE(
|
||||
FirDesignation(designation),
|
||||
containerFirFile.session,
|
||||
containerFirFile.declarationSiteSession,
|
||||
scopeSession,
|
||||
towerDataContextCollector
|
||||
)
|
||||
|
||||
+2
-2
@@ -12,11 +12,11 @@ import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.resolve.firProvider
|
||||
|
||||
fun FirDeclaration.getContainingFile(): FirFile? {
|
||||
val provider = session.firProvider
|
||||
val provider = declarationSiteSession.firProvider
|
||||
return when (this) {
|
||||
is FirFile -> this
|
||||
is FirCallableDeclaration<*> -> provider.getFirCallableContainerFile(symbol)
|
||||
is FirClassLikeDeclaration<*> -> provider.getFirClassifierContainerFile(symbol)
|
||||
else -> error("Unsupported declaration ${this::class.java}")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -27,7 +27,7 @@ abstract class AbstractFirSealedInheritorsTest : AbstractFirMultiModuleLazyResol
|
||||
val allClasses = firFile.listNestedClasses().closure { it.listNestedClasses() }
|
||||
val inheritorNames = allClasses.flatMap { firClass ->
|
||||
if (firClass.isSealed) {
|
||||
firClass.getSealedClassInheritors(firFile.session)
|
||||
firClass.getSealedClassInheritors(firFile.declarationSiteSession)
|
||||
} else {
|
||||
emptyList()
|
||||
}
|
||||
@@ -42,4 +42,4 @@ private fun FirDeclaration.listNestedClasses(): List<FirRegularClass> {
|
||||
is FirRegularClass -> declarations.filterIsInstance<FirRegularClass>()
|
||||
else -> emptyList()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ abstract class AbstractFirContextCollectionTest : KotlinLightCodeInsightFixtureT
|
||||
}
|
||||
if (declaration in elementsToCheckContext) {
|
||||
val collectedContext = PersistenceContextCollector.collectContext(
|
||||
SessionHolderImpl.createWithEmptyScopeSession(declaration.session),
|
||||
SessionHolderImpl.createWithEmptyScopeSession(declaration.declarationSiteSession),
|
||||
firFile,
|
||||
declaration
|
||||
)
|
||||
|
||||
+2
-2
@@ -49,7 +49,7 @@ internal fun KtAnnotatedSymbol.isHiddenByDeprecation(annotationUseSiteTarget: An
|
||||
annotationCall.classId?.asString() == "kotlin/Deprecated"
|
||||
} ?: return@withFir false
|
||||
|
||||
val qualifiedExpression = mapAnnotationParameters(deprecatedAnnotationCall, it.session)["level"] as? FirQualifiedAccessExpression
|
||||
val qualifiedExpression = mapAnnotationParameters(deprecatedAnnotationCall, it.declarationSiteSession)["level"] as? FirQualifiedAccessExpression
|
||||
?: return@withFir false
|
||||
|
||||
val calleeReference = (qualifiedExpression.calleeReference as? FirNamedReference)?.name?.asString()
|
||||
@@ -122,4 +122,4 @@ internal fun KtAnnotatedSymbol.computeAnnotations(
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ internal fun KtTypeAndAnnotations.asPsiType(
|
||||
val type = this.type
|
||||
require(type is KtFirType)
|
||||
require(context is KtFirSymbol<*>)
|
||||
val session = context.firRef.withFir(phase) { it.session }
|
||||
val session = context.firRef.withFir(phase) { it.declarationSiteSession }
|
||||
return type.coneType.asPsiType(session, context.firRef.resolveState, TypeMappingMode.DEFAULT, parent)
|
||||
}
|
||||
|
||||
@@ -72,7 +72,7 @@ internal fun KtNamedClassOrObjectSymbol.typeForClassSymbol(psiElement: PsiElemen
|
||||
}
|
||||
require(types is KtFirType)
|
||||
|
||||
val session = firRef.withFir { it.session }
|
||||
val session = firRef.withFir { it.declarationSiteSession }
|
||||
return types.coneType.asPsiType(session, firRef.resolveState, TypeMappingMode.DEFAULT, psiElement)
|
||||
}
|
||||
|
||||
@@ -167,7 +167,7 @@ internal fun KtType.mapSupertype(
|
||||
val contextSymbol = classSymbol
|
||||
require(contextSymbol is KtFirSymbol<*>)
|
||||
|
||||
val session = contextSymbol.firRef.withFir { it.session }
|
||||
val session = contextSymbol.firRef.withFir { it.declarationSiteSession }
|
||||
|
||||
return mapSupertype(
|
||||
psiContext,
|
||||
@@ -297,7 +297,7 @@ internal fun KtType.getTypeNullability(context: KtSymbol, phase: FirResolvePhase
|
||||
if (coneType.classId?.shortClassName?.asString() == SpecialNames.ANONYMOUS) return NullabilityType.NotNull
|
||||
|
||||
val canonicalSignature = context.firRef.withFir(phase) {
|
||||
it.session.jvmTypeMapper.mapType(coneType, TypeMappingMode.DEFAULT).descriptor
|
||||
it.declarationSiteSession.jvmTypeMapper.mapType(coneType, TypeMappingMode.DEFAULT).descriptor
|
||||
}
|
||||
|
||||
if (canonicalSignature == "[L<error>;") return NullabilityType.NotNull
|
||||
@@ -349,4 +349,4 @@ internal fun KtSimpleConstantValue<*>.createPsiLiteral(parent: PsiElement): PsiE
|
||||
internal inline fun <T> T.applyIf(`if`: Boolean, body: T.() -> T): T =
|
||||
if (`if`) body() else this
|
||||
|
||||
internal fun BitSet.copy(): BitSet = clone() as BitSet
|
||||
internal fun BitSet.copy(): BitSet = clone() as BitSet
|
||||
|
||||
+1
-1
@@ -160,4 +160,4 @@ fun FirElement.findPsi(session: FirSession): PsiElement? =
|
||||
* Otherwise, behaves the same way as [findPsi] returns exact PSI declaration corresponding to passed [FirDeclaration]
|
||||
*/
|
||||
fun FirDeclaration.findReferencePsi(): PsiElement? =
|
||||
psi ?: FirIdeDeserializedDeclarationSourceProvider.findPsi(this, (session as FirIdeSession).project)
|
||||
psi ?: FirIdeDeserializedDeclarationSourceProvider.findPsi(this, (declarationSiteSession as FirIdeSession).project)
|
||||
|
||||
+2
-2
@@ -30,7 +30,7 @@ object KtDeclarationAndFirDeclarationEqualityChecker {
|
||||
&& !isTheSameTypes(
|
||||
psi.receiverTypeReference!!,
|
||||
fir.receiverTypeRef!!,
|
||||
fir.session,
|
||||
fir.declarationSiteSession,
|
||||
isVararg = false
|
||||
)
|
||||
) {
|
||||
@@ -44,7 +44,7 @@ object KtDeclarationAndFirDeclarationEqualityChecker {
|
||||
if (!isTheSameTypes(
|
||||
candidateParameterType,
|
||||
expectedParameter.returnTypeRef,
|
||||
fir.session,
|
||||
fir.declarationSiteSession,
|
||||
isVararg = expectedParameter.isVararg
|
||||
)
|
||||
) {
|
||||
|
||||
+1
-1
@@ -75,7 +75,7 @@ internal class KtFirScopeProvider(
|
||||
memberScopeCache.getOrPut(classSymbol) {
|
||||
|
||||
val firScope = classSymbol.withFirForScope { fir ->
|
||||
val firSession = fir.session
|
||||
val firSession = fir.declarationSiteSession
|
||||
fir.unsubstitutedScope(
|
||||
firSession,
|
||||
ScopeSession(),
|
||||
|
||||
+1
-1
@@ -105,7 +105,7 @@ internal class KtFirSymbolDeclarationOverridesProvider(
|
||||
containingDeclaration.firRef.withFir(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) { firContainer ->
|
||||
callableSymbol.firRef.withFirUnsafe { firCallableDeclaration ->
|
||||
val firTypeScope = firContainer.unsubstitutedScope(
|
||||
firContainer.session,
|
||||
firContainer.declarationSiteSession,
|
||||
ScopeSession(),
|
||||
withForcedTypeCalculator = false
|
||||
)
|
||||
|
||||
+2
-2
@@ -41,7 +41,7 @@ internal class KtFirSymbolDeclarationRendererProvider(
|
||||
|
||||
return (containingSymbol ?: symbol).firRef.withFir(phaseNeeded) { fir ->
|
||||
val containingFir = containingSymbol?.firRef?.withFirUnsafe { it }
|
||||
FirIdeRenderer.render(fir, containingFir, options, fir.session)
|
||||
FirIdeRenderer.render(fir, containingFir, options, fir.declarationSiteSession)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ internal class KtFirAnonymousFunctionSymbol(
|
||||
) : KtAnonymousFunctionSymbol(), KtFirSymbol<FirAnonymousFunction> {
|
||||
private val builder by weakRef(_builder)
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
|
||||
override val annotatedType: KtTypeAndAnnotations by cached {
|
||||
firRef.returnTypeAndAnnotations(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE, builder)
|
||||
@@ -49,4 +49,4 @@ internal class KtFirAnonymousFunctionSymbol(
|
||||
KtPsiBasedSymbolPointer.createForSymbolFromSource(this)?.let { return it }
|
||||
error("Could not create a pointer for anonymous function from library")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -35,7 +35,7 @@ internal class KtFirAnonymousObjectSymbol(
|
||||
) : KtAnonymousObjectSymbol(), KtFirSymbol<FirAnonymousObject> {
|
||||
private val builder by weakRef(_builder)
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
|
||||
override val annotations: List<KtAnnotationCall> by cached { firRef.toAnnotationsList() }
|
||||
override fun containsAnnotation(classId: ClassId): Boolean = firRef.containsAnnotation(classId)
|
||||
@@ -48,4 +48,4 @@ internal class KtFirAnonymousObjectSymbol(
|
||||
override fun createPointer(): KtSymbolPointer<KtAnonymousObjectSymbol> =
|
||||
KtPsiBasedSymbolPointer.createForSymbolFromSource(this)
|
||||
?: throw CanNotCreateSymbolPointerForLocalLibraryDeclarationException("Cannot create pointer for KtFirAnonymousObjectSymbol")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -42,7 +42,7 @@ internal class KtFirConstructorSymbol(
|
||||
) : KtConstructorSymbol(), KtFirSymbol<FirConstructor> {
|
||||
private val builder by weakRef(_builder)
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
|
||||
override val annotatedType: KtTypeAndAnnotations by cached {
|
||||
firRef.returnTypeAndAnnotations(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE, builder)
|
||||
|
||||
+1
-1
@@ -34,7 +34,7 @@ internal class KtFirEnumEntrySymbol(
|
||||
private val builder by weakRef(_builder)
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
|
||||
override val name: Name get() = firRef.withFir { it.name }
|
||||
override val annotatedType: KtTypeAndAnnotations by cached {
|
||||
|
||||
+2
-2
@@ -28,7 +28,7 @@ internal class KtFirFileSymbol(
|
||||
override val token: ValidityToken,
|
||||
) : KtFileSymbol(), KtSymbolWithDeclarations, KtFirSymbol<FirFile> {
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
|
||||
override fun createPointer(): KtSymbolPointer<KtFileSymbol> {
|
||||
KtPsiBasedSymbolPointer.createForSymbolFromSource(this)?.let { return it }
|
||||
@@ -38,4 +38,4 @@ internal class KtFirFileSymbol(
|
||||
override val annotations: List<KtAnnotationCall> by cached { firRef.toAnnotationsList() }
|
||||
override fun containsAnnotation(classId: ClassId): Boolean = firRef.containsAnnotation(classId)
|
||||
override val annotationClassIds: Collection<ClassId> by cached { firRef.getAnnotationClassIds() }
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -43,7 +43,7 @@ internal class KtFirFunctionSymbol(
|
||||
) : KtFunctionSymbol(), KtFirSymbol<FirSimpleFunction> {
|
||||
private val builder by weakRef(_builder)
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
override val name: Name get() = firRef.withFir { it.name }
|
||||
override val annotatedType: KtTypeAndAnnotations by cached {
|
||||
firRef.returnTypeAndAnnotations(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE, builder)
|
||||
|
||||
+2
-2
@@ -32,7 +32,7 @@ internal class KtFirJavaFieldSymbol(
|
||||
) : KtJavaFieldSymbol(), KtFirSymbol<FirField> {
|
||||
private val builder by weakRef(_builder)
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
|
||||
override val annotatedType: KtTypeAndAnnotations by cached {
|
||||
firRef.returnTypeAndAnnotations(FirResolvePhase.TYPES, builder)
|
||||
@@ -49,4 +49,4 @@ internal class KtFirJavaFieldSymbol(
|
||||
override fun createPointer(): KtSymbolPointer<KtJavaFieldSymbol> {
|
||||
TODO("Creating pointers for java fields is not supported yet")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ internal class KtFirKotlinPropertySymbol(
|
||||
|
||||
private val builder by weakRef(_builder)
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
|
||||
override val isVal: Boolean get() = firRef.withFir { it.isVal }
|
||||
override val name: Name get() = firRef.withFir { it.name }
|
||||
|
||||
+2
-2
@@ -36,7 +36,7 @@ internal class KtFirLocalVariableSymbol(
|
||||
|
||||
private val builder by weakRef(_builder)
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
|
||||
override val isVal: Boolean get() = firRef.withFir { it.isVal }
|
||||
override val name: Name get() = firRef.withFir { it.name }
|
||||
@@ -49,4 +49,4 @@ internal class KtFirLocalVariableSymbol(
|
||||
KtPsiBasedSymbolPointer.createForSymbolFromSource(this)?.let { return it }
|
||||
throw CanNotCreateSymbolPointerForLocalLibraryDeclarationException(name.asString())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -38,7 +38,7 @@ internal class KtFirNamedClassOrObjectSymbol(
|
||||
) : KtNamedClassOrObjectSymbol(), KtFirSymbol<FirRegularClass> {
|
||||
private val builder by weakRef(_builder)
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
override val name: Name get() = firRef.withFir { it.name }
|
||||
override val classIdIfNonLocal: ClassId?
|
||||
get() = firRef.withFir { fir ->
|
||||
@@ -101,4 +101,4 @@ internal class KtFirNamedClassOrObjectSymbol(
|
||||
}
|
||||
return KtFirClassOrObjectInLibrarySymbolPointer(classIdIfNonLocal!!)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ internal class KtFirPropertyGetterSymbol(
|
||||
|
||||
private val builder by weakRef(_builder)
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
|
||||
override val isDefault: Boolean get() = firRef.withFir { it is FirDefaultPropertyAccessor }
|
||||
override val isInline: Boolean get() = firRef.withFir { it.isInline }
|
||||
@@ -63,4 +63,4 @@ internal class KtFirPropertyGetterSymbol(
|
||||
KtPsiBasedSymbolPointer.createForSymbolFromSource(this)?.let { return it }
|
||||
TODO("Creating pointers for getters from library is not supported yet")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -40,7 +40,7 @@ internal class KtFirPropertySetterSymbol(
|
||||
|
||||
private val builder by weakRef(_builder)
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
|
||||
override val isDefault: Boolean get() = firRef.withFir { it is FirDefaultPropertyAccessor }
|
||||
override val isInline: Boolean get() = firRef.withFir { it.isInline }
|
||||
@@ -70,4 +70,4 @@ internal class KtFirPropertySetterSymbol(
|
||||
KtPsiBasedSymbolPointer.createForSymbolFromSource(this)?.let { return it }
|
||||
TODO("Creating pointers for setters from library is not supported yet")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -44,7 +44,7 @@ internal class KtFirSyntheticJavaPropertySymbol(
|
||||
) : KtSyntheticJavaPropertySymbol(), KtFirSymbol<FirSyntheticProperty> {
|
||||
private val builder by weakRef(_builder)
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
|
||||
override val isVal: Boolean get() = firRef.withFir { it.isVal }
|
||||
override val name: Name get() = firRef.withFir { it.name }
|
||||
|
||||
+2
-2
@@ -23,7 +23,7 @@ internal class KtFirTypeAliasSymbol(
|
||||
override val token: ValidityToken
|
||||
) : KtTypeAliasSymbol(), KtFirSymbol<FirTypeAlias> {
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
override val name: Name get() = firRef.withFir { it.name }
|
||||
override val classIdIfNonLocal: ClassId get() = firRef.withFir { it.symbol.classId }
|
||||
|
||||
@@ -31,4 +31,4 @@ internal class KtFirTypeAliasSymbol(
|
||||
KtPsiBasedSymbolPointer.createForSymbolFromSource(this)?.let { return it }
|
||||
TODO("Creating symbols for library typealiases is not supported yet")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -29,7 +29,7 @@ internal class KtFirTypeParameterSymbol(
|
||||
) : KtTypeParameterSymbol(), KtFirSymbol<FirTypeParameter> {
|
||||
private val builder by weakRef(_builder)
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
|
||||
override val name: Name get() = firRef.withFir { it.name }
|
||||
|
||||
@@ -44,4 +44,4 @@ internal class KtFirTypeParameterSymbol(
|
||||
KtPsiBasedSymbolPointer.createForSymbolFromSource(this)?.let { return it }
|
||||
TODO("Creating symbols for library type parameters is not supported yet")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -34,7 +34,7 @@ internal class KtFirValueParameterSymbol(
|
||||
) : KtValueParameterSymbol(), KtFirSymbol<FirValueParameter> {
|
||||
private val builder by weakRef(_builder)
|
||||
override val firRef = firRef(fir, resolveState)
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.session) }
|
||||
override val psi: PsiElement? by firRef.withFirAndCache { fir -> fir.findPsi(fir.declarationSiteSession) }
|
||||
|
||||
override val name: Name get() = firRef.withFir { it.name }
|
||||
override val isVararg: Boolean get() = firRef.withFir { it.isVararg }
|
||||
@@ -52,4 +52,4 @@ internal class KtFirValueParameterSymbol(
|
||||
KtPsiBasedSymbolPointer.createForSymbolFromSource(this)?.let { return it }
|
||||
TODO("Creating pointers for functions parameters from library is not supported yet")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -29,17 +29,17 @@ internal class KtFirAnnotationCall(
|
||||
override val token: ValidityToken get() = containingDeclaration.token
|
||||
|
||||
override val psi: KtCallElement? by containingDeclaration.withFirAndCache { fir ->
|
||||
fir.findPsi(fir.session) as? KtCallElement
|
||||
fir.findPsi(fir.declarationSiteSession) as? KtCallElement
|
||||
}
|
||||
|
||||
override val classId: ClassId? by containingDeclaration.withFirAndCache(AnnotationPhases.PHASE_FOR_ANNOTATION_CLASS_ID) { fir ->
|
||||
annotationCallRef.getClassId(fir.session)
|
||||
annotationCallRef.getClassId(fir.declarationSiteSession)
|
||||
}
|
||||
|
||||
override val useSiteTarget: AnnotationUseSiteTarget? get() = annotationCallRef.useSiteTarget
|
||||
|
||||
override val arguments: List<KtNamedConstantValue> by containingDeclaration.withFirAndCache(FirResolvePhase.TYPES) { fir ->
|
||||
mapAnnotationParameters(annotationCallRef, fir.session).map { (name, expression) ->
|
||||
mapAnnotationParameters(annotationCallRef, fir.declarationSiteSession).map { (name, expression) ->
|
||||
KtNamedConstantValue(name, expression.convertConstantExpression())
|
||||
}
|
||||
}
|
||||
|
||||
+3
-3
@@ -25,15 +25,15 @@ internal fun FirRefWithValidityCheck<FirAnnotatedDeclaration>.toAnnotationsList(
|
||||
|
||||
internal fun FirRefWithValidityCheck<FirAnnotatedDeclaration>.containsAnnotation(classId: ClassId): Boolean =
|
||||
withFir(AnnotationPhases.PHASE_FOR_ANNOTATION_CLASS_ID) { fir ->
|
||||
fir.annotations.any { it.getClassId(fir.session) == classId }
|
||||
fir.annotations.any { it.getClassId(fir.declarationSiteSession) == classId }
|
||||
}
|
||||
|
||||
internal fun FirRefWithValidityCheck<FirAnnotatedDeclaration>.getAnnotationClassIds(): Collection<ClassId> =
|
||||
withFir(AnnotationPhases.PHASE_FOR_ANNOTATION_CLASS_ID) { fir ->
|
||||
fir.annotations.mapNotNull { it.getClassId(fir.session) }
|
||||
fir.annotations.mapNotNull { it.getClassId(fir.declarationSiteSession) }
|
||||
}
|
||||
|
||||
|
||||
internal object AnnotationPhases {
|
||||
val PHASE_FOR_ANNOTATION_CLASS_ID = FirResolvePhase.TYPES
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ internal abstract class KtFirMemberSymbolPointer<S : KtSymbol>(
|
||||
ScopeSession(),
|
||||
withForcedTypeCalculator = false
|
||||
)
|
||||
return analysisSession.chooseCandidateAndCreateSymbol(scope, owner.session)
|
||||
return analysisSession.chooseCandidateAndCreateSymbol(scope, owner.declarationSiteSession)
|
||||
}
|
||||
|
||||
protected abstract fun KtFirAnalysisSession.chooseCandidateAndCreateSymbol(
|
||||
|
||||
+1
-1
@@ -21,7 +21,7 @@ internal abstract class KtTopLevelCallableSymbolPointer<S : KtCallableSymbol>(
|
||||
require(analysisSession is KtFirAnalysisSession)
|
||||
val candidates = analysisSession.getCallableSymbols(callableId)
|
||||
if (candidates.isEmpty()) return null
|
||||
val session = candidates.first().fir.session
|
||||
val session = candidates.first().fir.declarationSiteSession
|
||||
return analysisSession.chooseCandidateAndCreateSymbol(candidates, session)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ internal inline fun <reified D : FirDeclaration> Collection<FirCallableSymbol<*>
|
||||
}
|
||||
|
||||
internal fun FirDeclaration.createSignature(): IdSignature {
|
||||
val signatureComposer = session.ideSessionComponents.signatureComposer
|
||||
val signatureComposer = declarationSiteSession.ideSessionComponents.signatureComposer
|
||||
return signatureComposer.composeSignature(this)
|
||||
?: error("Could not compose signature for ${this.renderWithType(FirRenderer.RenderMode.WithResolvePhases)}, looks like it is private or local")
|
||||
}
|
||||
|
||||
+2
-2
@@ -26,11 +26,11 @@ abstract class AbstractKtDeclarationAndFirDeclarationEqualityChecker : KotlinLig
|
||||
if (!KtDeclarationAndFirDeclarationEqualityChecker.representsTheSameDeclaration(ktFunction, firFunction)) {
|
||||
throw FileComparisonFailure(
|
||||
/* message= */ null,
|
||||
KtDeclarationAndFirDeclarationEqualityChecker.renderPsi(ktFunction, firFunction.session),
|
||||
KtDeclarationAndFirDeclarationEqualityChecker.renderPsi(ktFunction, firFunction.declarationSiteSession),
|
||||
KtDeclarationAndFirDeclarationEqualityChecker.renderFir(firFunction),
|
||||
/* expectedFilePath= */ null
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user