Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(429)

Unified Diff: pkg/analyzer/lib/src/generated/sdk.dart

Issue 1686613002: Use different SDKs based on option settings (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | pkg/analyzer/lib/src/generated/utilities_general.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 a2b6325a0ab50b5b6079f26de68e663487a1f362..42351c41c980482f72e07d8c24c416bd71eb7b76 100644
--- a/pkg/analyzer/lib/src/generated/sdk.dart
+++ b/pkg/analyzer/lib/src/generated/sdk.dart
@@ -8,11 +8,17 @@ import 'dart:collection';
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
-import 'package:analyzer/src/generated/engine.dart' show AnalysisContext;
+import 'package:analyzer/src/generated/engine.dart'
+ show AnalysisContext, AnalysisOptions;
import 'package:analyzer/src/generated/source.dart'
show ContentCache, Source, UriKind;
/**
+ * A function used to create a new DartSdk
+ */
+typedef DartSdk SdkCreator();
+
+/**
* A Dart SDK installed in a specified location.
*/
abstract class DartSdk {
@@ -79,6 +85,54 @@ abstract class DartSdk {
}
/**
+ * Manages the DartSdk's that
Paul Berry 2016/02/09 18:21:18 Incomplete comment
+ */
+class DartSdkManager {
+ /**
+ * 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.
+ */
+ Map<int, DartSdk> sdkMap = new HashMap<int, DartSdk>();
+
+ /**
+ * Initialize a newly created manager.
+ */
+ DartSdkManager(this.sdkCreator);
+
+ /**
+ * Return any SDK that has been created, or `null` if no SDKs have been
+ * created.
+ */
+ DartSdk get anySdk {
+ if (sdkMap.isEmpty) {
+ return null;
+ }
+ return sdkMap.values.first;
+ }
+
+ /**
+ * 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();
+ DartSdk sdk = sdkMap[encoding];
+ if (sdk == null) {
+ sdk = sdkCreator();
+ sdkMap[encoding] = sdk;
+ sdk.context.analysisOptions.setCrossContextOptionsFrom(options);
+ }
+ return sdk;
+ }
+}
+
+/**
* A map from Dart library URI's to the [SdkLibraryImpl] representing that
* library.
*/
« no previous file with comments | « pkg/analyzer/lib/src/generated/engine.dart ('k') | pkg/analyzer/lib/src/generated/utilities_general.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698