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

Side by Side Diff: pkg/polymer/lib/src/build/linter.dart

Issue 50073007: fix barback and polymer build warnings (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month 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
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 * 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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 76
77 Future _readAndCollectElements(AssetId id, Transform transform, 77 Future _readAndCollectElements(AssetId id, Transform transform,
78 Set<AssetId> seen, Map<String, _ElementSummary> elements) { 78 Set<AssetId> seen, Map<String, _ElementSummary> elements) {
79 if (id == null || seen.contains(id)) return new Future.value(null); 79 if (id == null || seen.contains(id)) return new Future.value(null);
80 seen.add(id); 80 seen.add(id);
81 return readAsHtml(id, transform).then( 81 return readAsHtml(id, transform).then(
82 (doc) => _collectElements(doc, id, transform, seen, elements)); 82 (doc) => _collectElements(doc, id, transform, seen, elements));
83 } 83 }
84 84
85 Future<List<AssetId>> _getImportedIds( 85 Future<List<AssetId>> _getImportedIds(
86 Document document, AssetId sourceId, Tranform transform) { 86 Document document, AssetId sourceId, Transform transform) {
87 var importIds = []; 87 var importIds = [];
88 var logger = transform.logger; 88 var logger = transform.logger;
89 for (var tag in document.queryAll('link')) { 89 for (var tag in document.queryAll('link')) {
90 if (tag.attributes['rel'] != 'import') continue; 90 if (tag.attributes['rel'] != 'import') continue;
91 var href = tag.attributes['href']; 91 var href = tag.attributes['href'];
92 var span = tag.sourceSpan; 92 var span = tag.sourceSpan;
93 var id = resolve(sourceId, href, logger, span); 93 var id = resolve(sourceId, href, logger, span);
94 if (id == null || 94 if (id == null ||
95 (id.package == 'polymer' && id.path == 'lib/init.html')) continue; 95 (id.package == 'polymer' && id.path == 'lib/init.html')) continue;
96 importIds.add(assetExists(id, transform).then((exists) { 96 importIds.add(assetExists(id, transform).then((exists) {
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 super.visitElement(node); 246 super.visitElement(node);
247 break; 247 break;
248 } 248 }
249 } 249 }
250 250
251 void run(Document doc) { 251 void run(Document doc) {
252 visit(doc); 252 visit(doc);
253 253
254 if (_isEntrypoint && !_dartTagSeen) { 254 if (_isEntrypoint && !_dartTagSeen) {
255 _logger.error(USE_INIT_DART, span: doc.body.sourceSpan); 255 _logger.error(USE_INIT_DART, span: doc.body.sourceSpan);
256 } 256 }
257 257
258 if (_isEntrypoint && !_dartJSSeen) { 258 if (_isEntrypoint && !_dartJSSeen) {
259 // TODO(sigmund): remove this when webkitStartDart is gone. 259 // TODO(sigmund): remove this when webkitStartDart is gone.
260 _logger.error(USE_DART_JS, span: doc.body.sourceSpan); 260 _logger.error(USE_DART_JS, span: doc.body.sourceSpan);
261 } 261 }
262 } 262 }
263 263
264 /** Produce warnings for invalid link-rel tags. */ 264 /** Produce warnings for invalid link-rel tags. */
265 void _validateLinkElement(Element node) { 265 void _validateLinkElement(Element node) {
266 var rel = node.attributes['rel']; 266 var rel = node.attributes['rel'];
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
534 */ 534 */
535 bool _isCustomTag(String name) { 535 bool _isCustomTag(String name) {
536 if (name == null || !name.contains('-')) return false; 536 if (name == null || !name.contains('-')) return false;
537 return !_invalidTagNames.containsKey(name); 537 return !_invalidTagNames.containsKey(name);
538 } 538 }
539 539
540 const String _RED_COLOR = '\u001b[31m'; 540 const String _RED_COLOR = '\u001b[31m';
541 const String _MAGENTA_COLOR = '\u001b[35m'; 541 const String _MAGENTA_COLOR = '\u001b[35m';
542 const String _NO_COLOR = '\u001b[0m'; 542 const String _NO_COLOR = '\u001b[0m';
543 543
544 const String USE_INIT_DART = 544 const String USE_INIT_DART =
545 'To run a polymer applications, you need to call "initPolymer". You can ' 545 'To run a polymer applications, you need to call "initPolymer". You can '
546 'either include a generic script tag that does this for you:' 546 'either include a generic script tag that does this for you:'
547 '\'<script type="application/dart">import "package:polymer/init.dart";' 547 '\'<script type="application/dart">import "package:polymer/init.dart";'
548 '</script>\' or add your own script tag and call that function. ' 548 '</script>\' or add your own script tag and call that function. '
549 'Make sure the script tag is placed after all HTML imports.'; 549 'Make sure the script tag is placed after all HTML imports.';
550 550
551 const String USE_DART_JS = 551 const String USE_DART_JS =
552 'To run a polymer applications in Dartium, make sure to include' 552 'To run a polymer applications in Dartium, make sure to include'
553 '\'<script src="packages/browser/dart.js"></script>\' in your page'; 553 '\'<script src="packages/browser/dart.js"></script>\' in your page';
554 554
555 const String BOOT_JS_DEPRECATED = 555 const String BOOT_JS_DEPRECATED =
556 '"boot.js" is now deprecated. Instead, you can initialize your polymer ' 556 '"boot.js" is now deprecated. Instead, you can initialize your polymer '
557 'application by calling "initPolymer()" in your main. If you don\'t have a ' 557 'application by calling "initPolymer()" in your main. If you don\'t have a '
558 'main, then you can include our generic main by adding the following ' 558 'main, then you can include our generic main by adding the following '
559 'script tag to your page: \'<script type="application/dart">import ' 559 'script tag to your page: \'<script type="application/dart">import '
560 '"package:polymer/init.dart";</script>\'. Additionally you need to ' 560 '"package:polymer/init.dart";</script>\'. Additionally you need to '
561 'include: \'<script src="packages/browser/dart.js"></script>\' in the page ' 561 'include: \'<script src="packages/browser/dart.js"></script>\' in the page '
562 'too. Make sure these script tags come after all HTML imports.'; 562 'too. Make sure these script tags come after all HTML imports.';
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698