Skip to content

Add option addLast to recipe AddOrUpdateAnnotationAttribute - #8765

Open
ghusta wants to merge 1 commit into
openrewrite:mainfrom
ghusta:feature/add-addLast-option-to-AddOrUpdateAnnotationAttribute
Open

Add option addLast to recipe AddOrUpdateAnnotationAttribute#8765
ghusta wants to merge 1 commit into
openrewrite:mainfrom
ghusta:feature/add-addLast-option-to-AddOrUpdateAnnotationAttribute

Conversation

@ghusta

@ghusta ghusta commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What's changed?

Added option addLast to recipe AddOrUpdateAnnotationAttribute.

What's your motivation?

So far, when an annotation attribute is added, it is inserted at the first position in the attributes list.

This new option will insert a new attibute at last position when true.

Checklist

@kdelay kdelay left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addLast=true mangles annotations whose arguments span lines. On 05644eb,
("org.junit.Test", "value", "1", null, true, false, true) turns

@Test(
        other = 0
)

into

@Test(
        other = 0
        , value = 1)

The whitespace before ) is the last argument's right padding, so appending
after it renders that padding before the new comma. addLast=null on the same
input stays well formed. Moving the padding onto the appended argument yields
other = 0, value = 1 inside the parens and keeps all 81 tests in the class green.

@ghusta

ghusta commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@kdelay Thanks for your feedback 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: In Progress

Development

Successfully merging this pull request may close these issues.

2 participants