Skip to content
This repository was archived by the owner on Aug 18, 2018. It is now read-only.

Commit 30a4dcc

Browse files
committed
Merge pull request #39 from dart-lang/shared-sources-fix
dont remove unreachable sources if using a shared sources cache
2 parents cde6c50 + 7ee7c39 commit 30a4dcc

File tree

3 files changed

+23
-9
lines changed

3 files changed

+23
-9
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
1+
## 0.4.2+1
2+
3+
* Contains a fix for the `useSharedSources` option that could result in null
4+
library elements when running on multiple entry points.
5+
16
## 0.4.2
27

38
* Use Strong Mode, fixes
4-
[#38](https://github.com/dart-lang/code_transformers/issues/38).
9+
[#38](https://github.com/dart-lang/code_transformers/issues/38).
510

611
## 0.4.1
712

lib/src/resolver_impl.dart

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,11 +49,15 @@ class ResolverImpl implements Resolver {
4949
/// Completer for wrapping up the current phase.
5050
Completer _currentPhaseComplete;
5151

52+
/// Whether or not we are using a shared sources cache.
53+
final bool _usingSharedSources;
54+
5255
/// Creates a resolver with a given [sdk] implementation for resolving
5356
/// `dart:*` imports.
5457
ResolverImpl(DartSdk sdk, DartUriResolver dartUriResolver,
5558
{AnalysisOptions options, Map<AssetId, AssetBasedSource> sources})
56-
: sources = sources ?? <AssetId, AssetBasedSource>{} {
59+
: _usingSharedSources = sources != null,
60+
sources = sources ?? <AssetId, AssetBasedSource>{} {
5761
if (options == null) {
5862
options = new AnalysisOptionsImpl()
5963
..cacheSize = 256 // # of sources to cache ASTs for.
@@ -144,12 +148,17 @@ class ResolverImpl implements Resolver {
144148
return visiting.future.then((_) {
145149
var changeSet = new ChangeSet();
146150
toUpdate.forEach((pending) => pending.apply(changeSet));
147-
var unreachableAssets =
148-
sources.keys.toSet().difference(visited).map((id) => sources[id]);
149-
for (var unreachable in unreachableAssets) {
150-
changeSet.removedSource(unreachable);
151-
unreachable.updateContents(null);
152-
sources.remove(unreachable.assetId);
151+
152+
// If we aren't using shared sources, then remove from the cache any
153+
// sources which are no longer reachable.
154+
if (!_usingSharedSources) {
155+
var unreachableAssets =
156+
sources.keys.toSet().difference(visited).map((id) => sources[id]);
157+
for (var unreachable in unreachableAssets) {
158+
changeSet.removedSource(unreachable);
159+
unreachable.updateContents(null);
160+
sources.remove(unreachable.assetId);
161+
}
153162
}
154163

155164
// Update the analyzer context with the latest sources

pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: code_transformers
2-
version: 0.4.2
2+
version: 0.4.2+1
33
author: Dart Team <[email protected]>
44
description: Collection of utilities related to creating barback transformers.
55
homepage: https://github.com/dart-lang/code-transformers

0 commit comments

Comments
 (0)