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

Unified Diff: lib/src/multi_package_resolver.dart

Issue 1187163003: Fix multipackage resolver paths (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Created 5 years, 6 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/src/multi_package_resolver.dart
diff --git a/lib/src/multi_package_resolver.dart b/lib/src/multi_package_resolver.dart
index 8321419cf9eb24a6a9b37aae35abfe807d4055fb..5851c377de098ea235c6e70e7acb2f1df75bb6c4 100644
--- a/lib/src/multi_package_resolver.dart
+++ b/lib/src/multi_package_resolver.dart
@@ -20,13 +20,16 @@ class MultiPackageResolver extends UriResolver {
@override
Source resolveAbsolute(Uri uri) {
- var path = _expandPath(uri);
- if (path == null) return null;
-
- var resolvedPath = _resolve(path);
- if (resolvedPath == null) return null;
-
- return new FileBasedSource.con2(uri, new JavaFile(resolvedPath));
+ var candidates = _expandPath(uri);
+ if (candidates == null) return null;
+
+ for (var path in candidates) {
+ var resolvedPath = _resolve(path);
+ if (resolvedPath != null) {
+ return new FileBasedSource.con2(uri, new JavaFile(resolvedPath));
+ }
+ }
+ return null;
}
/// Resolve [path] by looking at each prefix in [searchPaths] and returning
@@ -40,12 +43,12 @@ class MultiPackageResolver extends UriResolver {
}
/// Expand `uri.path`, replacing dots in the package name with slashes.
- String _expandPath(Uri uri) {
+ List<String> _expandPath(Uri uri) {
if (uri.scheme != 'package') return null;
var path = uri.path;
var slashPos = path.indexOf('/');
var packagePath = path.substring(0, slashPos).replaceAll(".", "/");
var filePath = path.substring(slashPos + 1);
- return '${packagePath}/lib/${filePath}';
+ return ['$packagePath/lib/$filePath', '$packagePath/$filePath'];
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698