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

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

Issue 2988743002: Remove the analysus.reanalyze request from the plugin API (Closed)
Patch Set: Restart plugins Created 3 years, 5 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 148cc37ee311317b2139a7a77d8ee973389a1eb5..11b61997ce1b3e41b264889385044dcde171c1ef 100644
--- a/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
+++ b/pkg/analysis_server/lib/src/plugin/plugin_manager.dart
@@ -156,6 +156,22 @@ abstract class PluginInfo {
}
/**
+ * Add the given context [roots] to the set of context roots being analyzed by
+ * this plugin.
+ */
+ void addContextRoots(Iterable<analyzer.ContextRoot> roots) {
+ bool changed = false;
+ for (analyzer.ContextRoot contextRoot in roots) {
+ if (contextRoots.add(contextRoot)) {
+ changed = true;
+ }
+ }
+ if (changed) {
+ _updatePluginRoots();
+ }
+ }
+
+ /**
* Return `true` if at least one of the context roots being analyzed contains
* the file with the given [filePath].
*/
@@ -490,6 +506,46 @@ class PluginManager {
}
/**
+ * Restart all currently running plugins.
+ */
+ Future<Null> restartPlugins() async {
+ for (PluginInfo plugin in _pluginMap.values.toList()) {
+ if (plugin.currentSession != null) {
+ //
+ // Capture needed state.
+ //
+ Set<analyzer.ContextRoot> contextRoots = plugin.contextRoots;
+ String path = plugin.pluginId;
+ //
+ // Stop the plugin.
+ //
+ await plugin.stop();
+ //
+ // Restart the plugin.
+ //
+ _pluginMap[path] = plugin;
+ PluginSession session = await plugin.start(byteStorePath, sdkPath);
+ session?.onDone?.then((_) {
+ _pluginMap.remove(path);
+ });
+ //
+ // Re-initialize the plugin.
+ //
+ plugin.addContextRoots(contextRoots);
+ if (_analysisSetSubscriptionsParams != null) {
+ plugin.sendRequest(_analysisSetSubscriptionsParams);
+ }
+ if (_overlayState.isNotEmpty) {
+ plugin.sendRequest(new AnalysisUpdateContentParams(_overlayState));
+ }
+ if (_analysisSetPriorityFilesParams != null) {
+ plugin.sendRequest(_analysisSetPriorityFilesParams);
+ }
+ }
+ }
+ }
+
+ /**
* 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.
« 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