From a0a226c03f8e53fecae0d1e61cb49e2cd5c73f04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Vonr=C3=BCti?= Date: Sat, 23 Apr 2022 13:14:48 +0200 Subject: [PATCH] Improve speed search for unwrapping parameters in Kotlin Unwrap parameter actions now look like "Unwrap 'println' arg '123'" instead of "Unwrap '123'" Thus, speed search for "unarg" will only show unwrapping parameter actions, hiding the other noise. You can also search for which outer method call to remove/unwrap. closes https://github.com/JetBrains/intellij-community/pull/1996 GitOrigin-RevId: 600066e68fa9fcb3c1dad8a559aee0534a3add21 --- .../resources/resources-en/messages/KotlinBundle.properties | 1 + .../codeInsight/unwrap/KotlinFunctionParameterUnwrapper.kt | 5 ++++- .../idea/codeInsight/unwrap/KotlinUnwrapDescriptor.java | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/plugins/kotlin/base/resources/resources-en/messages/KotlinBundle.properties b/plugins/kotlin/base/resources/resources-en/messages/KotlinBundle.properties index b6931e688206..95bf291151c1 100644 --- a/plugins/kotlin/base/resources/resources-en/messages/KotlinBundle.properties +++ b/plugins/kotlin/base/resources/resources-en/messages/KotlinBundle.properties @@ -242,6 +242,7 @@ overridden.marker.overrides.choose.implementation.find.usages=Super Implementati remove.expression=Remove ''{0}'' unwrap.expression=Unwrap ''{0}'' +unwrap.parameter=Unwrap ''{0}'' arg ''{1}'' remove.else=Remove else in ''{0}'' unwrap.else=Unwrap else in ''{0}'' diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/codeInsight/unwrap/KotlinFunctionParameterUnwrapper.kt b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/codeInsight/unwrap/KotlinFunctionParameterUnwrapper.kt index 795f4b466714..94a4e924e438 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/codeInsight/unwrap/KotlinFunctionParameterUnwrapper.kt +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/codeInsight/unwrap/KotlinFunctionParameterUnwrapper.kt @@ -186,6 +186,9 @@ class KotlinFunctionParameterUnwrapper(val key: String) : KotlinUnwrapRemoveBase // but because we support the caret to be on LPAR/COMMA and other tokens this doesn't work val target = argumentToUnwrap(e) ?: error("Description asked for a non applicable unwrapper") - return KotlinBundle.message(key, getExpressionShortText(target)) + val callee = target.getStrictParentOfType()?.calleeExpression + ?.let(::getExpressionShortText) ?: "?" + + return KotlinBundle.message(key, callee, getExpressionShortText(target)) } } diff --git a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/codeInsight/unwrap/KotlinUnwrapDescriptor.java b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/codeInsight/unwrap/KotlinUnwrapDescriptor.java index c289b18109e5..d05ca7fbd480 100644 --- a/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/codeInsight/unwrap/KotlinUnwrapDescriptor.java +++ b/plugins/kotlin/idea/src/org/jetbrains/kotlin/idea/codeInsight/unwrap/KotlinUnwrapDescriptor.java @@ -20,7 +20,7 @@ public class KotlinUnwrapDescriptor extends UnwrapDescriptorBase { new KotlinUnwrappers.KotlinFinallyUnwrapper("unwrap.expression"), new KotlinUnwrappers.KotlinFinallyRemover("remove.expression"), new KotlinLambdaUnwrapper("unwrap.expression"), - new KotlinFunctionParameterUnwrapper("unwrap.expression") + new KotlinFunctionParameterUnwrapper("unwrap.parameter") }; } }