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

Unified Diff: pkg/polymer/lib/src/build/script_compactor.dart

Issue 180933002: combine script extractor and import inliner (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: fix multiple linked scripts 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/polymer/lib/src/build/import_inliner.dart ('k') | pkg/polymer/lib/transformer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/polymer/lib/src/build/script_compactor.dart
diff --git a/pkg/polymer/lib/src/build/script_compactor.dart b/pkg/polymer/lib/src/build/script_compactor.dart
index 9dd07e2bce04db2bf541174e5d079d3bc206f6df..ac03e838b196ed8dc372e66b26643bfae5facec9 100644
--- a/pkg/polymer/lib/src/build/script_compactor.dart
+++ b/pkg/polymer/lib/src/build/script_compactor.dart
@@ -9,14 +9,11 @@ import 'dart:async';
import 'dart:convert';
import 'package:analyzer/src/generated/ast.dart';
-import 'package:analyzer/src/generated/error.dart';
-import 'package:analyzer/src/generated/parser.dart';
-import 'package:analyzer/src/generated/scanner.dart';
import 'package:barback/barback.dart';
import 'package:path/path.dart' as path;
import 'package:source_maps/span.dart' show SourceFile;
-import 'code_extractor.dart'; // import just for documentation.
+import 'import_inliner.dart' show ImportInliner; // just for docs.
import 'common.dart';
/// Combines Dart script tags into a single script tag, and creates a new Dart
@@ -24,7 +21,7 @@ import 'common.dart';
///
/// This transformer assumes that all script tags point to external files. To
/// support script tags with inlined code, use this transformer after running
-/// [InlineCodeExtractor] on an earlier phase.
+/// [ImportInliner] on an earlier phase.
///
/// Internally, this transformer will convert each script tag into an import
/// statement to a library, and then uses `initPolymer` (see polymer.dart) to
@@ -129,7 +126,7 @@ class ScriptCompactor extends Transformer with PolymerTransformer {
var initializers = [];
return transform.readInputAsString(dartLibrary).then((code) {
var file = new SourceFile.text(_simpleUriForSource(dartLibrary), code);
- var unit = _parseCompilationUnit(code);
+ var unit = parseCompilationUnit(code);
return Future.forEach(unit.directives, (directive) {
// Include anything from parts.
@@ -224,21 +221,6 @@ class ScriptCompactor extends Transformer with PolymerTransformer {
}
}
-/// Parse [code] using analyzer.
-CompilationUnit _parseCompilationUnit(String code) {
- var errorListener = new _ErrorCollector();
- var reader = new CharSequenceReader(code);
- var scanner = new Scanner(null, reader, errorListener);
- var token = scanner.tokenize();
- var parser = new Parser(null, errorListener);
- return parser.parseCompilationUnit(token);
-}
-
-class _ErrorCollector extends AnalysisErrorListener {
- final errors = <AnalysisError>[];
- onError(error) => errors.add(error);
-}
-
// TODO(sigmund): consider support for importing annotations with prefixes.
bool _isInitMethodAnnotation(Annotation node) =>
node.name.name == 'initMethod' && node.constructorName == null &&
« no previous file with comments | « pkg/polymer/lib/src/build/import_inliner.dart ('k') | pkg/polymer/lib/transformer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698