diff options
author | Laurent Le Brun <laurentlb@google.com> | 2015-09-14 17:14:41 +0000 |
---|---|---|
committer | John Field <jfield@google.com> | 2015-09-15 20:25:30 +0000 |
commit | cd2ad0f9e082d101c0e9664729a4d2632659361d (patch) | |
tree | f8eeafdc44eaa4a292103cb0af6107263ac5882d /src/main/java/com/google/devtools/build | |
parent | 097736ee9490e4ccf25cf56a201198f3a0388af7 (diff) |
Fix and test SyntaxTreeVisitor
--
MOS_MIGRATED_REVID=103003770
Diffstat (limited to 'src/main/java/com/google/devtools/build')
-rw-r--r-- | src/main/java/com/google/devtools/build/lib/syntax/SyntaxTreeVisitor.java | 29 |
1 files changed, 22 insertions, 7 deletions
diff --git a/src/main/java/com/google/devtools/build/lib/syntax/SyntaxTreeVisitor.java b/src/main/java/com/google/devtools/build/lib/syntax/SyntaxTreeVisitor.java index d625c24973..a19d5ca1c0 100644 --- a/src/main/java/com/google/devtools/build/lib/syntax/SyntaxTreeVisitor.java +++ b/src/main/java/com/google/devtools/build/lib/syntax/SyntaxTreeVisitor.java @@ -40,7 +40,7 @@ public class SyntaxTreeVisitor { visit(node.getValue()); } - public void visit(Parameter node) { + public void visit(Parameter<?, ?> node) { // leaf node (we need the function for overrides) } @@ -55,6 +55,9 @@ public class SyntaxTreeVisitor { } public void visit(FuncallExpression node) { + if (node.getObject() != null) { + visit(node.getObject()); + } visit(node.getFunction()); visitAll(node.getArguments()); } @@ -66,7 +69,7 @@ public class SyntaxTreeVisitor { visit(node.getElementExpression()); for (ListComprehension.Clause clause : node.getClauses()) { if (clause.getLValue() != null) { - visit(clause.getLValue().getExpression()); + visit(clause.getLValue()); } visit(clause.getExpression()); } @@ -79,6 +82,12 @@ public class SyntaxTreeVisitor { visit(node.getListExpression()); } + public void visit(ForStatement node) { + visit(node.getVariable().getExpression()); + visit(node.getCollection()); + visitAll(node.block()); + } + public void visit(LoadStatement node) { visitAll(node.getSymbols()); } @@ -93,8 +102,12 @@ public class SyntaxTreeVisitor { public void visit(StringLiteral node) { } + public void visit(LValue node) { + visit(node.getExpression()); + } + public void visit(AssignmentStatement node) { - visit(node.getLValue().getExpression()); + visit(node.getLValue()); visit(node.getExpression()); } @@ -114,10 +127,7 @@ public class SyntaxTreeVisitor { public void visit(FunctionDefStatement node) { visit(node.getIdent()); - List<Expression> defaults = node.getSignature().getDefaultValues(); - if (defaults != null) { - visitAll(defaults); - } + visitAll(node.getParameters()); visitAll(node.getStatements()); } @@ -138,6 +148,11 @@ public class SyntaxTreeVisitor { visit(node.getExpression()); } + public void visit(DotExpression node) { + visit(node.getObj()); + visit(node.getField()); + } + public void visit(Comment node) { } |