diff --git a/plugins/kotlin/completion/impl-shared/src/org/jetbrains/kotlin/idea/completion/implCommon/stringTemplates/LambdaSignatureTemplates.kt b/plugins/kotlin/completion/impl-shared/src/org/jetbrains/kotlin/idea/completion/implCommon/stringTemplates/LambdaSignatureTemplates.kt index d31375dd12aa..84cd5ef4c43b 100644 --- a/plugins/kotlin/completion/impl-shared/src/org/jetbrains/kotlin/idea/completion/implCommon/stringTemplates/LambdaSignatureTemplates.kt +++ b/plugins/kotlin/completion/impl-shared/src/org/jetbrains/kotlin/idea/completion/implCommon/stringTemplates/LambdaSignatureTemplates.kt @@ -1,7 +1,6 @@ // Copyright 2000-2024 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package org.jetbrains.kotlin.idea.completion.implCommon.stringTemplates -import com.intellij.codeInsight.daemon.impl.quickfix.EmptyExpression import com.intellij.codeInsight.lookup.LookupElement import com.intellij.codeInsight.lookup.LookupElementBuilder import com.intellij.codeInsight.template.Expression @@ -14,11 +13,7 @@ import org.jetbrains.kotlin.analysis.api.renderer.base.annotations.KaRendererAnn import org.jetbrains.kotlin.analysis.api.renderer.types.KaTypeRenderer import org.jetbrains.kotlin.analysis.api.renderer.types.impl.KaTypeRendererForSource import org.jetbrains.kotlin.analysis.api.types.KaFunctionType -import org.jetbrains.kotlin.analysis.api.types.KaType -import org.jetbrains.kotlin.idea.base.codeInsight.KotlinNameSuggester -import org.jetbrains.kotlin.lexer.KtTokens import org.jetbrains.kotlin.name.Name -import org.jetbrains.kotlin.renderer.render @KaExperimentalApi private val NoAnnotationsTypeRenderer: KaTypeRenderer = KaTypeRendererForSource.WITH_QUALIFIED_NAMES.with { @@ -36,64 +31,65 @@ fun Template.build( isToShortenLongNames = true // isToReformat = true //TODO - for (index in 0 until parametersCount) { - if (index == 0) { - addTextSegment("(") - } - - addVariable( - /* expression = */ EmptyExpression(), - /* isAlwaysStopAt = */ true, - ) - - addTextSegment(if (index == parametersCount - 1) ")" else ", ") - } - - val typeNames = mutableMapOf>() - val kotlinNameSuggester = KotlinNameSuggester() + //for (index in 0 until parametersCount) { + // if (index == 0) { + // addTextSegment("(") + // } + // + // addVariable( + // /* expression = */ EmptyExpression(), + // /* isAlwaysStopAt = */ true, + // ) + // + // addTextSegment(if (index == parametersCount - 1) ")" else ", ") + //} + // + //val typeNames = mutableMapOf>() + //val kotlinNameSuggester = KotlinNameSuggester() addTextSegment(" { ") - val parameterTypes = trailingFunctionType.parameterTypes - .zip(suggestedParameterNames) - val iterator = parameterTypes.iterator() - while (iterator.hasNext()) { - val (parameterType, suggestedName) = iterator.next() - //TODO: check for names in scope - val validator = typeNames.getOrPut(parameterType) { - mutableSetOf() - }::add - - val items = (suggestedName?.let { sequenceOf(it.render()) } - ?: kotlinNameSuggester.suggestTypeNames(parameterType)) - .map { KotlinNameSuggester.suggestNameByName(it, validator) } - .toList() - - addVariable( - /* expression = */ LambdaParameterExpression(items), - /* isAlwaysStopAt = */ true, - ) - - //parameterType.render( - // renderer = NoAnnotationsTypeRenderer, - // position = Variance.INVARIANT, - //).let { typeText -> - // addTextSegment(KtTokens.COLON.value) - // addTextSegment(" ") - // addTextSegment(typeText) - //} - - if (iterator.hasNext()) { - addTextSegment(KtTokens.COMMA.value) - addTextSegment(" ") - } - } - - if (parameterTypes.isNotEmpty()) { - addTextSegment(" ") - addTextSegment(KtTokens.ARROW.value) - addTextSegment(" ") - } + //val parameterTypes = trailingFunctionType.parameterTypes + // .zip(suggestedParameterNames) + //val iterator = parameterTypes.iterator() + //while (iterator.hasNext()) { + // val (parameterType, suggestedName) = iterator.next() + // + // //TODO: check for names in scope + // val validator = typeNames.getOrPut(parameterType) { + // mutableSetOf() + // }::add + // + // val items = (suggestedName?.let { sequenceOf(it.render()) } + // ?: kotlinNameSuggester.suggestTypeNames(parameterType)) + // .map { KotlinNameSuggester.suggestNameByName(it, validator) } + // .toList() + // + // addVariable( + // /* expression = */ LambdaParameterExpression(items), + // /* isAlwaysStopAt = */ true, + // ) + // + // parameterType.render( + // renderer = NoAnnotationsTypeRenderer, + // position = Variance.INVARIANT, + // ).let { typeText -> + // addTextSegment(KtTokens.COLON.value) + // addTextSegment(" ") + // addTextSegment(typeText) + // } + // + // if (iterator.hasNext()) { + // addTextSegment(KtTokens.COMMA.value) + // addTextSegment(" ") + // } + //} + // + //if (parameterTypes.isNotEmpty()) { + // addTextSegment(" ") + // addTextSegment(KtTokens.ARROW.value) + // addTextSegment(" ") + //} addEndVariable() addTextSegment(" }") } diff --git a/plugins/kotlin/completion/testData/handlers/basic/TypeInferedFromWrapperType.fir.kt.after b/plugins/kotlin/completion/testData/handlers/basic/TypeInferedFromWrapperType.fir.kt.after index 62aef38e738c..97bb05a9320f 100644 --- a/plugins/kotlin/completion/testData/handlers/basic/TypeInferedFromWrapperType.fir.kt.after +++ b/plugins/kotlin/completion/testData/handlers/basic/TypeInferedFromWrapperType.fir.kt.after @@ -7,7 +7,7 @@ fun > C.some(arg: (type: T) -> Unit): C { fun main(args: Array) { val x = Cn() - x.some { type -> } + x.some { } } //ELEMENT: some diff --git a/plugins/kotlin/completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunction.fir.kt.after b/plugins/kotlin/completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunction.fir.kt.after index 6ddf308e9456..16e8affb2a60 100644 --- a/plugins/kotlin/completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunction.fir.kt.after +++ b/plugins/kotlin/completion/testData/handlers/basic/highOrderFunctions/HigherOrderFunction.fir.kt.after @@ -2,7 +2,7 @@ fun Array.filter(predicate: (element: T) -> Boolean): java.util.List = throw UnsupportedOperationException() fun main(args: Array) { - args.filter { element -> } + args.filter { } } // ELEMENT: filter diff --git a/plugins/kotlin/completion/testData/handlers/basic/highOrderFunctions/SameTypeParameters.fir.kt.after b/plugins/kotlin/completion/testData/handlers/basic/highOrderFunctions/SameTypeParameters.fir.kt.after index f290f85b6c3a..7a1e1a6a7590 100644 --- a/plugins/kotlin/completion/testData/handlers/basic/highOrderFunctions/SameTypeParameters.fir.kt.after +++ b/plugins/kotlin/completion/testData/handlers/basic/highOrderFunctions/SameTypeParameters.fir.kt.after @@ -3,7 +3,7 @@ fun foo(f: (Int, Int, Int) -> Unit) { } fun main() { - foo { i, i1, i2 -> } + foo { } } // ELEMENT: foo diff --git a/plugins/kotlin/completion/testData/handlers/basic/typeArgsForCall/FunctionTypeParameter1.fir.kt.after b/plugins/kotlin/completion/testData/handlers/basic/typeArgsForCall/FunctionTypeParameter1.fir.kt.after index a501d52aeb37..ffdf7d706f42 100644 --- a/plugins/kotlin/completion/testData/handlers/basic/typeArgsForCall/FunctionTypeParameter1.fir.kt.after +++ b/plugins/kotlin/completion/testData/handlers/basic/typeArgsForCall/FunctionTypeParameter1.fir.kt.after @@ -2,7 +2,7 @@ fun T1.foo(handler: (T2) -> Boolean) {} fun f() { - "".foo { value -> } + "".foo { } } // ELEMENT: foo diff --git a/plugins/kotlin/completion/testData/handlers/basic/typeArgsForCall/FunctionTypeParameter2.fir.kt.after b/plugins/kotlin/completion/testData/handlers/basic/typeArgsForCall/FunctionTypeParameter2.fir.kt.after index 36c3056e4375..96bcb299e959 100644 --- a/plugins/kotlin/completion/testData/handlers/basic/typeArgsForCall/FunctionTypeParameter2.fir.kt.after +++ b/plugins/kotlin/completion/testData/handlers/basic/typeArgsForCall/FunctionTypeParameter2.fir.kt.after @@ -1,6 +1,6 @@ // FIR_COMPARISON fun f(list: List) { - list.map { string -> } + list.map { } } // ELEMENT: map diff --git a/plugins/kotlin/completion/testData/handlers/basic/typeArgsForCall/FunctionTypeParameter3.fir.kt.after b/plugins/kotlin/completion/testData/handlers/basic/typeArgsForCall/FunctionTypeParameter3.fir.kt.after index df1e636e4013..b5250572e9de 100644 --- a/plugins/kotlin/completion/testData/handlers/basic/typeArgsForCall/FunctionTypeParameter3.fir.kt.after +++ b/plugins/kotlin/completion/testData/handlers/basic/typeArgsForCall/FunctionTypeParameter3.fir.kt.after @@ -2,7 +2,7 @@ fun T1.foo(handler: suspend (T2) -> Boolean) {} fun f() { - "".foo { value -> } + "".foo { } } // ELEMENT: foo diff --git a/plugins/kotlin/completion/testData/handlers/basic/typeArgsForGenericFun/WithParamFunc_LambdaExplicitInferrable.fir.kt.after b/plugins/kotlin/completion/testData/handlers/basic/typeArgsForGenericFun/WithParamFunc_LambdaExplicitInferrable.fir.kt.after index aed693bc9f2b..73bb0dd1d92e 100644 --- a/plugins/kotlin/completion/testData/handlers/basic/typeArgsForGenericFun/WithParamFunc_LambdaExplicitInferrable.fir.kt.after +++ b/plugins/kotlin/completion/testData/handlers/basic/typeArgsForGenericFun/WithParamFunc_LambdaExplicitInferrable.fir.kt.after @@ -7,7 +7,7 @@ fun > Iterable.mapTo(destination: C, transf fun main() { val strings = listOf("abc", "def") - strings.mapTo(mutableSetOf(), { it.length }).map { i -> } + strings.mapTo(mutableSetOf(), { it.length }).map { } } // ELEMENT: map // TAIL_TEXT: " { transform: (Int) -> R } for Iterable in kotlin.collections" \ No newline at end of file