Skip to content

Commit

Permalink
Revert "SimplifyBooleanExpressionVisitor removed need for Unnecessary…
Browse files Browse the repository at this point in the history
…ParenthesesVisitor"

This reverts commit c752297.
  • Loading branch information
timtebeek committed Aug 19, 2023
1 parent c752297 commit 767d683
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ public class RefasterTemplateProcessor extends AbstractProcessor {

static Set<String> DO_AFTER_VISIT = Stream.of(
"new org.openrewrite.java.ShortenFullyQualifiedTypeReferences().getVisitor()",
"new org.openrewrite.java.cleanup.UnnecessaryParenthesesVisitor()",
"new org.openrewrite.java.cleanup.SimplifyBooleanExpressionVisitor()"
).collect(Collectors.toCollection(LinkedHashSet::new));

Expand Down
2 changes: 2 additions & 0 deletions src/test/resources/recipes/MultipleDereferencesRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public J visitMethodInvocation(J.MethodInvocation elem, ExecutionContext ctx) {
JavaTemplate.Matcher matcher;
if ((matcher = before.matcher(getCursor())).find()) {
doAfterVisit(new org.openrewrite.java.ShortenFullyQualifiedTypeReferences().getVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.UnnecessaryParenthesesVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.SimplifyBooleanExpressionVisitor());
return after.apply(getCursor(), elem.getCoordinates().replace(), matcher.parameter(0), matcher.parameter(0));
}
Expand Down Expand Up @@ -92,6 +93,7 @@ public J visitBinary(J.Binary elem, ExecutionContext ctx) {
JavaTemplate.Matcher matcher;
if ((matcher = before.matcher(getCursor())).find()) {
doAfterVisit(new org.openrewrite.java.ShortenFullyQualifiedTypeReferences().getVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.UnnecessaryParenthesesVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.SimplifyBooleanExpressionVisitor());
return after.apply(getCursor(), elem.getCoordinates().replace());
}
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/recipes/NestedPreconditionsRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ public J visitExpression(Expression elem, ExecutionContext ctx) {
maybeRemoveImport("java.util.HashMap");
maybeAddImport("java.util.Hashtable");
doAfterVisit(new org.openrewrite.java.ShortenFullyQualifiedTypeReferences().getVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.UnnecessaryParenthesesVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.SimplifyBooleanExpressionVisitor());
return hashtable.apply(getCursor(), elem.getCoordinates().replace(), matcher.parameter(0));
}
Expand Down
3 changes: 3 additions & 0 deletions src/test/resources/recipes/ShouldAddImportsRecipes.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ public J visitMethodInvocation(J.MethodInvocation elem, ExecutionContext ctx) {
if ((matcher = before.matcher(getCursor())).find()) {
maybeAddImport("java.util.Objects");
doAfterVisit(new org.openrewrite.java.ShortenFullyQualifiedTypeReferences().getVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.UnnecessaryParenthesesVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.SimplifyBooleanExpressionVisitor());
return after.apply(getCursor(), elem.getCoordinates().replace(), matcher.parameter(0));
}
Expand Down Expand Up @@ -99,6 +100,7 @@ public J visitMethodInvocation(J.MethodInvocation elem, ExecutionContext ctx) {
if ((matcher = equals.matcher(getCursor())).find() || (matcher = compareZero.matcher(getCursor())).find()) {
maybeRemoveImport("java.util.Objects");
doAfterVisit(new org.openrewrite.java.ShortenFullyQualifiedTypeReferences().getVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.UnnecessaryParenthesesVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.SimplifyBooleanExpressionVisitor());
return isis.apply(getCursor(), elem.getCoordinates().replace(), matcher.parameter(0), matcher.parameter(1));
}
Expand Down Expand Up @@ -136,6 +138,7 @@ public J visitMethodInvocation(J.MethodInvocation elem, ExecutionContext ctx) {
if ((matcher = before.matcher(getCursor())).find()) {
maybeRemoveImport("java.util.Objects.hash");
doAfterVisit(new org.openrewrite.java.ShortenFullyQualifiedTypeReferences().getVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.UnnecessaryParenthesesVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.SimplifyBooleanExpressionVisitor());
return after.apply(getCursor(), elem.getCoordinates().replace(), matcher.parameter(0));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public J visitBinary(J.Binary elem, ExecutionContext ctx) {
JavaTemplate.Matcher matcher;
if ((matcher = before.matcher(getCursor())).find()) {
doAfterVisit(new org.openrewrite.java.ShortenFullyQualifiedTypeReferences().getVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.UnnecessaryParenthesesVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.SimplifyBooleanExpressionVisitor());
return after.apply(getCursor(), elem.getCoordinates().replace(), matcher.parameter(0));
}
Expand Down Expand Up @@ -92,6 +93,7 @@ public J visitBinary(J.Binary elem, ExecutionContext ctx) {
JavaTemplate.Matcher matcher;
if ((matcher = before.matcher(getCursor())).find()) {
doAfterVisit(new org.openrewrite.java.ShortenFullyQualifiedTypeReferences().getVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.UnnecessaryParenthesesVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.SimplifyBooleanExpressionVisitor());
return after.apply(getCursor(), elem.getCoordinates().replace(), matcher.parameter(0));
}
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/recipes/UseStringIsEmptyRecipe.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public J visitBinary(J.Binary elem, ExecutionContext ctx) {
JavaTemplate.Matcher matcher;
if ((matcher = before.matcher(getCursor())).find()) {
doAfterVisit(new org.openrewrite.java.ShortenFullyQualifiedTypeReferences().getVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.UnnecessaryParenthesesVisitor());
doAfterVisit(new org.openrewrite.java.cleanup.SimplifyBooleanExpressionVisitor());
return after.apply(getCursor(), elem.getCoordinates().replace(), matcher.parameter(0));
}
Expand Down

0 comments on commit 767d683

Please sign in to comment.