| 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 // Returns null if no need to rename a node. | 5 // Returns null if no need to rename a node. |
| 6 typedef String Renamer(Node node); | 6 typedef String Renamer(Node node); |
| 7 | 7 |
| 8 class Unparser implements Visitor { | 8 class Unparser implements Visitor { |
| 9 final Renamer rename; | 9 Renamer rename; |
| 10 StringBuffer sb; | 10 StringBuffer sb; |
| 11 | 11 |
| 12 Unparser() : this.withRenamer((Node) => null); | 12 Unparser() { |
| 13 rename = (Node node) => null; |
| 14 } |
| 13 Unparser.withRenamer(this.rename); | 15 Unparser.withRenamer(this.rename); |
| 14 | 16 |
| 15 String unparse(Node node) { | 17 String unparse(Node node) { |
| 16 sb = new StringBuffer(); | 18 sb = new StringBuffer(); |
| 17 visit(node); | 19 visit(node); |
| 18 return sb.toString(); | 20 return sb.toString(); |
| 19 } | 21 } |
| 20 | 22 |
| 21 void add(SourceString string) { | 23 void add(SourceString string) { |
| 22 string.printOn(sb); | 24 string.printOn(sb); |
| (...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 sb.add(' '); | 506 sb.add(' '); |
| 505 } | 507 } |
| 506 visit(node.name); | 508 visit(node.name); |
| 507 if (node.typeParameters !== null) { | 509 if (node.typeParameters !== null) { |
| 508 visit(node.typeParameters); | 510 visit(node.typeParameters); |
| 509 } | 511 } |
| 510 visit(node.formals); | 512 visit(node.formals); |
| 511 add(node.endToken.value); | 513 add(node.endToken.value); |
| 512 } | 514 } |
| 513 } | 515 } |
| OLD | NEW |