| Index: lib/src/driver.dart
|
| diff --git a/lib/src/driver.dart b/lib/src/driver.dart
|
| index 5a5dc4efca4f18b909ad13ebda357a96447d8697..d39a39e6fb86a491833716a23437c6612e2356c1 100644
|
| --- a/lib/src/driver.dart
|
| +++ b/lib/src/driver.dart
|
| @@ -273,6 +273,12 @@ class Driver {
|
| printAndFail(
|
| 'Package config files are not supported yet. For status see: https://github.com/dart-lang/sdk/issues/23373');
|
| } else if (options.packageRootPath != null) {
|
| + Map<String, List<fileSystem.Folder>> packageMap =
|
| + _PackageRootPackageMapBuilder.buildPackageMap(
|
| + options.packageRootPath);
|
| + if (packageMap != null) {
|
| + resolvers.add(new SdkExtUriResolver(packageMap));
|
| + }
|
| JavaFile packageDirectory = new JavaFile(options.packageRootPath);
|
| resolvers.add(new PackageUriResolver([packageDirectory]));
|
| } else {
|
| @@ -436,6 +442,28 @@ class Driver {
|
| }
|
| }
|
|
|
| +/// [SdkExtUriResolver] needs a Map from package name to folder. In the case
|
| +/// that the analyzer is invoked with a --package-root option, we need to
|
| +/// manually create this mapping. Given [packageRootPath],
|
| +/// [_PackageRootPackageMapBuilder] creates a simple mapping from package name
|
| +/// to full path on disk (resolving any symbolic links).
|
| +class _PackageRootPackageMapBuilder {
|
| + static Map<String, List<fileSystem.Folder>> buildPackageMap(
|
| + String packageRootPath) {
|
| + var packageRoot = new Directory(packageRootPath);
|
| + var packages = packageRoot.listSync(followLinks: false);
|
| + var result = new Map<String, List<fileSystem.Folder>>();
|
| + for (var package in packages) {
|
| + var packageName = path.basename(package.path);
|
| + var realPath = package.resolveSymbolicLinksSync();
|
| + result[packageName] = [
|
| + PhysicalResourceProvider.INSTANCE.getFolder(realPath)
|
| + ];
|
| + }
|
| + return result;
|
| + }
|
| +}
|
| +
|
| /// Provides a framework to read command line options from stdin and feed them
|
| /// to a callback.
|
| class _BatchRunner {
|
|
|