| Index: pkg/analyzer/lib/src/generated/sdk.dart
|
| diff --git a/pkg/analyzer/lib/src/generated/sdk.dart b/pkg/analyzer/lib/src/generated/sdk.dart
|
| index 8705867323fc27716d9745ec22ba2d6b5f7df1e4..16bc5e85d125ff8b6fc6f281eb6295777683c1ff 100644
|
| --- a/pkg/analyzer/lib/src/generated/sdk.dart
|
| +++ b/pkg/analyzer/lib/src/generated/sdk.dart
|
| @@ -11,6 +11,7 @@ import 'package:analyzer/dart/ast/visitor.dart';
|
| import 'package:analyzer/src/generated/engine.dart'
|
| show AnalysisContext, AnalysisOptions;
|
| import 'package:analyzer/src/generated/source.dart' show Source;
|
| +import 'package:analyzer/src/generated/utilities_general.dart';
|
|
|
| /**
|
| * A function used to create a new DartSdk with the given [options]. If the
|
| @@ -96,20 +97,32 @@ abstract class DartSdk {
|
| */
|
| class DartSdkManager {
|
| /**
|
| + * The absolute path to the directory containing the default SDK.
|
| + */
|
| + final String defaultSdkDirectory;
|
| +
|
| + /**
|
| + * A flag indicating whether it is acceptable to use summaries when they are
|
| + * available.
|
| + */
|
| + final bool canUseSummaries;
|
| +
|
| + /**
|
| * The function used to create new SDK's.
|
| */
|
| final SdkCreator sdkCreator;
|
|
|
| /**
|
| - * A table mapping (an encoding of) analysis options to the SDK that has been
|
| - * configured with those options.
|
| + * A table mapping (an encoding of) analysis options and SDK locations to the
|
| + * DartSdk from that location that has been configured with those options.
|
| */
|
| - Map<int, DartSdk> sdkMap = new HashMap<int, DartSdk>();
|
| + Map<SdkDescription, DartSdk> sdkMap = new HashMap<SdkDescription, DartSdk>();
|
|
|
| /**
|
| * Initialize a newly created manager.
|
| */
|
| - DartSdkManager(this.sdkCreator);
|
| + DartSdkManager(
|
| + this.defaultSdkDirectory, this.canUseSummaries, this.sdkCreator);
|
|
|
| /**
|
| * Return any SDK that has been created, or `null` if no SDKs have been
|
| @@ -127,9 +140,20 @@ class DartSdkManager {
|
| * If such an SDK has not yet been created, then the [sdkCreator] will be
|
| * invoked to create it.
|
| */
|
| + DartSdk getSdk(SdkDescription description, DartSdk ifAbsent()) {
|
| + return sdkMap.putIfAbsent(description, ifAbsent);
|
| + }
|
| +
|
| + /**
|
| + * Return the Dart SDK that is appropriate for the given analysis [options].
|
| + * If such an SDK has not yet been created, then the [sdkCreator] will be
|
| + * invoked to create it.
|
| + */
|
| DartSdk getSdkForOptions(AnalysisOptions options) {
|
| - int encoding = options.encodeCrossContextOptions();
|
| - return sdkMap.putIfAbsent(encoding, () => sdkCreator(options));
|
| + // TODO(brianwilkerson) Remove this method and the field sdkCreator.
|
| + SdkDescription description =
|
| + new SdkDescription(<String>[defaultSdkDirectory], options);
|
| + return getSdk(description, () => sdkCreator(options));
|
| }
|
| }
|
|
|
| @@ -173,6 +197,58 @@ class LibraryMap {
|
| int size() => _libraryMap.length;
|
| }
|
|
|
| +/**
|
| + * A description of a [DartSdk].
|
| + */
|
| +class SdkDescription {
|
| + /**
|
| + * The paths to the files or directories that define the SDK.
|
| + */
|
| + final List<String> paths;
|
| +
|
| + /**
|
| + * The analysis options that will be used by the SDK's context.
|
| + */
|
| + final AnalysisOptions options;
|
| +
|
| + /**
|
| + * Initialize a newly created SDK description to describe an SDK based on the
|
| + * files or directories at the given [paths] that is analyzed using the given
|
| + * [options].
|
| + */
|
| + SdkDescription(this.paths, this.options);
|
| +
|
| + @override
|
| + int get hashCode {
|
| + int hashCode = options.encodeCrossContextOptions();
|
| + for (String path in paths) {
|
| + hashCode = JenkinsSmiHash.combine(hashCode, path.hashCode);
|
| + }
|
| + return JenkinsSmiHash.finish(hashCode);
|
| + }
|
| +
|
| + @override
|
| + bool operator ==(Object other) {
|
| + if (other is SdkDescription) {
|
| + if (options.encodeCrossContextOptions() !=
|
| + other.options.encodeCrossContextOptions()) {
|
| + return false;
|
| + }
|
| + int length = paths.length;
|
| + if (other.paths.length != length) {
|
| + return false;
|
| + }
|
| + for (int i = 0; i < length; i++) {
|
| + if (other.paths[i] != paths[i]) {
|
| + return false;
|
| + }
|
| + }
|
| + return true;
|
| + }
|
| + return false;
|
| + }
|
| +}
|
| +
|
| class SdkLibrariesReader_LibraryBuilder extends RecursiveAstVisitor<Object> {
|
| /**
|
| * The prefix added to the name of a library to form the URI used in code to
|
|
|