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

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

Issue 217163005: Code transformers fixes for latest analyzer update (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
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 dcb05328ce60e810083ab7a24c0ea36c554dbca8..fcfcd29ab6b147d25b619f942f198639af45c191 100644
--- a/pkg/code_transformers/lib/src/resolver_impl.dart
+++ b/pkg/code_transformers/lib/src/resolver_impl.dart
@@ -80,7 +80,7 @@ class ResolverImpl implements Resolver {
// Can only have one resolve in progress at a time, so chain the current
// resolution to be after the last one.
var phaseComplete = new Completer();
- var future = _lastPhaseComplete.then((_) {
+ var future = _lastPhaseComplete.whenComplete(() {
_currentPhaseComplete = phaseComplete;
return _performResolve(transform,
entryPoints == null ? [transform.primaryInput.id] : entryPoints);
@@ -129,8 +129,12 @@ class ResolverImpl implements Resolver {
source.dependentAssets.where((id) => !visited.contains(id))
.forEach(processAsset);
}, onError: (e) {
- _context.applyChanges(new ChangeSet()..removedSource(sources[assetId]));
- sources.remove(assetId);
+ var source = sources[assetId];
+ if (source != null && source.exists()) {
+ _context.applyChanges(
+ new ChangeSet()..removedSource(source));
+ sources[assetId].updateContents(null);
+ }
}));
}
entryPoints.forEach(processAsset);
@@ -140,10 +144,13 @@ class ResolverImpl implements Resolver {
return visiting.future.then((_) {
var changeSet = new ChangeSet();
toUpdate.forEach((pending) => pending.apply(changeSet));
- var unreachableAssets = new Set.from(sources.keys).difference(visited);
+ var unreachableAssets = sources.keys.toSet()
+ .difference(visited)
+ .map((id) => sources[id]);
for (var unreachable in unreachableAssets) {
- changeSet.removedSource(sources[unreachable]);
- sources.remove(unreachable);
+ changeSet.removedSource(unreachable);
+ unreachable.updateContents(null);
+ sources.remove(unreachable.assetId);
}
// Update the analyzer context with the latest sources
@@ -336,7 +343,7 @@ class _AssetBasedSource extends Source {
/// Gets all imports/parts/exports which resolve to assets (non-Dart files).
Iterable<AssetId> get dependentAssets => _dependentAssets;
- bool exists() => true;
+ bool exists() => _contents != null;
bool operator ==(Object other) =>
other is _AssetBasedSource && assetId == other.assetId;
@@ -409,10 +416,16 @@ class _AssetUriResolver implements UriResolver {
Source resolveAbsolute(Uri uri) {
var assetId = _resolve(null, uri.toString(), logger, null);
+ if (assetId == null) {
+ logger.error('Unable to resolve asset ID for "$uri"');
+ return null;
+ }
var source = _resolver.sources[assetId];
- /// All resolved assets should be available by this point.
+ // Analyzer expects that sources which are referenced but do not exist yet
+ // still exist, so just make an empty source.
if (source == null) {
- logger.error('Unable to find asset for "$uri"');
+ source = new _AssetBasedSource(assetId, _resolver);
+ _resolver.sources[assetId] = source;
}
return source;
}
@@ -578,7 +591,7 @@ class FutureGroup<E> {
}
/**
- * A Future that complets with a List of the values from all the added
+ * A Future that completes with a List of the values from all the added
* tasks, when they have all completed.
*
* If any task fails, this Future will receive the error. Only the first
« no previous file with comments | « no previous file | pkg/code_transformers/lib/src/resolvers.dart » ('j') | pkg/code_transformers/test/resolver_test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698