-
Notifications
You must be signed in to change notification settings - Fork 354
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Append items to annotation attribute array #4667
Append items to annotation attribute array #4667
Conversation
I think your first proposed option is the way to go. You'd want to separately be able to specify whether you only want to add a property value when it's missing but also be able to specify whether you want to replace or append the new value(s) |
f49737c
to
268f576
Compare
rewrite-java/src/main/java/org/openrewrite/java/AddOrUpdateAnnotationAttribute.java
Outdated
Show resolved
Hide resolved
rewrite-java/src/main/java/org/openrewrite/java/AddOrUpdateAnnotationAttribute.java
Outdated
Show resolved
Hide resolved
rewrite-java/src/main/java/org/openrewrite/java/AddOrUpdateAnnotationAttribute.java
Outdated
Show resolved
Hide resolved
rewrite-java/src/main/java/org/openrewrite/java/AddOrUpdateAnnotationAttribute.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved aside from the last suggestion; let me know then we can merge right after.
…otationAttribute.java Co-authored-by: Tim te Beek <tim@moderne.io>
* Add some initial tests * Add append functionality * Add markers * Fix constructor after merge * Polish code * Verify default behavior retained for declarative recipes through use of `null` in tests * Add test that fails due to unexpected second cycle * Adopt Markers.findFirst * Add newline to indicate Marker is on assignment * Fix test and polish * Update rewrite-java/src/main/java/org/openrewrite/java/AddOrUpdateAnnotationAttribute.java Co-authored-by: Tim te Beek <tim@moderne.io> --------- Co-authored-by: Tim te Beek <tim@moderne.io>
What's changed?
This PR enhances the functionality of the
AddOrUpdateAnnotationAttribute
recipe, allowing not only to override but also to append to array values. A new option,arrayAppend
, has been introduced, enabling users to append to attributes with anarray
type. When used in conjunction with theaddOnly
option, users can control whether a value will be appended only if it is not already present, thereby avoiding duplication.What's your motivation?
AddOrUpdateAnnotationAttribute
to add values to an array #4157Anyone you would like to review specifically?
@timtebeek @Laurens-W
Checklist