mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
remove unused DDC --package-paths options and MultiPackageResolver
R=vsm@google.com Review URL: https://codereview.chromium.org/2527433002 .
This commit is contained in:
parent
f6fbc40423
commit
f109556fb7
|
@ -4,6 +4,7 @@
|
|||
- add support for AMD modules and make it the default.
|
||||
- precompile the SDK in AMD, CommonJS, and ES6 flavors.
|
||||
- legacy module format is deprecated.
|
||||
- remove --package-paths option
|
||||
|
||||
## 0.1.24
|
||||
- workaround breaking change on requestAnimationFrame
|
||||
|
|
|
@ -22,8 +22,6 @@ import 'package:analyzer/src/summary/summary_sdk.dart' show SummaryBasedDartSdk;
|
|||
import 'package:cli_util/cli_util.dart' show getSdkDir;
|
||||
import 'package:path/path.dart' as path;
|
||||
|
||||
import 'multi_package_resolver.dart' show MultiPackageResolver;
|
||||
|
||||
/// Options used to set up Source URI resolution in the analysis context.
|
||||
class AnalyzerOptions {
|
||||
/// Custom URI mappings, such as "dart:foo" -> "path/to/foo.dart"
|
||||
|
@ -35,9 +33,6 @@ class AnalyzerOptions {
|
|||
/// List of summary file paths.
|
||||
final List<String> summaryPaths;
|
||||
|
||||
/// List of paths used for the multi-package resolver.
|
||||
final List<String> packagePaths;
|
||||
|
||||
/// Path to the dart-sdk. Null if `useMockSdk` is true or if the path couldn't
|
||||
/// be determined
|
||||
final String dartSdkPath;
|
||||
|
@ -55,7 +50,6 @@ class AnalyzerOptions {
|
|||
this.dartSdkSummaryPath,
|
||||
this.customUrlMappings: const {},
|
||||
this.packageRoot: null,
|
||||
this.packagePaths: const [],
|
||||
this.declaredVariables: const {}})
|
||||
: dartSdkPath = dartSdkPath ?? getSdkDir().path;
|
||||
|
||||
|
@ -77,13 +71,9 @@ class AnalyzerOptions {
|
|||
dartSdkSummaryPath: sdkSummaryPath,
|
||||
customUrlMappings: _parseUrlMappings(args['url-mapping']),
|
||||
packageRoot: args['package-root'],
|
||||
packagePaths: (args['package-paths'] as String)?.split(',') ?? [],
|
||||
declaredVariables: declaredVariables);
|
||||
}
|
||||
|
||||
/// Whether to resolve 'package:' uris using the multi-package resolver.
|
||||
bool get useMultiPackage => packagePaths.isNotEmpty;
|
||||
|
||||
static void addArguments(ArgParser parser) {
|
||||
parser
|
||||
..addOption('summary',
|
||||
|
@ -98,9 +88,7 @@ class AnalyzerOptions {
|
|||
help: '--url-mapping=libraryUri,/path/to/library.dart uses\n'
|
||||
'library.dart as the source for an import of of "libraryUri".',
|
||||
allowMultiple: true,
|
||||
splitCommas: false)
|
||||
..addOption('package-paths',
|
||||
help: 'use a list of directories to resolve "package:" imports');
|
||||
splitCommas: false);
|
||||
}
|
||||
|
||||
static Map<String, String> _parseUrlMappings(Iterable argument) {
|
||||
|
@ -168,12 +156,7 @@ List<UriResolver> createFileResolvers(AnalyzerOptions options,
|
|||
builder.convertPackagesToMap(builder.createPackageMap('')));
|
||||
}
|
||||
|
||||
return [
|
||||
new ResourceUriResolver(resourceProvider),
|
||||
options.useMultiPackage
|
||||
? new MultiPackageResolver(options.packagePaths)
|
||||
: packageResolver()
|
||||
];
|
||||
return [new ResourceUriResolver(resourceProvider), packageResolver()];
|
||||
}
|
||||
|
||||
FolderBasedDartSdk _createFolderBasedDartSdk(String sdkPath) {
|
||||
|
|
|
@ -1,53 +0,0 @@
|
|||
// Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
|
||||
// for details. All rights reserved. Use of this source code is governed by a
|
||||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'dart:io';
|
||||
|
||||
import 'package:analyzer/src/generated/java_io.dart';
|
||||
import 'package:analyzer/src/generated/source.dart';
|
||||
import 'package:analyzer/src/generated/source_io.dart';
|
||||
import 'package:path/path.dart' show join;
|
||||
|
||||
/// A package resolver that supports a non-standard package layout, where
|
||||
/// packages with dotted names are expanded to a hierarchy of directories, and
|
||||
/// packages can be found on one or more locations.
|
||||
class MultiPackageResolver extends UriResolver {
|
||||
final List<String> searchPaths;
|
||||
MultiPackageResolver(this.searchPaths);
|
||||
|
||||
@override
|
||||
Source resolveAbsolute(Uri uri, [Uri actualUri]) {
|
||||
var candidates = _expandPath(uri);
|
||||
if (candidates == null) return null;
|
||||
|
||||
for (var path in candidates) {
|
||||
var resolvedPath = _resolve(path);
|
||||
if (resolvedPath != null) {
|
||||
return new FileBasedSource(
|
||||
new JavaFile(resolvedPath), actualUri != null ? actualUri : uri);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Resolve [path] by looking at each prefix in [searchPaths] and returning
|
||||
/// the first location where `prefix + path` exists.
|
||||
String _resolve(String path) {
|
||||
for (var prefix in searchPaths) {
|
||||
var resolvedPath = join(prefix, path);
|
||||
if (new File(resolvedPath).existsSync()) return resolvedPath;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// Expand `uri.path`, replacing dots in the package name with slashes.
|
||||
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', '$packagePath/$filePath'];
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue