Skip to content

Commit

Permalink
Call parentheses what they are.
Browse files Browse the repository at this point in the history
	Change on 2017/09/25 by kstanger <kstanger@google.com>

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=169948724
  • Loading branch information
kstanger authored and tomball committed Sep 25, 2017
1 parent ded2122 commit b97e921
Showing 1 changed file with 4 additions and 4 deletions.
Expand Up @@ -981,7 +981,7 @@ public boolean visit(Initializer node) {
} }


private void acceptMacroArgument(Expression expr) { private void acceptMacroArgument(Expression expr) {
if (needsBracketsForMacro(expr)) { if (needsParenthesesForMacro(expr)) {
buffer.append('('); buffer.append('(');
expr.accept(this); expr.accept(this);
buffer.append(')'); buffer.append(')');
Expand All @@ -990,7 +990,7 @@ private void acceptMacroArgument(Expression expr) {
} }
} }


private boolean needsBracketsForMacro(Expression expr) { private boolean needsParenthesesForMacro(Expression expr) {
boolean[] hasComma = { false }; boolean[] hasComma = { false };
expr.accept(new TreeVisitor() { expr.accept(new TreeVisitor() {
@Override @Override
Expand All @@ -1000,11 +1000,11 @@ public boolean visit(ArrayInitializer node) {
} }
@Override @Override
public boolean visit(CommaExpression node) { public boolean visit(CommaExpression node) {
return false; // Adds brackets around children. return false; // Adds parentheses around children.
} }
@Override @Override
public boolean visit(FunctionInvocation node) { public boolean visit(FunctionInvocation node) {
return false; // Adds brackets around children. return false; // Adds parentheses around children.
} }
@Override @Override
public boolean visit(StringLiteral node) { public boolean visit(StringLiteral node) {
Expand Down

0 comments on commit b97e921

Please sign in to comment.