Skip to content

Commit

Permalink
SimplifyBooleanExpression should only remove parens when related
Browse files Browse the repository at this point in the history
The `SimplifyBooleanExpressionVisitor` should only remove unnecessary parentheses when the visitor already changed the parenthesized expression.
  • Loading branch information
knutwannheden committed Dec 15, 2023
1 parent dd5e502 commit b70c34b
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ public J visitBinary(J.Binary binary, ExecutionContext ctx) {
}

@Override
public J postVisit(J tree, ExecutionContext ctx) {
J j = tree;
if (j instanceof J.Parentheses) {
public <T extends J> J visitParentheses(J.Parentheses<T> parens, ExecutionContext ctx) {
J j = super.visitParentheses(parens, ctx);
if (j != parens && j instanceof J.Parentheses) {
j = new UnnecessaryParenthesesVisitor<>().visit(j, ctx, getCursor().getParentOrThrow());
}
return j;
Expand Down

0 comments on commit b70c34b

Please sign in to comment.