-
Notifications
You must be signed in to change notification settings - Fork 455
fix: CommentOutProperty to work with single keys #4392
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
Conversation
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-java/src/main/java/org/openrewrite/java/table/ClasspathTypeCount.java
- lines 47-47
Thanks for the runnable example here @jonesbusy ! Had a brief look, and I suspect there's an logical error in the recipe. As a bit of background: comments are not floating elements, but attached to the next LST element. That allows them to move with the code, as opposed to having to always check of and move both with any restructuring. In this case, it seems the recipe has made the assumption that we can remove the comment, and add it to the "next" element. But in your case there is no next element, so the comment is accidentally lost. What we should be doing here (I think) is to add any left over comment to the |
Thanks for the hint. Really helpful. I will try to take a look at it and perform also more test when the key is not the last element of the document |
1f3d17f
to
ec5e0aa
Compare
I did a tentative to implement visitDocument. Not sure if it's the best approach (and if I understand it completly). But at least the tests added are passing now. Any other advice appreciated |
rewrite-yaml/src/main/java/org/openrewrite/yaml/CommentOutProperty.java
Outdated
Show resolved
Hide resolved
rewrite-yaml/src/test/java/org/openrewrite/yaml/CommentOutPropertyTest.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.
Thanks for taking this on! Exactly what I had in mind indeed; I've added & fixed another test case where there might be multiple documents, and with that I think we're good to merge once the tests pass.
Thanks for the fixed and merge! Much appreciated |
Just demonstrate it doesn't works as expected (or I didn't understood the recipe).
Instead of commenting out the property it's removed.
What's changed?
What's your motivation?
Anything in particular you'd like reviewers to focus on?
Anyone you would like to review specifically?
Have you considered any alternatives or workarounds?
Any additional context
Checklist