diff --git a/CHANGELOG.md b/CHANGELOG.md index bd565c7..d5d8485 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,12 @@ +## 0.4.2+1 + +* Contains a fix for the `useSharedSources` option that could result in null + library elements when running on multiple entry points. + ## 0.4.2 * Use Strong Mode, fixes - [#38](https://github.com/dart-lang/code_transformers/issues/38). + [#38](https://github.com/dart-lang/code_transformers/issues/38). ## 0.4.1 diff --git a/lib/src/resolver_impl.dart b/lib/src/resolver_impl.dart index efc5cfd..699f3eb 100644 --- a/lib/src/resolver_impl.dart +++ b/lib/src/resolver_impl.dart @@ -49,11 +49,15 @@ class ResolverImpl implements Resolver { /// Completer for wrapping up the current phase. Completer _currentPhaseComplete; + /// Whether or not we are using a shared sources cache. + final bool _usingSharedSources; + /// Creates a resolver with a given [sdk] implementation for resolving /// `dart:*` imports. ResolverImpl(DartSdk sdk, DartUriResolver dartUriResolver, {AnalysisOptions options, Map sources}) - : sources = sources ?? {} { + : _usingSharedSources = sources != null, + sources = sources ?? {} { if (options == null) { options = new AnalysisOptionsImpl() ..cacheSize = 256 // # of sources to cache ASTs for. @@ -144,12 +148,17 @@ class ResolverImpl implements Resolver { return visiting.future.then((_) { var changeSet = new ChangeSet(); toUpdate.forEach((pending) => pending.apply(changeSet)); - var unreachableAssets = - sources.keys.toSet().difference(visited).map((id) => sources[id]); - for (var unreachable in unreachableAssets) { - changeSet.removedSource(unreachable); - unreachable.updateContents(null); - sources.remove(unreachable.assetId); + + // If we aren't using shared sources, then remove from the cache any + // sources which are no longer reachable. + if (!_usingSharedSources) { + var unreachableAssets = + sources.keys.toSet().difference(visited).map((id) => sources[id]); + for (var unreachable in unreachableAssets) { + changeSet.removedSource(unreachable); + unreachable.updateContents(null); + sources.remove(unreachable.assetId); + } } // Update the analyzer context with the latest sources diff --git a/pubspec.yaml b/pubspec.yaml index 9053f9a..2b03081 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: code_transformers -version: 0.4.2 +version: 0.4.2+1 author: Dart Team description: Collection of utilities related to creating barback transformers. homepage: https://github.com/dart-lang/code-transformers