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

dont remove unreachable sources if using a shared sources cache #39

Merged
merged 1 commit into from
Mar 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
23 changes: 16 additions & 7 deletions lib/src/resolver_impl.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<AssetId, AssetBasedSource> sources})
: sources = sources ?? <AssetId, AssetBasedSource>{} {
: _usingSharedSources = sources != null,
sources = sources ?? <AssetId, AssetBasedSource>{} {
if (options == null) {
options = new AnalysisOptionsImpl()
..cacheSize = 256 // # of sources to cache ASTs for.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: code_transformers
version: 0.4.2
version: 0.4.2+1
author: Dart Team <[email protected]>
description: Collection of utilities related to creating barback transformers.
homepage: https://github.com/dart-lang/code-transformers
Expand Down