Skip to content

Commit 3af8131

Browse files
committed
Add 'removeUnusedLambdaParameters' to the cleanup settings.
Signed-off-by: Roland Grunberg <[email protected]>
1 parent 86c2adf commit 3af8131

File tree

2 files changed

+54
-1
lines changed

2 files changed

+54
-1
lines changed

document/_java.learnMoreAboutCleanUps.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -405,4 +405,56 @@ public class A {
405405
Parser a12;
406406
}
407407
}
408+
```
409+
410+
### `removeUnusedLambdaParameters`
411+
412+
Rename unused lambda parameters, or unused pattern variables to `_`.
413+
414+
For example:
415+
416+
```java
417+
public class Unused {
418+
419+
private interface J {
420+
public void run(String a, String b);
421+
}
422+
423+
public static void main(String[] args) {
424+
record R(int i, long l) {}
425+
426+
J j = (a, b) -> System.out.println(a);
427+
j.run("a", "b");
428+
429+
R r = new R(1, 1);
430+
switch (r) {
431+
case R(_, long l) -> {}
432+
case R r2 -> {}
433+
}
434+
}
435+
}
436+
```
437+
438+
becomes:
439+
440+
```java
441+
public class Unused {
442+
443+
private interface J {
444+
public void run(String a, String b);
445+
}
446+
447+
public static void main(String[] args) {
448+
record R(int i, long l) {}
449+
450+
J j = (a, _) -> System.out.println(a);
451+
j.run("a", "b");
452+
453+
R r = new R(1, 1);
454+
switch (r) {
455+
case R(_, _) -> {}
456+
case R _ -> {}
457+
}
458+
}
459+
}
408460
```

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1313,7 +1313,8 @@
13131313
"switchExpression",
13141314
"tryWithResource",
13151315
"renameFileToType",
1316-
"organizeImports"
1316+
"organizeImports",
1317+
"removeUnusedLambdaParameters"
13171318
]
13181319
},
13191320
"default": [

0 commit comments

Comments
 (0)