FIR IDE: make some session components to be non-thread local
To avoid memory leaks
This commit is contained in:
+3
-3
@@ -41,9 +41,9 @@ private constructor(
|
||||
override val scopeProvider by threadLocal { KtFirScopeProvider(this, firSymbolBuilder, project, firResolveState, token) }
|
||||
override val symbolProvider: KtSymbolProvider =
|
||||
KtFirSymbolProvider(this, firResolveState.rootModuleSession.firSymbolProvider, firResolveState, firSymbolBuilder, token)
|
||||
override val completionCandidateChecker: KtCompletionCandidateChecker by threadLocal { KtFirCompletionCandidateChecker(this, token) }
|
||||
override val symbolDeclarationOverridesProvider: KtSymbolDeclarationOverridesProvider
|
||||
by threadLocal { KtFirSymbolDeclarationOverridesProvider(this, token) }
|
||||
override val completionCandidateChecker: KtCompletionCandidateChecker = KtFirCompletionCandidateChecker(this, token)
|
||||
override val symbolDeclarationOverridesProvider: KtSymbolDeclarationOverridesProvider =
|
||||
KtFirSymbolDeclarationOverridesProvider(this, token)
|
||||
|
||||
override fun createContextDependentCopy(): KtAnalysisSession {
|
||||
check(!isContextSession) { "Cannot create context-dependent copy of KtAnalysis session from a context dependent one" }
|
||||
|
||||
+3
-2
@@ -32,6 +32,7 @@ import org.jetbrains.kotlin.psi.KtExpression
|
||||
import org.jetbrains.kotlin.psi.KtFile
|
||||
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
|
||||
import java.util.concurrent.ConcurrentHashMap
|
||||
|
||||
internal class KtFirCompletionCandidateChecker(
|
||||
analysisSession: KtFirAnalysisSession,
|
||||
@@ -40,7 +41,7 @@ internal class KtFirCompletionCandidateChecker(
|
||||
override val analysisSession: KtFirAnalysisSession by weakRef(analysisSession)
|
||||
|
||||
private val completionContextCache =
|
||||
HashMap<Pair<FirFile, KtCallableDeclaration>, LowLevelFirApiFacadeForCompletion.FirCompletionContext>()
|
||||
ConcurrentHashMap<Pair<FirFile, KtCallableDeclaration>, LowLevelFirApiFacadeForCompletion.FirCompletionContext>()
|
||||
|
||||
override fun checkExtensionFitsCandidate(
|
||||
firSymbolForCandidate: KtCallableSymbol,
|
||||
@@ -94,7 +95,7 @@ internal class KtFirCompletionCandidateChecker(
|
||||
): Sequence<ImplicitReceiverValue<*>?> {
|
||||
val enclosingContext = EnclosingDeclarationContext.detect(originalFile, fakeNameExpression)
|
||||
|
||||
val completionContext = completionContextCache.getOrCreate(firFile to enclosingContext.fakeEnclosingDeclaration) {
|
||||
val completionContext = completionContextCache.computeIfAbsent(firFile to enclosingContext.fakeEnclosingDeclaration) {
|
||||
enclosingContext.buildCompletionContext(firFile, firResolveState)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user