Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(84)

Side by Side Diff: packages/csslib/lib/src/tree_base.dart

Issue 2989763002: Update charted to 0.4.8 and roll (Closed)
Patch Set: Removed Cutch from list of reviewers Created 3 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « packages/csslib/lib/src/tree.dart ('k') | packages/csslib/lib/src/tree_printer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 {
11 /** The source code this [TreeNode] represents. */ 11 /** The source code this [TreeNode] represents. */
12 final SourceSpan span; 12 final SourceSpan span;
13 13
14 TreeNode(this.span); 14 TreeNode(this.span);
15 15
16 TreeNode clone(); 16 TreeNode clone();
17 17
18 /** Classic double-dispatch visitor for implementing passes. */ 18 /** Classic double-dispatch visitor for implementing passes. */
19 void visit(VisitorBase visitor); 19 visit(VisitorBase visitor);
20 20
21 /** A multiline string showing the node and its children. */ 21 /** A multiline string showing the node and its children. */
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
(...skipping 22 matching lines...) Expand all
52 52
53 void heading(String name, [span]) { 53 void heading(String name, [span]) {
54 write(name); 54 write(name);
55 if (span != null) { 55 if (span != null) {
56 buf.write(' (${span.message('')})'); 56 buf.write(' (${span.message('')})');
57 } 57 }
58 buf.write('\n'); 58 buf.write('\n');
59 } 59 }
60 60
61 String toValue(value) { 61 String toValue(value) {
62 if (value == null) return 'null'; 62 if (value == null)
63 else if (value is Identifier) return value.name; 63 return 'null';
64 else return value.toString(); 64 else if (value is Identifier)
65 return value.name;
66 else
67 return value.toString();
65 } 68 }
66 69
67 void writeNode(String label, TreeNode node) { 70 void writeNode(String label, TreeNode node) {
68 write('${label}: '); 71 write('${label}: ');
69 depth += 1; 72 depth += 1;
70 if (node != null) node.visit(printer); 73 if (node != null)
71 else writeln('null'); 74 node.visit(printer);
75 else
76 writeln('null');
72 depth -= 1; 77 depth -= 1;
73 } 78 }
74 79
75 void writeValue(String label, value) { 80 void writeValue(String label, value) {
76 var v = toValue(value); 81 var v = toValue(value);
77 writeln('${label}: ${v}'); 82 writeln('${label}: ${v}');
78 } 83 }
79 84
80 void writeNodeList(String label, List<TreeNode> list) { 85 void writeNodeList(String label, List<TreeNode> list) {
81 writeln('${label} ['); 86 writeln('${label} [');
82 if (list != null) { 87 if (list != null) {
83 depth += 1; 88 depth += 1;
84 for (var node in list) { 89 for (var node in list) {
85 if (node != null) { 90 if (node != null) {
86 node.visit(printer); 91 node.visit(printer);
87 } else { 92 } else {
88 writeln('null'); 93 writeln('null');
89 } 94 }
90 } 95 }
91 depth -= 1; 96 depth -= 1;
92 writeln(']'); 97 writeln(']');
93 } 98 }
94 } 99 }
95 100
96 String toString() => buf.toString(); 101 String toString() => buf.toString();
97 } 102 }
OLDNEW
« no previous file with comments | « packages/csslib/lib/src/tree.dart ('k') | packages/csslib/lib/src/tree_printer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698