[FIR IDE] Resolve tree builder
This commit is contained in:
committed by
teamcityserver
parent
07edb15138
commit
b948ef4bd6
+10
-7
@@ -30,6 +30,7 @@ import org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.FirElementsRec
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.file.structure.KtToFirMapping
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.RawFirNonLocalDeclarationBuilder
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.RawFirReplacement
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.ResolveTreeBuilder
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.buildFileFirAnnotation
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.buildFirUserTypeRef
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.providers.firIdeProvider
|
||||
@@ -267,13 +268,15 @@ object LowLevelFirApiFacadeForResolveOnAir {
|
||||
declaration = copiedFirDeclaration,
|
||||
firFile = originalFirFile
|
||||
)
|
||||
state.firLazyDeclarationResolver.runLazyDesignatedOnAirResolveToBodyWithoutLock(
|
||||
designation = onAirDesignation,
|
||||
moduleFileCache = state.rootModuleSession.cache,
|
||||
checkPCE = true,
|
||||
onAirCreatedDeclaration = onAirCreatedDeclaration,
|
||||
towerDataContextCollector = collector,
|
||||
)
|
||||
ResolveTreeBuilder.resolveEnsure(onAirDesignation.declaration, FirResolvePhase.BODY_RESOLVE) {
|
||||
state.firLazyDeclarationResolver.runLazyDesignatedOnAirResolveToBodyWithoutLock(
|
||||
designation = onAirDesignation,
|
||||
moduleFileCache = state.rootModuleSession.cache,
|
||||
checkPCE = true,
|
||||
onAirCreatedDeclaration = onAirCreatedDeclaration,
|
||||
towerDataContextCollector = collector,
|
||||
)
|
||||
}
|
||||
copiedFirDeclaration
|
||||
}
|
||||
|
||||
|
||||
+16
-2
@@ -19,6 +19,7 @@ import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirDeclarationDesignation
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.FirLazyBodiesCalculator
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.ResolveTreeBuilder
|
||||
|
||||
fun FirIdeDesignatedImpliciteTypesBodyResolveTransformerForReturnTypeCalculator(
|
||||
designation: Iterator<FirElement>,
|
||||
@@ -78,7 +79,14 @@ private class FirIdeDesignatedBodyResolveTransformerForReturnTypeCalculatorImpl(
|
||||
simpleFunction.processCallable {
|
||||
FirLazyBodiesCalculator.calculateLazyBodiesForFunction(it)
|
||||
}
|
||||
return super.transformSimpleFunction(simpleFunction, data)
|
||||
|
||||
return if (simpleFunction.returnTypeRef is FirResolvedTypeRef) {
|
||||
super.transformSimpleFunction(simpleFunction, data)
|
||||
} else {
|
||||
return ResolveTreeBuilder.resolveReturnTypeCalculation(simpleFunction) {
|
||||
super.transformSimpleFunction(simpleFunction, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
override fun transformProperty(
|
||||
@@ -88,6 +96,12 @@ private class FirIdeDesignatedBodyResolveTransformerForReturnTypeCalculatorImpl(
|
||||
property.processCallable {
|
||||
FirLazyBodiesCalculator.calculateLazyBodyForProperty(it)
|
||||
}
|
||||
return super.transformProperty(property, data)
|
||||
return if (property.returnTypeRef is FirResolvedTypeRef) {
|
||||
super.transformProperty(property, data)
|
||||
} else {
|
||||
return ResolveTreeBuilder.resolveReturnTypeCalculation(property) {
|
||||
super.transformProperty(property, data)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+13
-6
@@ -7,6 +7,7 @@ package org.jetbrains.kotlin.idea.fir.low.level.api.file.builder
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.annotations.PrivateForInline
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.ResolveTreeBuilder
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.util.lockWithPCECheck
|
||||
import java.util.concurrent.locks.ReentrantLock
|
||||
import kotlin.concurrent.withLock
|
||||
@@ -16,15 +17,21 @@ import kotlin.concurrent.withLock
|
||||
* !!! We temporary remove its correct implementation to fix deadlocks problem. Do not use this until this comment is present
|
||||
*/
|
||||
internal class LockProvider<KEY> {
|
||||
val globalLock = ReentrantLock()
|
||||
//We temporary disable multi-locks to fix deadlocks problem
|
||||
private val globalLock = ReentrantLock()
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
inline fun <R> withWriteLock(@Suppress("UNUSED_PARAMETER") key: KEY, action: () -> R): R =
|
||||
globalLock.withLock(action)
|
||||
inline fun <R> withWriteLock(@Suppress("UNUSED_PARAMETER") key: KEY, action: () -> R): R {
|
||||
val startTime = System.currentTimeMillis()
|
||||
return globalLock.withLock { ResolveTreeBuilder.lockNode(startTime, action) }
|
||||
}
|
||||
|
||||
|
||||
@OptIn(PrivateForInline::class)
|
||||
inline fun <R> withWriteLockPCECheck(@Suppress("UNUSED_PARAMETER") key: KEY, lockingIntervalMs: Long, action: () -> R): R =
|
||||
globalLock.lockWithPCECheck(lockingIntervalMs, action) //We temporary disable multi-locks to fix deadlocks problem
|
||||
inline fun <R> withWriteLockPCECheck(@Suppress("UNUSED_PARAMETER") key: KEY, lockingIntervalMs: Long, action: () -> R): R {
|
||||
val startTime = System.currentTimeMillis()
|
||||
return globalLock.lockWithPCECheck(lockingIntervalMs) { ResolveTreeBuilder.lockNode(startTime, action) }
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -36,7 +43,7 @@ internal inline fun <R> LockProvider<FirFile>.runCustomResolveUnderLock(
|
||||
body: () -> R
|
||||
): R {
|
||||
return if (checkPCE) {
|
||||
withWriteLockPCECheck(key = firFile, lockingIntervalMs = 50L, action = body)
|
||||
withWriteLockPCECheck(key = firFile, lockingIntervalMs = 50L, body)
|
||||
} else {
|
||||
withWriteLock(key = firFile, action = body)
|
||||
}
|
||||
|
||||
+19
-14
@@ -120,13 +120,15 @@ internal class FirLazyDeclarationResolver(private val firFileBuilder: FirFileBui
|
||||
if (toPhase == FirResolvePhase.IMPORTS) return
|
||||
if (firFile.resolvePhase >= toPhase) return
|
||||
moduleFileCache.firFileLockProvider.runCustomResolveUnderLock(firFile, checkPCE) {
|
||||
lazyResolveFileDeclarationWithoutLock(
|
||||
firFile = firFile,
|
||||
moduleFileCache = moduleFileCache,
|
||||
toPhase = toPhase,
|
||||
scopeSession = scopeSession,
|
||||
checkPCE = checkPCE,
|
||||
)
|
||||
ResolveTreeBuilder.resolveEnsure(firFile, toPhase) {
|
||||
lazyResolveFileDeclarationWithoutLock(
|
||||
firFile = firFile,
|
||||
moduleFileCache = moduleFileCache,
|
||||
toPhase = toPhase,
|
||||
scopeSession = scopeSession,
|
||||
checkPCE = checkPCE,
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -288,13 +290,16 @@ internal class FirLazyDeclarationResolver(private val firFileBuilder: FirFileBui
|
||||
}
|
||||
|
||||
moduleFileCache.firFileLockProvider.runCustomResolveUnderLock(designation.firFile, checkPCE) {
|
||||
runLazyDesignatedResolveWithoutLock(
|
||||
designation = designation,
|
||||
moduleFileCache = moduleFileCache,
|
||||
scopeSession = scopeSession,
|
||||
toPhase = neededPhase,
|
||||
checkPCE = checkPCE,
|
||||
)
|
||||
ResolveTreeBuilder.resolveEnsure(designation.declaration, neededPhase) {
|
||||
runLazyDesignatedResolveWithoutLock(
|
||||
designation = designation,
|
||||
moduleFileCache = moduleFileCache,
|
||||
scopeSession = scopeSession,
|
||||
toPhase = neededPhase,
|
||||
checkPCE = checkPCE,
|
||||
)
|
||||
designation.declaration
|
||||
}
|
||||
}
|
||||
|
||||
if (!isLocalDeclarationResolveRequested) return firDeclarationToResolve
|
||||
|
||||
+154
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* Copyright 2010-2021 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.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve
|
||||
|
||||
import org.jetbrains.kotlin.fir.declarations.FirDeclaration
|
||||
import org.jetbrains.kotlin.fir.declarations.FirResolvePhase
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFileSymbol
|
||||
import java.io.File
|
||||
|
||||
internal object ResolveTreeBuilder {
|
||||
|
||||
private val file: File? by lazy(LazyThreadSafetyMode.PUBLICATION) {
|
||||
System.getProperty("fir.lazy.resolve.dump")?.let {
|
||||
File(it)
|
||||
}
|
||||
}
|
||||
|
||||
class Context(var rootCall: Boolean = true, var underLock: Boolean = false, val builder: StringBuilder = StringBuilder())
|
||||
|
||||
val currentContext: ThreadLocal<Context> = ThreadLocal.withInitial { Context() }
|
||||
|
||||
private fun FirResolvePhase.firPhaseName(): String = when (this) {
|
||||
FirResolvePhase.RAW_FIR -> "Raw"
|
||||
FirResolvePhase.IMPORTS -> "Imports"
|
||||
FirResolvePhase.SUPER_TYPES -> "SuperTypes"
|
||||
FirResolvePhase.TYPES -> "Types"
|
||||
FirResolvePhase.STATUS -> "Status"
|
||||
FirResolvePhase.ARGUMENTS_OF_ANNOTATIONS -> "ArgumentsOfAnnotations"
|
||||
FirResolvePhase.CONTRACTS -> "Contracts"
|
||||
FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE -> "ImplicitTypes"
|
||||
FirResolvePhase.BODY_RESOLVE -> "Body"
|
||||
else -> "?"
|
||||
}
|
||||
|
||||
fun resolvePhase(
|
||||
declaration: FirDeclaration,
|
||||
phase: FirResolvePhase,
|
||||
body: () -> Unit
|
||||
) {
|
||||
newNodeContext {
|
||||
resolveToDeclaration(declaration, "Phase", false, phase) {
|
||||
body()
|
||||
declaration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun resolveEnsure(
|
||||
declaration: FirDeclaration,
|
||||
phase: FirResolvePhase,
|
||||
body: () -> Unit
|
||||
) {
|
||||
newNodeContext {
|
||||
resolveToDeclaration(declaration, "Ensure", true, phase) {
|
||||
body()
|
||||
declaration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline fun <T> lockNode(startTime: Long, body: () -> T): T {
|
||||
if (file == null) return body()
|
||||
val waitEnd = System.currentTimeMillis()
|
||||
val currentContext = currentContext.get()
|
||||
val builderLength = currentContext.builder.length
|
||||
val wasUnderLock = currentContext.underLock
|
||||
currentContext.underLock = true
|
||||
return newNodeContext {
|
||||
try {
|
||||
body()
|
||||
} finally {
|
||||
val contentionTime = waitEnd - startTime
|
||||
val executionTime = System.currentTimeMillis() - waitEnd
|
||||
if (!wasUnderLock && builderLength != currentContext.builder.length) {
|
||||
val tag = "<UnderLock waitTime=\"$contentionTime\" executionTime=\"$executionTime\">"
|
||||
currentContext.builder.insert(builderLength, tag)
|
||||
currentContext.builder.append("</UnderLock>")
|
||||
}
|
||||
currentContext.underLock = wasUnderLock
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun <T : FirDeclaration> resolveReturnTypeCalculation(
|
||||
declaration: FirDeclaration,
|
||||
body: () -> T
|
||||
): T = newNodeContext {
|
||||
resolveToDeclaration(declaration, "RTC", true, null, body)
|
||||
}
|
||||
|
||||
private fun FirDeclaration.toDeclarationName(): String = when (val symbol = symbol) {
|
||||
is FirClassSymbol<*> -> symbol.classId.asSingleFqName().asString()
|
||||
is FirCallableSymbol<*> -> symbol.callableId.asSingleFqName().asString()
|
||||
is FirFileSymbol -> symbol.fir.name
|
||||
else -> symbol::class.qualifiedName
|
||||
} ?: "${this::class.qualifiedName}:${hashCode()}"
|
||||
|
||||
private fun <T : FirDeclaration> resolveToDeclaration(
|
||||
declaration: FirDeclaration,
|
||||
nodeName: String,
|
||||
needWriteDeclarationName: Boolean,
|
||||
phase: FirResolvePhase? = null,
|
||||
body: () -> T
|
||||
): T {
|
||||
if (phase != null && declaration.resolvePhase >= phase) return body()
|
||||
|
||||
val currentContext = currentContext.get()
|
||||
val currentPosition = currentContext.builder.length
|
||||
var withException = true
|
||||
val start = System.currentTimeMillis()
|
||||
try {
|
||||
return body().also {
|
||||
withException = false
|
||||
}
|
||||
} finally {
|
||||
val end = System.currentTimeMillis()
|
||||
val timeAttr = " time=\"${end - start}\""
|
||||
val phaseAttr = if (phase != null) " phase=\"${phase.firPhaseName()}\"" else ""
|
||||
val declarationAttr = if (needWriteDeclarationName) " declaration=\"${declaration.toDeclarationName()}\"" else ""
|
||||
val exceptionAttr = if (withException) " withException=\"true\"" else ""
|
||||
val nodeContent = "$declarationAttr$phaseAttr$timeAttr$exceptionAttr"
|
||||
|
||||
if (currentPosition == currentContext.builder.length) {
|
||||
currentContext.builder.append("<$nodeName$nodeContent />")
|
||||
} else {
|
||||
currentContext.builder.insert(currentPosition, "<$nodeName$nodeContent>")
|
||||
currentContext.builder.append("</$nodeName>")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private inline fun <T> newNodeContext(body: () -> T): T {
|
||||
val dumpFile = file ?: return body()
|
||||
val currentContext = currentContext.get()
|
||||
val oldRootEnsure = currentContext.rootCall
|
||||
try {
|
||||
currentContext.rootCall = false
|
||||
return body()
|
||||
} finally {
|
||||
currentContext.rootCall = oldRootEnsure
|
||||
if (oldRootEnsure) {
|
||||
synchronized(dumpFile) {
|
||||
dumpFile.appendText(currentContext.builder.toString())
|
||||
}
|
||||
currentContext.builder.clear()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+5
-2
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.resolve.transformers.plugin.FirAnnotationArgumen
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.FirPhaseRunner
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirDeclarationDesignationWithFile
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.ResolveTreeBuilder
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.util.ensurePhase
|
||||
|
||||
internal class FirDesignatedAnnotationArgumentsResolveTransformerForIDE(
|
||||
@@ -54,8 +55,10 @@ internal class FirDesignatedAnnotationArgumentsResolveTransformerForIDE(
|
||||
|
||||
val designationIterator = designation.toSequenceWithFile(includeTarget = false).iterator()
|
||||
|
||||
phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.ARGUMENTS_OF_ANNOTATIONS) {
|
||||
moveNextDeclaration(designationIterator)
|
||||
ResolveTreeBuilder.resolvePhase(designation.declaration, FirResolvePhase.ARGUMENTS_OF_ANNOTATIONS) {
|
||||
phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.ARGUMENTS_OF_ANNOTATIONS) {
|
||||
moveNextDeclaration(designationIterator)
|
||||
}
|
||||
}
|
||||
|
||||
FirLazyTransformerForIDE.updatePhaseDeep(designation.declaration, FirResolvePhase.ARGUMENTS_OF_ANNOTATIONS)
|
||||
|
||||
+5
-3
@@ -16,8 +16,8 @@ import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.ImplicitBodyRe
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.body.resolve.createReturnTypeCalculatorForIDE
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.FirPhaseRunner
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirDeclarationDesignationWithFile
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.element.builder.FirIdeDesignatedImpliciteTypesBodyResolveTransformerForReturnTypeCalculator
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.element.builder.FirIdeEnsureBasedTransformerForReturnTypeCalculator
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.ResolveTreeBuilder
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.transformers.FirLazyTransformerForIDE.Companion.updatePhaseDeep
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.util.ensurePhase
|
||||
|
||||
@@ -55,8 +55,10 @@ internal class FirDesignatedBodyResolveTransformerForIDE(
|
||||
if (designation.declaration.resolvePhase >= FirResolvePhase.BODY_RESOLVE) return
|
||||
designation.declaration.ensurePhase(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE)
|
||||
|
||||
phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.BODY_RESOLVE) {
|
||||
designation.firFile.transform<FirFile, ResolutionMode>(this, ResolutionMode.ContextIndependent)
|
||||
ResolveTreeBuilder.resolvePhase(designation.declaration, FirResolvePhase.BODY_RESOLVE) {
|
||||
phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.BODY_RESOLVE) {
|
||||
designation.firFile.transform<FirFile, ResolutionMode>(this, ResolutionMode.ContextIndependent)
|
||||
}
|
||||
}
|
||||
|
||||
ideDeclarationTransformer.ensureDesignationPassed()
|
||||
|
||||
+5
-2
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.fir.resolve.transformers.contracts.FirContractResolv
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.FirPhaseRunner
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirDeclarationDesignationWithFile
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.FirLazyBodiesCalculator
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.ResolveTreeBuilder
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.transformers.FirLazyTransformerForIDE.Companion.updatePhaseDeep
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.util.ensurePhase
|
||||
|
||||
@@ -47,8 +48,10 @@ internal class FirDesignatedContractsResolveTransformerForIDE(
|
||||
designation.declaration.ensurePhase(FirResolvePhase.ARGUMENTS_OF_ANNOTATIONS)
|
||||
|
||||
FirLazyBodiesCalculator.calculateLazyBodiesInside(designation)
|
||||
phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.CONTRACTS) {
|
||||
designation.firFile.transform<FirFile, ResolutionMode>(this, ResolutionMode.ContextIndependent)
|
||||
ResolveTreeBuilder.resolvePhase(designation.declaration, FirResolvePhase.CONTRACTS) {
|
||||
phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.CONTRACTS) {
|
||||
designation.firFile.transform<FirFile, ResolutionMode>(this, ResolutionMode.ContextIndependent)
|
||||
}
|
||||
}
|
||||
|
||||
ideDeclarationTransformer.ensureDesignationPassed()
|
||||
|
||||
+5
-2
@@ -17,6 +17,7 @@ import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.FirPhaseRunner
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirDeclarationDesignationWithFile
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.element.builder.FirIdeDesignatedImpliciteTypesBodyResolveTransformerForReturnTypeCalculator
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.ResolveTreeBuilder
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.transformers.FirLazyTransformerForIDE.Companion.updatePhaseDeep
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.util.ensurePhase
|
||||
|
||||
@@ -54,8 +55,10 @@ internal class FirDesignatedImplicitTypesTransformerForIDE(
|
||||
if (designation.declaration.resolvePhase >= FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) return
|
||||
designation.declaration.ensurePhase(FirResolvePhase.CONTRACTS)
|
||||
|
||||
phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) {
|
||||
designation.firFile.transform<FirFile, ResolutionMode>(this, ResolutionMode.ContextIndependent)
|
||||
ResolveTreeBuilder.resolvePhase(designation.declaration, FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) {
|
||||
phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.IMPLICIT_TYPES_BODY_RESOLVE) {
|
||||
designation.firFile.transform<FirFile, ResolutionMode>(this, ResolutionMode.ContextIndependent)
|
||||
}
|
||||
}
|
||||
|
||||
ideDeclarationTransformer.ensureDesignationPassed()
|
||||
|
||||
+5
-2
@@ -13,6 +13,7 @@ import org.jetbrains.kotlin.fir.resolve.transformers.FirStatusResolveTransformer
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.StatusComputationSession
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.FirPhaseRunner
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirDeclarationDesignationWithFile
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.ResolveTreeBuilder
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.transformers.FirLazyTransformerForIDE.Companion.updatePhaseDeep
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.util.ensurePhase
|
||||
|
||||
@@ -40,8 +41,10 @@ internal class FirDesignatedStatusResolveTransformerForIDE(
|
||||
designation.declaration.ensurePhase(FirResolvePhase.TYPES)
|
||||
|
||||
val transformer = FirDesignatedStatusResolveTransformerForIDE()
|
||||
phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.STATUS) {
|
||||
designation.firFile.transform<FirElement, FirResolvedDeclarationStatus?>(transformer, null)
|
||||
ResolveTreeBuilder.resolvePhase(designation.declaration, FirResolvePhase.STATUS) {
|
||||
phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.STATUS) {
|
||||
designation.firFile.transform<FirElement, FirResolvedDeclarationStatus?>(transformer, null)
|
||||
}
|
||||
}
|
||||
|
||||
transformer.designationTransformer.ensureDesignationPassed()
|
||||
|
||||
+8
-4
@@ -20,6 +20,7 @@ import org.jetbrains.kotlin.idea.fir.low.level.api.api.collectDesignation
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.file.builder.ModuleFileCache
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.file.builder.runCustomResolveUnderLock
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.FirLazyDeclarationResolver
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.ResolveTreeBuilder
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.transformers.FirLazyTransformerForIDE.Companion.updatePhaseDeep
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.util.checkCanceled
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.util.ensurePhase
|
||||
@@ -143,11 +144,14 @@ internal class FirDesignatedSupertypeResolverTransformerForIDE(
|
||||
FirDeclarationDesignationWithFile(targetPath, resolvableTarget, designation.firFile)
|
||||
} else designation
|
||||
|
||||
phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.SUPER_TYPES) {
|
||||
val collected = collect(targetDesignation)
|
||||
supertypeComputationSession.breakLoops(session)
|
||||
apply(collected)
|
||||
ResolveTreeBuilder.resolvePhase(designation.declaration, FirResolvePhase.SUPER_TYPES) {
|
||||
phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.SUPER_TYPES) {
|
||||
val collected = collect(targetDesignation)
|
||||
supertypeComputationSession.breakLoops(session)
|
||||
apply(collected)
|
||||
}
|
||||
}
|
||||
|
||||
updatePhaseDeep(designation.declaration, FirResolvePhase.SUPER_TYPES)
|
||||
ensureResolved(designation.declaration)
|
||||
ensureResolvedDeep(designation.declaration)
|
||||
|
||||
+5
-2
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.fir.types.FirImplicitTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.FirPhaseRunner
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.api.FirDeclarationDesignationWithFile
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.lazy.resolve.ResolveTreeBuilder
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.transformers.FirLazyTransformerForIDE.Companion.updatePhaseDeep
|
||||
import org.jetbrains.kotlin.idea.fir.low.level.api.util.ensurePhase
|
||||
|
||||
@@ -43,8 +44,10 @@ internal class FirDesignatedTypeResolverTransformerForIDE(
|
||||
if (designation.declaration.resolvePhase >= FirResolvePhase.TYPES) return
|
||||
designation.declaration.ensurePhase(FirResolvePhase.SUPER_TYPES)
|
||||
|
||||
phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.TYPES) {
|
||||
designation.firFile.transform<FirFile, Any?>(this, null)
|
||||
ResolveTreeBuilder.resolvePhase(designation.declaration, FirResolvePhase.TYPES) {
|
||||
phaseRunner.runPhaseWithCustomResolve(FirResolvePhase.TYPES) {
|
||||
designation.firFile.transform<FirFile, Any?>(this, null)
|
||||
}
|
||||
}
|
||||
|
||||
declarationTransformer.ensureDesignationPassed()
|
||||
|
||||
Reference in New Issue
Block a user