| 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 Unparser implements Visitor { | 5 class Unparser implements Visitor { |
| 6 StringBuffer sb; | 6 StringBuffer sb; |
| 7 | 7 |
| 8 Unparser(); | 8 Unparser(); |
| 9 | 9 |
| 10 String unparse(Node node) { | 10 String unparse(Node node) { |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 sb.add(' '); | 176 sb.add(' '); |
| 177 visit(node.elements); | 177 visit(node.elements); |
| 178 } | 178 } |
| 179 | 179 |
| 180 visitModifiers(Modifiers node) => node.visitChildren(this); | 180 visitModifiers(Modifiers node) => node.visitChildren(this); |
| 181 | 181 |
| 182 /** | 182 /** |
| 183 * Unparses given NodeList starting from specific node. | 183 * Unparses given NodeList starting from specific node. |
| 184 */ | 184 */ |
| 185 unparseNodeListFrom(NodeList node, Link<Node> from) { | 185 unparseNodeListFrom(NodeList node, Link<Node> from) { |
| 186 if (from.isEmpty()) return; |
| 186 String delimiter = (node.delimiter === null) ? " " : "${node.delimiter} "; | 187 String delimiter = (node.delimiter === null) ? " " : "${node.delimiter} "; |
| 187 from.printOn(sb, delimiter); | 188 visit(from.head); |
| 189 for (Link link = from.tail; !link.isEmpty(); link = link.tail) { |
| 190 sb.add(delimiter); |
| 191 visit(link.head); |
| 192 } |
| 188 } | 193 } |
| 189 | 194 |
| 190 visitNodeList(NodeList node) { | 195 visitNodeList(NodeList node) { |
| 191 if (node.beginToken !== null) add(node.beginToken.value); | 196 if (node.beginToken !== null) add(node.beginToken.value); |
| 192 if (node.nodes !== null) { | 197 if (node.nodes !== null) { |
| 193 unparseNodeListFrom(node, node.nodes); | 198 unparseNodeListFrom(node, node.nodes); |
| 194 } | 199 } |
| 195 if (node.endToken !== null) add(node.endToken.value); | 200 if (node.endToken !== null) add(node.endToken.value); |
| 196 } | 201 } |
| 197 | 202 |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 472 sb.add(' '); | 477 sb.add(' '); |
| 473 } | 478 } |
| 474 visit(node.name); | 479 visit(node.name); |
| 475 if (node.typeParameters !== null) { | 480 if (node.typeParameters !== null) { |
| 476 visit(node.typeParameters); | 481 visit(node.typeParameters); |
| 477 } | 482 } |
| 478 visit(node.formals); | 483 visit(node.formals); |
| 479 add(node.endToken.value); | 484 add(node.endToken.value); |
| 480 } | 485 } |
| 481 } | 486 } |
| OLD | NEW |