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

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

Issue 2834993002: Add support for three more plugin requests (Closed)
Patch Set: Created 3 years, 8 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
Index: pkg/analysis_server/lib/src/plugin/plugin_manager.dart
diff --git a/pkg/analysis_server/lib/src/plugin/plugin_manager.dart b/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
index 645cb4c948d86d8f2882acada4acd024faffd9b3..663443fe4724dc1198f928384ded90bb8fd60b3f 100644
--- a/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
+++ b/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
@@ -98,6 +98,15 @@ class PluginInfo {
}
/**
+ * If the plugin is currently running, send a request based on the given
+ * [params] to the plugin. If the plugin is not running, the request will
+ * silently be dropped.
+ */
+ void sendRequest(RequestParams params) {
+ currentSession?.sendRequest(params);
+ }
+
+ /**
* Start a new isolate that is running the plugin. Return the state object
* used to interact with the plugin.
*/
@@ -168,6 +177,27 @@ class PluginManager {
Map<String, PluginInfo> _pluginMap = <String, PluginInfo>{};
/**
+ * The parameters for the last 'analysis.setPriorityFiles' request that was
+ * received from the client. Because plugins are lazily discovered, this needs
+ * to be retained so that it can be sent after a plugin has been started.
+ */
+ AnalysisSetPriorityFilesParams _analysisSetPriorityFilesParams;
+
+ /**
+ * The parameters for the last 'analysis.setSubscriptions' request that was
+ * received from the client. Because plugins are lazily discovered, this needs
+ * to be retained so that it can be sent after a plugin has been started.
+ */
+ AnalysisSetSubscriptionsParams _analysisSetSubscriptionsParams;
+
+ /**
+ * The current state of content overlays. Because plugins are lazily
+ * discovered, the state needs to be retained so that it can be sent after a
+ * plugin has been started.
+ */
+ Map<String, dynamic> _overlayState = <String, dynamic>{};
+
+ /**
* Initialize a newly created plugin manager. The notifications from the
* running plugins will be handled by the given [notificationManager].
*/
@@ -182,7 +212,9 @@ class PluginManager {
Future<Null> addPluginToContextRoot(
analyzer.ContextRoot contextRoot, String path) async {
PluginInfo plugin = _pluginMap[path];
+ bool isNew = false;
if (plugin == null) {
+ isNew = true;
List<String> pluginPaths = _pathsFor(path);
plugin = new PluginInfo(path, pluginPaths[0], pluginPaths[1],
notificationManager, instrumentationService);
@@ -195,6 +227,17 @@ class PluginManager {
}
}
plugin.addContextRoot(contextRoot);
+ if (isNew) {
+ if (_analysisSetSubscriptionsParams != null) {
+ plugin.sendRequest(_analysisSetSubscriptionsParams);
+ }
+ if (_overlayState.isNotEmpty) {
+ plugin.sendRequest(new AnalysisUpdateContentParams(_overlayState));
+ }
+ if (_analysisSetPriorityFilesParams != null) {
+ plugin.sendRequest(_analysisSetPriorityFilesParams);
+ }
+ }
}
/**
@@ -244,6 +287,61 @@ class PluginManager {
}
/**
+ * Send a request based on the given [params] to existing plugins to set the
+ * priority files to those specified by the [params]. As a side-effect, record
+ * the parameters so that they can be sent to any newly started plugins.
+ */
+ void setAnalysisSetPriorityFilesParams(
+ AnalysisSetPriorityFilesParams params) {
+ for (PluginInfo plugin in _pluginMap.values) {
+ plugin.sendRequest(params);
+ }
+ _analysisSetPriorityFilesParams = params;
+ }
+
+ /**
+ * Send a request based on the given [params] to existing plugins to set the
+ * subscriptions to those specified by the [params]. As a side-effect, record
+ * the parameters so that they can be sent to any newly started plugins.
+ */
+ void setAnalysisSetSubscriptionsParams(
+ AnalysisSetSubscriptionsParams params) {
+ for (PluginInfo plugin in _pluginMap.values) {
+ plugin.sendRequest(params);
+ }
+ _analysisSetSubscriptionsParams = params;
+ }
+
+ /**
+ * Send a request based on the given [params] to existing plugins to set the
+ * content overlays to those specified by the [params]. As a side-effect,
+ * update the overlay state so that it can be sent to any newly started
+ * plugins.
+ */
+ void setAnalysisUpdateContentParams(AnalysisUpdateContentParams params) {
+ for (PluginInfo plugin in _pluginMap.values) {
+ plugin.sendRequest(params);
+ }
+ Map<String, dynamic> files = params.files;
+ for (String file in files.keys) {
+ Object overlay = files[file];
+ if (overlay is RemoveContentOverlay) {
+ _overlayState.remove(file);
+ } else if (overlay is AddContentOverlay) {
+ _overlayState[file] = overlay;
+ } else if (overlay is ChangeContentOverlay) {
+ AddContentOverlay previousOverlay = _overlayState[file];
+ String newContent =
+ SourceEdit.applySequence(previousOverlay.content, overlay.edits);
+ _overlayState[file] = new AddContentOverlay(newContent);
+ } else {
+ throw new ArgumentError(
+ 'Invalid class of overlay: ${overlay.runtimeType}');
+ }
+ }
+ }
+
+ /**
* Stop all of the plugins that are currently running.
*/
Future<List<Null>> stopAll() {
« no previous file with comments | « pkg/analysis_server/lib/src/domain_analysis.dart ('k') | pkg/analysis_server/lib/src/plugin/request_converter.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698