From 731f19ee3658653229b923a25923da0242c69ad4 Mon Sep 17 00:00:00 2001 From: Valentin Kipyatkov Date: Tue, 3 Nov 2015 21:39:29 +0300 Subject: [PATCH] Changed behavior --- .../idea/completion/InsertHandlerProvider.kt | 15 +++++++++------ .../idea/completion/LookupElementFactory.kt | 2 +- .../testData/basic/common/SuperMembers.kt | 4 ++-- 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt index 7167587e820..2b5d9ad61ee 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/InsertHandlerProvider.kt @@ -47,14 +47,17 @@ class InsertHandlerProvider( 0 -> KotlinFunctionInsertHandler.Normal(needTypeArguments, inputValueArguments = false) 1 -> { - val parameterType = parameters.single().getType() - if (KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(parameterType)) { - val parameterCount = KotlinBuiltIns.getParameterTypeProjectionsFromFunctionType(parameterType).size() - if (parameterCount <= 1) { - // otherwise additional item with lambda template is to be added - return KotlinFunctionInsertHandler.Normal(needTypeArguments, inputValueArguments = false, lambdaInfo = GenerateLambdaInfo(parameterType, false)) + if (callType != CallType.SUPER_MEMBERS) { // for super call we don't suggest to generate "super.foo { ... }" (seems to be non-typical use) + val parameterType = parameters.single().getType() + if (KotlinBuiltIns.isExactFunctionOrExtensionFunctionType(parameterType)) { + val parameterCount = KotlinBuiltIns.getParameterTypeProjectionsFromFunctionType(parameterType).size() + if (parameterCount <= 1) { + // otherwise additional item with lambda template is to be added + return KotlinFunctionInsertHandler.Normal(needTypeArguments, inputValueArguments = false, lambdaInfo = GenerateLambdaInfo(parameterType, false)) + } } } + KotlinFunctionInsertHandler.Normal(needTypeArguments, inputValueArguments = true) } diff --git a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt index 56d4e56bb75..eefacdfa4d4 100644 --- a/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt +++ b/idea/idea-completion/src/org/jetbrains/kotlin/idea/completion/LookupElementFactory.kt @@ -66,7 +66,7 @@ class LookupElementFactory( result.add(lookupElement) // add special item for function with one argument of function type with more than one parameter - if (descriptor is FunctionDescriptor && isNormalCall) { + if (descriptor is FunctionDescriptor && isNormalCall && callType != CallType.SUPER_MEMBERS) { result.addSpecialFunctionCallElements(descriptor, useReceiverTypes) } diff --git a/idea/idea-completion/testData/basic/common/SuperMembers.kt b/idea/idea-completion/testData/basic/common/SuperMembers.kt index 5b0a7545b74..cdc0918a0e1 100644 --- a/idea/idea-completion/testData/basic/common/SuperMembers.kt +++ b/idea/idea-completion/testData/basic/common/SuperMembers.kt @@ -49,6 +49,6 @@ abstract class A : Base(), I { // EXIST_JAVA_ONLY: { itemText: "getAbsolutePath", attributes: "" } // ABSENT: absolutePath -// EXIST: { itemText: "onLambda1", tailText: " {...} (p: () -> Unit)", attributes: "" } +// EXIST: { itemText: "onLambda1", tailText: "(p: () -> Unit)", attributes: "" } // EXIST: { itemText: "onLambda2", tailText: "(p: (Int, String) -> Unit)", attributes: "" } -// EXIST: { itemText: "onLambda2", tailText: " { Int, String -> ... } (p: (Int, String) -> Unit)", attributes: "" } +// ABSENT: { itemText: "onLambda2", tailText: " { Int, String -> ... } (p: (Int, String) -> Unit)" }