Skip to content

Commit

Permalink
Issue checkstyle#3048: ParenPad now correctly evaluates precedence pa…
Browse files Browse the repository at this point in the history
…rens
  • Loading branch information
Subbu Dantu authored and Subbu Dantu committed Mar 21, 2017
1 parent e763212 commit 7718c0a
Showing 1 changed file with 13 additions and 3 deletions.
Expand Up @@ -181,11 +181,21 @@ private void processExpression(DetailAST ast) {
DetailAST childAst = ast.getFirstChild();
while (childAst != null) {
if (childAst.getType() == TokenTypes.LPAREN) {
processLeft(childAst);
processExpression(childAst);
if (childAst.getNextSibling().getType() == TokenTypes.TYPECAST) {
processExpression(childAst);
}
else {
processLeft(childAst);
processExpression(childAst);
}
}
else if (childAst.getType() == TokenTypes.RPAREN && !isInTypecast(childAst)) {
processRight(childAst);
if (childAst.getPreviousSibling().getType() == TokenTypes.TYPECAST) {
processExpression(childAst);
}
else {
processRight(childAst);
}
}
else if (!isAcceptableToken(childAst)) {
//Traverse all subtree tokens which will never be configured
Expand Down

0 comments on commit 7718c0a

Please sign in to comment.