FIR IDE: remove error handling from function completion

This commit is contained in:
Ilya Kirillov
2021-06-02 00:36:12 +02:00
committed by TeamCityServer
parent a1fcc34bbc
commit ae7a6dc742
3 changed files with 10 additions and 21 deletions
@@ -50,8 +50,8 @@ internal abstract class FirCompletionContributorBase<C : FirRawPositionCompletio
if (symbol !is KtNamedSymbol) return
with(lookupElementFactory) {
createLookupElement(symbol)
?.let { applyWeighers(it, symbol, expectedType) }
?.let(sink::addElement)
.let { applyWeighers(it, symbol, expectedType) }
.let(sink::addElement)
}
}
@@ -40,7 +40,7 @@ internal class FunctionLookupElementFactory {
symbol: KtFunctionSymbol,
importStrategy: CallableImportStrategy,
insertionStrategy: CallableInsertionStrategy
): LookupElementBuilder? {
): LookupElementBuilder {
val lookupObject = FunctionLookupObject(
symbol.name,
importStrategy = importStrategy,
@@ -55,22 +55,11 @@ internal class FunctionLookupElementFactory {
CallableInsertionStrategy.AS_IDENTIFIER -> QuotedNamesAwareInsertionHandler()
}
return try {
LookupElementBuilder.create(lookupObject, symbol.name.asString())
.withTailText(getTailText(symbol), true)
.withTypeText(symbol.annotatedType.type.render(CompletionShortNamesRenderer.TYPE_RENDERING_OPTIONS))
.withInsertHandler(insertionHandler)
.let { withSymbolInfo(symbol, it) }
} catch (e: Throwable) {
if (e is ControlFlowException) throw e
LOG.error(e)
null
}
}
companion object {
private val LOG = logger<FunctionLookupElementFactory>()
return LookupElementBuilder.create(lookupObject, symbol.name.asString())
.withTailText(getTailText(symbol), true)
.withTypeText(symbol.annotatedType.type.render(CompletionShortNamesRenderer.TYPE_RENDERING_OPTIONS))
.withInsertHandler(insertionHandler)
.let { withSymbolInfo(symbol, it) }
}
}
@@ -22,7 +22,7 @@ internal class KotlinFirLookupElementFactory {
private val typeParameterLookupElementFactory = TypeParameterLookupElementFactory()
private val packagePartLookupElementFactory = PackagePartLookupElementFactory()
fun KtAnalysisSession.createLookupElement(symbol: KtNamedSymbol): LookupElement? {
fun KtAnalysisSession.createLookupElement(symbol: KtNamedSymbol): LookupElement {
return when (symbol) {
is KtCallableSymbol -> createCallableLookupElement(
symbol,
@@ -39,7 +39,7 @@ internal class KotlinFirLookupElementFactory {
symbol: KtCallableSymbol,
importingStrategy: CallableImportStrategy,
insertionStrategy: CallableInsertionStrategy,
): LookupElementBuilder? {
): LookupElementBuilder {
return when (symbol) {
is KtFunctionSymbol -> with(functionLookupElementFactory) { createLookup(symbol, importingStrategy, insertionStrategy) }
is KtVariableLikeSymbol -> with(variableLookupElementFactory) { createLookup(symbol, importingStrategy) }