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

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

Issue 1830703002: Pass AnalysisOptions into SdkCreator, disable changing afterwards. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 9 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/sdk.dart ('k') | pkg/analyzer/test/generated/all_the_rest_test.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_io.dart
diff --git a/pkg/analyzer/lib/src/generated/sdk_io.dart b/pkg/analyzer/lib/src/generated/sdk_io.dart
index 6f03a84708270f3404cd5d8ca78a711fffb19137..38b3cfbd09983ccc122b3a76707474e9dd7247dd 100644
--- a/pkg/analyzer/lib/src/generated/sdk_io.dart
+++ b/pkg/analyzer/lib/src/generated/sdk_io.dart
@@ -249,6 +249,11 @@ class DirectoryBasedDartSdk implements DartSdk {
Map<String, Source> _uriToSourceMap = new HashMap<String, Source>();
/**
+ * The [AnalysisOptions] to use to create the [context].
+ */
+ AnalysisOptions _analysisOptions;
+
+ /**
* Initialize a newly created SDK to represent the Dart SDK installed in the
* [sdkDirectory]. The flag [useDart2jsPaths] is `true` if the dart2js path
* should be used when it is available
@@ -258,12 +263,31 @@ class DirectoryBasedDartSdk implements DartSdk {
_libraryMap = initialLibraryMap(useDart2jsPaths);
}
+ /**
+ * Set the [options] for this SDK analysis context. Throw [StateError] if the
+ * context has been already created.
+ */
+ void set analysisOptions(AnalysisOptions options) {
+ if (_analysisContext != null) {
+ throw new StateError(
+ 'Analysis options cannot be changed after context creation.');
+ }
+ _analysisOptions = options;
+ }
+
@override
AnalysisContext get context {
if (_analysisContext == null) {
- _analysisContext = new SdkAnalysisContext();
+ _analysisContext = new SdkAnalysisContext(_analysisOptions);
SourceFactory factory = new SourceFactory([new DartUriResolver(this)]);
_analysisContext.sourceFactory = factory;
+ if (_useSummary) {
+ PackageBundle sdkBundle = _getSummarySdkBundle();
+ if (sdkBundle != null) {
+ _analysisContext.resultProvider =
+ new SdkSummaryResultProvider(_analysisContext, sdkBundle);
+ }
+ }
}
return _analysisContext;
}
@@ -393,14 +417,11 @@ class DirectoryBasedDartSdk implements DartSdk {
* Specify whether SDK summary should be used.
*/
void set useSummary(bool use) {
- _useSummary = use;
- if (_useSummary) {
- PackageBundle sdkBundle = _getSummarySdkBundle();
- if (sdkBundle != null) {
- _analysisContext.resultProvider =
- new SdkSummaryResultProvider(_analysisContext, sdkBundle);
- }
+ if (_analysisContext != null) {
+ throw new StateError(
+ 'The "useSummary" flag cannot be changed after context creation.');
}
+ _useSummary = use;
}
/**
@@ -552,8 +573,8 @@ class DirectoryBasedDartSdk implements DartSdk {
*/
PackageBundle _getSummarySdkBundle() {
String rootPath = directory.getAbsolutePath();
- String name =
- context.analysisOptions.strongMode ? 'strong.sum' : 'spec.sum';
+ bool strongMode = _analysisOptions?.strongMode ?? false;
+ String name = strongMode ? 'strong.sum' : 'spec.sum';
String path = pathos.join(rootPath, 'lib', '_internal', name);
try {
File file = new File(path);
« no previous file with comments | « pkg/analyzer/lib/src/generated/sdk.dart ('k') | pkg/analyzer/test/generated/all_the_rest_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698