| 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 /** | 5 /** |
| 6 * Pretty-prints Node tree in XML-like format. | 6 * Pretty-prints Node tree in XML-like format. |
| 7 * | 7 * |
| 8 * TODO(smok): Add main() to run from command-line to print out tree for given | 8 * TODO(smok): Add main() to run from command-line to print out tree for given |
| 9 * .dart file. | 9 * .dart file. |
| 10 */ | 10 */ |
| 11 class PrettyPrinter implements Visitor { | 11 class PrettyPrinter implements Visitor { |
| 12 | 12 |
| 13 /** String used to represent one level of indent. */ | 13 /** String used to represent one level of indent. */ |
| 14 static final String INDENT = " "; | 14 static const String INDENT = " "; |
| 15 | 15 |
| 16 StringBuffer sb; | 16 StringBuffer sb; |
| 17 int depth; | 17 int depth; |
| 18 /** Prefix for the type passed to the next [openNode()] call. */ | 18 /** Prefix for the type passed to the next [openNode()] call. */ |
| 19 String nextTypePrefix; | 19 String nextTypePrefix; |
| 20 /** Nodes that were opened with [openNode()] calls. */ | 20 /** Nodes that were opened with [openNode()] calls. */ |
| 21 Link<String> currentNodeTypes; | 21 Link<String> currentNodeTypes; |
| 22 | 22 |
| 23 PrettyPrinter() : | 23 PrettyPrinter() : |
| 24 sb = new StringBuffer(), | 24 sb = new StringBuffer(), |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 visitWithPrefix(node.type, "type:"); | 394 visitWithPrefix(node.type, "type:"); |
| 395 visitWithPrefix(node.modifiers, "modifiers:"); | 395 visitWithPrefix(node.modifiers, "modifiers:"); |
| 396 visitWithPrefix(node.definitions, "definitions:"); | 396 visitWithPrefix(node.definitions, "definitions:"); |
| 397 closeNode(); | 397 closeNode(); |
| 398 } | 398 } |
| 399 | 399 |
| 400 visitWhile(While node) { | 400 visitWhile(While node) { |
| 401 visitNodeWithChildren(node, "While"); | 401 visitNodeWithChildren(node, "While"); |
| 402 } | 402 } |
| 403 } | 403 } |
| OLD | NEW |