Commit 241a923
Fix RemoveUnusedPrivateFields for Lombok annotations after visibility modifiers (#759)
* Fix RemoveUnusedPrivateFields to detect annotations after visibility modifiers
The recipe was incorrectly removing Lombok-annotated fields when the annotation
was placed after the visibility modifier (e.g., `private @Getter String foo;`)
instead of before it (e.g., `@Getter private String foo;`).
The fix adds a helper method `hasAnyAnnotations()` that checks for both:
- Leading annotations (before modifiers)
- Type annotations (after modifiers, stored as J.AnnotatedType)
Fixes #757
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
* Simplify approach
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ce75f31 commit 241a923
File tree
2 files changed
+28
-0
lines changed- src
- main/java/org/openrewrite/staticanalysis
- test/java/org/openrewrite/staticanalysis
2 files changed
+28
-0
lines changedLines changed: 2 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| |||
138 | 139 | | |
139 | 140 | | |
140 | 141 | | |
| 142 | + | |
141 | 143 | | |
142 | 144 | | |
143 | 145 | | |
| |||
Lines changed: 26 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
448 | 448 | | |
449 | 449 | | |
450 | 450 | | |
| 451 | + | |
| 452 | + | |
| 453 | + | |
| 454 | + | |
| 455 | + | |
| 456 | + | |
| 457 | + | |
| 458 | + | |
| 459 | + | |
| 460 | + | |
| 461 | + | |
| 462 | + | |
| 463 | + | |
| 464 | + | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
| 474 | + | |
| 475 | + | |
| 476 | + | |
451 | 477 | | |
452 | 478 | | |
453 | 479 | | |
| |||
0 commit comments