From 83a9b4fb870078133324230c6927691587e9194c Mon Sep 17 00:00:00 2001 From: Roman Golyshev Date: Tue, 2 Mar 2021 16:07:19 +0300 Subject: [PATCH] FIR IDE: Only insert FqNames for non-extension non-members properties This is not completely correct, will be fixed later --- .../completion/KotlinFirLookupElementFactory.kt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/KotlinFirLookupElementFactory.kt b/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/KotlinFirLookupElementFactory.kt index a80ee208cec..60bc17f0195 100644 --- a/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/KotlinFirLookupElementFactory.kt +++ b/idea/idea-fir/src/org/jetbrains/kotlin/idea/completion/KotlinFirLookupElementFactory.kt @@ -115,7 +115,8 @@ private class VariableLookupElementFactory { if (setterName != null) "$getterName()/$setterName()" else "$getterName()" private fun createInsertHandler(symbol: KtVariableLikeSymbol): InsertHandler { - val callableId = symbol.callableIdIfExists ?: return QuotedNamesAwareInsertionHandler(symbol.name) + val callableId = symbol.callableIdIfExists + if (callableId == null || !symbol.canBeCalledByFqName) return QuotedNamesAwareInsertionHandler(symbol.name) return ShorteningVariableInsertionHandler(callableId) } @@ -133,6 +134,20 @@ private class VariableLookupElementFactory { is KtConstructorParameterSymbol, is KtSetterParameterSymbol -> null } + + private val KtVariableLikeSymbol.canBeCalledByFqName: Boolean + get() = when (this) { + is KtKotlinPropertySymbol -> dispatchType == null && receiverType == null + + is KtEnumEntrySymbol -> true + + is KtJavaFieldSymbol, + is KtSyntheticJavaPropertySymbol, + is KtLocalVariableSymbol, + is KtFunctionParameterSymbol, + is KtConstructorParameterSymbol, + is KtSetterParameterSymbol -> false + } } private class FunctionLookupElementFactory {