From 6d7084b7b4923d3f25b8bab87d24f4fa5ea5da9c Mon Sep 17 00:00:00 2001 From: Roland Grunberg Date: Wed, 13 Nov 2024 09:51:27 -0500 Subject: [PATCH] Add 'removeUnusedLambdaParameters' to the cleanup settings. Signed-off-by: Roland Grunberg --- document/_java.learnMoreAboutCleanUps.md | 26 ++++++++++++++++++++++++ package.json | 3 ++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/document/_java.learnMoreAboutCleanUps.md b/document/_java.learnMoreAboutCleanUps.md index a6b8e3cbd6..36d74d746c 100644 --- a/document/_java.learnMoreAboutCleanUps.md +++ b/document/_java.learnMoreAboutCleanUps.md @@ -405,4 +405,30 @@ public class A { Parser a12; } } +``` + +### `removeUnusedLambdaParameters` + +Rename unused lambda parameters, or unused pattern variables to `_`. + +For example: + +```java +J j = (a, b) -> System.out.println(a); + +switch (r) { + case R(_, long l) -> {} + case R r2 -> {} +} +``` + +becomes: + +```java +J j = (a, _) -> System.out.println(a); + +switch (r) { + case R(_, _) -> {} + case R _ -> {} +} ``` \ No newline at end of file diff --git a/package.json b/package.json index f702896caa..8fbaabe8bb 100644 --- a/package.json +++ b/package.json @@ -1313,7 +1313,8 @@ "switchExpression", "tryWithResource", "renameFileToType", - "organizeImports" + "organizeImports", + "removeUnusedLambdaParameters" ] }, "default": [