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

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

Issue 60983003: pkg/csslib: fixed analysis error, more cleanup (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: nits 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/analyzer.dart ('k') | pkg/csslib/lib/src/messages.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 /** 7 /**
8 * Visitor that produces a formatted string representation of the CSS tree. 8 * Visitor that produces a formatted string representation of the CSS tree.
9 */ 9 */
10 class CssPrinter extends Visitor { 10 class CssPrinter extends Visitor {
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
97 void visitPageDirective(PageDirective node) { 97 void visitPageDirective(PageDirective node) {
98 emit('$_newLine@page'); 98 emit('$_newLine@page');
99 if (node.hasIdent || node.hasPseudoPage) { 99 if (node.hasIdent || node.hasPseudoPage) {
100 if (node.hasIdent) emit(' '); 100 if (node.hasIdent) emit(' ');
101 emit(node._ident); 101 emit(node._ident);
102 emit(node.hasPseudoPage ? ':${node._pseudoPage}' : ''); 102 emit(node.hasPseudoPage ? ':${node._pseudoPage}' : '');
103 } 103 }
104 emit(' '); 104 emit(' ');
105 105
106 var declsMargin = node._declsMargin; 106 var declsMargin = node._declsMargin;
107 int declsMarginLength = declsMargin.length; 107 var declsMarginLength = declsMargin.length;
108 for (var i = 0; i < declsMarginLength; i++) { 108 for (var i = 0; i < declsMarginLength; i++) {
109 if (i > 0) emit(_newLine); 109 if (i > 0) emit(_newLine);
110 emit('{$_newLine'); 110 emit('{$_newLine');
111 declsMargin[i].visit(this); 111 declsMargin[i].visit(this);
112 emit('}'); 112 emit('}');
113 } 113 }
114 } 114 }
115 115
116 /** @charset "charset encoding" */ 116 /** @charset "charset encoding" */
117 void visitCharsetDirective(CharsetDirective node) { 117 void visitCharsetDirective(CharsetDirective node) {
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 154
155 void visitKeyFrameBlock(KeyFrameBlock node) { 155 void visitKeyFrameBlock(KeyFrameBlock node) {
156 emit('$_sp$_sp'); 156 emit('$_sp$_sp');
157 node._blockSelectors.visit(this); 157 node._blockSelectors.visit(this);
158 emit('$_sp{$_newLine'); 158 emit('$_sp{$_newLine');
159 node._declarations.visit(this); 159 node._declarations.visit(this);
160 emit('$_sp$_sp}$_newLine'); 160 emit('$_sp$_sp}$_newLine');
161 } 161 }
162 162
163 void visitStyletDirective(StyletDirective node) { 163 void visitStyletDirective(StyletDirective node) {
164 emit('/* @stylet export as ${node._dartClassName} */\n'); 164 emit('/* @stylet export as ${node.dartClassName} */\n');
165 } 165 }
166 166
167 void visitNamespaceDirective(NamespaceDirective node) { 167 void visitNamespaceDirective(NamespaceDirective node) {
168 bool isStartingQuote(String ch) => ('\'"'.indexOf(ch) >= 0); 168 bool isStartingQuote(String ch) => ('\'"'.indexOf(ch) >= 0);
169 169
170 if (isStartingQuote(node._uri)) { 170 if (isStartingQuote(node._uri)) {
171 emit(' @namespace ${node.prefix}"${node._uri}"'); 171 emit(' @namespace ${node.prefix}"${node._uri}"');
172 } else { 172 } else {
173 if (_isTesting) { 173 if (_isTesting) {
174 // Emit exactly was we parsed. 174 // Emit exactly was we parsed.
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 217
218 void visitRuleSet(RuleSet node) { 218 void visitRuleSet(RuleSet node) {
219 emit("$_newLine"); 219 emit("$_newLine");
220 node._selectorGroup.visit(this); 220 node._selectorGroup.visit(this);
221 emit(" {$_newLine"); 221 emit(" {$_newLine");
222 node._declarationGroup.visit(this); 222 node._declarationGroup.visit(this);
223 emit("}"); 223 emit("}");
224 } 224 }
225 225
226 void visitDeclarationGroup(DeclarationGroup node) { 226 void visitDeclarationGroup(DeclarationGroup node) {
227 var declarations = node._declarations; 227 var declarations = node.declarations;
228 var declarationsLength = declarations.length; 228 var declarationsLength = declarations.length;
229 for (var i = 0; i < declarationsLength; i++) { 229 for (var i = 0; i < declarationsLength; i++) {
230 if (i > 0) emit(_newLine); 230 if (i > 0) emit(_newLine);
231 emit("$_sp$_sp"); 231 emit("$_sp$_sp");
232 declarations[i].visit(this); 232 declarations[i].visit(this);
233 emit(";"); 233 emit(";");
234 } 234 }
235 if (declarationsLength > 0) emit(_newLine); 235 if (declarationsLength > 0) emit(_newLine);
236 } 236 }
237 237
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 emit(')'); 331 emit(')');
332 } 332 }
333 333
334 void visitNegationSelector(NegationSelector node) { 334 void visitNegationSelector(NegationSelector node) {
335 emit(':not('); 335 emit(':not(');
336 node.negationArg.visit(this); 336 node.negationArg.visit(this);
337 emit(')'); 337 emit(')');
338 } 338 }
339 339
340 void visitSelectorExpression(SelectorExpression node) { 340 void visitSelectorExpression(SelectorExpression node) {
341 var expressions = node._expressions; 341 var expressions = node.expressions;
342 var expressionsLength = expressions.length; 342 var expressionsLength = expressions.length;
343 for (var i = 0; i < expressionsLength; i++) { 343 for (var i = 0; i < expressionsLength; i++) {
344 // Add space seperator between terms without an operator. 344 // Add space seperator between terms without an operator.
345 var expression = expressions[i]; 345 var expression = expressions[i];
346 expression.visit(this); 346 expression.visit(this);
347 } 347 }
348 } 348 }
349 349
350 void visitUnicodeRangeTerm(UnicodeRangeTerm node) { 350 void visitUnicodeRangeTerm(UnicodeRangeTerm node) {
351 if (node.hasSecond) { 351 if (node.hasSecond) {
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 508
509 void visitWildcard(Wildcard node) { 509 void visitWildcard(Wildcard node) {
510 emit('*'); 510 emit('*');
511 } 511 }
512 512
513 void visitDartStyleExpression(DartStyleExpression node) { 513 void visitDartStyleExpression(DartStyleExpression node) {
514 // TODO(terry): TBD 514 // TODO(terry): TBD
515 throw UnimplementedError; 515 throw UnimplementedError;
516 } 516 }
517 } 517 }
OLDNEW
« no previous file with comments | « pkg/csslib/lib/src/analyzer.dart ('k') | pkg/csslib/lib/src/messages.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698