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

Side by Side 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'dart:async'; 5 import 'dart:async';
6 import 'dart:collection'; 6 import 'dart:collection';
7 import 'dart:convert'; 7 import 'dart:convert';
8 import 'dart:io' show Platform, Process, ProcessResult; 8 import 'dart:io' show Platform, Process, ProcessResult;
9 9
10 import 'package:analysis_server/src/plugin/notification_manager.dart'; 10 import 'package:analysis_server/src/plugin/notification_manager.dart';
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 * Add the given [contextRoot] to the set of context roots being analyzed by 149 * Add the given [contextRoot] to the set of context roots being analyzed by
150 * this plugin. 150 * this plugin.
151 */ 151 */
152 void addContextRoot(analyzer.ContextRoot contextRoot) { 152 void addContextRoot(analyzer.ContextRoot contextRoot) {
153 if (contextRoots.add(contextRoot)) { 153 if (contextRoots.add(contextRoot)) {
154 _updatePluginRoots(); 154 _updatePluginRoots();
155 } 155 }
156 } 156 }
157 157
158 /** 158 /**
159 * Add the given context [roots] to the set of context roots being analyzed by
160 * this plugin.
161 */
162 void addContextRoots(Iterable<analyzer.ContextRoot> roots) {
163 bool changed = false;
164 for (analyzer.ContextRoot contextRoot in roots) {
165 if (contextRoots.add(contextRoot)) {
166 changed = true;
167 }
168 }
169 if (changed) {
170 _updatePluginRoots();
171 }
172 }
173
174 /**
159 * Return `true` if at least one of the context roots being analyzed contains 175 * Return `true` if at least one of the context roots being analyzed contains
160 * the file with the given [filePath]. 176 * the file with the given [filePath].
161 */ 177 */
162 bool isAnalyzing(String filePath) { 178 bool isAnalyzing(String filePath) {
163 for (var contextRoot in contextRoots) { 179 for (var contextRoot in contextRoots) {
164 if (contextRoot.containsFile(filePath)) { 180 if (contextRoot.containsFile(filePath)) {
165 return true; 181 return true;
166 } 182 }
167 } 183 }
168 return false; 184 return false;
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
483 for (PluginInfo plugin in plugins) { 499 for (PluginInfo plugin in plugins) {
484 plugin.removeContextRoot(contextRoot); 500 plugin.removeContextRoot(contextRoot);
485 if (plugin is DiscoveredPluginInfo && plugin.contextRoots.isEmpty) { 501 if (plugin is DiscoveredPluginInfo && plugin.contextRoots.isEmpty) {
486 _pluginMap.remove(plugin.path); 502 _pluginMap.remove(plugin.path);
487 plugin.stop(); 503 plugin.stop();
488 } 504 }
489 } 505 }
490 } 506 }
491 507
492 /** 508 /**
509 * Restart all currently running plugins.
510 */
511 Future<Null> restartPlugins() async {
512 for (PluginInfo plugin in _pluginMap.values.toList()) {
513 if (plugin.currentSession != null) {
514 //
515 // Capture needed state.
516 //
517 Set<analyzer.ContextRoot> contextRoots = plugin.contextRoots;
518 String path = plugin.pluginId;
519 //
520 // Stop the plugin.
521 //
522 await plugin.stop();
523 //
524 // Restart the plugin.
525 //
526 _pluginMap[path] = plugin;
527 PluginSession session = await plugin.start(byteStorePath, sdkPath);
528 session?.onDone?.then((_) {
529 _pluginMap.remove(path);
530 });
531 //
532 // Re-initialize the plugin.
533 //
534 plugin.addContextRoots(contextRoots);
535 if (_analysisSetSubscriptionsParams != null) {
536 plugin.sendRequest(_analysisSetSubscriptionsParams);
537 }
538 if (_overlayState.isNotEmpty) {
539 plugin.sendRequest(new AnalysisUpdateContentParams(_overlayState));
540 }
541 if (_analysisSetPriorityFilesParams != null) {
542 plugin.sendRequest(_analysisSetPriorityFilesParams);
543 }
544 }
545 }
546 }
547
548 /**
493 * Send a request based on the given [params] to existing plugins to set the 549 * Send a request based on the given [params] to existing plugins to set the
494 * priority files to those specified by the [params]. As a side-effect, record 550 * priority files to those specified by the [params]. As a side-effect, record
495 * the parameters so that they can be sent to any newly started plugins. 551 * the parameters so that they can be sent to any newly started plugins.
496 */ 552 */
497 void setAnalysisSetPriorityFilesParams( 553 void setAnalysisSetPriorityFilesParams(
498 AnalysisSetPriorityFilesParams params) { 554 AnalysisSetPriorityFilesParams params) {
499 for (PluginInfo plugin in _pluginMap.values) { 555 for (PluginInfo plugin in _pluginMap.values) {
500 plugin.sendRequest(params); 556 plugin.sendRequest(params);
501 } 557 }
502 _analysisSetPriorityFilesParams = params; 558 _analysisSetPriorityFilesParams = params;
(...skipping 474 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 * The completer that will be used to complete the future when the response is 1033 * The completer that will be used to complete the future when the response is
978 * received from the plugin. 1034 * received from the plugin.
979 */ 1035 */
980 final Completer<Response> completer; 1036 final Completer<Response> completer;
981 1037
982 /** 1038 /**
983 * Initialize a pending request. 1039 * Initialize a pending request.
984 */ 1040 */
985 _PendingRequest(this.method, this.requestTime, this.completer); 1041 _PendingRequest(this.method, this.requestTime, this.completer);
986 } 1042 }
OLDNEW
« 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