[FIR-IDE] Changes after review

Move usage of SingleCandidateResolver into dedicated component from KtFirAnalysisSession.
Add validity assertion, use concurrent map for context cache, provide original PSI when building context.
Update names, make other minor changes.
This commit is contained in:
Pavel Kirpichenkov
2020-08-21 19:02:46 +03:00
parent ec072798b1
commit dc538d420e
7 changed files with 193 additions and 90 deletions
@@ -40,6 +40,7 @@ abstract class KtAnalysisSession(override val token: ValidityToken) : ValidityTo
protected abstract val containingDeclarationProvider: KtSymbolContainingDeclarationProvider
protected abstract val symbolProvider: KtSymbolProvider
protected abstract val callResolver: KtCallResolver
protected abstract val completionCandidateChecker: KtCompletionCandidateChecker
/// TODO: get rid of
@@ -119,10 +120,16 @@ abstract class KtAnalysisSession(override val token: ValidityToken) : ValidityTo
return resolveToSymbols().singleOrNull()
}
abstract fun resolveAndCheckReceivers(
firSymbolForCandidate: KtCallableSymbol,
originalFile: KtFile,
nameExpression: KtSimpleNameExpression,
possibleReceiver: KtExpression?,
): Boolean
fun KtCallableSymbol.checkExtensionIsSuitable(
originalPsiFile: KtFile,
originalPosition: PsiElement?,
psiFakeCompletionExpression: KtSimpleNameExpression,
psiReceiverExpression: KtExpression?,
): Boolean = completionCandidateChecker.checkExtensionFitsCandidate(
this,
originalPsiFile,
originalPosition,
psiFakeCompletionExpression,
psiReceiverExpression
)
}
@@ -0,0 +1,22 @@
/*
* Copyright 2010-2020 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.frontend.api.components
import com.intellij.psi.PsiElement
import org.jetbrains.kotlin.idea.frontend.api.symbols.KtCallableSymbol
import org.jetbrains.kotlin.psi.KtExpression
import org.jetbrains.kotlin.psi.KtFile
import org.jetbrains.kotlin.psi.KtSimpleNameExpression
abstract class KtCompletionCandidateChecker : KtAnalysisSessionComponent() {
abstract fun checkExtensionFitsCandidate(
firSymbolForCandidate: KtCallableSymbol,
originalFile: KtFile,
originalPosition: PsiElement?,
nameExpression: KtSimpleNameExpression,
possibleExplicitReceiver: KtExpression?,
): Boolean
}