From f58f5dd82a10289e1959984366ead34d15d0e129 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Thu, 1 Oct 2015 22:33:43 +0300 Subject: [PATCH] Added parameters and type text (grayed) to "::xxx" items in smart completion --- .../kotlin/idea/completion/smart/SmartCompletion.kt | 9 +++------ .../testData/smart/callableReference/NoQualifier1.kt | 2 +- .../idea/completion/test/ExpectedCompletionUtils.kt | 4 +--- 3 files changed, 5 insertions(+), 10 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt index 1ca36e87d5e..625090d3069 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/smart/SmartCompletion.kt @@ -324,16 +324,13 @@ class SmartCompletion( if (matchedExpectedInfos.isEmpty()) return null var lookupElement = lookupElementFactory.createLookupElement(descriptor, useReceiverTypes = false, parametersAndTypeGrayed = true) - val text = "::" + (if (descriptor is ConstructorDescriptor) descriptor.getContainingDeclaration().getName() else descriptor.getName()) lookupElement = object: LookupElementDecorator(lookupElement) { - override fun getLookupString() = text - override fun getAllLookupStrings() = setOf(text) + override fun getLookupString() = "::" + delegate.lookupString + override fun getAllLookupStrings() = setOf(lookupString) override fun renderElement(presentation: LookupElementPresentation) { super.renderElement(presentation) - presentation.setItemText(text) - presentation.clearTail() - presentation.setTypeText(null) + presentation.itemText = "::" + presentation.itemText } override fun handleInsert(context: InsertionContext) { diff --git a/idea/idea-completion/testData/smart/callableReference/NoQualifier1.kt b/idea/idea-completion/testData/smart/callableReference/NoQualifier1.kt index 1d57eea8997..80325150e80 100644 --- a/idea/idea-completion/testData/smart/callableReference/NoQualifier1.kt +++ b/idea/idea-completion/testData/smart/callableReference/NoQualifier1.kt @@ -7,7 +7,7 @@ fun bar() { fun f1(){} fun f2(i: Int){} -// EXIST: { lookupString:"::f1", itemText:"::f1", tailText:null, typeText:null } +// EXIST: { lookupString: "::f1", itemText: "::f1", tailText: "() ()", typeText: "Unit" } // ABSENT: ::f2 // ABSENT: ::Unit // ABSENT: ::Nothing diff --git a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/ExpectedCompletionUtils.kt b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/ExpectedCompletionUtils.kt index 478bd236b23..dcc1777c772 100644 --- a/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/ExpectedCompletionUtils.kt +++ b/idea/idea-completion/tests/org/jetbrains/kotlin/idea/completion/test/ExpectedCompletionUtils.kt @@ -64,9 +64,7 @@ public object ExpectedCompletionUtils { throw RuntimeException("Invalid json property '$key'") } val value = entry.value - if (value !is JsonNull) { - map.put(key, value.asString) - } + map.put(key, if (value !is JsonNull) value.asString else null) } }