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

Unified Diff: pkg/code_transformers/lib/src/resolver_impl.dart

Issue 208623008: Include exports in resolver.libraries (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 9 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 | « no previous file | pkg/code_transformers/test/resolver_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..93825212a48964889a989ea1f74dbda1e2dd9670 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.importedLibraries.forEach(_collectLibraries);
+ lib.exportedLibraries.forEach(_collectLibraries);
+ }
LibraryElement getLibraryByName(String libraryName) =>
libraries.firstWhere((l) => l.name == libraryName, orElse: () => null);
« no previous file with comments | « no previous file | pkg/code_transformers/test/resolver_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698