Skip to content

Fix annotation handling in LombokValToFinalVar - #1237

Merged
greg-at-moderne merged 1 commit into
openrewrite:mainfrom
sullis:lombok-val-with-annotation
Sep 11, 2026
Merged

Fix annotation handling in LombokValToFinalVar#1237
greg-at-moderne merged 1 commit into
openrewrite:mainfrom
sullis:lombok-val-with-annotation

Conversation

@sullis

@sullis sullis commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

When building the replacement var identifier, the recipe used AnnotationService.getAllAnnotations(getCursor()). At that point the cursor is on the J.VariableDeclarations, so this returns the annotations of the whole declaration (e.g. a @SuppressWarnings("unchecked") on the statement), not the annotations attached to the type expression. Those declaration-level annotations were then attached to the new var identifier as well, leaving them printed twice.

This takes the annotations from the type expression itself instead, which is what the new type identifier should carry over. Declaration-level annotations stay where they already are on the J.VariableDeclarations.

Added a test covering @SuppressWarnings("unchecked") on a val declaration.

🤖 Generated with Claude Code

@sullis

sullis commented Sep 10, 2026

Copy link
Copy Markdown
Contributor Author

cc: @greg-at-moderne @timtebeek

@greg-at-moderne
greg-at-moderne self-requested a review September 11, 2026 07:13
@github-project-automation github-project-automation Bot moved this from In Progress to Ready to Review in OpenRewrite Sep 11, 2026
@greg-at-moderne

Copy link
Copy Markdown
Contributor

The CI failure seems unrelated. Yet I fail to understand why it would be happening in this branch, but not happening in main.

@greg-at-moderne

Copy link
Copy Markdown
Contributor

OK. I think I get it. The branch is in the fork (understandably) and we don't want to share Code Genome secrets.

@greg-at-moderne
greg-at-moderne merged commit 108e946 into openrewrite:main Sep 11, 2026
0 of 2 checks passed
@github-project-automation github-project-automation Bot moved this from Ready to Review to Done in OpenRewrite Sep 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants