Skip to content

Commit

Permalink
Mention regular expressions in the recipe description.
Browse files Browse the repository at this point in the history
  • Loading branch information
sambsnyd committed Jun 13, 2024
1 parent 7182d7b commit 3e06d4f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
4 changes: 2 additions & 2 deletions rewrite-core/src/main/java/org/openrewrite/text/Find.java
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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;
Expand Down
27 changes: 14 additions & 13 deletions rewrite-core/src/main/java/org/openrewrite/text/FindAndReplace.java
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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;
Expand Down Expand Up @@ -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<?, ExecutionContext> getVisitor() {
TreeVisitor<?, ExecutionContext> visitor = new TreeVisitor<Tree, ExecutionContext>() {
Expand Down

0 comments on commit 3e06d4f

Please sign in to comment.