| OLD | NEW |
| 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 Loading... |
| 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(sdkDir != null ? sdkDir : dartSdkDirectory); |
| 51 : resolvers = new Resolvers.fromMock({ |
| 52 // The list of types below is derived from: |
| 53 // * types we use via our smoke queries, including HtmlElement and |
| 54 // types from `_typeHandlers` (deserialize.dart) |
| 55 // * types that are used internally by the resolver (see |
| 56 // _initializeFrom in resolver.dart). |
| 57 'dart:core': ''' |
| 58 library dart.core; |
| 59 class Object {} |
| 60 class Function {} |
| 61 class StackTrace {} |
| 62 class Symbol {} |
| 63 class Type {} |
| 64 |
| 65 class String extends Object {} |
| 66 class bool extends Object {} |
| 67 class num extends Object {} |
| 68 class int extends num {} |
| 69 class double extends num {} |
| 70 class DateTime extends Object {} |
| 71 class Null extends Object {} |
| 72 |
| 73 class Deprecated extends Object { |
| 74 final String expires; |
| 75 const Deprecated(this.expires); |
| 76 } |
| 77 const Object deprecated = const Deprecated("next release"); |
| 78 |
| 79 class List<V> extends Object {} |
| 80 class Map<K, V> extends Object {} |
| 81 ''', |
| 82 'dart:html': ''' |
| 83 library dart.html; |
| 84 class HtmlElement {} |
| 85 ''', |
| 86 }); |
| 87 |
| 88 |
| 49 | 89 |
| 50 /// Only run on entry point .html files. | 90 /// Only run on entry point .html files. |
| 51 // TODO(nweiz): This should just take an AssetId when barback <0.13.0 support | 91 // TODO(nweiz): This should just take an AssetId when barback <0.13.0 support |
| 52 // is dropped. | 92 // is dropped. |
| 53 Future<bool> isPrimary(idOrAsset) { | 93 Future<bool> isPrimary(idOrAsset) { |
| 54 var id = idOrAsset is AssetId ? idOrAsset : idOrAsset.id; | 94 var id = idOrAsset is AssetId ? idOrAsset : idOrAsset.id; |
| 55 return new Future.value(options.isHtmlEntryPoint(id)); | 95 return new Future.value(options.isHtmlEntryPoint(id)); |
| 56 } | 96 } |
| 57 | 97 |
| 58 Future apply(Transform transform) => | 98 Future apply(Transform transform) => |
| (...skipping 661 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 720 for (var c in combinators) { | 760 for (var c in combinators) { |
| 721 if (c is ShowElementCombinator) { | 761 if (c is ShowElementCombinator) { |
| 722 var show = c.shownNames.toSet(); | 762 var show = c.shownNames.toSet(); |
| 723 elements.retainWhere((e) => show.contains(e.displayName)); | 763 elements.retainWhere((e) => show.contains(e.displayName)); |
| 724 } else if (c is HideElementCombinator) { | 764 } else if (c is HideElementCombinator) { |
| 725 var hide = c.hiddenNames.toSet(); | 765 var hide = c.hiddenNames.toSet(); |
| 726 elements.removeWhere((e) => hide.contains(e.displayName)); | 766 elements.removeWhere((e) => hide.contains(e.displayName)); |
| 727 } | 767 } |
| 728 } | 768 } |
| 729 } | 769 } |
| OLD | NEW |