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 11 matching lines...) Expand all Loading... |
22 String toDebugString() { | 22 String toDebugString() { |
23 var to = new TreeOutput(); | 23 var to = new TreeOutput(); |
24 var tp = new _TreePrinter(to, true); | 24 var tp = new _TreePrinter(to, true); |
25 this.visit(tp); | 25 this.visit(tp); |
26 return to.buf.toString(); | 26 return to.buf.toString(); |
27 } | 27 } |
28 } | 28 } |
29 | 29 |
30 /** The base type for expressions. */ | 30 /** The base type for expressions. */ |
31 abstract class Expression extends TreeNode { | 31 abstract class Expression extends TreeNode { |
32 Expression(SourceSpan span): super(span); | 32 Expression(SourceSpan span) : super(span); |
33 } | 33 } |
34 | 34 |
35 /** Simple class to provide a textual dump of trees for debugging. */ | 35 /** Simple class to provide a textual dump of trees for debugging. */ |
36 class TreeOutput { | 36 class TreeOutput { |
37 int depth = 0; | 37 int depth = 0; |
38 final StringBuffer buf = new StringBuffer(); | 38 final StringBuffer buf = new StringBuffer(); |
39 VisitorBase printer; | 39 VisitorBase printer; |
40 | 40 |
41 void write(String s) { | 41 void write(String s) { |
42 for (int i=0; i < depth; i++) { | 42 for (int i = 0; i < depth; i++) { |
43 buf.write(' '); | 43 buf.write(' '); |
44 } | 44 } |
45 buf.write(s); | 45 buf.write(s); |
46 } | 46 } |
47 | 47 |
48 void writeln(String s) { | 48 void writeln(String s) { |
49 write(s); | 49 write(s); |
50 buf.write('\n'); | 50 buf.write('\n'); |
51 } | 51 } |
52 | 52 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 writeln('null'); | 88 writeln('null'); |
89 } | 89 } |
90 } | 90 } |
91 depth -= 1; | 91 depth -= 1; |
92 writeln(']'); | 92 writeln(']'); |
93 } | 93 } |
94 } | 94 } |
95 | 95 |
96 String toString() => buf.toString(); | 96 String toString() => buf.toString(); |
97 } | 97 } |
OLD | NEW |