| OLD | NEW |
| 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 library driver; | 5 library driver; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:analysis_server/http_server.dart'; | 10 import 'package:analysis_server/http_server.dart'; |
| 11 import 'package:analysis_server/plugin/plugin.dart'; |
| 11 import 'package:analysis_server/src/analysis_server.dart'; | 12 import 'package:analysis_server/src/analysis_server.dart'; |
| 13 import 'package:analysis_server/src/plugin/plugin_impl.dart'; |
| 14 import 'package:analysis_server/src/plugin/server_plugin.dart'; |
| 12 import 'package:analysis_server/src/socket_server.dart'; | 15 import 'package:analysis_server/src/socket_server.dart'; |
| 13 import 'package:analysis_server/stdio_server.dart'; | 16 import 'package:analysis_server/stdio_server.dart'; |
| 14 import 'package:analyzer/instrumentation/instrumentation.dart'; | 17 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 15 import 'package:analyzer/src/generated/engine.dart'; | 18 import 'package:analyzer/src/generated/engine.dart'; |
| 16 import 'package:analyzer/src/generated/incremental_logger.dart'; | 19 import 'package:analyzer/src/generated/incremental_logger.dart'; |
| 17 import 'package:analyzer/src/generated/java_io.dart'; | 20 import 'package:analyzer/src/generated/java_io.dart'; |
| 18 import 'package:analyzer/src/generated/sdk.dart'; | 21 import 'package:analyzer/src/generated/sdk.dart'; |
| 19 import 'package:analyzer/src/generated/sdk_io.dart'; | 22 import 'package:analyzer/src/generated/sdk_io.dart'; |
| 20 import 'package:args/args.dart'; | 23 import 'package:args/args.dart'; |
| 21 | 24 |
| (...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 113 /** | 116 /** |
| 114 * The name of the option used to disable error notifications. | 117 * The name of the option used to disable error notifications. |
| 115 */ | 118 */ |
| 116 static const String NO_ERROR_NOTIFICATION = "no-error-notification"; | 119 static const String NO_ERROR_NOTIFICATION = "no-error-notification"; |
| 117 | 120 |
| 118 /** | 121 /** |
| 119 * The instrumentation server that is to be used by the analysis server. | 122 * The instrumentation server that is to be used by the analysis server. |
| 120 */ | 123 */ |
| 121 InstrumentationServer instrumentationServer; | 124 InstrumentationServer instrumentationServer; |
| 122 | 125 |
| 126 /** |
| 127 * The plugins that are defined outside the analysis_server package. |
| 128 */ |
| 129 List<Plugin> _userDefinedPlugins = <Plugin>[]; |
| 130 |
| 123 SocketServer socketServer; | 131 SocketServer socketServer; |
| 124 | 132 |
| 125 HttpAnalysisServer httpServer; | 133 HttpAnalysisServer httpServer; |
| 126 | 134 |
| 127 StdioAnalysisServer stdioServer; | 135 StdioAnalysisServer stdioServer; |
| 128 | 136 |
| 129 Driver(); | 137 Driver(); |
| 138 |
| 139 /** |
| 140 * Set the [plugins] that are defined outside the analysis_server package. |
| 141 */ |
| 142 void set userDefinedPlugins(List<Plugin> plugins) { |
| 143 _userDefinedPlugins = plugins == null ? <Plugin>[] : plugins; |
| 144 } |
| 145 |
| 130 /** | 146 /** |
| 131 * Use the given command-line arguments to start this server. | 147 * Use the given command-line arguments to start this server. |
| 132 */ | 148 */ |
| 133 void start(List<String> args) { | 149 void start(List<String> args) { |
| 134 ArgParser parser = new ArgParser(); | 150 ArgParser parser = new ArgParser(); |
| 135 parser.addOption( | 151 parser.addOption( |
| 136 CLIENT_ID, | 152 CLIENT_ID, |
| 137 help: "an identifier used to identify the client"); | 153 help: "an identifier used to identify the client"); |
| 138 parser.addFlag( | 154 parser.addFlag( |
| 139 ENABLE_INCREMENTAL_RESOLUTION_API, | 155 ENABLE_INCREMENTAL_RESOLUTION_API, |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 227 } else { | 243 } else { |
| 228 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk, | 244 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk, |
| 229 // which will make a guess. | 245 // which will make a guess. |
| 230 defaultSdk = DirectoryBasedDartSdk.defaultSdk; | 246 defaultSdk = DirectoryBasedDartSdk.defaultSdk; |
| 231 } | 247 } |
| 232 | 248 |
| 233 InstrumentationService service = | 249 InstrumentationService service = |
| 234 new InstrumentationService(instrumentationServer); | 250 new InstrumentationService(instrumentationServer); |
| 235 // service.logVersion(results[CLIENT_ID], defaultSdk.sdkVersion); | 251 // service.logVersion(results[CLIENT_ID], defaultSdk.sdkVersion); |
| 236 AnalysisEngine.instance.instrumentationService = service; | 252 AnalysisEngine.instance.instrumentationService = service; |
| 253 // |
| 254 // Process all of the plugins so that extensions are registered. |
| 255 // |
| 256 ServerPlugin serverPlugin = new ServerPlugin(); |
| 257 List<Plugin> plugins = <Plugin>[]; |
| 258 plugins.add(serverPlugin); |
| 259 plugins.addAll(_userDefinedPlugins); |
| 260 ExtensionManager manager = new ExtensionManager(); |
| 261 manager.processPlugins(plugins); |
| 237 | 262 |
| 238 socketServer = new SocketServer(analysisServerOptions, defaultSdk, service); | 263 socketServer = |
| 264 new SocketServer(analysisServerOptions, defaultSdk, service, serverPlugi
n); |
| 239 httpServer = new HttpAnalysisServer(socketServer); | 265 httpServer = new HttpAnalysisServer(socketServer); |
| 240 stdioServer = new StdioAnalysisServer(socketServer); | 266 stdioServer = new StdioAnalysisServer(socketServer); |
| 241 | 267 |
| 242 if (serve_http) { | 268 if (serve_http) { |
| 243 httpServer.serveHttp(port); | 269 httpServer.serveHttp(port); |
| 244 } | 270 } |
| 245 | 271 |
| 246 _captureExceptions(service, () { | 272 _captureExceptions(service, () { |
| 247 stdioServer.serveStdio().then((_) { | 273 stdioServer.serveStdio().then((_) { |
| 248 if (serve_http) { | 274 if (serve_http) { |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 /** | 312 /** |
| 287 * Print information about how to use the server. | 313 * Print information about how to use the server. |
| 288 */ | 314 */ |
| 289 void _printUsage(ArgParser parser) { | 315 void _printUsage(ArgParser parser) { |
| 290 print('Usage: $BINARY_NAME [flags]'); | 316 print('Usage: $BINARY_NAME [flags]'); |
| 291 print(''); | 317 print(''); |
| 292 print('Supported flags are:'); | 318 print('Supported flags are:'); |
| 293 print(parser.usage); | 319 print(parser.usage); |
| 294 } | 320 } |
| 295 } | 321 } |
| OLD | NEW |