Chromium Code Reviews| 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 final bool printDebugInfo; | |
| 8 | 7 |
| 9 Unparser([this.printDebugInfo = false]); | 8 Unparser(); |
| 10 | 9 |
| 11 String unparse(Node node) { | 10 String unparse(Node node) { |
| 12 sb = new StringBuffer(); | 11 sb = new StringBuffer(); |
| 13 visit(node); | 12 visit(node); |
| 14 return sb.toString(); | 13 return sb.toString(); |
| 15 } | 14 } |
| 16 | 15 |
| 17 void add(SourceString string) { | 16 void add(SourceString string) { |
| 18 string.printOn(sb); | 17 string.printOn(sb); |
| 19 } | 18 } |
| 20 | 19 |
| 21 visit(Node node) { | 20 visit(Node node) { |
| 22 if (node !== null) { | 21 if (node !== null) { |
|
Anton Muhin
2012/06/05 09:35:19
probably it's time to go single line now: if (node
Roman
2012/06/05 11:09:07
Done.
By the way, Dart style guide is ambiguous:
Anton Muhin
2012/06/05 11:39:21
You may want to file a bug.
Historically, at leas
| |
| 23 if (printDebugInfo) sb.add('[${node.getObjectDescription()}: '); | |
| 24 node.accept(this); | 22 node.accept(this); |
| 25 if (printDebugInfo) sb.add(']'); | |
| 26 } else if (printDebugInfo) { | |
| 27 sb.add('[null]'); | |
| 28 } | 23 } |
| 29 } | 24 } |
| 30 | 25 |
| 31 visitBlock(Block node) { | 26 visitBlock(Block node) { |
| 32 visit(node.statements); | 27 visit(node.statements); |
| 33 } | 28 } |
| 34 | 29 |
| 35 visitCascade(Cascade node) { | 30 visitCascade(Cascade node) { |
| 36 visit(node.expression); | 31 visit(node.expression); |
| 37 } | 32 } |
| (...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 425 sb.add(' '); | 420 sb.add(' '); |
| 426 } | 421 } |
| 427 visit(node.name); | 422 visit(node.name); |
| 428 if (node.typeParameters !== null) { | 423 if (node.typeParameters !== null) { |
| 429 visit(node.typeParameters); | 424 visit(node.typeParameters); |
| 430 } | 425 } |
| 431 visit(node.formals); | 426 visit(node.formals); |
| 432 add(node.endToken.value); | 427 add(node.endToken.value); |
| 433 } | 428 } |
| 434 } | 429 } |
| OLD | NEW |