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 part of csslib.visitor; | 5 part of csslib.visitor; |
6 | 6 |
7 /** | 7 /** |
8 * The base type for all nodes in a CSS abstract syntax tree. | 8 * The base type for all nodes in a CSS abstract syntax tree. |
9 */ | 9 */ |
10 abstract class TreeNode { | 10 abstract class TreeNode { |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 if (node != null) node.visit(printer); | 70 if (node != null) node.visit(printer); |
71 else writeln('null'); | 71 else writeln('null'); |
72 depth -= 1; | 72 depth -= 1; |
73 } | 73 } |
74 | 74 |
75 void writeValue(String label, value) { | 75 void writeValue(String label, value) { |
76 var v = toValue(value); | 76 var v = toValue(value); |
77 writeln('${label}: ${v}'); | 77 writeln('${label}: ${v}'); |
78 } | 78 } |
79 | 79 |
80 void writeList(String label, List<TreeNode> list) { | |
81 write('${label}: '); | |
82 if (list == null) { | |
83 buf.write('null'); | |
84 buf.write('\n'); | |
85 } else { | |
86 for (var item in list) { | |
87 buf.write(item.toString()); | |
88 buf.write(', '); | |
89 } | |
90 buf.write('\n'); | |
91 } | |
92 } | |
93 | |
94 void writeNodeList(String label, List<TreeNode> list) { | 80 void writeNodeList(String label, List<TreeNode> list) { |
95 writeln('${label} ['); | 81 writeln('${label} ['); |
96 if (list != null) { | 82 if (list != null) { |
97 depth += 1; | 83 depth += 1; |
98 for (var node in list) { | 84 for (var node in list) { |
99 if (node != null) { | 85 if (node != null) { |
100 node.visit(printer); | 86 node.visit(printer); |
101 } else { | 87 } else { |
102 writeln('null'); | 88 writeln('null'); |
103 } | 89 } |
104 } | 90 } |
105 depth -= 1; | 91 depth -= 1; |
106 writeln(']'); | 92 writeln(']'); |
107 } | 93 } |
108 } | 94 } |
109 | 95 |
110 String toString() => buf.toString(); | 96 String toString() => buf.toString(); |
111 } | 97 } |
OLD | NEW |