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

Side by Side Diff: pkg/analysis_server/lib/src/server/driver.dart

Issue 3004523003: Remove more references to the old plugin system (Closed)
Patch Set: Created 3 years, 4 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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:io'; 6 import 'dart:io';
7 import 'dart:math'; 7 import 'dart:math';
8 8
9 import 'package:analysis_server/src/analysis_server.dart'; 9 import 'package:analysis_server/src/analysis_server.dart';
10 import 'package:analysis_server/src/server/diagnostic_server.dart'; 10 import 'package:analysis_server/src/server/diagnostic_server.dart';
11 import 'package:analysis_server/src/server/http_server.dart'; 11 import 'package:analysis_server/src/server/http_server.dart';
12 import 'package:analysis_server/src/server/stdio_server.dart'; 12 import 'package:analysis_server/src/server/stdio_server.dart';
13 import 'package:analysis_server/src/socket_server.dart'; 13 import 'package:analysis_server/src/socket_server.dart';
14 import 'package:analysis_server/starter.dart'; 14 import 'package:analysis_server/starter.dart';
15 import 'package:analyzer/file_system/physical_file_system.dart'; 15 import 'package:analyzer/file_system/physical_file_system.dart';
16 import 'package:analyzer/instrumentation/file_instrumentation.dart'; 16 import 'package:analyzer/instrumentation/file_instrumentation.dart';
17 import 'package:analyzer/instrumentation/instrumentation.dart'; 17 import 'package:analyzer/instrumentation/instrumentation.dart';
18 import 'package:analyzer/plugin/resolver_provider.dart'; 18 import 'package:analyzer/plugin/resolver_provider.dart';
19 import 'package:analyzer/src/context/builder.dart'; 19 import 'package:analyzer/src/context/builder.dart';
20 import 'package:analyzer/src/dart/sdk/sdk.dart'; 20 import 'package:analyzer/src/dart/sdk/sdk.dart';
21 import 'package:analyzer/src/generated/engine.dart'; 21 import 'package:analyzer/src/generated/engine.dart';
22 import 'package:analyzer/src/generated/sdk.dart'; 22 import 'package:analyzer/src/generated/sdk.dart';
23 import 'package:args/args.dart'; 23 import 'package:args/args.dart';
24 import 'package:linter/src/rules.dart' as linter; 24 import 'package:linter/src/rules.dart' as linter;
25 import 'package:plugin/manager.dart'; 25 import 'package:plugin/manager.dart';
26 import 'package:plugin/plugin.dart';
27 import 'package:telemetry/crash_reporting.dart'; 26 import 'package:telemetry/crash_reporting.dart';
28 import 'package:telemetry/telemetry.dart' as telemetry; 27 import 'package:telemetry/telemetry.dart' as telemetry;
29 28
30 /// Commandline argument parser. (Copied from analyzer/lib/options.dart) 29 /// Commandline argument parser. (Copied from analyzer/lib/options.dart)
31 /// TODO(pquitslund): replaces with a simple [ArgParser] instance 30 /// TODO(pquitslund): replaces with a simple [ArgParser] instance
32 /// when the args package supports ignoring unrecognized 31 /// when the args package supports ignoring unrecognized
33 /// options/flags (https://github.com/dart-lang/args/issues/9). 32 /// options/flags (https://github.com/dart-lang/args/issues/9).
34 class CommandLineParser { 33 class CommandLineParser {
35 final List<String> _knownFlags; 34 final List<String> _knownFlags;
36 final bool _alwaysIgnoreUnrecognized; 35 final bool _alwaysIgnoreUnrecognized;
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
260 * resolved in some contexts. 259 * resolved in some contexts.
261 */ 260 */
262 ResolverProvider fileResolverProvider; 261 ResolverProvider fileResolverProvider;
263 262
264 /** 263 /**
265 * The package resolver provider used to override the way package URI's are 264 * The package resolver provider used to override the way package URI's are
266 * resolved in some contexts. 265 * resolved in some contexts.
267 */ 266 */
268 ResolverProvider packageResolverProvider; 267 ResolverProvider packageResolverProvider;
269 268
270 /**
271 * The plugins that are defined outside the analysis_server package.
272 */
273 List<Plugin> _userDefinedPlugins = <Plugin>[];
274
275 SocketServer socketServer; 269 SocketServer socketServer;
276 270
277 HttpAnalysisServer httpServer; 271 HttpAnalysisServer httpServer;
278 272
279 StdioAnalysisServer stdioServer; 273 StdioAnalysisServer stdioServer;
280 274
281 Driver(); 275 Driver();
282 276
283 /** 277 /**
284 * Set the [plugins] that are defined outside the analysis_server package.
285 */
286 void set userDefinedPlugins(List<Plugin> plugins) {
287 _userDefinedPlugins = plugins ?? <Plugin>[];
288 }
289
290 /**
291 * Use the given command-line [arguments] to start this server. 278 * Use the given command-line [arguments] to start this server.
292 * 279 *
293 * At least temporarily returns AnalysisServer so that consumers of the 280 * At least temporarily returns AnalysisServer so that consumers of the
294 * starter API can then use the server, this is done as a stopgap for the 281 * starter API can then use the server, this is done as a stopgap for the
295 * angular plugin until the official plugin API is finished. 282 * angular plugin until the official plugin API is finished.
296 */ 283 */
297 AnalysisServer start(List<String> arguments) { 284 AnalysisServer start(List<String> arguments) {
298 CommandLineParser parser = _createArgParser(); 285 CommandLineParser parser = _createArgParser();
299 ArgResults results = parser.parse(arguments, <String, String>{}); 286 ArgResults results = parser.parse(arguments, <String, String>{});
300 287
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 print(''); 335 print('');
349 _printUsage(parser.parser, analytics); 336 _printUsage(parser.parser, analytics);
350 exitCode = 1; 337 exitCode = 1;
351 return null; 338 return null;
352 } 339 }
353 } 340 }
354 341
355 // 342 //
356 // Process all of the plugins so that extensions are registered. 343 // Process all of the plugins so that extensions are registered.
357 // 344 //
358 List<Plugin> plugins = <Plugin>[];
359 plugins.addAll(AnalysisEngine.instance.requiredPlugins);
360 plugins.addAll(_userDefinedPlugins);
361 ExtensionManager manager = new ExtensionManager(); 345 ExtensionManager manager = new ExtensionManager();
362 manager.processPlugins(plugins); 346 manager.processPlugins(AnalysisEngine.instance.requiredPlugins);
363 linter.registerLintRules(); 347 linter.registerLintRules();
364 348
365 String defaultSdkPath; 349 String defaultSdkPath;
366 if (results[SDK_OPTION] != null) { 350 if (results[SDK_OPTION] != null) {
367 defaultSdkPath = results[SDK_OPTION]; 351 defaultSdkPath = results[SDK_OPTION];
368 } else { 352 } else {
369 // No path to the SDK was provided. 353 // No path to the SDK was provided.
370 // Use DirectoryBasedDartSdk.defaultSdkDirectory, which will make a guess. 354 // Use DirectoryBasedDartSdk.defaultSdkDirectory, which will make a guess.
371 defaultSdkPath = FolderBasedDartSdk 355 defaultSdkPath = FolderBasedDartSdk
372 .defaultSdkDirectory(PhysicalResourceProvider.INSTANCE) 356 .defaultSdkDirectory(PhysicalResourceProvider.INSTANCE)
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
410 socketServer = new SocketServer( 394 socketServer = new SocketServer(
411 analysisServerOptions, 395 analysisServerOptions,
412 new DartSdkManager(defaultSdkPath, true), 396 new DartSdkManager(defaultSdkPath, true),
413 defaultSdk, 397 defaultSdk,
414 instrumentationService, 398 instrumentationService,
415 diagnosticServer, 399 diagnosticServer,
416 fileResolverProvider, 400 fileResolverProvider,
417 packageResolverProvider); 401 packageResolverProvider);
418 httpServer = new HttpAnalysisServer(socketServer); 402 httpServer = new HttpAnalysisServer(socketServer);
419 stdioServer = new StdioAnalysisServer(socketServer); 403 stdioServer = new StdioAnalysisServer(socketServer);
420 socketServer.userDefinedPlugins = _userDefinedPlugins;
421 404
422 diagnosticServer.httpServer = httpServer; 405 diagnosticServer.httpServer = httpServer;
423 if (serve_http) { 406 if (serve_http) {
424 diagnosticServer.startOnPort(port); 407 diagnosticServer.startOnPort(port);
425 } 408 }
426 409
427 _captureExceptions(instrumentationService, () { 410 _captureExceptions(instrumentationService, () {
428 stdioServer.serveStdio().then((_) async { 411 stdioServer.serveStdio().then((_) async {
429 if (serve_http) { 412 if (serve_http) {
430 httpServer.close(); 413 httpServer.close();
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
610 593
611 _DiagnosticServerImpl(); 594 _DiagnosticServerImpl();
612 595
613 @override 596 @override
614 Future<int> getServerPort() => httpServer.serveHttp(); 597 Future<int> getServerPort() => httpServer.serveHttp();
615 598
616 Future startOnPort(int port) { 599 Future startOnPort(int port) {
617 return httpServer.serveHttp(port); 600 return httpServer.serveHttp(port);
618 } 601 }
619 } 602 }
OLDNEW
« no previous file with comments | « pkg/analysis_server/lib/src/analysis_server.dart ('k') | pkg/analysis_server/lib/src/socket_server.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698