mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
Remove support for '--package-root'.
Bug: https://github.com/dart-lang/sdk/issues/41197 Change-Id: Ia10946b4db2204cc11e78a1d114578ba79904e78 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/149045 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
571f564eda
commit
fc1a782168
|
@ -824,7 +824,6 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
|
|||
@override
|
||||
ContextBuilder createContextBuilder(Folder folder, AnalysisOptions options) {
|
||||
String defaultPackageFilePath;
|
||||
String defaultPackagesDirectoryPath;
|
||||
var path = (analysisServer.contextManager as ContextManagerImpl)
|
||||
.normalizedPackageRoots[folder.path];
|
||||
if (path != null) {
|
||||
|
@ -832,8 +831,6 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
|
|||
if (resource.exists) {
|
||||
if (resource is File) {
|
||||
defaultPackageFilePath = path;
|
||||
} else {
|
||||
defaultPackagesDirectoryPath = path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -841,7 +838,6 @@ class ServerContextManagerCallbacks extends ContextManagerCallbacks {
|
|||
var builderOptions = ContextBuilderOptions();
|
||||
builderOptions.defaultOptions = options;
|
||||
builderOptions.defaultPackageFilePath = defaultPackageFilePath;
|
||||
builderOptions.defaultPackagesDirectoryPath = defaultPackagesDirectoryPath;
|
||||
var builder = ContextBuilder(
|
||||
resourceProvider, analysisServer.sdkManager, null,
|
||||
options: builderOptions);
|
||||
|
|
|
@ -706,7 +706,6 @@ class LspServerContextManagerCallbacks extends ContextManagerCallbacks {
|
|||
@override
|
||||
ContextBuilder createContextBuilder(Folder folder, AnalysisOptions options) {
|
||||
String defaultPackageFilePath;
|
||||
String defaultPackagesDirectoryPath;
|
||||
var path = (analysisServer.contextManager as ContextManagerImpl)
|
||||
.normalizedPackageRoots[folder.path];
|
||||
if (path != null) {
|
||||
|
@ -714,8 +713,6 @@ class LspServerContextManagerCallbacks extends ContextManagerCallbacks {
|
|||
if (resource.exists) {
|
||||
if (resource is File) {
|
||||
defaultPackageFilePath = path;
|
||||
} else {
|
||||
defaultPackagesDirectoryPath = path;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -723,7 +720,6 @@ class LspServerContextManagerCallbacks extends ContextManagerCallbacks {
|
|||
var builderOptions = ContextBuilderOptions();
|
||||
builderOptions.defaultOptions = options;
|
||||
builderOptions.defaultPackageFilePath = defaultPackageFilePath;
|
||||
builderOptions.defaultPackagesDirectoryPath = defaultPackagesDirectoryPath;
|
||||
var builder = ContextBuilder(
|
||||
resourceProvider, analysisServer.sdkManager, null,
|
||||
options: builderOptions);
|
||||
|
|
|
@ -23,7 +23,6 @@ const String ignoreUnrecognizedFlagsFlag = 'ignore-unrecognized-flags';
|
|||
const String implicitCastsFlag = 'implicit-casts';
|
||||
const String lintsFlag = 'lints';
|
||||
const String noImplicitDynamicFlag = 'no-implicit-dynamic';
|
||||
const String packageRootOption = 'package-root';
|
||||
const String packagesOption = 'packages';
|
||||
const String sdkPathOption = 'dart-sdk';
|
||||
|
||||
|
@ -69,7 +68,6 @@ ContextBuilderOptions createContextBuilderOptions(ArgResults args) {
|
|||
builderOptions.defaultAnalysisOptionsFilePath =
|
||||
args[analysisOptionsFileOption];
|
||||
builderOptions.defaultPackageFilePath = args[packagesOption];
|
||||
builderOptions.defaultPackagesDirectoryPath = args[packageRootOption];
|
||||
//
|
||||
// Analysis options.
|
||||
//
|
||||
|
@ -137,10 +135,6 @@ void defineAnalysisArguments(ArgParser parser,
|
|||
help: 'The path to the Dart SDK.', hide: ddc && hide);
|
||||
parser.addOption(analysisOptionsFileOption,
|
||||
help: 'Path to an analysis options file.', hide: ddc && hide);
|
||||
parser.addOption(packageRootOption,
|
||||
help: 'The path to a package root directory (deprecated). '
|
||||
'This option cannot be used with --packages.',
|
||||
hide: ddc && hide);
|
||||
parser.addFlag('strong',
|
||||
help: 'Enable strong mode (deprecated); this option is now ignored.',
|
||||
defaultsTo: true,
|
||||
|
@ -170,8 +164,7 @@ void defineAnalysisArguments(ArgParser parser,
|
|||
hide: hide);
|
||||
parser.addOption(packagesOption,
|
||||
help: 'The path to the package resolution configuration file, which '
|
||||
'supplies a mapping of package names\nto paths. This option cannot be '
|
||||
'used with --package-root.',
|
||||
'supplies a mapping of package names\nto paths.',
|
||||
hide: ddc);
|
||||
parser.addOption(sdkSummaryPathOption,
|
||||
help: 'The path to the Dart SDK summary file.', hide: hide);
|
||||
|
|
|
@ -28,7 +28,6 @@ import 'package:analyzer/src/hint/sdk_constraint_extractor.dart';
|
|||
import 'package:analyzer/src/summary/package_bundle_reader.dart';
|
||||
import 'package:analyzer/src/summary/summary_sdk.dart';
|
||||
import 'package:analyzer/src/task/options.dart';
|
||||
import 'package:analyzer/src/util/uri.dart';
|
||||
import 'package:analyzer/src/workspace/basic.dart';
|
||||
import 'package:analyzer/src/workspace/bazel.dart';
|
||||
import 'package:analyzer/src/workspace/gn.dart';
|
||||
|
@ -36,7 +35,6 @@ import 'package:analyzer/src/workspace/package_build.dart';
|
|||
import 'package:analyzer/src/workspace/pub.dart';
|
||||
import 'package:analyzer/src/workspace/workspace.dart';
|
||||
import 'package:args/args.dart';
|
||||
import 'package:path/src/context.dart';
|
||||
import 'package:yaml/yaml.dart';
|
||||
|
||||
/// A utility class used to build an analysis context for a given directory.
|
||||
|
@ -183,17 +181,14 @@ class ContextBuilder {
|
|||
// }
|
||||
|
||||
Packages createPackageMap(String rootDirectoryPath) {
|
||||
String filePath = builderOptions.defaultPackageFilePath;
|
||||
if (filePath != null) {
|
||||
File configFile = resourceProvider.getFile(filePath);
|
||||
var configPath = builderOptions.defaultPackageFilePath;
|
||||
if (configPath != null) {
|
||||
var configFile = resourceProvider.getFile(configPath);
|
||||
return parsePackagesFile(resourceProvider, configFile);
|
||||
} else {
|
||||
var resource = resourceProvider.getResource(rootDirectoryPath);
|
||||
return findPackagesFrom(resourceProvider, resource);
|
||||
}
|
||||
String directoryPath = builderOptions.defaultPackagesDirectoryPath;
|
||||
if (directoryPath != null) {
|
||||
Folder folder = resourceProvider.getFolder(directoryPath);
|
||||
return getPackagesFromFolder(folder);
|
||||
}
|
||||
return findPackagesFromFile(rootDirectoryPath);
|
||||
}
|
||||
|
||||
SourceFactory createSourceFactory(String rootPath, AnalysisOptions options,
|
||||
|
@ -217,28 +212,6 @@ class ContextBuilder {
|
|||
}
|
||||
}
|
||||
|
||||
/// Finds a package resolution strategy for the directory at the given absolute
|
||||
/// [path].
|
||||
///
|
||||
/// This function first tries to locate a `.packages` file in the directory. If
|
||||
/// that is not found, it instead checks for the presence of a `packages/`
|
||||
/// directory in the same place. If that also fails, it starts checking parent
|
||||
/// directories for a `.packages` file, and stops if it finds it. Otherwise it
|
||||
/// gives up and returns [Packages.empty].
|
||||
Packages findPackagesFromFile(String path) {
|
||||
Resource location = _findPackagesLocation(path);
|
||||
if (location is File) {
|
||||
try {
|
||||
return parsePackagesFile(resourceProvider, location);
|
||||
} catch (_) {
|
||||
return Packages.empty;
|
||||
}
|
||||
} else if (location is Folder) {
|
||||
return getPackagesFromFolder(location);
|
||||
}
|
||||
return Packages.empty;
|
||||
}
|
||||
|
||||
/// Return the SDK that should be used to analyze code. Use the given
|
||||
/// [workspace] and [analysisOptions] to locate the SDK.
|
||||
///
|
||||
|
@ -385,96 +358,6 @@ class ContextBuilder {
|
|||
return null;
|
||||
}
|
||||
|
||||
/// Create a [Packages] object for a 'package' directory ([folder]).
|
||||
///
|
||||
/// Package names are resolved as relative to sub-directories of the package
|
||||
/// directory.
|
||||
///
|
||||
/// TODO(scheglov) Remove this feature
|
||||
Packages getPackagesFromFolder(Folder folder) {
|
||||
Context pathContext = resourceProvider.pathContext;
|
||||
var map = <String, Package>{};
|
||||
for (Resource child in folder.getChildren()) {
|
||||
if (child is Folder) {
|
||||
// Inline resolveSymbolicLinks for performance reasons.
|
||||
String packageName = pathContext.basename(child.path);
|
||||
String packagePath = resolveSymbolicLink(child);
|
||||
var rootFolder = resourceProvider.getFolder(packagePath);
|
||||
var libFolder = rootFolder.getChildAssumingFolder('lib');
|
||||
var package = Package(
|
||||
name: packageName,
|
||||
rootFolder: rootFolder,
|
||||
libFolder: libFolder,
|
||||
languageVersion: null,
|
||||
);
|
||||
map[packageName] = package;
|
||||
}
|
||||
}
|
||||
return Packages(map);
|
||||
}
|
||||
|
||||
/// Resolve any symbolic links encoded in the path to the given [folder].
|
||||
String resolveSymbolicLink(Folder folder) {
|
||||
try {
|
||||
return folder.resolveSymbolicLinksSync().path;
|
||||
} on FileSystemException {
|
||||
return folder.path;
|
||||
}
|
||||
}
|
||||
|
||||
/// Resolve any symbolic links encoded in the URI's in the given [map] by
|
||||
/// replacing the values in the map.
|
||||
void resolveSymbolicLinks(Map<String, Uri> map) {
|
||||
Context pathContext = resourceProvider.pathContext;
|
||||
for (String packageName in map.keys) {
|
||||
var uri = map[packageName];
|
||||
String path = fileUriToNormalizedPath(pathContext, uri);
|
||||
Folder folder = resourceProvider.getFolder(path);
|
||||
String folderPath = resolveSymbolicLink(folder);
|
||||
// Add a '.' so that the URI is suitable for resolving relative URI's
|
||||
// against it.
|
||||
String uriPath = pathContext.join(folderPath, '.');
|
||||
map[packageName] = pathContext.toUri(uriPath);
|
||||
}
|
||||
}
|
||||
|
||||
/// Find the location of the package resolution file/directory for the
|
||||
/// directory at the given absolute [path].
|
||||
///
|
||||
/// Checks for a `.packages` file in the [path]. If not found,
|
||||
/// checks for a `packages` directory in the same directory. If still not
|
||||
/// found, starts checking parent directories for `.packages` until reaching
|
||||
/// the root directory.
|
||||
///
|
||||
/// Return a [File] object representing a `.packages` file if one is found, a
|
||||
/// [Folder] object for the `packages/` directory if that is found, or `null`
|
||||
/// if neither is found.
|
||||
Resource _findPackagesLocation(String path) {
|
||||
var resource = resourceProvider.getResource(path);
|
||||
while (resource != null) {
|
||||
if (resource is Folder) {
|
||||
var packageConfigFile = resource
|
||||
.getChildAssumingFolder('.dart_tool')
|
||||
.getChildAssumingFile('package_config.json');
|
||||
if (packageConfigFile.exists) {
|
||||
return packageConfigFile;
|
||||
}
|
||||
|
||||
var dotPackagesFile = resource.getChildAssumingFile('.packages');
|
||||
if (dotPackagesFile.exists) {
|
||||
return dotPackagesFile;
|
||||
}
|
||||
|
||||
var packagesDirectory = resource.getChildAssumingFolder('packages');
|
||||
if (packagesDirectory.exists) {
|
||||
return packagesDirectory;
|
||||
}
|
||||
}
|
||||
resource = resource.parent;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Return the `pubspec.yaml` file that should be used when analyzing code in
|
||||
/// the directory with the given [path], possibly `null`.
|
||||
File _findPubspecFile(String path) {
|
||||
|
@ -563,11 +446,6 @@ class ContextBuilderOptions {
|
|||
/// or `null` if the normal lookup mechanism should be used.
|
||||
String defaultPackageFilePath;
|
||||
|
||||
/// The file path of the packages directory that should be used in place of any
|
||||
/// file found using the normal (Package Specification DEP) lookup mechanism,
|
||||
/// or `null` if the normal lookup mechanism should be used.
|
||||
String defaultPackagesDirectoryPath;
|
||||
|
||||
/// A list of the paths of summary files that are to be used, or `null` if no
|
||||
/// summary information is available.
|
||||
List<String> librarySummaryPaths;
|
||||
|
|
|
@ -32,8 +32,8 @@ typedef AnalyzeFunctionBodiesPredicate = bool Function(Source source);
|
|||
|
||||
/// A context in which a single analysis can be performed and incrementally
|
||||
/// maintained. The context includes such information as the version of the SDK
|
||||
/// being analyzed against as well as the package-root used to resolve 'package:'
|
||||
/// URI's. (Both of which are known indirectly through the [SourceFactory].)
|
||||
/// being analyzed against, and how to resolve 'package:' URI's. (Both of which
|
||||
/// are known indirectly through the [SourceFactory].)
|
||||
///
|
||||
/// An analysis context also represents the state of the analysis, which includes
|
||||
/// knowing which sources have been included in the analysis (either directly or
|
||||
|
|
|
@ -12,7 +12,6 @@ import 'package:analyzer/file_system/file_system.dart'
|
|||
import 'package:analyzer/file_system/physical_file_system.dart';
|
||||
import 'package:analyzer/instrumentation/instrumentation.dart';
|
||||
import 'package:analyzer/src/analysis_options/analysis_options_provider.dart';
|
||||
import 'package:analyzer/src/context/builder.dart';
|
||||
import 'package:analyzer/src/context/packages.dart';
|
||||
import 'package:analyzer/src/dart/analysis/byte_store.dart';
|
||||
import 'package:analyzer/src/dart/analysis/driver.dart';
|
||||
|
@ -82,6 +81,7 @@ class DriverOptions {
|
|||
String packageConfigPath;
|
||||
|
||||
/// The path to the package root.
|
||||
@Deprecated('https://github.com/dart-lang/sdk/issues/41197')
|
||||
String packageRootPath;
|
||||
|
||||
/// Whether to use Dart's Strong Mode analyzer.
|
||||
|
@ -126,7 +126,6 @@ class LintDriver {
|
|||
List<UriResolver> get resolvers {
|
||||
// TODO(brianwilkerson) Use the context builder to compute all of the resolvers.
|
||||
ResourceProvider resourceProvider = PhysicalResourceProvider.INSTANCE;
|
||||
ContextBuilder builder = ContextBuilder(resourceProvider, null, null);
|
||||
|
||||
DartSdk sdk = options.mockSdk ??
|
||||
FolderBasedDartSdk(
|
||||
|
@ -134,17 +133,6 @@ class LintDriver {
|
|||
|
||||
List<UriResolver> resolvers = [DartUriResolver(sdk)];
|
||||
|
||||
if (options.packageRootPath != null) {
|
||||
builder.builderOptions.defaultPackagesDirectoryPath =
|
||||
options.packageRootPath;
|
||||
var packages = builder.createPackageMap(null);
|
||||
var packageMap = <String, List<Folder>>{};
|
||||
for (var package in packages.packages) {
|
||||
packageMap[package.name] = [package.libFolder];
|
||||
}
|
||||
resolvers.add(PackageMapUriResolver(resourceProvider, packageMap));
|
||||
}
|
||||
|
||||
var packageUriResolver = _getPackageUriResolver();
|
||||
if (packageUriResolver != null) {
|
||||
resolvers.add(packageUriResolver);
|
||||
|
|
|
@ -24,7 +24,6 @@ class ArgumentsTest with ResourceProviderMixin {
|
|||
String dartSdkSummaryPath = 'a';
|
||||
String defaultAnalysisOptionsFilePath = 'b';
|
||||
String defaultPackageFilePath = 'c';
|
||||
String defaultPackagesDirectoryPath = 'd';
|
||||
ArgParser parser = ArgParser();
|
||||
defineAnalysisArguments(parser);
|
||||
List<String> args = [
|
||||
|
@ -35,7 +34,6 @@ class ArgumentsTest with ResourceProviderMixin {
|
|||
'--no-implicit-dynamic',
|
||||
'--options=$defaultAnalysisOptionsFilePath',
|
||||
'--packages=$defaultPackageFilePath',
|
||||
'--package-root=$defaultPackagesDirectoryPath',
|
||||
];
|
||||
ArgResults result = parse(resourceProvider, parser, args);
|
||||
ContextBuilderOptions options = createContextBuilderOptions(result);
|
||||
|
@ -48,7 +46,6 @@ class ArgumentsTest with ResourceProviderMixin {
|
|||
expect(
|
||||
options.defaultAnalysisOptionsFilePath, defaultAnalysisOptionsFilePath);
|
||||
expect(options.defaultPackageFilePath, defaultPackageFilePath);
|
||||
expect(options.defaultPackagesDirectoryPath, defaultPackagesDirectoryPath);
|
||||
AnalysisOptionsImpl defaultOptions = options.defaultOptions;
|
||||
expect(defaultOptions, isNotNull);
|
||||
expect(defaultOptions.strongMode, true);
|
||||
|
@ -67,7 +64,6 @@ class ArgumentsTest with ResourceProviderMixin {
|
|||
expect(options.declaredVariables, isEmpty);
|
||||
expect(options.defaultAnalysisOptionsFilePath, isNull);
|
||||
expect(options.defaultPackageFilePath, isNull);
|
||||
expect(options.defaultPackagesDirectoryPath, isNull);
|
||||
AnalysisOptionsImpl defaultOptions = options.defaultOptions;
|
||||
expect(defaultOptions, isNotNull);
|
||||
expect(defaultOptions.strongMode, true);
|
||||
|
@ -129,7 +125,7 @@ class ArgumentsTest with ResourceProviderMixin {
|
|||
void test_defineAnalysisArguments() {
|
||||
ArgParser parser = ArgParser();
|
||||
defineAnalysisArguments(parser);
|
||||
expect(parser.options, hasLength(12));
|
||||
expect(parser.options, hasLength(11));
|
||||
}
|
||||
|
||||
void test_extractDefinedVariables() {
|
||||
|
|
|
@ -244,52 +244,6 @@ linter:
|
|||
_expectEqualOptions(options, AnalysisOptionsImpl());
|
||||
}
|
||||
|
||||
void test_createPackageMap_fromPackageDirectory_explicit() {
|
||||
// Use a package directory that is outside the project directory.
|
||||
String rootPath = convertPath('/root');
|
||||
String projectPath = join(rootPath, 'project');
|
||||
String packageDirPath = join(rootPath, 'packages');
|
||||
String fooName = 'foo';
|
||||
String fooPath = join(packageDirPath, fooName);
|
||||
String barName = 'bar';
|
||||
String barPath = join(packageDirPath, barName);
|
||||
newFolder(projectPath);
|
||||
newFolder(fooPath);
|
||||
newFolder(barPath);
|
||||
|
||||
builderOptions.defaultPackagesDirectoryPath = packageDirPath;
|
||||
|
||||
Packages packages = builder.createPackageMap(projectPath);
|
||||
_assertPackages(
|
||||
packages,
|
||||
{
|
||||
'foo': convertPath('/root/packages/foo/lib'),
|
||||
'bar': convertPath('/root/packages/bar/lib'),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void test_createPackageMap_fromPackageDirectory_inRoot() {
|
||||
// Use a package directory that is inside the project directory.
|
||||
String projectPath = convertPath('/root/project');
|
||||
String packageDirPath = join(projectPath, 'packages');
|
||||
String fooName = 'foo';
|
||||
String fooPath = join(packageDirPath, fooName);
|
||||
String barName = 'bar';
|
||||
String barPath = join(packageDirPath, barName);
|
||||
newFolder(fooPath);
|
||||
newFolder(barPath);
|
||||
|
||||
Packages packages = builder.createPackageMap(projectPath);
|
||||
_assertPackages(
|
||||
packages,
|
||||
{
|
||||
'foo': convertPath('/root/project/packages/foo/lib'),
|
||||
'bar': convertPath('/root/project/packages/bar/lib'),
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
void test_createPackageMap_fromPackageFile_explicit() {
|
||||
// Use a package file that is outside the project directory's hierarchy.
|
||||
String rootPath = convertPath('/root');
|
||||
|
|
|
@ -24,7 +24,6 @@ The following are the most commonly used options for dartanalyzer:
|
|||
Specify the path to the package resolution configuration file.
|
||||
For more information see
|
||||
[Package Resolution Configuration File](https://github.com/lrhn/dep-pkgspec/blob/master/DEP-pkgspec.md).
|
||||
This option cannot be used with `--package-root`.
|
||||
|
||||
* `--package-warnings`
|
||||
|
||||
|
@ -78,10 +77,3 @@ The following are advanced options to use with dartanalyzer:
|
|||
* `--url-mapping=libraryUri,/path/to/library.dart`
|
||||
|
||||
Use the specified library as the source for that particular import.
|
||||
|
||||
The following options are deprecated:
|
||||
|
||||
* `--package-root=`<br>
|
||||
**Deprecated.** Specify the directory to search for any libraries that are
|
||||
imported using `package:`. _This option is replaced as of Dart 1.12 with
|
||||
`--packages`._
|
||||
|
|
|
@ -598,9 +598,6 @@ class Driver with HasContextMixin implements CommandLineStarter {
|
|||
} catch (e) {
|
||||
printAndFail('Unable to read package config data from $path: $e');
|
||||
}
|
||||
} else if (options.packageRootPath != null) {
|
||||
var path = normalizePath(options.packageRootPath);
|
||||
packageMap = _PackageRootPackageMapBuilder.buildPackageMap(path);
|
||||
} else {
|
||||
var cwd = resourceProvider.getResource(path.current);
|
||||
// Look for .packages.
|
||||
|
@ -679,7 +676,6 @@ class Driver with HasContextMixin implements CommandLineStarter {
|
|||
CommandLineOptions previous, CommandLineOptions newOptions) {
|
||||
return previous != null &&
|
||||
newOptions != null &&
|
||||
newOptions.packageRootPath == previous.packageRootPath &&
|
||||
newOptions.packageConfigPath == previous.packageConfigPath &&
|
||||
_equalMaps(newOptions.definedVariables, previous.definedVariables) &&
|
||||
newOptions.log == previous.log &&
|
||||
|
@ -735,28 +731,3 @@ class _PackageInfo {
|
|||
|
||||
_PackageInfo(this.packages, this.packageMap);
|
||||
}
|
||||
|
||||
class _PackageRootPackageMapBuilder {
|
||||
/// In the case that the analyzer is invoked with a --package-root option, we
|
||||
/// need to manually create the mapping from package name to folder.
|
||||
///
|
||||
/// Given [packageRootPath], creates a simple mapping from package name
|
||||
/// to full path on disk (resolving any symbolic links).
|
||||
static Map<String, List<Folder>> buildPackageMap(String packageRootPath) {
|
||||
var packageRoot = io.Directory(packageRootPath);
|
||||
if (!packageRoot.existsSync()) {
|
||||
throw _DriverError(
|
||||
'Package root directory ($packageRootPath) does not exist.');
|
||||
}
|
||||
var packages = packageRoot.listSync(followLinks: false);
|
||||
var result = <String, List<Folder>>{};
|
||||
for (var package in packages) {
|
||||
var packageName = path.basename(package.path);
|
||||
var realPath = package.resolveSymbolicLinksSync();
|
||||
result[packageName] = [
|
||||
PhysicalResourceProvider.INSTANCE.getFolder(realPath)
|
||||
];
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -203,10 +203,6 @@ class CommandLineOptions {
|
|||
/// The path to a `.packages` configuration file
|
||||
String get packageConfigPath => contextBuilderOptions.defaultPackageFilePath;
|
||||
|
||||
/// The path to the package root
|
||||
String get packageRootPath =>
|
||||
contextBuilderOptions.defaultPackagesDirectoryPath;
|
||||
|
||||
/// The source files to analyze
|
||||
List<String> get sourceFiles => _sourceFiles;
|
||||
|
||||
|
@ -246,18 +242,9 @@ class CommandLineOptions {
|
|||
}
|
||||
}
|
||||
|
||||
// Check package config.
|
||||
{
|
||||
if (options.packageRootPath != null &&
|
||||
options.packageConfigPath != null) {
|
||||
printAndFail("Cannot specify both '--package-root' and '--packages.");
|
||||
return null; // Only reachable in testing.
|
||||
}
|
||||
}
|
||||
|
||||
// Build mode.
|
||||
if (options.buildModePersistentWorker && !options.buildMode) {
|
||||
printAndFail('The option --persisten_worker can be used only '
|
||||
printAndFail('The option --persistent_worker can be used only '
|
||||
'together with --build-mode.');
|
||||
return null; // Only reachable in testing.
|
||||
}
|
||||
|
|
|
@ -43,7 +43,6 @@ String makePerfReport(int startTime, int endTime, CommandLineOptions options,
|
|||
'showPackageWarningsPrefix': options.showPackageWarningsPrefix,
|
||||
'showSdkWarnings': options.showSdkWarnings,
|
||||
'definedVariables': options.definedVariables,
|
||||
'packageRootPath': options.packageRootPath,
|
||||
'packageConfigPath': options.packageConfigPath,
|
||||
'sourceFiles': options.sourceFiles,
|
||||
};
|
||||
|
|
|
@ -59,7 +59,6 @@ void main() {
|
|||
expect(options.ignoreUnrecognizedFlags, isFalse);
|
||||
expect(options.log, isFalse);
|
||||
expect(options.machineFormat, isFalse);
|
||||
expect(options.packageRootPath, isNull);
|
||||
expect(options.batchMode, isFalse);
|
||||
expect(options.showPackageWarnings, isFalse);
|
||||
expect(options.showSdkWarnings, isFalse);
|
||||
|
@ -188,12 +187,6 @@ void main() {
|
|||
expect(options.lints, isTrue);
|
||||
});
|
||||
|
||||
test('package root', () {
|
||||
var options = CommandLineOptions.parse(
|
||||
['--dart-sdk', '.', '--package-root', 'bar', 'foo.dart']);
|
||||
expect(options.packageRootPath, equals('bar'));
|
||||
});
|
||||
|
||||
test('package warnings', () {
|
||||
var options = CommandLineOptions.parse(
|
||||
['--dart-sdk', '.', '--package-warnings', 'foo.dart']);
|
||||
|
@ -238,15 +231,6 @@ void main() {
|
|||
expect(options.lintsAreFatal, isTrue);
|
||||
});
|
||||
|
||||
test("can't specify package and package-root", () {
|
||||
var failureMessage;
|
||||
CommandLineOptions.parse(
|
||||
['--package-root', '.', '--packages', '.', 'foo.dart'],
|
||||
printAndFail: (msg) => failureMessage = msg);
|
||||
expect(failureMessage,
|
||||
equals("Cannot specify both '--package-root' and '--packages."));
|
||||
});
|
||||
|
||||
test('bad SDK dir', () {
|
||||
var failureMessage;
|
||||
CommandLineOptions.parse(['--dart-sdk', '&&&&&', 'foo.dart'],
|
||||
|
|
Loading…
Reference in a new issue