FIR Completion: Rename FIR completion classes to be more uniform
This commit is contained in:
+6
-6
@@ -30,15 +30,15 @@ import org.jetbrains.kotlin.psi.psiUtil.getQualifiedExpressionForSelector
|
|||||||
|
|
||||||
class KotlinFirCompletionContributor : CompletionContributor() {
|
class KotlinFirCompletionContributor : CompletionContributor() {
|
||||||
init {
|
init {
|
||||||
extend(CompletionType.BASIC, PlatformPatterns.psiElement(), KotlinHighLevelApiContributor)
|
extend(CompletionType.BASIC, PlatformPatterns.psiElement(), KotlinFirCompletionProvider)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private object KotlinHighLevelApiContributor : CompletionProvider<CompletionParameters>() {
|
private object KotlinFirCompletionProvider : CompletionProvider<CompletionParameters>() {
|
||||||
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) {
|
override fun addCompletions(parameters: CompletionParameters, context: ProcessingContext, result: CompletionResultSet) {
|
||||||
if (shouldSuppressCompletion(parameters, result.prefixMatcher)) return
|
if (shouldSuppressCompletion(parameters, result.prefixMatcher)) return
|
||||||
|
|
||||||
KotlinAvailableScopesCompletionContributor.collectCompletions(parameters, result)
|
KotlinAvailableScopesCompletionProvider.addCompletions(parameters, result)
|
||||||
}
|
}
|
||||||
|
|
||||||
private val AFTER_NUMBER_LITERAL = PsiJavaPatterns.psiElement().afterLeafSkipping(
|
private val AFTER_NUMBER_LITERAL = PsiJavaPatterns.psiElement().afterLeafSkipping(
|
||||||
@@ -64,8 +64,8 @@ private object KotlinHighLevelApiContributor : CompletionProvider<CompletionPara
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private object KotlinAvailableScopesCompletionContributor {
|
private object KotlinAvailableScopesCompletionProvider {
|
||||||
private val lookupElementFactory = HighLevelApiLookupElementFactory()
|
private val lookupElementFactory = KotlinFirLookupElementFactory()
|
||||||
|
|
||||||
fun getOriginalPosition(parameters: CompletionParameters, originalFile: KtFile): PsiElement {
|
fun getOriginalPosition(parameters: CompletionParameters, originalFile: KtFile): PsiElement {
|
||||||
fun PsiElement.getPositionForExpressionFunctionBody(): PsiElement? {
|
fun PsiElement.getPositionForExpressionFunctionBody(): PsiElement? {
|
||||||
@@ -97,7 +97,7 @@ private object KotlinAvailableScopesCompletionContributor {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@OptIn(InvalidWayOfUsingAnalysisSession::class)
|
@OptIn(InvalidWayOfUsingAnalysisSession::class)
|
||||||
fun collectCompletions(parameters: CompletionParameters, result: CompletionResultSet) {
|
fun addCompletions(parameters: CompletionParameters, result: CompletionResultSet) {
|
||||||
val originalFile = parameters.originalFile as? KtFile ?: return
|
val originalFile = parameters.originalFile as? KtFile ?: return
|
||||||
|
|
||||||
val reference = (parameters.position.parent as? KtSimpleNameExpression)?.mainReference ?: return
|
val reference = (parameters.position.parent as? KtSimpleNameExpression)?.mainReference ?: return
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ import org.jetbrains.kotlin.idea.frontend.api.symbols.*
|
|||||||
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.*
|
import org.jetbrains.kotlin.idea.frontend.api.symbols.markers.*
|
||||||
import javax.swing.Icon
|
import javax.swing.Icon
|
||||||
|
|
||||||
internal object KotlinSymbolIconProvider {
|
internal object KotlinFirIconProvider {
|
||||||
fun getIconFor(symbol: KtNamedSymbol): Icon? {
|
fun getIconFor(symbol: KtNamedSymbol): Icon? {
|
||||||
if (symbol is KtFunctionSymbol) {
|
if (symbol is KtFunctionSymbol) {
|
||||||
val isAbstract = symbol.modality == KtCommonSymbolModality.ABSTRACT
|
val isAbstract = symbol.modality == KtCommonSymbolModality.ABSTRACT
|
||||||
+2
-2
@@ -24,7 +24,7 @@ import org.jetbrains.kotlin.psi.KtTypeArgumentList
|
|||||||
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
import org.jetbrains.kotlin.psi.psiUtil.endOffset
|
||||||
import org.jetbrains.kotlin.renderer.render
|
import org.jetbrains.kotlin.renderer.render
|
||||||
|
|
||||||
internal class HighLevelApiLookupElementFactory {
|
internal class KotlinFirLookupElementFactory {
|
||||||
private val classLookupElementFactory = ClassLookupElementFactory()
|
private val classLookupElementFactory = ClassLookupElementFactory()
|
||||||
private val variableLookupElementFactory = VariableLookupElementFactory()
|
private val variableLookupElementFactory = VariableLookupElementFactory()
|
||||||
private val functionLookupElementFactory = FunctionLookupElementFactory()
|
private val functionLookupElementFactory = FunctionLookupElementFactory()
|
||||||
@@ -41,7 +41,7 @@ internal class HighLevelApiLookupElementFactory {
|
|||||||
|
|
||||||
return elementBuilder
|
return elementBuilder
|
||||||
.withPsiElement(symbol.psi) // TODO check if it is a heavy operation and should be postponed
|
.withPsiElement(symbol.psi) // TODO check if it is a heavy operation and should be postponed
|
||||||
.withIcon(KotlinSymbolIconProvider.getIconFor(symbol))
|
.withIcon(KotlinFirIconProvider.getIconFor(symbol))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user