Skip to content
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

Merged

Conversation

ryan-hudson
Copy link
Contributor

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.

…e recipe from executing on non-plaintext files and causing Language specific LST information loss.
Copy link
Contributor

@timtebeek timtebeek left a 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.

@timtebeek timtebeek self-requested a review June 22, 2024 09:32
@timtebeek timtebeek added the enhancement New feature or request label Jun 22, 2024
Copy link
Contributor

@timtebeek timtebeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great addition!

@timtebeek timtebeek merged commit 08a386c into openrewrite:main Jun 24, 2024
2 checks passed
timtebeek added a commit to openrewrite/rewrite-spring that referenced this pull request Jun 24, 2024
@timtebeek
Copy link
Contributor

Also applied downstream in openrewrite/rewrite-spring@7fb21ed

crankydillo pushed a commit to crankydillo/rewrite that referenced this pull request Jul 11, 2024
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants