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

Unified Diff: pkg/analyzer/lib/src/generated/source.dart

Issue 1245263002: Actual URI support for package URI resolution. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Merge master (tk2). Created 5 years, 5 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/analyzer/lib/source/sdk_ext.dart ('k') | pkg/analyzer/lib/src/generated/source_io.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer/lib/src/generated/source.dart
diff --git a/pkg/analyzer/lib/src/generated/source.dart b/pkg/analyzer/lib/src/generated/source.dart
index 5b96dbd83198b1dc52ff1558ed8587a746e93809..077508264b51ddee37e5cf3c20fcaac5b988ed77 100644
--- a/pkg/analyzer/lib/src/generated/source.dart
+++ b/pkg/analyzer/lib/src/generated/source.dart
@@ -109,7 +109,7 @@ class CustomUriResolver extends UriResolver {
CustomUriResolver(this._urlMappings);
@override
- Source resolveAbsolute(Uri uri) {
+ Source resolveAbsolute(Uri uri, [Uri actualUri]) {
String mapping = _urlMappings[uri.toString()];
if (mapping == null) return null;
@@ -117,7 +117,7 @@ class CustomUriResolver extends UriResolver {
if (!fileUri.isAbsolute) return null;
JavaFile javaFile = new JavaFile.fromUri(fileUri);
- return new FileBasedSource(javaFile);
+ return new FileBasedSource(javaFile, actualUri);
}
}
@@ -156,7 +156,7 @@ class DartUriResolver extends UriResolver {
DartSdk get dartSdk => _sdk;
@override
- Source resolveAbsolute(Uri uri) {
+ Source resolveAbsolute(Uri uri, [Uri actualUri]) {
if (!isDartUri(uri)) {
return null;
}
@@ -814,22 +814,30 @@ class SourceFactory {
}
containedUri = containingSource.resolveRelativeUri(containedUri);
}
- // Now check .packages.
+
+ Uri actualUri = containedUri;
+
+ // Check .packages and update target and actual URIs as appropriate.
if (_packages != null && containedUri.scheme == 'package') {
Uri packageUri =
_packages.resolve(containedUri, notFound: (Uri packageUri) => null);
- // Ensure scheme is set.
- if (packageUri != null && packageUri.scheme == '') {
- packageUri = packageUri.replace(scheme: 'file');
+
+ if (packageUri != null) {
+ // Ensure scheme is set.
+ if (packageUri.scheme == '') {
+ packageUri = packageUri.replace(scheme: 'file');
+ }
+ containedUri = packageUri;
}
- containedUri = packageUri;
}
+
for (UriResolver resolver in _resolvers) {
- Source result = resolver.resolveAbsolute(containedUri);
+ Source result = resolver.resolveAbsolute(containedUri, actualUri);
if (result != null) {
return result;
}
}
+
return null;
}
}
@@ -1062,9 +1070,10 @@ abstract class UriResolver {
* resolved because the URI is invalid.
*
* @param uri the URI to be resolved
+ * @param actualUri the actual uri for this source -- if `null`, the value of [uri] will be used
* @return a [Source] representing the file to which given URI was resolved
*/
- Source resolveAbsolute(Uri uri);
+ Source resolveAbsolute(Uri uri, [Uri actualUri]);
/**
* Return an absolute URI that represents the given source, or `null` if a valid URI cannot
« no previous file with comments | « pkg/analyzer/lib/source/sdk_ext.dart ('k') | pkg/analyzer/lib/src/generated/source_io.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698