From 3e06d4f5719521f5cc65592438e9e58643b409f7 Mon Sep 17 00:00:00 2001 From: Sam Snyder Date: Thu, 13 Jun 2024 15:06:10 -0700 Subject: [PATCH] Mention regular expressions in the recipe description. --- .../main/java/org/openrewrite/text/Find.java | 4 +-- .../org/openrewrite/text/FindAndReplace.java | 27 ++++++++++--------- 2 files changed, 16 insertions(+), 15 deletions(-) diff --git a/rewrite-core/src/main/java/org/openrewrite/text/Find.java b/rewrite-core/src/main/java/org/openrewrite/text/Find.java index 5a631495016..d9270d801d6 100644 --- a/rewrite-core/src/main/java/org/openrewrite/text/Find.java +++ b/rewrite-core/src/main/java/org/openrewrite/text/Find.java @@ -46,7 +46,7 @@ public String getDisplayName() { @Override public String getDescription() { - return "Search for text, treating all textual sources as plain text."; + return "Textual search, optionally using Regular Expression (regex) to query."; } @Option(displayName = "Find", @@ -55,7 +55,7 @@ public String getDescription() { String find; @Option(displayName = "Regex", - description = "If true, `find` will be interpreted as a Regular Expression. Default `false`.", + description = "If true, `find` will be interpreted as a [Regular Expression](https://en.wikipedia.org/wiki/Regular_expression). Default `false`.", required = false) @Nullable Boolean regex; diff --git a/rewrite-core/src/main/java/org/openrewrite/text/FindAndReplace.java b/rewrite-core/src/main/java/org/openrewrite/text/FindAndReplace.java index a24333a9094..f7d7b0f14b0 100644 --- a/rewrite-core/src/main/java/org/openrewrite/text/FindAndReplace.java +++ b/rewrite-core/src/main/java/org/openrewrite/text/FindAndReplace.java @@ -37,6 +37,19 @@ @EqualsAndHashCode(callSuper = false) public class FindAndReplace extends Recipe { + @Override + public String getDisplayName() { + return "Find and replace"; + } + + @Override + public String getDescription() { + return "Textual find and replace, optionally interpreting the search query as a Regular Expression (regex). " + + "When operating on source files that are language-specific Lossless Semantic " + + "Tree, such as Java or XML, this operation converts the source file to plain text for the rest of the recipe run. " + + "So if you are combining this recipe with language-specific recipes in a single recipe run put all the language-specific recipes before this recipe."; + } + @Option(displayName = "Find", description = "The text to find (and replace). This snippet can be multiline.", example = "blacklist") @@ -50,7 +63,7 @@ public class FindAndReplace extends Recipe { String replace; @Option(displayName = "Regex", - description = "Default false. If true, `find` will be interpreted as a Regular Expression, and capture group contents will be available in `replace`.", + description = "Default false. If true, `find` will be interpreted as a [Regular Expression](https://en.wikipedia.org/wiki/Regular_expression), and capture group contents will be available in `replace`.", required = false) @Nullable Boolean regex; @@ -86,18 +99,6 @@ public class FindAndReplace extends Recipe { @Nullable String filePattern; - @Override - public String getDisplayName() { - return "Find and replace"; - } - - @Override - public String getDescription() { - return "Simple text find and replace. When the original source file is a language-specific Lossless Semantic " + - "Tree, this operation irreversibly converts the source file to a plain text file. Subsequent recipes " + - "will not be able to operate on language-specific type."; - } - @Override public TreeVisitor getVisitor() { TreeVisitor visitor = new TreeVisitor() {