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

Side by Side Diff: lib/src/analyzer.dart

Issue 19497002: Reducing the amount of code we generate in the compiler: We still continue (Closed) Base URL: git@github.com:dart-lang/web-ui.git@master
Patch Set: Created 7 years, 5 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
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 /** 5 /**
6 * Part of the template compilation that concerns with extracting information 6 * Part of the template compilation that concerns with extracting information
7 * from the HTML parse tree. 7 * from the HTML parse tree.
8 */ 8 */
9 library analyzer; 9 library analyzer;
10 10
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 if (node.tagName == 'style') { 103 if (node.tagName == 'style') {
104 // We've already parsed the CSS. 104 // We've already parsed the CSS.
105 // If this is a component remove the style node. 105 // If this is a component remove the style node.
106 if (_currentInfo is ComponentInfo) node.remove(); 106 if (_currentInfo is ComponentInfo) node.remove();
107 return; 107 return;
108 } 108 }
109 109
110 node = _bindAndReplaceElement(node); 110 node = _bindAndReplaceElement(node);
111 111
112 var lastInfo = _currentInfo; 112 var lastInfo = _currentInfo;
113 if (node.tagName == 'element') { 113 if (node.tagName == 'polymer-element') {
114 // If element is invalid _ElementLoader already reported an error, but 114 // If element is invalid _ElementLoader already reported an error, but
115 // we skip the body of the element here. 115 // we skip the body of the element here.
116 var name = node.attributes['name']; 116 var name = node.attributes['name'];
117 if (name == null) return; 117 if (name == null) return;
118 118
119 ComponentInfo component = _fileInfo.components[name]; 119 ComponentInfo component = _fileInfo.components[name];
120 if (component == null) return; 120 if (component == null) return;
121 121
122 // Associate <element> tag with its component.
123 component.elementNode = node;
124
125 _analyzeComponent(component); 122 _analyzeComponent(component);
126 123
127 _currentInfo = component; 124 _currentInfo = component;
128 125
129 // Remove the <element> tag from the tree 126 // Remove the <element> tag from the tree
130 node.remove(); 127 node.remove();
131 } 128 }
132 129
133 node.attributes.forEach((name, value) { 130 node.attributes.forEach((name, value) {
134 if (name.startsWith('on')) { 131 if (name.startsWith('on')) {
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 if (component == null) { 200 if (component == null) {
204 // TODO(jmesserly): warn for unknown element tags? 201 // TODO(jmesserly): warn for unknown element tags?
205 202
206 // <button is="fancy-button"> 203 // <button is="fancy-button">
207 var componentName = node.attributes['is']; 204 var componentName = node.attributes['is'];
208 if (componentName != null) { 205 if (componentName != null) {
209 component = _fileInfo.components[componentName]; 206 component = _fileInfo.components[componentName];
210 } else if (isCustomTag(node.tagName)) { 207 } else if (isCustomTag(node.tagName)) {
211 componentName = node.tagName; 208 componentName = node.tagName;
212 } 209 }
213 if (component == null && componentName != null) { 210 if (component == null && componentName != null &&
211 componentName != 'polymer-element') {
214 _messages.warning( 212 _messages.warning(
215 'custom element with tag name $componentName not found.', 213 'custom element with tag name $componentName not found.',
216 node.sourceSpan); 214 node.sourceSpan);
217 } 215 }
218 } 216 }
219 if (component != null && !component.hasConflict) { 217 if (component != null && !component.hasConflict) {
220 _currentInfo.usedComponents[component] = true; 218 _currentInfo.usedComponents[component] = true;
221 return component; 219 return component;
222 } 220 }
223 return null; 221 return null;
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 * must not be null. 363 * must not be null.
366 */ 364 */
367 _ElementLoader(this._global, this._fileInfo, this._packageRoot, 365 _ElementLoader(this._global, this._fileInfo, this._packageRoot,
368 this._messages) { 366 this._messages) {
369 _currentInfo = _fileInfo; 367 _currentInfo = _fileInfo;
370 } 368 }
371 369
372 void visitElement(Element node) { 370 void visitElement(Element node) {
373 switch (node.tagName) { 371 switch (node.tagName) {
374 case 'link': visitLinkElement(node); break; 372 case 'link': visitLinkElement(node); break;
375 case 'element': visitElementElement(node); break; 373 case 'element':
374 _messages.warning('<element> elements are not supported, use'
375 ' <polymer-element> instead', node.sourceSpan);
376 break;
377 case 'polymer-element':
378 visitElementElement(node);
379 break;
376 case 'script': visitScriptElement(node); break; 380 case 'script': visitScriptElement(node); break;
377 case 'head': 381 case 'head':
378 var savedInHead = _inHead; 382 var savedInHead = _inHead;
379 _inHead = true; 383 _inHead = true;
380 super.visitElement(node); 384 super.visitElement(node);
381 _inHead = savedInHead; 385 _inHead = savedInHead;
382 break; 386 break;
383 default: super.visitElement(node); break; 387 default: super.visitElement(node); break;
384 } 388 }
385 } 389 }
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after
719 } 723 }
720 } 724 }
721 } 725 }
722 } 726 }
723 } 727 }
724 } 728 }
725 729
726 return seen; 730 return seen;
727 } 731 }
728 } 732 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698