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

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

Issue 172923002: [polymer] fix editor hints -- query/queryAll and unused imports (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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
« no previous file with comments | « pkg/polymer/lib/src/build/code_extractor.dart ('k') | pkg/polymer/lib/src/build/runner.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
11 import 'dart:io';
12 import 'dart:async'; 11 import 'dart:async';
13 import 'dart:mirrors';
14 import 'dart:convert' show JSON;
15 12
16 import 'package:barback/barback.dart'; 13 import 'package:barback/barback.dart';
17 import 'package:html5lib/dom.dart'; 14 import 'package:html5lib/dom.dart';
18 import 'package:html5lib/dom_parsing.dart'; 15 import 'package:html5lib/dom_parsing.dart';
19 import 'package:source_maps/span.dart'; 16 import 'package:source_maps/span.dart';
20 17
21 import 'common.dart'; 18 import 'common.dart';
22 import 'utils.dart'; 19 import 'utils.dart';
23 20
24 /** 21 /**
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
72 if (id == null || seen.contains(id)) return new Future.value(null); 69 if (id == null || seen.contains(id)) return new Future.value(null);
73 seen.add(id); 70 seen.add(id);
74 return readAsHtml(id, transform).then( 71 return readAsHtml(id, transform).then(
75 (doc) => _collectElements(doc, id, transform, seen, elements)); 72 (doc) => _collectElements(doc, id, transform, seen, elements));
76 } 73 }
77 74
78 Future<List<AssetId>> _getImportedIds( 75 Future<List<AssetId>> _getImportedIds(
79 Document document, AssetId sourceId, Transform transform) { 76 Document document, AssetId sourceId, Transform transform) {
80 var importIds = []; 77 var importIds = [];
81 var logger = transform.logger; 78 var logger = transform.logger;
82 for (var tag in document.queryAll('link')) { 79 for (var tag in document.querySelectorAll('link')) {
83 if (tag.attributes['rel'] != 'import') continue; 80 if (tag.attributes['rel'] != 'import') continue;
84 var href = tag.attributes['href']; 81 var href = tag.attributes['href'];
85 var span = tag.sourceSpan; 82 var span = tag.sourceSpan;
86 var id = resolve(sourceId, href, logger, span); 83 var id = resolve(sourceId, href, logger, span);
87 if (id == null || 84 if (id == null ||
88 (id.package == 'polymer' && id.path == 'lib/init.html')) continue; 85 (id.package == 'polymer' && id.path == 'lib/init.html')) continue;
89 importIds.add(assetExists(id, transform).then((exists) { 86 importIds.add(assetExists(id, transform).then((exists) {
90 if (exists) return id; 87 if (exists) return id;
91 if (sourceId == transform.primaryInput.id) { 88 if (sourceId == transform.primaryInput.id) {
92 logger.error('couldn\'t find imported asset "${id.path}" in package ' 89 logger.error('couldn\'t find imported asset "${id.path}" in package '
93 '"${id.package}".', span: span); 90 '"${id.package}".', span: span);
94 } 91 }
95 })); 92 }));
96 } 93 }
97 return Future.wait(importIds); 94 return Future.wait(importIds);
98 } 95 }
99 96
100 void _addElements(Document document, TransformLogger logger, 97 void _addElements(Document document, TransformLogger logger,
101 Map<String, _ElementSummary> elements) { 98 Map<String, _ElementSummary> elements) {
102 for (var tag in document.queryAll('polymer-element')) { 99 for (var tag in document.querySelectorAll('polymer-element')) {
103 var name = tag.attributes['name']; 100 var name = tag.attributes['name'];
104 if (name == null) continue; 101 if (name == null) continue;
105 var extendsTag = tag.attributes['extends']; 102 var extendsTag = tag.attributes['extends'];
106 var span = tag.sourceSpan; 103 var span = tag.sourceSpan;
107 var existing = elements[name]; 104 var existing = elements[name];
108 if (existing != null) { 105 if (existing != null) {
109 106
110 // Report warning only once. 107 // Report warning only once.
111 if (existing.hasConflict) continue; 108 if (existing.hasConflict) continue;
112 existing.hasConflict = true; 109 existing.hasConflict = true;
(...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after
454 'Make sure the script tag is placed after all HTML imports.'; 451 'Make sure the script tag is placed after all HTML imports.';
455 452
456 const String BOOT_JS_DEPRECATED = 453 const String BOOT_JS_DEPRECATED =
457 '"boot.js" is now deprecated. Instead, you can initialize your polymer ' 454 '"boot.js" is now deprecated. Instead, you can initialize your polymer '
458 'application by calling "initPolymer()" in your main. If you don\'t have a ' 455 'application by calling "initPolymer()" in your main. If you don\'t have a '
459 'main, then you can include our generic main by adding the following ' 456 'main, then you can include our generic main by adding the following '
460 'script tag to your page: \'<script type="application/dart">export ' 457 'script tag to your page: \'<script type="application/dart">export '
461 '"package:polymer/init.dart";</script>\'. Additionally you need to ' 458 '"package:polymer/init.dart";</script>\'. Additionally you need to '
462 'include: \'<script src="packages/browser/dart.js"></script>\' in the page ' 459 'include: \'<script src="packages/browser/dart.js"></script>\' in the page '
463 'too. Make sure these script tags come after all HTML imports.'; 460 'too. Make sure these script tags come after all HTML imports.';
OLDNEW
« no previous file with comments | « pkg/polymer/lib/src/build/code_extractor.dart ('k') | pkg/polymer/lib/src/build/runner.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698