| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 * The base type for all nodes in a dart abstract syntax tree. | 5 * The base type for all nodes in a dart abstract syntax tree. |
| 6 */ | 6 */ |
| 7 class Node { | 7 class Node { |
| 8 /** The source code this [Node] represents. */ | 8 /** The source code this [Node] represents. */ |
| 9 SourceSpan span; | 9 SourceSpan span; |
| 10 | 10 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 } | 72 } |
| 73 buf.add(s); | 73 buf.add(s); |
| 74 } | 74 } |
| 75 | 75 |
| 76 void writeln(String s) { | 76 void writeln(String s) { |
| 77 write(s); | 77 write(s); |
| 78 buf.add('\n'); | 78 buf.add('\n'); |
| 79 } | 79 } |
| 80 | 80 |
| 81 void heading(String name, span) { | 81 void heading(String name, span) { |
| 82 buf.add(name); | 82 write(name); |
| 83 buf.add(' (${span.locationText})'); |
| 83 buf.add('\n'); | 84 buf.add('\n'); |
| 84 } | 85 } |
| 85 | 86 |
| 86 String toValue(value) { | 87 String toValue(value) { |
| 87 if (value == null) return 'null'; | 88 if (value == null) return 'null'; |
| 88 else if (value is Identifier) return value.name; | 89 else if (value is Identifier) return value.name; |
| 89 else return value.toString(); | 90 else return value.toString(); |
| 90 } | 91 } |
| 91 | 92 |
| 92 void writeNode(String label, Node node) { | 93 void writeNode(String label, Node node) { |
| (...skipping 17 matching lines...) Expand all Loading... |
| 110 } else { | 111 } else { |
| 111 for (var item in list) { | 112 for (var item in list) { |
| 112 buf.add(item.toString()); | 113 buf.add(item.toString()); |
| 113 buf.add(', '); | 114 buf.add(', '); |
| 114 } | 115 } |
| 115 buf.add('\n'); | 116 buf.add('\n'); |
| 116 } | 117 } |
| 117 } | 118 } |
| 118 | 119 |
| 119 void writeNodeList(String label, List list) { | 120 void writeNodeList(String label, List list) { |
| 120 writeln(label + ':...'); | 121 writeln('${label} ['); |
| 121 if (list != null) { | 122 if (list != null) { |
| 122 depth += 1; | 123 depth += 1; |
| 123 for (var node in list) { | 124 for (var node in list) { |
| 124 if (node != null) { | 125 if (node != null) { |
| 125 node.visit(printer); | 126 node.visit(printer); |
| 126 } else { | 127 } else { |
| 127 writeln('null'); | 128 writeln('null'); |
| 128 } | 129 } |
| 129 } | 130 } |
| 130 depth -= 1; | 131 depth -= 1; |
| 132 writeln(']'); |
| 131 } | 133 } |
| 132 } | 134 } |
| 133 } | 135 } |
| OLD | NEW |