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 52f803326eb9375b37ebeb897388ca7929c2346e..106dd5d960e6b1ecb2e6aaecf8b36581e5af7930 100644 |
--- a/pkg/code_transformers/lib/src/resolver_impl.dart |
+++ b/pkg/code_transformers/lib/src/resolver_impl.dart |
@@ -342,6 +342,8 @@ class _AssetBasedSource extends Source { |
/// Contents of the file. |
String get rawContents => _contents; |
+ Uri get uri => Uri.parse('asset:${assetId.package}/${assetId.path}'); |
+ |
/// Logger for the current transform. |
/// |
/// Only valid while the resolver is updating assets. |
@@ -377,16 +379,16 @@ class _AssetBasedSource extends Source { |
bool get isInSystemLibrary => false; |
- Source resolveRelative(Uri relativeUri) { |
+ Uri resolveRelative(Uri relativeUri) { |
var id = _resolve(assetId, relativeUri.toString(), _logger, null); |
- if (id == null) return null; |
+ if (id == null) return uri.resolveUri(relativeUri); |
// The entire AST should have been parsed and loaded at this point. |
var source = _resolver.sources[id]; |
if (source == null) { |
_logger.error('Could not load asset $id'); |
} |
- return source; |
+ return source.uri; |
} |
/// For logging errors. |
@@ -422,10 +424,17 @@ class _AssetUriResolver implements UriResolver { |
_AssetUriResolver(this._resolver); |
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; |
+ assert(uri.scheme != 'dart'); |
+ var assetId; |
+ if (uri.scheme == 'asset') { |
+ var parts = path.split(uri.path); |
+ assetId = new AssetId(parts[0], path.joinAll(parts.skip(1))); |
+ } else { |
+ 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]; |
// Analyzer expects that sources which are referenced but do not exist yet |