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
This commit is contained in:
Christian Vonrüti
2022-07-20 15:25:38 +00:00
committed by intellij-monorepo-bot
parent d77149caca
commit a0a226c03f
3 changed files with 6 additions and 2 deletions
@@ -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}''
@@ -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<KtCallExpression>()?.calleeExpression
?.let(::getExpressionShortText) ?: "?"
return KotlinBundle.message(key, callee, getExpressionShortText(target))
}
}
@@ -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")
};
}
}