Skip to content

Commit 3e06d4f

Browse files
committed
Mention regular expressions in the recipe description.
1 parent 7182d7b commit 3e06d4f

File tree

2 files changed

+16
-15
lines changed

2 files changed

+16
-15
lines changed

rewrite-core/src/main/java/org/openrewrite/text/Find.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public String getDisplayName() {
4646

4747
@Override
4848
public String getDescription() {
49-
return "Search for text, treating all textual sources as plain text.";
49+
return "Textual search, optionally using Regular Expression (regex) to query.";
5050
}
5151

5252
@Option(displayName = "Find",
@@ -55,7 +55,7 @@ public String getDescription() {
5555
String find;
5656

5757
@Option(displayName = "Regex",
58-
description = "If true, `find` will be interpreted as a Regular Expression. Default `false`.",
58+
description = "If true, `find` will be interpreted as a [Regular Expression](https://en.wikipedia.org/wiki/Regular_expression). Default `false`.",
5959
required = false)
6060
@Nullable
6161
Boolean regex;

rewrite-core/src/main/java/org/openrewrite/text/FindAndReplace.java

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,19 @@
3737
@EqualsAndHashCode(callSuper = false)
3838
public class FindAndReplace extends Recipe {
3939

40+
@Override
41+
public String getDisplayName() {
42+
return "Find and replace";
43+
}
44+
45+
@Override
46+
public String getDescription() {
47+
return "Textual find and replace, optionally interpreting the search query as a Regular Expression (regex). " +
48+
"When operating on source files that are language-specific Lossless Semantic " +
49+
"Tree, such as Java or XML, this operation converts the source file to plain text for the rest of the recipe run. " +
50+
"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.";
51+
}
52+
4053
@Option(displayName = "Find",
4154
description = "The text to find (and replace). This snippet can be multiline.",
4255
example = "blacklist")
@@ -50,7 +63,7 @@ public class FindAndReplace extends Recipe {
5063
String replace;
5164

5265
@Option(displayName = "Regex",
53-
description = "Default false. If true, `find` will be interpreted as a Regular Expression, and capture group contents will be available in `replace`.",
66+
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`.",
5467
required = false)
5568
@Nullable
5669
Boolean regex;
@@ -86,18 +99,6 @@ public class FindAndReplace extends Recipe {
8699
@Nullable
87100
String filePattern;
88101

89-
@Override
90-
public String getDisplayName() {
91-
return "Find and replace";
92-
}
93-
94-
@Override
95-
public String getDescription() {
96-
return "Simple text find and replace. When the original source file is a language-specific Lossless Semantic " +
97-
"Tree, this operation irreversibly converts the source file to a plain text file. Subsequent recipes " +
98-
"will not be able to operate on language-specific type.";
99-
}
100-
101102
@Override
102103
public TreeVisitor<?, ExecutionContext> getVisitor() {
103104
TreeVisitor<?, ExecutionContext> visitor = new TreeVisitor<Tree, ExecutionContext>() {

0 commit comments

Comments
 (0)