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

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

Issue 2836953002: Minor clean-up and bug fix (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 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;
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 this.notificationManager, this.instrumentationService); 205 this.notificationManager, this.instrumentationService);
206 206
207 /** 207 /**
208 * Add the plugin with the given [path] to the list of plugins that should be 208 * Add the plugin with the given [path] to the list of plugins that should be
209 * used when analyzing code for the given [contextRoot]. If the plugin had not 209 * used when analyzing code for the given [contextRoot]. If the plugin had not
210 * yet been started, then it will be started by this method. 210 * yet been started, then it will be started by this method.
211 */ 211 */
212 Future<Null> addPluginToContextRoot( 212 Future<Null> addPluginToContextRoot(
213 analyzer.ContextRoot contextRoot, String path) async { 213 analyzer.ContextRoot contextRoot, String path) async {
214 PluginInfo plugin = _pluginMap[path]; 214 PluginInfo plugin = _pluginMap[path];
215 bool isNew = false; 215 bool isNew = plugin == null;
216 if (plugin == null) { 216 if (isNew) {
217 isNew = true;
218 List<String> pluginPaths = _pathsFor(path); 217 List<String> pluginPaths = _pathsFor(path);
218 if (pluginPaths == null) {
219 return;
220 }
219 plugin = new PluginInfo(path, pluginPaths[0], pluginPaths[1], 221 plugin = new PluginInfo(path, pluginPaths[0], pluginPaths[1],
220 notificationManager, instrumentationService); 222 notificationManager, instrumentationService);
221 _pluginMap[path] = plugin; 223 _pluginMap[path] = plugin;
222 if (pluginPaths[0] != null) { 224 if (pluginPaths[0] != null) {
223 PluginSession session = await plugin.start(byteStorePath); 225 PluginSession session = await plugin.start(byteStorePath);
224 session.onDone.then((_) { 226 session.onDone.then((_) {
225 _pluginMap.remove(path); 227 _pluginMap.remove(path);
226 }); 228 });
227 } 229 }
228 } 230 }
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 if (!pluginFile.exists) { 382 if (!pluginFile.exists) {
381 return null; 383 return null;
382 } 384 }
383 File packagesFile = pluginFolder.getChildAssumingFile('.packages'); 385 File packagesFile = pluginFolder.getChildAssumingFile('.packages');
384 if (!packagesFile.exists) { 386 if (!packagesFile.exists) {
385 if (runPub) { 387 if (runPub) {
386 // TODO(brianwilkerson) Run pub in the pluginFolder. 388 // TODO(brianwilkerson) Run pub in the pluginFolder.
387 if (!packagesFile.exists) { 389 if (!packagesFile.exists) {
388 packagesFile = null; 390 packagesFile = null;
389 } 391 }
392 } else {
393 packagesFile = null;
390 } 394 }
391 packagesFile = null;
392 } 395 }
393 return <String>[pluginFile.path, packagesFile?.path]; 396 return <String>[pluginFile.path, packagesFile?.path];
394 } 397 }
395 398
396 Folder pluginFolder = resourceProvider.getFolder(pluginPath); 399 Folder pluginFolder = resourceProvider.getFolder(pluginPath);
397 if (!needToCopy(pluginFolder)) { 400 if (!needToCopy(pluginFolder)) {
398 return computePaths(pluginFolder); 401 return computePaths(pluginFolder);
399 } 402 }
400 // 403 //
401 // Copy the plugin directory to a unique subdirectory of the plugin 404 // Copy the plugin directory to a unique subdirectory of the plugin
(...skipping 198 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 Future<Null> stop() { 603 Future<Null> stop() {
601 if (channel == null) { 604 if (channel == null) {
602 throw new StateError('Cannot stop a plugin that is not running.'); 605 throw new StateError('Cannot stop a plugin that is not running.');
603 } 606 }
604 // TODO(brianwilkerson) Ensure that the isolate is killed if it does not 607 // TODO(brianwilkerson) Ensure that the isolate is killed if it does not
605 // terminate normally. 608 // terminate normally.
606 sendRequest(new PluginShutdownParams()); 609 sendRequest(new PluginShutdownParams());
607 return pluginStoppedCompleter.future; 610 return pluginStoppedCompleter.future;
608 } 611 }
609 } 612 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698