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 library csslib.visitor; | 5 library csslib.visitor; |
6 | 6 |
7 import 'package:source_maps/span.dart' show Span; | 7 import 'package:source_maps/span.dart' show Span; |
8 import 'parser.dart'; | 8 import 'parser.dart'; |
9 | 9 |
10 part 'src/css_printer.dart'; | 10 part 'src/css_printer.dart'; |
11 part 'src/tree.dart'; | 11 part 'src/tree.dart'; |
12 part 'src/tree_base.dart'; | 12 part 'src/tree_base.dart'; |
13 part 'src/tree_printer.dart'; | 13 part 'src/tree_printer.dart'; |
14 | 14 |
15 abstract class VisitorBase { | 15 abstract class VisitorBase { |
16 void visitCssComment(CssComment node); | 16 void visitCssComment(CssComment node); |
17 void visitCommentDefinition(CommentDefinition node); | 17 void visitCommentDefinition(CommentDefinition node); |
18 void visitStyleSheet(StyleSheet node); | 18 void visitStyleSheet(StyleSheet node); |
| 19 void visitNoOp(NoOp node); |
19 void visitTopLevelProduction(TopLevelProduction node); | 20 void visitTopLevelProduction(TopLevelProduction node); |
20 void visitDirective(Directive node); | 21 void visitDirective(Directive node); |
21 void visitMediaExpression(MediaExpression node); | 22 void visitMediaExpression(MediaExpression node); |
22 void visitMediaQuery(MediaQuery node); | 23 void visitMediaQuery(MediaQuery node); |
23 void visitMediaDirective(MediaDirective node); | 24 void visitMediaDirective(MediaDirective node); |
24 void visitHostDirective(HostDirective node); | 25 void visitHostDirective(HostDirective node); |
25 void visitPageDirective(PageDirective node); | 26 void visitPageDirective(PageDirective node); |
26 void visitCharsetDirective(CharsetDirective node); | 27 void visitCharsetDirective(CharsetDirective node); |
27 void visitImportDirective(ImportDirective node); | 28 void visitImportDirective(ImportDirective node); |
28 void visitKeyFrameDirective(KeyFrameDirective node); | 29 void visitKeyFrameDirective(KeyFrameDirective node); |
29 void visitKeyFrameBlock(KeyFrameBlock node); | 30 void visitKeyFrameBlock(KeyFrameBlock node); |
30 void visitFontFaceDirective(FontFaceDirective node); | 31 void visitFontFaceDirective(FontFaceDirective node); |
31 void visitStyletDirective(StyletDirective node); | 32 void visitStyletDirective(StyletDirective node); |
32 void visitNamespaceDirective(NamespaceDirective node); | 33 void visitNamespaceDirective(NamespaceDirective node); |
33 void visitVarDefinitionDirective(VarDefinitionDirective node); | 34 void visitVarDefinitionDirective(VarDefinitionDirective node); |
| 35 void visitMixinDefinition(MixinDefinition node); |
| 36 void visitMixinRulesetDirective(MixinRulesetDirective node); |
| 37 void visitMixinDeclarationDirective(MixinDeclarationDirective node); |
| 38 void visitIncludeDirective(IncludeDirective node); |
| 39 void visitContentDirective(ContentDirective node); |
34 | 40 |
35 void visitRuleSet(RuleSet node); | 41 void visitRuleSet(RuleSet node); |
36 void visitDeclarationGroup(DeclarationGroup node); | 42 void visitDeclarationGroup(DeclarationGroup node); |
37 void visitMarginGroup(DeclarationGroup node); | 43 void visitMarginGroup(DeclarationGroup node); |
38 void visitDeclaration(Declaration node); | 44 void visitDeclaration(Declaration node); |
39 void visitVarDefinition(VarDefinition node); | 45 void visitVarDefinition(VarDefinition node); |
| 46 void visitIncludeMixinAtDeclaration(IncludeMixinAtDeclaration node); |
| 47 void visitExtendDeclaration(ExtendDeclaration node); |
40 void visitSelectorGroup(SelectorGroup node); | 48 void visitSelectorGroup(SelectorGroup node); |
41 void visitSelector(Selector node); | 49 void visitSelector(Selector node); |
42 void visitSimpleSelectorSequence(SimpleSelectorSequence node); | 50 void visitSimpleSelectorSequence(SimpleSelectorSequence node); |
43 void visitSimpleSelector(SimpleSelector node); | 51 void visitSimpleSelector(SimpleSelector node); |
44 void visitElementSelector(ElementSelector node); | 52 void visitElementSelector(ElementSelector node); |
45 void visitNamespaceSelector(NamespaceSelector node); | 53 void visitNamespaceSelector(NamespaceSelector node); |
46 void visitAttributeSelector(AttributeSelector node); | 54 void visitAttributeSelector(AttributeSelector node); |
47 void visitIdSelector(IdSelector node); | 55 void visitIdSelector(IdSelector node); |
48 void visitClassSelector(ClassSelector node); | 56 void visitClassSelector(ClassSelector node); |
49 void visitPseudoClassSelector(PseudoClassSelector node); | 57 void visitPseudoClassSelector(PseudoClassSelector node); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
111 list[index].visit(this); | 119 list[index].visit(this); |
112 } | 120 } |
113 } | 121 } |
114 | 122 |
115 void visitTree(StyleSheet tree) => visitStyleSheet(tree); | 123 void visitTree(StyleSheet tree) => visitStyleSheet(tree); |
116 | 124 |
117 void visitStyleSheet(StyleSheet ss) { | 125 void visitStyleSheet(StyleSheet ss) { |
118 _visitNodeList(ss.topLevels); | 126 _visitNodeList(ss.topLevels); |
119 } | 127 } |
120 | 128 |
| 129 void visitNoOp(NoOp node) { } |
| 130 |
121 void visitTopLevelProduction(TopLevelProduction node) { } | 131 void visitTopLevelProduction(TopLevelProduction node) { } |
122 | 132 |
123 void visitDirective(Directive node) { } | 133 void visitDirective(Directive node) { } |
124 | 134 |
125 void visitCssComment(CssComment node) { } | 135 void visitCssComment(CssComment node) { } |
126 | 136 |
127 void visitCommentDefinition(CommentDefinition node) { } | 137 void visitCommentDefinition(CommentDefinition node) { } |
128 | 138 |
129 void visitMediaExpression(MediaExpression node) { | 139 void visitMediaExpression(MediaExpression node) { |
130 visitExpressions(node.exprs); | 140 visitExpressions(node.exprs); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 void visitStyletDirective(StyletDirective node) { | 196 void visitStyletDirective(StyletDirective node) { |
187 _visitNodeList(node._rulesets); | 197 _visitNodeList(node._rulesets); |
188 } | 198 } |
189 | 199 |
190 void visitNamespaceDirective(NamespaceDirective node) { } | 200 void visitNamespaceDirective(NamespaceDirective node) { } |
191 | 201 |
192 void visitVarDefinitionDirective(VarDefinitionDirective node) { | 202 void visitVarDefinitionDirective(VarDefinitionDirective node) { |
193 visitVarDefinition(node.def); | 203 visitVarDefinition(node.def); |
194 } | 204 } |
195 | 205 |
| 206 void visitMixinRulesetDirective(MixinRulesetDirective node) { |
| 207 _visitNodeList(node.rulesets); |
| 208 } |
| 209 |
| 210 void visitMixinDefinition(MixinDefinition node) { } |
| 211 |
| 212 void visitMixinDeclarationDirective(MixinDeclarationDirective node) { |
| 213 visitDeclarationGroup(node.declarations); |
| 214 } |
| 215 |
| 216 void visitIncludeDirective(IncludeDirective node) { |
| 217 for (var index = 0; index < node.args.length; index++) { |
| 218 var param = node.args[index]; |
| 219 _visitNodeList(param); |
| 220 } |
| 221 } |
| 222 |
| 223 void visitContentDirective(ContentDirective node) { |
| 224 // TODO(terry): TBD |
| 225 } |
| 226 |
196 void visitRuleSet(RuleSet node) { | 227 void visitRuleSet(RuleSet node) { |
197 visitSelectorGroup(node._selectorGroup); | 228 visitSelectorGroup(node._selectorGroup); |
198 visitDeclarationGroup(node._declarationGroup); | 229 visitDeclarationGroup(node._declarationGroup); |
199 } | 230 } |
200 | 231 |
201 void visitDeclarationGroup(DeclarationGroup node) { | 232 void visitDeclarationGroup(DeclarationGroup node) { |
202 _visitNodeList(node._declarations); | 233 _visitNodeList(node._declarations); |
203 } | 234 } |
204 | 235 |
205 void visitMarginGroup(MarginGroup node) => visitDeclarationGroup(node); | 236 void visitMarginGroup(MarginGroup node) => visitDeclarationGroup(node); |
206 | 237 |
207 void visitDeclaration(Declaration node) { | 238 void visitDeclaration(Declaration node) { |
208 visitIdentifier(node._property); | 239 visitIdentifier(node._property); |
209 if (node._expression != null) node._expression.visit(this); | 240 if (node._expression != null) node._expression.visit(this); |
210 } | 241 } |
211 | 242 |
212 void visitVarDefinition(VarDefinition node) { | 243 void visitVarDefinition(VarDefinition node) { |
213 visitIdentifier(node._property); | 244 visitIdentifier(node._property); |
214 if (node._expression != null) node._expression.visit(this); | 245 if (node._expression != null) node._expression.visit(this); |
215 } | 246 } |
216 | 247 |
| 248 void visitIncludeMixinAtDeclaration(IncludeMixinAtDeclaration node) { |
| 249 visitIncludeDirective(node.include); |
| 250 } |
| 251 |
| 252 void visitExtendDeclaration(ExtendDeclaration node) { |
| 253 _visitNodeList(node.selectors); |
| 254 } |
| 255 |
217 void visitSelectorGroup(SelectorGroup node) { | 256 void visitSelectorGroup(SelectorGroup node) { |
218 _visitNodeList(node.selectors); | 257 _visitNodeList(node.selectors); |
219 } | 258 } |
220 | 259 |
221 void visitSelector(Selector node) { | 260 void visitSelector(Selector node) { |
222 _visitNodeList(node._simpleSelectorSequences); | 261 _visitNodeList(node._simpleSelectorSequences); |
223 } | 262 } |
224 | 263 |
225 void visitSimpleSelectorSequence(SimpleSelectorSequence node) { | 264 void visitSimpleSelectorSequence(SimpleSelectorSequence node) { |
226 var selector = node._selector; | 265 var selector = node._selector; |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
436 void visitPaddingExpression(PaddingExpression node) { | 475 void visitPaddingExpression(PaddingExpression node) { |
437 // TODO(terry): TBD | 476 // TODO(terry): TBD |
438 throw UnimplementedError; | 477 throw UnimplementedError; |
439 } | 478 } |
440 | 479 |
441 void visitWidthExpression(WidthExpression node) { | 480 void visitWidthExpression(WidthExpression node) { |
442 // TODO(terry): TBD | 481 // TODO(terry): TBD |
443 throw UnimplementedError; | 482 throw UnimplementedError; |
444 } | 483 } |
445 } | 484 } |
OLD | NEW |