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..a8b489f68a27f71bd61c553d9d46835ca5b62aff 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,32 @@ class SourceFactory { |
} |
containedUri = containingSource.resolveRelativeUri(containedUri); |
} |
- // Now check .packages. |
+ |
+ Uri uriToResolve = containedUri; |
+ Uri actualUri = null; |
Brian Wilkerson
2015/07/21 18:48:34
I'm not convinced that it's ever necessary to pass
Paul Berry
2015/07/21 19:39:27
I agree--AFAIK, always passing containedUri to res
pquitslund
2015/07/21 20:55:10
Ok. Fixed up!
|
+ |
+ // 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'); |
+ } |
+ uriToResolve = packageUri; |
+ actualUri = containedUri; |
} |
- containedUri = packageUri; |
} |
+ |
for (UriResolver resolver in _resolvers) { |
- Source result = resolver.resolveAbsolute(containedUri); |
+ Source result = resolver.resolveAbsolute(uriToResolve, actualUri); |
if (result != null) { |
return result; |
} |
} |
+ |
return null; |
} |
} |
@@ -1062,9 +1072,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 |
Paul Berry
2015/07/21 19:39:27
We should document that the caller is allowed to p
pquitslund
2015/07/21 20:55:10
Done.
|
* @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 |