FIR IDE: add type parameters support to completion

This commit is contained in:
Ilya Kirillov
2020-09-01 19:18:00 +03:00
parent 6d18bb6ba2
commit 775dc7b135
2 changed files with 9 additions and 1 deletions
@@ -28,12 +28,14 @@ internal class HighLevelApiLookupElementFactory {
private val classLookupElementFactory = ClassLookupElementFactory() private val classLookupElementFactory = ClassLookupElementFactory()
private val variableLookupElementFactory = VariableLookupElementFactory() private val variableLookupElementFactory = VariableLookupElementFactory()
private val functionLookupElementFactory = FunctionLookupElementFactory() private val functionLookupElementFactory = FunctionLookupElementFactory()
private val typeParameterLookupElementFactory = TypeParameterLookupElementFactory()
fun createLookupElement(symbol: KtNamedSymbol): LookupElement { fun createLookupElement(symbol: KtNamedSymbol): LookupElement {
val elementBuilder = when (symbol) { val elementBuilder = when (symbol) {
is KtFunctionSymbol -> functionLookupElementFactory.createLookup(symbol) is KtFunctionSymbol -> functionLookupElementFactory.createLookup(symbol)
is KtVariableLikeSymbol -> variableLookupElementFactory.createLookup(symbol) is KtVariableLikeSymbol -> variableLookupElementFactory.createLookup(symbol)
is KtClassLikeSymbol -> classLookupElementFactory.createLookup(symbol) is KtClassLikeSymbol -> classLookupElementFactory.createLookup(symbol)
is KtTypeParameterSymbol -> typeParameterLookupElementFactory.createLookup(symbol)
else -> throw IllegalArgumentException("Cannot create a lookup element for $symbol") else -> throw IllegalArgumentException("Cannot create a lookup element for $symbol")
} }
@@ -54,6 +56,12 @@ private class ClassLookupElementFactory {
} }
} }
private class TypeParameterLookupElementFactory {
fun createLookup(symbol: KtTypeParameterSymbol): LookupElementBuilder {
return LookupElementBuilder.create(UniqueLookupObject(), symbol.name.asString())
}
}
private class VariableLookupElementFactory { private class VariableLookupElementFactory {
fun createLookup(symbol: KtVariableLikeSymbol): LookupElementBuilder { fun createLookup(symbol: KtVariableLikeSymbol): LookupElementBuilder {
return LookupElementBuilder.create(UniqueLookupObject(), symbol.name.asString()) return LookupElementBuilder.create(UniqueLookupObject(), symbol.name.asString())
@@ -136,7 +136,7 @@ private object KotlinAvailableScopesCompletionContributor {
extensionNonMembers.forEach(::addToCompletion) extensionNonMembers.forEach(::addToCompletion)
val availableClasses = implicitScopes.getClassClassLikeSymbols() val availableClasses = implicitScopes.getClassifierSymbols()
availableClasses.forEach(::addToCompletion) availableClasses.forEach(::addToCompletion)
} }
} }