-
Notifications
You must be signed in to change notification settings - Fork 357
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
feat: recipe for adding a key value pair to a json #4341
base: main
Are you sure you want to change the base?
Conversation
rewrite-json/src/main/java/org/openrewrite/json/AddKeyValue.java
Outdated
Show resolved
Hide resolved
rewrite-json/src/main/java/org/openrewrite/json/AddKeyValue.java
Outdated
Show resolved
Hide resolved
rewrite-json/src/main/java/org/openrewrite/json/AddKeyValue.java
Outdated
Show resolved
Hide resolved
rewrite-json/src/test/java/org/openrewrite/json/AddKeyValueTest.java
Outdated
Show resolved
Hide resolved
rewrite-json/src/test/java/org/openrewrite/json/AddKeyValueTest.java
Outdated
Show resolved
Hide resolved
rewrite-json/src/test/java/org/openrewrite/json/AddKeyValueTest.java
Outdated
Show resolved
Hide resolved
rewrite-json/src/test/java/org/openrewrite/json/AddKeyValueTest.java
Outdated
Show resolved
Hide resolved
rewrite-json/src/test/java/org/openrewrite/json/AddKeyValueTest.java
Outdated
Show resolved
Hide resolved
rewrite-json/src/main/java/org/openrewrite/json/AddKeyValue.java
Outdated
Show resolved
Hide resolved
Thanks for the work here @dpozinen ! I'll review after I come back home Sunday. Also, it seems like the automated suggestions broke compilation after being applied
|
rewrite-json/src/main/java/org/openrewrite/json/AddKeyValue.java
Outdated
Show resolved
Hide resolved
rewrite-json/src/main/java/org/openrewrite/json/AddKeyValue.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.
Some suggestions could not be made:
- rewrite-gradle/src/main/groovy/RewriteSettings.groovy
- lines 31-36
rewrite-json/src/test/java/org/openrewrite/json/AddKeyValueTest.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.
Some suggestions could not be made:
- rewrite-gradle/src/main/groovy/RewriteSettings.groovy
- lines 31-36
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.
Some suggestions could not be made:
- rewrite-gradle/src/main/groovy/RewriteSettings.groovy
- lines 31-36
rewrite-json/src/test/java/org/openrewrite/json/AddKeyValueTest.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.
Took me a little while longer to get to this one; looking quite good already. One thing I would still like to change is the formatting used when we append to existing elements. Right now that retains the newline before the comma introduced, where I think this will look better if that comma is on the same line as the line before it. Do you see an option to work that in still @dpozinen ?
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.
Some suggestions could not be made:
- rewrite-gradle/src/main/groovy/RewriteSettings.groovy
- lines 31-36
I only just now see you had logged an issue along those exact lines; thanks again! It's not always easy to keep up. :) |
Hi, yeah, I'm not entirely sure where to start with this issue, do I need to create a new style? I'll see when I have the time to get more in depth into how rewrite writes the LST, because the comma isn't part of spacing/padding of the element and is added somewhere internally I also see you made some changes to the logic namely here. Not sure why when appending ( |
What's changed?
Added recipe to add a new key and value to a json.
What's your motivation?
Currently, we can rename keys and change values, but can't add new entries to a json