OLD | NEW |
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:io' show Platform; | 7 import 'dart:io' show Platform; |
8 | 8 |
9 import 'package:analysis_server/src/plugin/notification_manager.dart'; | 9 import 'package:analysis_server/src/plugin/notification_manager.dart'; |
10 import 'package:analyzer/context/context_root.dart' as analyzer; | 10 import 'package:analyzer/context/context_root.dart' as analyzer; |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 } | 244 } |
245 } | 245 } |
246 } | 246 } |
247 | 247 |
248 /** | 248 /** |
249 * Broadcast a request built from the given [params] to all of the plugins | 249 * Broadcast a request built from the given [params] to all of the plugins |
250 * that are currently associated with the given [contextRoot]. Return a list | 250 * that are currently associated with the given [contextRoot]. Return a list |
251 * containing futures that will complete when each of the plugins have sent a | 251 * containing futures that will complete when each of the plugins have sent a |
252 * response. | 252 * response. |
253 */ | 253 */ |
254 Map<PluginInfo, Future<Response>> broadcastRequest( | 254 Map<PluginInfo, Future<Response>> broadcastRequest(RequestParams params, |
255 analyzer.ContextRoot contextRoot, RequestParams params) { | 255 {analyzer.ContextRoot contextRoot}) { |
256 List<PluginInfo> plugins = pluginsForContextRoot(contextRoot); | 256 List<PluginInfo> plugins = pluginsForContextRoot(contextRoot); |
257 Map<PluginInfo, Future<Response>> responseMap = | 257 Map<PluginInfo, Future<Response>> responseMap = |
258 <PluginInfo, Future<Response>>{}; | 258 <PluginInfo, Future<Response>>{}; |
259 for (PluginInfo plugin in plugins) { | 259 for (PluginInfo plugin in plugins) { |
260 responseMap[plugin] = plugin.currentSession?.sendRequest(params); | 260 responseMap[plugin] = plugin.currentSession?.sendRequest(params); |
261 } | 261 } |
262 return responseMap; | 262 return responseMap; |
263 } | 263 } |
264 | 264 |
265 /** | 265 /** |
(...skipping 27 matching lines...) Expand all Loading... |
293 } | 293 } |
294 return responses; | 294 return responses; |
295 } | 295 } |
296 | 296 |
297 /** | 297 /** |
298 * Return a list of all of the plugins that are currently associated with the | 298 * Return a list of all of the plugins that are currently associated with the |
299 * given [contextRoot]. | 299 * given [contextRoot]. |
300 */ | 300 */ |
301 @visibleForTesting | 301 @visibleForTesting |
302 List<PluginInfo> pluginsForContextRoot(analyzer.ContextRoot contextRoot) { | 302 List<PluginInfo> pluginsForContextRoot(analyzer.ContextRoot contextRoot) { |
| 303 if (contextRoot == null) { |
| 304 return _pluginMap.values.toList(); |
| 305 } |
303 List<PluginInfo> plugins = <PluginInfo>[]; | 306 List<PluginInfo> plugins = <PluginInfo>[]; |
304 for (PluginInfo plugin in _pluginMap.values) { | 307 for (PluginInfo plugin in _pluginMap.values) { |
305 if (plugin.contextRoots.contains(contextRoot)) { | 308 if (plugin.contextRoots.contains(contextRoot)) { |
306 plugins.add(plugin); | 309 plugins.add(plugin); |
307 } | 310 } |
308 } | 311 } |
309 return plugins; | 312 return plugins; |
310 } | 313 } |
311 | 314 |
312 /** | 315 /** |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
663 Future<Null> stop() { | 666 Future<Null> stop() { |
664 if (channel == null) { | 667 if (channel == null) { |
665 throw new StateError('Cannot stop a plugin that is not running.'); | 668 throw new StateError('Cannot stop a plugin that is not running.'); |
666 } | 669 } |
667 // TODO(brianwilkerson) Ensure that the isolate is killed if it does not | 670 // TODO(brianwilkerson) Ensure that the isolate is killed if it does not |
668 // terminate normally. | 671 // terminate normally. |
669 sendRequest(new PluginShutdownParams()); | 672 sendRequest(new PluginShutdownParams()); |
670 return pluginStoppedCompleter.future; | 673 return pluginStoppedCompleter.future; |
671 } | 674 } |
672 } | 675 } |
OLD | NEW |