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

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: Rename Source.resolveRelative to resolveRelativeUri, soften version constraints 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
« no previous file with comments | « pkg/code_transformers/lib/src/dart_sdk.dart ('k') | pkg/code_transformers/pubspec.yaml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..1d257055ba8676dbc6d5e7650187e923e0d96db7 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.
@@ -389,6 +391,18 @@ class _AssetBasedSource extends Source {
return source;
}
+ Uri resolveRelativeUri(Uri relativeUri) {
+ var id = _resolve(assetId, relativeUri.toString(), _logger, 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.uri;
+ }
+
/// For logging errors.
SourceSpan _getSpan(AstNode node, [String contents]) =>
_getSourceFile(contents).span(node.offset, node.end);
@@ -422,10 +436,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
« no previous file with comments | « pkg/code_transformers/lib/src/dart_sdk.dart ('k') | pkg/code_transformers/pubspec.yaml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698