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

Side by Side Diff: pkg/polymer/lib/src/css_analyzer.dart

Issue 23658002: Remove processing of dart code, summary.dart, simplified info.dart (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « pkg/polymer/lib/src/compiler.dart ('k') | pkg/polymer/lib/src/css_emitters.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 /** Portion of the analyzer dealing with CSS sources. */ 5 /** Portion of the analyzer dealing with CSS sources. */
6 library polymer.src.css_analyzer; 6 library polymer.src.css_analyzer;
7 7
8 import 'package:csslib/parser.dart' as css; 8 import 'package:csslib/parser.dart' as css;
9 import 'package:csslib/visitor.dart'; 9 import 'package:csslib/visitor.dart';
10 import 'package:html5lib/dom.dart'; 10 import 'package:html5lib/dom.dart';
(...skipping 30 matching lines...) Expand all
41 _AnalyzerCss(this.packageRoot, this.info, this._pseudoElements, 41 _AnalyzerCss(this.packageRoot, this.info, this._pseudoElements,
42 this._messages, this._warningsAsErrors); 42 this._messages, this._warningsAsErrors);
43 43
44 /** 44 /**
45 * Run the analyzer on every file that is a style sheet or any component that 45 * Run the analyzer on every file that is a style sheet or any component that
46 * has a style tag. 46 * has a style tag.
47 */ 47 */
48 void process(SourceFile file) { 48 void process(SourceFile file) {
49 var fileInfo = info[file.path]; 49 var fileInfo = info[file.path];
50 if (file.isStyleSheet || fileInfo.styleSheets.length > 0) { 50 if (file.isStyleSheet || fileInfo.styleSheets.length > 0) {
51 var styleSheets = processVars(fileInfo); 51 var styleSheets = processVars(fileInfo.inputUrl, fileInfo);
52 52
53 // Add to list of all style sheets analyzed. 53 // Add to list of all style sheets analyzed.
54 allStyleSheets.addAll(styleSheets); 54 allStyleSheets.addAll(styleSheets);
55 } 55 }
56 56
57 // Process any components. 57 // Process any components.
58 for (var component in fileInfo.declaredComponents) { 58 for (var component in fileInfo.declaredComponents) {
59 var all = processVars(component); 59 var all = processVars(fileInfo.inputUrl, component);
60 60
61 // Add to list of all style sheets analyzed. 61 // Add to list of all style sheets analyzed.
62 allStyleSheets.addAll(all); 62 allStyleSheets.addAll(all);
63 } 63 }
64 64
65 processCustomPseudoElements(); 65 processCustomPseudoElements();
66 } 66 }
67 67
68 void normalize() { 68 void normalize() {
69 // Remove all var definitions for all style sheets analyzed. 69 // Remove all var definitions for all style sheets analyzed.
70 for (var tree in allStyleSheets) new _RemoveVarDefinitions().visitTree(tree) ; 70 for (var tree in allStyleSheets) new _RemoveVarDefinitions().visitTree(tree) ;
71 } 71 }
72 72
73 List<StyleSheet> processVars(var libraryInfo) { 73 List<StyleSheet> processVars(inputUrl, libraryInfo) {
74 // Get list of all stylesheet(s) dependencies referenced from this file. 74 // Get list of all stylesheet(s) dependencies referenced from this file.
75 var styleSheets = _dependencies(libraryInfo).toList(); 75 var styleSheets = _dependencies(inputUrl, libraryInfo).toList();
76 76
77 var errors = []; 77 var errors = [];
78 css.analyze(styleSheets, errors: errors, options: 78 css.analyze(styleSheets, errors: errors, options:
79 [_warningsAsErrors ? '--warnings_as_errors' : '', 'memory']); 79 [_warningsAsErrors ? '--warnings_as_errors' : '', 'memory']);
80 80
81 // Print errors as warnings. 81 // Print errors as warnings.
82 for (var e in errors) { 82 for (var e in errors) {
83 _messages.warning(e.message, e.span); 83 _messages.warning(e.message, e.span);
84 } 84 }
85 85
(...skipping 25 matching lines...) Expand all
111 for (var tree in allStyleSheets) { 111 for (var tree in allStyleSheets) {
112 polyFiller.visitTree(tree); 112 polyFiller.visitTree(tree);
113 } 113 }
114 } 114 }
115 115
116 /** 116 /**
117 * Given a component or file check if any stylesheets referenced. If so then 117 * Given a component or file check if any stylesheets referenced. If so then
118 * return a list of all referenced stylesheet dependencies (@imports or <link 118 * return a list of all referenced stylesheet dependencies (@imports or <link
119 * rel="stylesheet" ..>). 119 * rel="stylesheet" ..>).
120 */ 120 */
121 Set<StyleSheet> _dependencies(var libraryInfo, {Set<StyleSheet> seen}) { 121 Set<StyleSheet> _dependencies(inputUrl, libraryInfo, {Set<StyleSheet> seen}) {
122 if (seen == null) seen = new Set(); 122 if (seen == null) seen = new Set();
123 123
124 // Used to resolve all pathing information.
125 var inputUrl = libraryInfo is FileInfo
126 ? libraryInfo.inputUrl
127 : (libraryInfo as ComponentInfo).declaringFile.inputUrl;
128
129 for (var styleSheet in libraryInfo.styleSheets) { 124 for (var styleSheet in libraryInfo.styleSheets) {
130 if (!seen.contains(styleSheet)) { 125 if (!seen.contains(styleSheet)) {
131 // TODO(terry): VM uses expandos to implement hashes. Currently, it's a 126 // TODO(terry): VM uses expandos to implement hashes. Currently, it's a
132 // linear (not constant) time cost (see dartbug.com/5746). 127 // linear (not constant) time cost (see dartbug.com/5746).
133 // If this bug isn't fixed and performance show's this a 128 // If this bug isn't fixed and performance show's this a
134 // a problem we'll need to implement our own hashCode or 129 // a problem we'll need to implement our own hashCode or
135 // use a different key for better perf. 130 // use a different key for better perf.
136 // Add the stylesheet. 131 // Add the stylesheet.
137 seen.add(styleSheet); 132 seen.add(styleSheet);
138 133
139 // Any other imports in this stylesheet? 134 // Any other imports in this stylesheet?
140 var urlInfos = findImportsInStyleSheet(styleSheet, packageRoot, 135 var urlInfos = findImportsInStyleSheet(styleSheet, packageRoot,
141 inputUrl, _messages); 136 inputUrl, _messages);
142 137
143 // Process other imports in this stylesheets. 138 // Process other imports in this stylesheets.
144 for (var importSS in urlInfos) { 139 for (var importSS in urlInfos) {
145 var importInfo = info[importSS.resolvedPath]; 140 var importInfo = info[importSS.resolvedPath];
146 if (importInfo != null) { 141 if (importInfo != null) {
147 // Add all known stylesheets processed. 142 // Add all known stylesheets processed.
148 seen.addAll(importInfo.styleSheets); 143 seen.addAll(importInfo.styleSheets);
149 // Find dependencies for stylesheet referenced with a 144 // Find dependencies for stylesheet referenced with a
150 // @import 145 // @import
151 for (var ss in importInfo.styleSheets) { 146 for (var ss in importInfo.styleSheets) {
152 var urls = findImportsInStyleSheet(ss, packageRoot, inputUrl, 147 var urls = findImportsInStyleSheet(ss, packageRoot, inputUrl,
153 _messages); 148 _messages);
154 for (var url in urls) { 149 for (var url in urls) {
155 _dependencies(info[url.resolvedPath], seen: seen); 150 var fileInfo = info[url.resolvedPath];
151 _dependencies(fileInfo.inputUrl, fileInfo, seen: seen);
156 } 152 }
157 } 153 }
158 } 154 }
159 } 155 }
160 } 156 }
161 } 157 }
162 158
163 return seen; 159 return seen;
164 } 160 }
165 } 161 }
(...skipping 332 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 494
499 // Find all imports return list of @imports in this style tag. 495 // Find all imports return list of @imports in this style tag.
500 var urlInfos = findImportsInStyleSheet(styleSheet, _packageRoot, 496 var urlInfos = findImportsInStyleSheet(styleSheet, _packageRoot,
501 _inputUrl, _messages); 497 _inputUrl, _messages);
502 imports.addAll(urlInfos); 498 imports.addAll(urlInfos);
503 } 499 }
504 } 500 }
505 super.visitElement(node); 501 super.visitElement(node);
506 } 502 }
507 } 503 }
OLDNEW
« no previous file with comments | « pkg/polymer/lib/src/compiler.dart ('k') | pkg/polymer/lib/src/css_emitters.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698