`UseTextBlocks` should not delete comments
Closed this issue · 4 comments
Hi - there are two problems with the way text blocks are being created, illustrated in this image.
- The comments in the original have been deleted. There is no good way to insert comments into a text block, but in such cases you could just leave the old syntax in place.
- When you're creating text block within an annotation like this, there is no need for the trailing
\
. I admit this might be hard to detect and do correctly and reliably. Perhaps there could be an option though.
This bug report is really about 1.
I am using the Gradle plugin, version 6.6.4.
Hi @aholland ; thanks for pointing that out! Yes indeed we should not convert to text blocks when there's comments; a case currently missed in UseTextBlocks
If you'd want to help out retain comments the quickest way is likely to add a draft PR with a new test, based on this existing test, but with a comment thrown in somewhere in the middle. Ideally we convert none of it to text blocks.
Your second comment of ending up with trailing slashes in SQL queries is maybe best handled with a run of our Format SQL recipe: https://docs.openrewrite.org/recipes/sql/formatsql. I think that ought to already introduce newlines, as seen in the tests.
Hello @timtebeek i think that this issue was already fixed, i maked some test and we are not converting to text blocks when there's comments.
Awesome, thanks a lot for confirming!