Skip to content

Commit

Permalink
FIR IDE: fix memory leak in scope provider
Browse files Browse the repository at this point in the history
  • Loading branch information
darthorimar committed Nov 23, 2020
1 parent 64895fe commit 559b07d
Showing 1 changed file with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,13 @@ import java.util.*

internal class KtFirScopeProvider(
analysisSession: KtAnalysisSession,
private val builder: KtSymbolByFirBuilder,
builder: KtSymbolByFirBuilder,
private val project: Project,
firResolveState: FirModuleResolveState,
override val token: ValidityToken,
) : KtScopeProvider(), ValidityTokenOwner {
override val analysisSession: KtAnalysisSession by weakRef(analysisSession)
private val builder by weakRef(builder)
private val firResolveState by weakRef(firResolveState)
private val firScopeStorage = FirScopeRegistry()

Expand Down Expand Up @@ -133,13 +134,13 @@ internal class KtFirScopeProvider(
}

private fun buildCompletionContextForEnclosingDeclaration(
originalFile: KtFile,
ktFile: KtFile,
positionInFakeFile: KtElement
): LowLevelFirApiFacadeForCompletion.FirCompletionContext {
val originalFirFile = LowLevelFirApiFacade.getFirFile(originalFile, firResolveState)
val declarationContext = EnclosingDeclarationContext.detect(originalFile, positionInFakeFile)
val firFile = LowLevelFirApiFacade.getFirFile(ktFile, firResolveState)
val declarationContext = EnclosingDeclarationContext.detect(positionInFakeFile)

return declarationContext.buildCompletionContext(originalFirFile, firResolveState)
return declarationContext.buildCompletionContext(firFile, firResolveState)
}

private fun convertToKtScope(firScope: FirScope): KtScope {
Expand Down

0 comments on commit 559b07d

Please sign in to comment.