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

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

Issue 315813003: Support using a mock SDK with the resolver in code-transformers, and switch (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 6 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
(...skipping 27 matching lines...) Expand all
38 /// [ImportInliner] on an earlier phase. 38 /// [ImportInliner] on an earlier phase.
39 /// 39 ///
40 /// Internally, this transformer will convert each script tag into an import 40 /// Internally, this transformer will convert each script tag into an import
41 /// statement to a library, and then uses `initPolymer` (see polymer.dart) to 41 /// statement to a library, and then uses `initPolymer` (see polymer.dart) to
42 /// process `@initMethod` and `@CustomTag` annotations in those libraries. 42 /// process `@initMethod` and `@CustomTag` annotations in those libraries.
43 class ScriptCompactor extends Transformer { 43 class ScriptCompactor extends Transformer {
44 final Resolvers resolvers; 44 final Resolvers resolvers;
45 final TransformOptions options; 45 final TransformOptions options;
46 46
47 ScriptCompactor(this.options, {String sdkDir}) 47 ScriptCompactor(this.options, {String sdkDir})
48 : resolvers = new Resolvers(sdkDir != null ? sdkDir : dartSdkDirectory); 48 // TODO(sigmund): consider restoring here a resolver that uses the real
49 // SDK once the analyzer is lazy and only an resolves what it needs:
50 //: resolvers = new Resolvers.fromSdkDirectory(
51 // sdkDir != null ? sdkDir : dartSdkDirectory);
52 : resolvers = new Resolvers.fromMock({
53 'dart:core': '''
Jennifer Messerly 2014/06/04 04:17:39 just curious, how was this list chosen?
Siggi Cherem (dart-lang) 2014/06/04 21:25:19 The list of libraries was a bit adhoc, I was addin
54 library dart.core;
55 class Object {}
56
57 class String extends Object {}
58 class num extends Object {}
59 class int extends num {}
60 class double extends num {}
61 class List<V> extends Object {}
62 class Map<K, V> extends Object {}
63 class Set<V> extends Object {}
64 ''',
65 'dart:async': 'library dart.async;',
66 'dart:html': '''
67 library dart.html;
68 class HtmlElement {}
69 ''',
70 'dart:math': 'library dart.math;',
71 'dart:collection': 'library dart.collection;',
72 'dart:js': 'library dart.js;',
73 'dart:svg': 'library dart.svg;',
74 'dart:convert': 'library dart.convert;',
75 'dart:mirrors': 'library dart.mirrors;',
76 'dart:isolate': 'library dart.isolate;',
77 });
78
79
49 80
50 /// Only run on entry point .html files. 81 /// Only run on entry point .html files.
51 // TODO(nweiz): This should just take an AssetId when barback <0.13.0 support 82 // TODO(nweiz): This should just take an AssetId when barback <0.13.0 support
52 // is dropped. 83 // is dropped.
53 Future<bool> isPrimary(idOrAsset) { 84 Future<bool> isPrimary(idOrAsset) {
54 var id = idOrAsset is AssetId ? idOrAsset : idOrAsset.id; 85 var id = idOrAsset is AssetId ? idOrAsset : idOrAsset.id;
55 return new Future.value(options.isHtmlEntryPoint(id)); 86 return new Future.value(options.isHtmlEntryPoint(id));
56 } 87 }
57 88
58 Future apply(Transform transform) => 89 Future apply(Transform transform) =>
(...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 for (var c in combinators) { 751 for (var c in combinators) {
721 if (c is ShowElementCombinator) { 752 if (c is ShowElementCombinator) {
722 var show = c.shownNames.toSet(); 753 var show = c.shownNames.toSet();
723 elements.retainWhere((e) => show.contains(e.displayName)); 754 elements.retainWhere((e) => show.contains(e.displayName));
724 } else if (c is HideElementCombinator) { 755 } else if (c is HideElementCombinator) {
725 var hide = c.hiddenNames.toSet(); 756 var hide = c.hiddenNames.toSet();
726 elements.removeWhere((e) => hide.contains(e.displayName)); 757 elements.removeWhere((e) => hide.contains(e.displayName));
727 } 758 }
728 } 759 }
729 } 760 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698