| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 class AbstractVisitor<R> implements Visitor<R> { | 5 class AbstractVisitor<R> implements Visitor<R> { |
| 6 abstract R visitNode(Node node); | 6 abstract R visitNode(Node node); |
| 7 | 7 |
| 8 R visitBlock(Block node) => visitStatement(node); | 8 R visitBlock(Block node) => visitStatement(node); |
| 9 R visitBreakStatement(BreakStatement node) => visitGotoStatement(node); | 9 R visitBreakStatement(BreakStatement node) => visitGotoStatement(node); |
| 10 R visitCatchBlock(CatchBlock node) => visitNode(node); | 10 R visitCatchBlock(CatchBlock node) => visitNode(node); |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 R visitStringInterpolation(StringInterpolation node) => visitExpression(node); | 54 R visitStringInterpolation(StringInterpolation node) => visitExpression(node); |
| 55 R visitStringInterpolationPart(StringInterpolationPart node) { | 55 R visitStringInterpolationPart(StringInterpolationPart node) { |
| 56 return visitNode(node); | 56 return visitNode(node); |
| 57 } | 57 } |
| 58 R visitSwitchCase(SwitchCase node) => visitNode(node); | 58 R visitSwitchCase(SwitchCase node) => visitNode(node); |
| 59 R visitSwitchStatement(SwitchStatement node) => visitStatement(node); | 59 R visitSwitchStatement(SwitchStatement node) => visitStatement(node); |
| 60 R visitThrow(Throw node) => visitStatement(node); | 60 R visitThrow(Throw node) => visitStatement(node); |
| 61 R visitTryStatement(TryStatement node) => visitStatement(node); | 61 R visitTryStatement(TryStatement node) => visitStatement(node); |
| 62 R visitTypeAnnotation(TypeAnnotation node) => visitNode(node); | 62 R visitTypeAnnotation(TypeAnnotation node) => visitNode(node); |
| 63 R visitTypedef(Typedef node) => visitNode(node); | 63 R visitTypedef(Typedef node) => visitNode(node); |
| 64 R visitTypeVariable(TypeVariable node) => visitNode(node); |
| 64 R visitVariableDefinitions(VariableDefinitions node) => visitStatement(node); | 65 R visitVariableDefinitions(VariableDefinitions node) => visitStatement(node); |
| 65 R visitWhile(While node) => visitLoop(node); | 66 R visitWhile(While node) => visitLoop(node); |
| 66 } | 67 } |
| 67 | 68 |
| 68 /** | 69 /** |
| 69 * This visitor takes another visitor and applies it to every | 70 * This visitor takes another visitor and applies it to every |
| 70 * node in the tree. There is currently no way to control the | 71 * node in the tree. There is currently no way to control the |
| 71 * traversal. | 72 * traversal. |
| 72 */ | 73 */ |
| 73 class TraversingVisitor extends AbstractVisitor { | 74 class TraversingVisitor extends AbstractVisitor { |
| 74 final Visitor visitor; | 75 final Visitor visitor; |
| 75 | 76 |
| 76 TraversingVisitor(Visitor this.visitor); | 77 TraversingVisitor(Visitor this.visitor); |
| 77 | 78 |
| 78 visitNode(Node node) { | 79 visitNode(Node node) { |
| 79 node.accept(visitor); | 80 node.accept(visitor); |
| 80 node.visitChildren(this); | 81 node.visitChildren(this); |
| 81 } | 82 } |
| 82 } | 83 } |
| OLD | NEW |