Skip to content

Commit 4c9fb31

Browse files
committed
Fix multipackage resolver paths
[email protected] Review URL: https://codereview.chromium.org/1187163003
1 parent d48b153 commit 4c9fb31

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

pkg/dev_compiler/lib/src/multi_package_resolver.dart

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,16 @@ class MultiPackageResolver extends UriResolver {
2020

2121
@override
2222
Source resolveAbsolute(Uri uri) {
23-
var path = _expandPath(uri);
24-
if (path == null) return null;
25-
26-
var resolvedPath = _resolve(path);
27-
if (resolvedPath == null) return null;
28-
29-
return new FileBasedSource.con2(uri, new JavaFile(resolvedPath));
23+
var candidates = _expandPath(uri);
24+
if (candidates == null) return null;
25+
26+
for (var path in candidates) {
27+
var resolvedPath = _resolve(path);
28+
if (resolvedPath != null) {
29+
return new FileBasedSource.con2(uri, new JavaFile(resolvedPath));
30+
}
31+
}
32+
return null;
3033
}
3134

3235
/// Resolve [path] by looking at each prefix in [searchPaths] and returning
@@ -40,12 +43,12 @@ class MultiPackageResolver extends UriResolver {
4043
}
4144

4245
/// Expand `uri.path`, replacing dots in the package name with slashes.
43-
String _expandPath(Uri uri) {
46+
List<String> _expandPath(Uri uri) {
4447
if (uri.scheme != 'package') return null;
4548
var path = uri.path;
4649
var slashPos = path.indexOf('/');
4750
var packagePath = path.substring(0, slashPos).replaceAll(".", "/");
4851
var filePath = path.substring(slashPos + 1);
49-
return '${packagePath}/lib/${filePath}';
52+
return ['$packagePath/lib/$filePath', '$packagePath/$filePath'];
5053
}
5154
}

0 commit comments

Comments
 (0)