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

Side by Side Diff: pkg/csslib/lib/src/tree_printer.dart

Issue 64373003: pkg/csslib: types, fixes, cleanup (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: more Created 7 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « pkg/csslib/lib/src/tree_base.dart ('k') | pkg/csslib/lib/src/validate.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) 2013, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2013, 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 // TODO(terry): Enable class for debug only; when conditional imports enabled. 7 // TODO(terry): Enable class for debug only; when conditional imports enabled.
8 8
9 /** Helper function to dump the CSS AST. */ 9 /** Helper function to dump the CSS AST. */
10 String treeToDebugString(styleSheet, [bool useSpan = false]) { 10 String treeToDebugString(StyleSheet styleSheet, [bool useSpan = false]) {
11 var to = new TreeOutput(); 11 var to = new TreeOutput();
12 new _TreePrinter(to, useSpan)..visitTree(styleSheet); 12 new _TreePrinter(to, useSpan)..visitTree(styleSheet);
13 return to.toString(); 13 return to.toString();
14 } 14 }
15 15
16 /** Tree dump for debug output of the CSS AST. */ 16 /** Tree dump for debug output of the CSS AST. */
17 class _TreePrinter extends Visitor { 17 class _TreePrinter extends Visitor {
18 var output; 18 final TreeOutput output;
19 final bool useSpan; 19 final bool useSpan;
20 _TreePrinter(this.output, this.useSpan) { output.printer = this; } 20 _TreePrinter(this.output, this.useSpan) { output.printer = this; }
21 21
22 void visitTree(tree) => visitStylesheet(tree); 22 void visitTree(StyleSheet tree) => visitStylesheet(tree);
23 23
24 void heading(String heading, node) { 24 void heading(String heading, node) {
25 if (useSpan) { 25 if (useSpan) {
26 output.heading(heading, node.span); 26 output.heading(heading, node.span);
27 } else { 27 } else {
28 output.heading(heading); 28 output.heading(heading);
29 } 29 }
30 } 30 }
31 31
32 void visitStylesheet(StyleSheet node) { 32 void visitStylesheet(StyleSheet node) {
(...skipping 26 matching lines...) Expand all
59 } 59 }
60 60
61 void visitMediaExpression(MediaExpression node) { 61 void visitMediaExpression(MediaExpression node) {
62 heading('MediaExpression', node); 62 heading('MediaExpression', node);
63 output.writeValue('feature', node.mediaFeature); 63 output.writeValue('feature', node.mediaFeature);
64 if (node.andOperator) output.writeValue('AND operator', ''); 64 if (node.andOperator) output.writeValue('AND operator', '');
65 visitExpressions(node.exprs); 65 visitExpressions(node.exprs);
66 } 66 }
67 67
68 void visitMediaQueries(MediaQuery query) { 68 void visitMediaQueries(MediaQuery query) {
69 output.headeing('MediaQueries'); 69 output.heading('MediaQueries');
70 output.writeValue('unary', query.unary); 70 output.writeValue('unary', query.unary);
71 output.writeValue('media type', query.mediaType); 71 output.writeValue('media type', query.mediaType);
72 output.writeNodeList('media expressions', query.expressions); 72 output.writeNodeList('media expressions', query.expressions);
73 } 73 }
74 74
75 void visitMediaDirective(MediaDirective node) { 75 void visitMediaDirective(MediaDirective node) {
76 heading('MediaDirective', node); 76 heading('MediaDirective', node);
77 output.depth++; 77 output.depth++;
78 output.writeNodeList('media queries', node.mediaQueries); 78 output.writeNodeList('media queries', node.mediaQueries);
79 output.writeNodeList('rule sets', node.rulesets); 79 output.writeNodeList('rule sets', node.rulesets);
(...skipping 24 matching lines...) Expand all
104 } 104 }
105 105
106 void visitContentDirective(ContentDirective node) { 106 void visitContentDirective(ContentDirective node) {
107 print("ContentDirective not implemented"); 107 print("ContentDirective not implemented");
108 } 108 }
109 109
110 void visitKeyFrameDirective(KeyFrameDirective node) { 110 void visitKeyFrameDirective(KeyFrameDirective node) {
111 heading('KeyFrameDirective', node); 111 heading('KeyFrameDirective', node);
112 output.depth++; 112 output.depth++;
113 output.writeValue('keyframe', node.keyFrameName); 113 output.writeValue('keyframe', node.keyFrameName);
114 output.writeValue('name', node._name); 114 output.writeValue('name', node.name);
115 output.writeNodeList('blocks', node._blocks); 115 output.writeNodeList('blocks', node._blocks);
116 output.depth--; 116 output.depth--;
117 } 117 }
118 118
119 void visitKeyFrameBlock(KeyFrameBlock node) { 119 void visitKeyFrameBlock(KeyFrameBlock node) {
120 heading('KeyFrameBlock', node); 120 heading('KeyFrameBlock', node);
121 output.depth++; 121 output.depth++;
122 super.visitKeyFrameBlock(node); 122 super.visitKeyFrameBlock(node);
123 output.depth--; 123 output.depth--;
124 } 124 }
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
237 heading('Selector Group', node); 237 heading('Selector Group', node);
238 output.depth++; 238 output.depth++;
239 output.writeNodeList('selectors', node.selectors); 239 output.writeNodeList('selectors', node.selectors);
240 output.depth--; 240 output.depth--;
241 } 241 }
242 242
243 void visitSelector(Selector node) { 243 void visitSelector(Selector node) {
244 heading('Selector', node); 244 heading('Selector', node);
245 output.depth++; 245 output.depth++;
246 output.writeNodeList('simpleSelectorsSequences', 246 output.writeNodeList('simpleSelectorsSequences',
247 node._simpleSelectorSequences); 247 node.simpleSelectorSequences);
248 output.depth--; 248 output.depth--;
249 } 249 }
250 250
251 void visitSimpleSelectorSequence(SimpleSelectorSequence node) { 251 void visitSimpleSelectorSequence(SimpleSelectorSequence node) {
252 heading('SimpleSelectorSequence', node); 252 heading('SimpleSelectorSequence', node);
253 output.depth++; 253 output.depth++;
254 if (node.isCombinatorNone) { 254 if (node.isCombinatorNone) {
255 output.writeValue('combinator', "NONE"); 255 output.writeValue('combinator', "NONE");
256 } else if (node.isCombinatorDescendant) { 256 } else if (node.isCombinatorDescendant) {
257 output.writeValue('combinator', "descendant"); 257 output.writeValue('combinator', "descendant");
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 } 548 }
549 549
550 void visitPaddingExpression(PaddingExpression node) { 550 void visitPaddingExpression(PaddingExpression node) {
551 heading('Dart Style PaddingExpression', node); 551 heading('Dart Style PaddingExpression', node);
552 } 552 }
553 553
554 void visitWidthExpression(WidthExpression node) { 554 void visitWidthExpression(WidthExpression node) {
555 heading('Dart Style WidthExpression', node); 555 heading('Dart Style WidthExpression', node);
556 } 556 }
557 } 557 }
OLDNEW
« no previous file with comments | « pkg/csslib/lib/src/tree_base.dart ('k') | pkg/csslib/lib/src/validate.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698