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

Unified Diff: pkg/analysis_server/lib/src/analysis_server.dart

Issue 335123008: Implement analysis.updateOptions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments Created 6 years, 6 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 | « no previous file | pkg/analysis_server/lib/src/constants.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/src/analysis_server.dart
diff --git a/pkg/analysis_server/lib/src/analysis_server.dart b/pkg/analysis_server/lib/src/analysis_server.dart
index 6e7f35d45d2812fcc38d8e7333e4eba6b3449dbc..fe0b55f11713b65024f15464749615bd3c350b06 100644
--- a/pkg/analysis_server/lib/src/analysis_server.dart
+++ b/pkg/analysis_server/lib/src/analysis_server.dart
@@ -36,6 +36,11 @@ final DirectoryBasedDartSdk SHARED_SDK = DirectoryBasedDartSdk.defaultSdk;
class AnalysisServerContextDirectoryManager extends ContextDirectoryManager {
final AnalysisServer analysisServer;
+ /**
+ * The default options used to create new analysis contexts.
+ */
+ AnalysisOptionsImpl defaultOptions = new AnalysisOptionsImpl();
+
AnalysisServerContextDirectoryManager(this.analysisServer, ResourceProvider resourceProvider)
: super(resourceProvider);
@@ -44,7 +49,9 @@ class AnalysisServerContextDirectoryManager extends ContextDirectoryManager {
ContextDirectory contextDirectory = new ContextDirectory(
analysisServer.defaultSdk, folder, pubspecFile);
analysisServer.folderMap[folder] = contextDirectory;
- analysisServer.schedulePerformAnalysisOperation(contextDirectory.context);
+ AnalysisContext context = contextDirectory.context;
+ context.analysisOptions = new AnalysisOptionsImpl.con1(defaultOptions);
+ analysisServer.schedulePerformAnalysisOperation(context);
}
@override
@@ -210,6 +217,31 @@ class AnalysisServer {
}
/**
+ * Use the given updaters to update the values of the options in every
+ * existing analysis context.
+ */
+ void updateOptions(List<OptionUpdater> optionUpdaters) {
+ //
+ // Update existing contexts.
+ //
+ folderMap.forEach((Folder folder, ContextDirectory directory) {
+ AnalysisContext context = directory.context;
+ AnalysisOptionsImpl options = new AnalysisOptionsImpl.con1(context.analysisOptions);
+ optionUpdaters.forEach((OptionUpdater optionUpdater) {
+ optionUpdater(options);
+ });
+ context.analysisOptions = options;
+ });
+ //
+ // Update the defaults used to create new contexts.
+ //
+ AnalysisOptionsImpl options = contextDirectoryManager.defaultOptions;
+ optionUpdaters.forEach((OptionUpdater optionUpdater) {
+ optionUpdater(options);
+ });
+ }
+
+ /**
* Adds the given [ServerOperation] to the queue, but does not schedule
* operations execution.
*/
@@ -540,6 +572,7 @@ class ContextDirectory {
AnalysisContext get context => _context;
}
+typedef void OptionUpdater(AnalysisOptionsImpl options);
/**
* An enumeration of the services provided by the server domain.
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/constants.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698