| 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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 694 for (var e in lib.exports) { | 694 for (var e in lib.exports) { |
| 695 var exported = e.exportedLibrary.units.expand((u) => u.types).toList(); | 695 var exported = e.exportedLibrary.units.expand((u) => u.types).toList(); |
| 696 _filter(exported, e.combinators); | 696 _filter(exported, e.combinators); |
| 697 result.addAll(exported); | 697 result.addAll(exported); |
| 698 } | 698 } |
| 699 return result; | 699 return result; |
| 700 } | 700 } |
| 701 | 701 |
| 702 /// Retrieves all top-level methods that are visible if you were to import | 702 /// Retrieves all top-level methods that are visible if you were to import |
| 703 /// [lib]. This includes exported methods from other libraries too. | 703 /// [lib]. This includes exported methods from other libraries too. |
| 704 List<ClassElement> _visibleTopLevelMethodsOf(LibraryElement lib) { | 704 List<FunctionElement> _visibleTopLevelMethodsOf(LibraryElement lib) { |
| 705 var result = []; | 705 var result = []; |
| 706 result.addAll(lib.units.expand((u) => u.functions)); | 706 result.addAll(lib.units.expand((u) => u.functions)); |
| 707 for (var e in lib.exports) { | 707 for (var e in lib.exports) { |
| 708 var exported = e.exportedLibrary.units | 708 var exported = e.exportedLibrary.units |
| 709 .expand((u) => u.functions).toList(); | 709 .expand((u) => u.functions).toList(); |
| 710 _filter(exported, e.combinators); | 710 _filter(exported, e.combinators); |
| 711 result.addAll(exported); | 711 result.addAll(exported); |
| 712 } | 712 } |
| 713 return result; | 713 return result; |
| 714 } | 714 } |
| 715 | 715 |
| 716 /// Filters [elements] that come from an export, according to its show/hide | 716 /// Filters [elements] that come from an export, according to its show/hide |
| 717 /// combinators. This modifies [elements] in place. | 717 /// combinators. This modifies [elements] in place. |
| 718 void _filter(List<analyzer.Element> elements, | 718 void _filter(List<analyzer.Element> elements, |
| 719 List<NamespaceCombinator> combinators) { | 719 List<NamespaceCombinator> combinators) { |
| 720 for (var c in combinators) { | 720 for (var c in combinators) { |
| 721 if (c is ShowElementCombinator) { | 721 if (c is ShowElementCombinator) { |
| 722 var show = c.shownNames.toSet(); | 722 var show = c.shownNames.toSet(); |
| 723 elements.retainWhere((e) => show.contains(e.displayName)); | 723 elements.retainWhere((e) => show.contains(e.displayName)); |
| 724 } else if (c is HideElementCombinator) { | 724 } else if (c is HideElementCombinator) { |
| 725 var hide = c.hiddenNames.toSet(); | 725 var hide = c.hiddenNames.toSet(); |
| 726 elements.removeWhere((e) => hide.contains(e.displayName)); | 726 elements.removeWhere((e) => hide.contains(e.displayName)); |
| 727 } | 727 } |
| 728 } | 728 } |
| 729 } | 729 } |
| OLD | NEW |