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

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

Issue 196943024: Adding some asset-related utilities to code_transformers (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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
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 /// 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:html5lib/dom.dart'; 13 import 'package:html5lib/dom.dart';
13 import 'package:html5lib/dom_parsing.dart'; 14 import 'package:html5lib/dom_parsing.dart';
14 import 'package:source_maps/span.dart'; 15 import 'package:source_maps/span.dart';
15 16
16 import 'common.dart'; 17 import 'common.dart';
17 import 'utils.dart'; 18 import 'utils.dart';
18 19
19 /// 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
20 /// 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
21 /// creates a new asset containing all the warnings. 22 /// creates a new asset containing all the warnings.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 } 68 }
68 69
69 Future<List<AssetId>> _getImportedIds( 70 Future<List<AssetId>> _getImportedIds(
70 Document document, AssetId sourceId, Transform transform) { 71 Document document, AssetId sourceId, Transform transform) {
71 var importIds = []; 72 var importIds = [];
72 var logger = transform.logger; 73 var logger = transform.logger;
73 for (var tag in document.querySelectorAll('link')) { 74 for (var tag in document.querySelectorAll('link')) {
74 if (tag.attributes['rel'] != 'import') continue; 75 if (tag.attributes['rel'] != 'import') continue;
75 var href = tag.attributes['href']; 76 var href = tag.attributes['href'];
76 var span = tag.sourceSpan; 77 var span = tag.sourceSpan;
77 var id = resolve(sourceId, href, logger, span); 78 var id = uriToAssetId(sourceId, href, logger, span);
78 if (id == null || 79 if (id == null ||
79 (id.package == 'polymer' && id.path == 'lib/init.html')) continue; 80 (id.package == 'polymer' && id.path == 'lib/init.html')) continue;
80 importIds.add(assetExists(id, transform).then((exists) { 81 importIds.add(assetExists(id, transform).then((exists) {
81 if (exists) return id; 82 if (exists) return id;
82 if (sourceId == transform.primaryInput.id) { 83 if (sourceId == transform.primaryInput.id) {
83 logger.error('couldn\'t find imported asset "${id.path}" in package ' 84 logger.error('couldn\'t find imported asset "${id.path}" in package '
84 '"${id.package}".', span: span); 85 '"${id.package}".', span: span);
85 } 86 }
86 })); 87 }));
87 } 88 }
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 'Make sure the script tag is placed after all HTML imports.'; 416 'Make sure the script tag is placed after all HTML imports.';
416 417
417 const String BOOT_JS_DEPRECATED = 418 const String BOOT_JS_DEPRECATED =
418 '"boot.js" is now deprecated. Instead, you can initialize your polymer ' 419 '"boot.js" is now deprecated. Instead, you can initialize your polymer '
419 'application by calling "initPolymer()" in your main. If you don\'t have a ' 420 'application by calling "initPolymer()" in your main. If you don\'t have a '
420 'main, then you can include our generic main by adding the following ' 421 'main, then you can include our generic main by adding the following '
421 'script tag to your page: \'<script type="application/dart">export ' 422 'script tag to your page: \'<script type="application/dart">export '
422 '"package:polymer/init.dart";</script>\'. Additionally you need to ' 423 '"package:polymer/init.dart";</script>\'. Additionally you need to '
423 'include: \'<script src="packages/browser/dart.js"></script>\' in the page ' 424 'include: \'<script src="packages/browser/dart.js"></script>\' in the page '
424 'too. Make sure these script tags come after all HTML imports.'; 425 'too. Make sure these script tags come after all HTML imports.';
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698