OLD | NEW |
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 class Generate { | 5 class Generate { |
6 | 6 |
7 // Build up list of all known class selectors in all CSS files. | 7 // Build up list of all known class selectors in all CSS files. |
8 static List<String> computeClassSelectors(RuleSet ruleset, classes) { | 8 static List<String> computeClassSelectors(RuleSet ruleset, classes) { |
9 for (final selector in ruleset.selectorGroup.selectors) { | 9 for (final selector in ruleset.selectorGroup.selectors) { |
10 var selSeqs = selector.simpleSelectorSequences; | 10 var selSeqs = selector.simpleSelectorSequences; |
11 for (final selSeq in selSeqs) { | 11 for (final selSeq in selSeqs) { |
12 var simpleSelector = selSeq.simpleSelector; | 12 var simpleSelector = selSeq.simpleSelector; |
13 if (simpleSelector is ClassSelector) { | 13 if (simpleSelector is ClassSelector) { |
14 String className = simpleSelector.name; | 14 String className = simpleSelector.name; |
15 if (classes.indexOf(className) == -1) { // Class name already known? | 15 if (classes.indexOf(className) == -1) { // Class name already known? |
16 // No, expose it. | 16 // No, expose it. |
17 classes.add(className); | 17 classes.add(className); |
18 } | 18 } |
19 } | 19 } |
20 } | 20 } |
21 } | 21 } |
22 | 22 |
23 return classes; | 23 return classes; |
24 } | 24 } |
25 | 25 |
26 static dartClass(FileSystem files, String outPath, Stylesheet stylesheet, | 26 static dartClass(var files, String outPath, Stylesheet stylesheet, |
27 String filename) { | 27 String filename) { |
28 | 28 |
29 List<String> knownClasses = []; | 29 List<String> knownClasses = []; |
30 | 30 |
31 StringBuffer buff = new StringBuffer( | 31 StringBuffer buff = new StringBuffer( |
32 '// File generated by Dart CSS from source file ${filename}\n' + | 32 '// File generated by Dart CSS from source file ${filename}\n' + |
33 '// Do not edit.\n\n'); | 33 '// Do not edit.\n\n'); |
34 | 34 |
35 // Emit class for any @stylet directive. | 35 // Emit class for any @stylet directive. |
36 for (final production in stylesheet._topLevels) { | 36 for (final production in stylesheet._topLevels) { |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 buff.add(classSelectors.toString()); | 83 buff.add(classSelectors.toString()); |
84 | 84 |
85 // Write Dart file. | 85 // Write Dart file. |
86 String outFile = '${outPath}CSS.dart'; | 86 String outFile = '${outPath}CSS.dart'; |
87 files.writeString(outFile, buff.toString()); | 87 files.writeString(outFile, buff.toString()); |
88 | 88 |
89 return outFile; | 89 return outFile; |
90 } | 90 } |
91 } | 91 } |
92 | 92 |
OLD | NEW |