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

Side by Side Diff: pkg/analysis_server/lib/src/plugin/plugin_manager.dart

Issue 2830863002: Initial support for getting fixes from plugins (Closed)
Patch Set: address comments 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 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: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;
11 import 'package:analyzer/file_system/file_system.dart'; 11 import 'package:analyzer/file_system/file_system.dart';
12 import 'package:analyzer/instrumentation/instrumentation.dart'; 12 import 'package:analyzer/instrumentation/instrumentation.dart';
13 import 'package:analyzer/src/generated/bazel.dart'; 13 import 'package:analyzer/src/generated/bazel.dart';
14 import 'package:analyzer/src/generated/gn.dart'; 14 import 'package:analyzer/src/generated/gn.dart';
15 import 'package:analyzer_plugin/channel/channel.dart'; 15 import 'package:analyzer_plugin/channel/channel.dart';
16 import 'package:analyzer_plugin/protocol/protocol.dart'; 16 import 'package:analyzer_plugin/protocol/protocol.dart';
17 import 'package:analyzer_plugin/protocol/protocol_generated.dart'; 17 import 'package:analyzer_plugin/protocol/protocol_generated.dart';
18 import 'package:analyzer_plugin/src/channel/isolate_channel.dart'; 18 import 'package:analyzer_plugin/src/channel/isolate_channel.dart';
19 import 'package:analyzer_plugin/src/protocol/protocol_internal.dart'; 19 import 'package:analyzer_plugin/src/protocol/protocol_internal.dart';
20 import 'package:convert/convert.dart'; 20 import 'package:convert/convert.dart';
21 import 'package:crypto/crypto.dart'; 21 import 'package:crypto/crypto.dart';
22 import 'package:meta/meta.dart'; 22 import 'package:meta/meta.dart';
23 import 'package:path/path.dart' as path; 23 import 'package:path/path.dart' as path;
24 24
25 /** 25 /**
26 * Information about a single plugin. 26 * Information about a single plugin.
27 */ 27 */
28 @visibleForTesting
29 class PluginInfo { 28 class PluginInfo {
30 /** 29 /**
31 * The path to the root directory of the definition of the plugin on disk (the 30 * The path to the root directory of the definition of the plugin on disk (the
32 * directory containing the 'pubspec.yaml' file and the 'bin' directory). 31 * directory containing the 'pubspec.yaml' file and the 'bin' directory).
33 */ 32 */
34 final String path; 33 final String path;
35 34
36 /** 35 /**
37 * The path to the 'plugin.dart' file that will be executed in an isolate. 36 * The path to the 'plugin.dart' file that will be executed in an isolate.
38 */ 37 */
(...skipping 27 matching lines...) Expand all
66 */ 65 */
67 PluginSession currentSession; 66 PluginSession currentSession;
68 67
69 /** 68 /**
70 * Initialize the newly created information about a plugin. 69 * Initialize the newly created information about a plugin.
71 */ 70 */
72 PluginInfo(this.path, this.executionPath, this.packagesPath, 71 PluginInfo(this.path, this.executionPath, this.packagesPath,
73 this.notificationManager, this.instrumentationService); 72 this.notificationManager, this.instrumentationService);
74 73
75 /** 74 /**
75 * Return the data known about this plugin.
76 */
77 PluginData get data =>
78 new PluginData(path, currentSession?.name, currentSession?.version);
79
80 /**
76 * Add the given [contextRoot] to the set of context roots being analyzed by 81 * Add the given [contextRoot] to the set of context roots being analyzed by
77 * this plugin. 82 * this plugin.
78 */ 83 */
79 void addContextRoot(analyzer.ContextRoot contextRoot) { 84 void addContextRoot(analyzer.ContextRoot contextRoot) {
80 if (contextRoots.add(contextRoot)) { 85 if (contextRoots.add(contextRoot)) {
81 _updatePluginRoots(); 86 _updatePluginRoots();
82 } 87 }
83 } 88 }
84 89
85 /** 90 /**
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 } 196 }
192 plugin.addContextRoot(contextRoot); 197 plugin.addContextRoot(contextRoot);
193 } 198 }
194 199
195 /** 200 /**
196 * Broadcast a request built from the given [params] to all of the plugins 201 * Broadcast a request built from the given [params] to all of the plugins
197 * that are currently associated with the given [contextRoot]. Return a list 202 * that are currently associated with the given [contextRoot]. Return a list
198 * containing futures that will complete when each of the plugins have sent a 203 * containing futures that will complete when each of the plugins have sent a
199 * response. 204 * response.
200 */ 205 */
201 List<Future<Response>> broadcast( 206 Map<PluginInfo, Future<Response>> broadcast(
202 analyzer.ContextRoot contextRoot, RequestParams params) { 207 analyzer.ContextRoot contextRoot, RequestParams params) {
203 List<PluginInfo> plugins = pluginsForContextRoot(contextRoot); 208 List<PluginInfo> plugins = pluginsForContextRoot(contextRoot);
204 return plugins 209 Map<PluginInfo, Future<Response>> responseMap =
205 .map((PluginInfo plugin) => plugin.currentSession?.sendRequest(params)) 210 <PluginInfo, Future<Response>>{};
206 .toList(); 211 for (PluginInfo plugin in plugins) {
212 responseMap[plugin] = plugin.currentSession?.sendRequest(params);
213 }
214 return responseMap;
207 } 215 }
208 216
209 /** 217 /**
210 * Return a list of all of the plugins that are currently associated with the 218 * Return a list of all of the plugins that are currently associated with the
211 * given [contextRoot]. 219 * given [contextRoot].
212 */ 220 */
213 @visibleForTesting 221 @visibleForTesting
214 List<PluginInfo> pluginsForContextRoot(analyzer.ContextRoot contextRoot) { 222 List<PluginInfo> pluginsForContextRoot(analyzer.ContextRoot contextRoot) {
215 List<PluginInfo> plugins = <PluginInfo>[]; 223 List<PluginInfo> plugins = <PluginInfo>[];
216 for (PluginInfo plugin in _pluginMap.values) { 224 for (PluginInfo plugin in _pluginMap.values) {
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 Future<Null> stop() { 502 Future<Null> stop() {
495 if (channel == null) { 503 if (channel == null) {
496 throw new StateError('Cannot stop a plugin that is not running.'); 504 throw new StateError('Cannot stop a plugin that is not running.');
497 } 505 }
498 // TODO(brianwilkerson) Ensure that the isolate is killed if it does not 506 // TODO(brianwilkerson) Ensure that the isolate is killed if it does not
499 // terminate normally. 507 // terminate normally.
500 sendRequest(new PluginShutdownParams()); 508 sendRequest(new PluginShutdownParams());
501 return pluginStoppedCompleter.future; 509 return pluginStoppedCompleter.future;
502 } 510 }
503 } 511 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/edit/edit_domain.dart ('k') | pkg/analysis_server/test/src/domain_abstract_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698