| OLD | NEW |
| 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 * Logic to validate that developers are correctly using Polymer constructs. | 6 * Logic to validate that developers are correctly using Polymer constructs. |
| 7 * This is mainly used to produce warnings for feedback in the editor. | 7 * This is mainly used to produce warnings for feedback in the editor. |
| 8 */ | 8 */ |
| 9 library polymer.src.build.linter; | 9 library polymer.src.build.linter; |
| 10 | 10 |
| (...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 ? extendsTag : extendsType.baseExtendsTag; | 213 ? extendsTag : extendsType.baseExtendsTag; |
| 214 | 214 |
| 215 _ElementSummary(this.tagName, this.extendsTag, this.span); | 215 _ElementSummary(this.tagName, this.extendsTag, this.span); |
| 216 | 216 |
| 217 String toString() => "($tagName <: $extendsTag)"; | 217 String toString() => "($tagName <: $extendsTag)"; |
| 218 } | 218 } |
| 219 | 219 |
| 220 class _LinterVisitor extends TreeVisitor { | 220 class _LinterVisitor extends TreeVisitor { |
| 221 TransformLogger _logger; | 221 TransformLogger _logger; |
| 222 bool _inPolymerElement = false; | 222 bool _inPolymerElement = false; |
| 223 bool _dartJSSeen = false; | |
| 224 bool _dartTagSeen = false; | 223 bool _dartTagSeen = false; |
| 225 bool _isEntrypoint; | 224 bool _isEntrypoint; |
| 226 Map<String, _ElementSummary> _elements; | 225 Map<String, _ElementSummary> _elements; |
| 227 | 226 |
| 228 _LinterVisitor(this._logger, this._elements, this._isEntrypoint) { | 227 _LinterVisitor(this._logger, this._elements, this._isEntrypoint) { |
| 229 // We normalize the map, so each element has a direct reference to any | 228 // We normalize the map, so each element has a direct reference to any |
| 230 // element it extends from. | 229 // element it extends from. |
| 231 for (var tag in _elements.values) { | 230 for (var tag in _elements.values) { |
| 232 var extendsTag = tag.extendsTag; | 231 var extendsTag = tag.extendsTag; |
| 233 if (extendsTag == null) continue; | 232 if (extendsTag == null) continue; |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 362 } | 361 } |
| 363 _dartTagSeen = true; | 362 _dartTagSeen = true; |
| 364 } | 363 } |
| 365 | 364 |
| 366 if (src == null) return; | 365 if (src == null) return; |
| 367 | 366 |
| 368 if (src == 'packages/polymer/boot.js') { | 367 if (src == 'packages/polymer/boot.js') { |
| 369 _logger.warning(BOOT_JS_DEPRECATED, span: node.sourceSpan); | 368 _logger.warning(BOOT_JS_DEPRECATED, span: node.sourceSpan); |
| 370 return; | 369 return; |
| 371 } | 370 } |
| 372 if (src == 'packages/browser/dart.js' || | |
| 373 src == 'packages/unittest/test_controller.js') { | |
| 374 _dartJSSeen = true; | |
| 375 return; | |
| 376 } | |
| 377 | 371 |
| 378 if (src.endsWith('.dart') && !isDart) { | 372 if (src.endsWith('.dart') && !isDart) { |
| 379 _logger.warning('Wrong script type, expected type="application/dart".', | 373 _logger.warning('Wrong script type, expected type="application/dart".', |
| 380 span: node.sourceSpan); | 374 span: node.sourceSpan); |
| 381 return; | 375 return; |
| 382 } | 376 } |
| 383 | 377 |
| 384 if (!src.endsWith('.dart') && isDart) { | 378 if (!src.endsWith('.dart') && isDart) { |
| 385 _logger.warning('"application/dart" scripts should ' | 379 _logger.warning('"application/dart" scripts should ' |
| 386 'use the .dart file extension.', | 380 'use the .dart file extension.', |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 'Make sure the script tag is placed after all HTML imports.'; | 529 'Make sure the script tag is placed after all HTML imports.'; |
| 536 | 530 |
| 537 const String BOOT_JS_DEPRECATED = | 531 const String BOOT_JS_DEPRECATED = |
| 538 '"boot.js" is now deprecated. Instead, you can initialize your polymer ' | 532 '"boot.js" is now deprecated. Instead, you can initialize your polymer ' |
| 539 'application by calling "initPolymer()" in your main. If you don\'t have a ' | 533 'application by calling "initPolymer()" in your main. If you don\'t have a ' |
| 540 'main, then you can include our generic main by adding the following ' | 534 'main, then you can include our generic main by adding the following ' |
| 541 'script tag to your page: \'<script type="application/dart">export ' | 535 'script tag to your page: \'<script type="application/dart">export ' |
| 542 '"package:polymer/init.dart";</script>\'. Additionally you need to ' | 536 '"package:polymer/init.dart";</script>\'. Additionally you need to ' |
| 543 'include: \'<script src="packages/browser/dart.js"></script>\' in the page ' | 537 'include: \'<script src="packages/browser/dart.js"></script>\' in the page ' |
| 544 'too. Make sure these script tags come after all HTML imports.'; | 538 'too. Make sure these script tags come after all HTML imports.'; |
| OLD | NEW |