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

Side by Side Diff: pkg/polymer/lib/src/build/script_compactor.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
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 /** Transfomer that combines multiple dart script tags into a single one. */ 5 /** Transfomer that combines multiple dart script tags into a single one. */
6 library polymer.src.build.script_compactor; 6 library polymer.src.build.script_compactor;
7 7
8 import 'dart:async'; 8 import 'dart:async';
9 import 'dart:convert'; 9 import 'dart:convert';
10 10
11 import 'package:analyzer/src/generated/ast.dart'; 11 import 'package:analyzer/src/generated/ast.dart';
12 import 'package:analyzer/src/generated/error.dart'; 12 import 'package:analyzer/src/generated/error.dart';
13 import 'package:analyzer/src/generated/parser.dart'; 13 import 'package:analyzer/src/generated/parser.dart';
14 import 'package:analyzer/src/generated/scanner.dart'; 14 import 'package:analyzer/src/generated/scanner.dart';
15 import 'package:barback/barback.dart'; 15 import 'package:barback/barback.dart';
16 import 'package:html5lib/parser.dart' show parseFragment;
17 import 'package:path/path.dart' as path; 16 import 'package:path/path.dart' as path;
18 import 'package:source_maps/span.dart' show SourceFile; 17 import 'package:source_maps/span.dart' show SourceFile;
19 18
20 import 'code_extractor.dart'; // import just for documentation. 19 import 'code_extractor.dart'; // import just for documentation.
21 import 'common.dart'; 20 import 'common.dart';
22 21
23 /** 22 /**
24 * Combines Dart script tags into a single script tag, and creates a new Dart 23 * Combines Dart script tags into a single script tag, and creates a new Dart
25 * file that calls the main function of each of the original script tags. 24 * file that calls the main function of each of the original script tags.
26 * 25 *
(...skipping 19 matching lines...) Expand all
46 var secondaryId = id.addExtension('.scriptUrls'); 45 var secondaryId = id.addExtension('.scriptUrls');
47 var logger = transform.logger; 46 var logger = transform.logger;
48 return readPrimaryAsHtml(transform).then((document) { 47 return readPrimaryAsHtml(transform).then((document) {
49 return transform.readInputAsString(secondaryId).then((libraryIds) { 48 return transform.readInputAsString(secondaryId).then((libraryIds) {
50 var libraries = (JSON.decode(libraryIds) as Iterable).map( 49 var libraries = (JSON.decode(libraryIds) as Iterable).map(
51 (data) => new AssetId.deserialize(data)).toList(); 50 (data) => new AssetId.deserialize(data)).toList();
52 var mainLibraryId; 51 var mainLibraryId;
53 var mainScriptTag; 52 var mainScriptTag;
54 bool changed = false; 53 bool changed = false;
55 54
56 for (var tag in document.queryAll('script')) { 55 for (var tag in document.querySelectorAll('script')) {
57 var src = tag.attributes['src']; 56 var src = tag.attributes['src'];
58 if (src == 'packages/polymer/boot.js') { 57 if (src == 'packages/polymer/boot.js') {
59 tag.remove(); 58 tag.remove();
60 continue; 59 continue;
61 } 60 }
62 if (tag.attributes['type'] != 'application/dart') continue; 61 if (tag.attributes['type'] != 'application/dart') continue;
63 if (src == null) { 62 if (src == null) {
64 logger.warning('unexpected script without a src url. The ' 63 logger.warning('unexpected script without a src url. The '
65 'ScriptCompactor transformer should run after running the ' 64 'ScriptCompactor transformer should run after running the '
66 'InlineCodeExtractor', span: tag.sourceSpan); 65 'InlineCodeExtractor', span: tag.sourceSpan);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
277 "() => Polymer.register('$tagName', $prefix.$typeName)"; 276 "() => Polymer.register('$tagName', $prefix.$typeName)";
278 } 277 }
279 278
280 _getSpan(SourceFile file, ASTNode node) => file.span(node.offset, node.end); 279 _getSpan(SourceFile file, ASTNode node) => file.span(node.offset, node.end);
281 280
282 const MAIN_HEADER = """ 281 const MAIN_HEADER = """
283 library app_bootstrap; 282 library app_bootstrap;
284 283
285 import 'package:polymer/polymer.dart'; 284 import 'package:polymer/polymer.dart';
286 """; 285 """;
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698