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

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

Issue 428303004: Breaking changes in 'analyzer' package. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Merge code_transformers CL Created 6 years, 4 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 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

Powered by Google App Engine
This is Rietveld 408576698