OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 CloningVisitor implements Visitor<Node> { | 5 class CloningVisitor implements Visitor<Node> { |
6 final TreeElements originalTreeElements; | 6 final TreeElements originalTreeElements; |
7 final TreeElementMapping cloneTreeElements; | 7 final TreeElementMapping cloneTreeElements; |
8 | 8 |
9 CloningVisitor(this.originalTreeElements) | 9 CloningVisitor(this.originalTreeElements) |
10 : cloneTreeElements = new TreeElementMapping(); | 10 : cloneTreeElements = new TreeElementMapping(); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 visitNewExpression(NewExpression node) => new NewExpression( | 121 visitNewExpression(NewExpression node) => new NewExpression( |
122 node.newToken, visit(node.send)); | 122 node.newToken, visit(node.send)); |
123 | 123 |
124 rewriteNodeList(NodeList node, Link link) => | 124 rewriteNodeList(NodeList node, Link link) => |
125 new NodeList(node.beginToken, link, node.endToken, node.delimiter); | 125 new NodeList(node.beginToken, link, node.endToken, node.delimiter); |
126 | 126 |
127 visitNodeList(NodeList node) { | 127 visitNodeList(NodeList node) { |
128 // Special case for classes which exist in hierarchy, but not | 128 // Special case for classes which exist in hierarchy, but not |
129 // in the visitor. | 129 // in the visitor. |
130 if (node is Prefix) { | 130 if (node is Prefix) { |
131 return node.nodes.isEmpty() ? | 131 return node.nodes.isEmpty ? |
132 new Prefix() : new Prefix.singleton(visit(node.nodes.head)); | 132 new Prefix() : new Prefix.singleton(visit(node.nodes.head)); |
133 } | 133 } |
134 if (node is Postfix) { | 134 if (node is Postfix) { |
135 return node.nodes.isEmpty() ? | 135 return node.nodes.isEmpty ? |
136 new Postfix() : new Postfix.singleton(visit(node.nodes.head)); | 136 new Postfix() : new Postfix.singleton(visit(node.nodes.head)); |
137 } | 137 } |
138 LinkBuilder<Node> builder = new LinkBuilder<Node>(); | 138 LinkBuilder<Node> builder = new LinkBuilder<Node>(); |
139 for (Node n in node.nodes) { | 139 for (Node n in node.nodes) { |
140 builder.addLast(visit(n)); | 140 builder.addLast(visit(n)); |
141 } | 141 } |
142 return rewriteNodeList(node, builder.toLink()); | 142 return rewriteNodeList(node, builder.toLink()); |
143 } | 143 } |
144 | 144 |
145 visitOperator(Operator node) => new Operator(node.token); | 145 visitOperator(Operator node) => new Operator(node.token); |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 } | 268 } |
269 | 269 |
270 Node visitStringNode(StringNode node) { | 270 Node visitStringNode(StringNode node) { |
271 unimplemented('visitNode', node: node); | 271 unimplemented('visitNode', node: node); |
272 } | 272 } |
273 | 273 |
274 unimplemented(String message, {Node node}) { | 274 unimplemented(String message, {Node node}) { |
275 throw message; | 275 throw message; |
276 } | 276 } |
277 } | 277 } |
OLD | NEW |