Chromium Code Reviews| Index: pkg/code_transformers/lib/src/resolver_impl.dart |
| diff --git a/pkg/code_transformers/lib/src/resolver_impl.dart b/pkg/code_transformers/lib/src/resolver_impl.dart |
| index f26c0726a4f58f5a5e14bee5e33793883f81dd19..22492ac4684b5db090731a14f1650adf680d822a 100644 |
| --- a/pkg/code_transformers/lib/src/resolver_impl.dart |
| +++ b/pkg/code_transformers/lib/src/resolver_impl.dart |
| @@ -44,6 +44,7 @@ class ResolverImpl implements Resolver { |
| /// The currently resolved entry libraries, or null if nothing is resolved. |
| List<LibraryElement> _entryLibraries; |
| + Set<LibraryElement> _libraries; |
| /// Future indicating when this resolver is done in the current phase. |
| Future _lastPhaseComplete = new Future.value(); |
| @@ -101,6 +102,7 @@ class ResolverImpl implements Resolver { |
| // Clear out libraries since they should not be referenced after release. |
| _entryLibraries = null; |
| + _libraries = null; |
| _currentTransform = null; |
| } |
| @@ -156,8 +158,22 @@ class ResolverImpl implements Resolver { |
| }); |
| } |
| - Iterable<LibraryElement> get libraries => |
| - _entryLibraries.expand((lib) => lib.visibleLibraries).toSet(); |
| + Iterable<LibraryElement> get libraries { |
| + if (_libraries == null) { |
| + // Note: we don't use `lib.visibleLibraries` because that excludes the |
| + // exports seen in the entry libraries. |
| + _libraries = new Set<LibraryElement>(); |
| + _entryLibraries.forEach(_collectLibraries); |
| + } |
| + return _libraries; |
| + } |
| + |
| + void _collectLibraries(LibraryElement lib) { |
| + if (lib == null || _libraries.contains(lib)) return; |
| + _libraries.add(lib); |
| + lib.imports.map((i) => i.importedLibrary).forEach(_collectLibraries); |
|
blois
2014/03/21 22:13:21
use importedLibraries rather than imports?
ditto f
Siggi Cherem (dart-lang)
2014/03/21 22:21:10
Done. Nice, I totally missed that API :)
|
| + lib.exports.map((e) => e.exportedLibrary).forEach(_collectLibraries); |
| + } |
| LibraryElement getLibraryByName(String libraryName) => |
| libraries.firstWhere((l) => l.name == libraryName, orElse: () => null); |