-
Notifications
You must be signed in to change notification settings - Fork 365
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
Add PlaintextOnly Option to FindAndReplace Recipe #4277
Add PlaintextOnly Option to FindAndReplace Recipe #4277
Conversation
…e recipe from executing on non-plaintext files and causing Language specific LST information loss.
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.
Good suggestion indeed! Prevents accidental LST type loss, so good safe addition. Some minor suggestions and a note for myself to look closer.
rewrite-core/src/main/java/org/openrewrite/text/FindAndReplace.java
Outdated
Show resolved
Hide resolved
rewrite-core/src/main/java/org/openrewrite/text/FindAndReplace.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.
Great addition!
As suggested in - openrewrite/rewrite#4277 - #538
Also applied downstream in openrewrite/rewrite-spring@7fb21ed |
* Added a PlaintextOnly property to FindAndReplace recipe to prevent the recipe from executing on non-plaintext files and causing Language specific LST information loss. * Removed constructors
What's changed?
Added a Plaintext Only option to the find and replace recipe, which when enabled, limits the recipe to only act on plaintext files. This option defaults to false.
What's your motivation?
FindAndReplace by default replaces text in for most sourcefile types, which may not be desirable in certain cases since this recipe coverts any sourcefile to a plaintext file, thereby causing information loss for the rest of the recipe run. Enabling this flag limits the recipe scope to plaintext files for cases where a user only wants to replace something thats already parsed as a plaintext file.
For example, this flag could prove useful in this PR where we only want to touch manifest and dockerfiles.