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 /// Logic to validate that developers are correctly using Polymer constructs. | 5 /// Logic to validate that developers are correctly using Polymer constructs. |
6 /// This is mainly used to produce warnings for feedback in the editor. | 6 /// This is mainly used to produce warnings for feedback in the editor. |
7 library polymer.src.build.linter; | 7 library polymer.src.build.linter; |
8 | 8 |
9 import 'dart:async'; | 9 import 'dart:async'; |
10 | 10 |
11 import 'package:barback/barback.dart'; | 11 import 'package:barback/barback.dart'; |
12 import 'package:code_transformers/assets.dart'; | 12 import 'package:code_transformers/assets.dart'; |
13 import 'package:html5lib/dom.dart'; | 13 import 'package:html5lib/dom.dart'; |
14 import 'package:html5lib/dom_parsing.dart'; | 14 import 'package:html5lib/dom_parsing.dart'; |
15 import 'package:source_maps/span.dart'; | 15 import 'package:source_span/source_span.dart'; |
16 | 16 |
17 import 'common.dart'; | 17 import 'common.dart'; |
18 import 'utils.dart'; | 18 import 'utils.dart'; |
19 | 19 |
20 /// A linter that checks for common Polymer errors and produces warnings to | 20 /// A linter that checks for common Polymer errors and produces warnings to |
21 /// show on the editor or the command line. Leaves sources unchanged, but | 21 /// show on the editor or the command line. Leaves sources unchanged, but |
22 /// creates a new asset containing all the warnings. | 22 /// creates a new asset containing all the warnings. |
23 class Linter extends Transformer with PolymerTransformer { | 23 class Linter extends Transformer with PolymerTransformer { |
24 final TransformOptions options; | 24 final TransformOptions options; |
25 | 25 |
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
123 | 123 |
124 | 124 |
125 /// Information needed about other polymer-element tags in order to validate | 125 /// Information needed about other polymer-element tags in order to validate |
126 /// how they are used and extended. | 126 /// how they are used and extended. |
127 /// | 127 /// |
128 /// Note: these are only created for polymer-element, because pure custom | 128 /// Note: these are only created for polymer-element, because pure custom |
129 /// elements don't have a declarative form. | 129 /// elements don't have a declarative form. |
130 class _ElementSummary { | 130 class _ElementSummary { |
131 final String tagName; | 131 final String tagName; |
132 final String extendsTag; | 132 final String extendsTag; |
133 final Span span; | 133 final SourceSpan span; |
134 | 134 |
135 _ElementSummary extendsType; | 135 _ElementSummary extendsType; |
136 bool hasConflict = false; | 136 bool hasConflict = false; |
137 | 137 |
138 String get baseExtendsTag { | 138 String get baseExtendsTag { |
139 if (extendsType != null) return extendsType.baseExtendsTag; | 139 if (extendsType != null) return extendsType.baseExtendsTag; |
140 if (extendsTag != null && !extendsTag.contains('-')) return extendsTag; | 140 if (extendsTag != null && !extendsTag.contains('-')) return extendsTag; |
141 return null; | 141 return null; |
142 } | 142 } |
143 | 143 |
(...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
450 '\'<script type="application/dart">export "package:polymer/init.dart";' | 450 '\'<script type="application/dart">export "package:polymer/init.dart";' |
451 '</script>\' or add your own script tag and call that function. ' | 451 '</script>\' or add your own script tag and call that function. ' |
452 'Make sure the script tag is placed after all HTML imports.'; | 452 'Make sure the script tag is placed after all HTML imports.'; |
453 | 453 |
454 const String NO_DART_SCRIPT_AND_EXPERIMENTAL = | 454 const String NO_DART_SCRIPT_AND_EXPERIMENTAL = |
455 'The experimental bootstrap feature doesn\'t support script tags on ' | 455 'The experimental bootstrap feature doesn\'t support script tags on ' |
456 'the main document (for now).'; | 456 'the main document (for now).'; |
457 | 457 |
458 const List<String> INTERNALLY_DEFINED_ELEMENTS = | 458 const List<String> INTERNALLY_DEFINED_ELEMENTS = |
459 const ['auto-binding-dart', 'polymer-element']; | 459 const ['auto-binding-dart', 'polymer-element']; |
OLD | NEW |