| 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/src/analysis_server.dart'; | 11 import 'package:analysis_server/src/analysis_server.dart'; |
| 12 import 'package:analysis_server/src/socket_server.dart'; | 12 import 'package:analysis_server/src/socket_server.dart'; |
| 13 import 'package:analysis_server/stdio_server.dart'; | 13 import 'package:analysis_server/stdio_server.dart'; |
| 14 import 'package:analyzer/instrumentation/instrumentation.dart'; |
| 14 import 'package:analyzer/src/generated/incremental_logger.dart'; | 15 import 'package:analyzer/src/generated/incremental_logger.dart'; |
| 15 import 'package:analyzer/src/generated/java_io.dart'; | 16 import 'package:analyzer/src/generated/java_io.dart'; |
| 16 import 'package:analyzer/src/generated/sdk.dart'; | 17 import 'package:analyzer/src/generated/sdk.dart'; |
| 17 import 'package:analyzer/src/generated/sdk_io.dart'; | 18 import 'package:analyzer/src/generated/sdk_io.dart'; |
| 18 import 'package:args/args.dart'; | 19 import 'package:args/args.dart'; |
| 19 | 20 |
| 20 | 21 |
| 21 /** | 22 /** |
| 22 * Initializes incremental logger. | 23 * Initializes incremental logger. |
| 23 * | 24 * |
| (...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 * TODO(paulberry): get rid of this once the 'analysis.updateSdks' request is | 108 * TODO(paulberry): get rid of this once the 'analysis.updateSdks' request is |
| 108 * operational. | 109 * operational. |
| 109 */ | 110 */ |
| 110 static const String SDK_OPTION = "sdk"; | 111 static const String SDK_OPTION = "sdk"; |
| 111 | 112 |
| 112 /** | 113 /** |
| 113 * The name of the option used to disable error notifications. | 114 * The name of the option used to disable error notifications. |
| 114 */ | 115 */ |
| 115 static const String NO_ERROR_NOTIFICATION = "no-error-notification"; | 116 static const String NO_ERROR_NOTIFICATION = "no-error-notification"; |
| 116 | 117 |
| 118 /** |
| 119 * The instrumentation server that is to be used by the analysis server. |
| 120 */ |
| 121 InstrumentationServer instrumentationServer; |
| 122 |
| 117 SocketServer socketServer; | 123 SocketServer socketServer; |
| 118 | 124 |
| 119 HttpAnalysisServer httpServer; | 125 HttpAnalysisServer httpServer; |
| 120 | 126 |
| 121 StdioAnalysisServer stdioServer; | 127 StdioAnalysisServer stdioServer; |
| 122 | 128 |
| 123 Driver(); | 129 Driver(); |
| 124 /** | 130 /** |
| 125 * Use the given command-line arguments to start this server. | 131 * Use the given command-line arguments to start this server. |
| 126 */ | 132 */ |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 help: | 172 help: |
| 167 "disable sending all analysis error notifications to the server (not
yet implemented)", | 173 "disable sending all analysis error notifications to the server (not
yet implemented)", |
| 168 defaultsTo: false, | 174 defaultsTo: false, |
| 169 negatable: false); | 175 negatable: false); |
| 170 | 176 |
| 171 ArgResults results = parser.parse(args); | 177 ArgResults results = parser.parse(args); |
| 172 if (results[HELP_OPTION]) { | 178 if (results[HELP_OPTION]) { |
| 173 _printUsage(parser); | 179 _printUsage(parser); |
| 174 return; | 180 return; |
| 175 } | 181 } |
| 176 if (results[ENABLE_INSTRUMENTATION_OPTION]) { | 182 |
| 177 if (results[INSTRUMENTATION_LOG_FILE_OPTION] != null) { | 183 // TODO(brianwilkerson) Enable this after it is possible for an |
| 178 // TODO(brianwilkerson) Initialize the instrumentation system with | 184 // instrumentation server to be provided. |
| 179 // logging. | 185 // if (results[ENABLE_INSTRUMENTATION_OPTION]) { |
| 180 } else { | 186 //// if (results[INSTRUMENTATION_LOG_FILE_OPTION] != null) { |
| 181 // TODO(brianwilkerson) Initialize the instrumentation system without | 187 //// // TODO(brianwilkerson) Initialize the instrumentation server with |
| 182 // logging. | 188 //// // logging. |
| 183 } | 189 //// } else { |
| 184 } | 190 //// // TODO(brianwilkerson) Initialize the instrumentation server withou
t |
| 191 //// // logging. |
| 192 //// } |
| 193 // if (instrumentationServer == null) { |
| 194 // print('Exiting server: enabled instrumentation without providing an in
strumentation server'); |
| 195 // print(''); |
| 196 // _printUsage(parser); |
| 197 // return; |
| 198 // } |
| 199 // } else { |
| 200 // if (instrumentationServer != null) { |
| 201 // print('Exiting server: providing an instrumentation server without ena
bling instrumentation'); |
| 202 // print(''); |
| 203 // _printUsage(parser); |
| 204 // return; |
| 205 // } |
| 206 // } |
| 185 | 207 |
| 186 int port; | 208 int port; |
| 187 bool serve_http = false; | 209 bool serve_http = false; |
| 188 if (results[PORT_OPTION] != null) { | 210 if (results[PORT_OPTION] != null) { |
| 189 serve_http = true; | 211 serve_http = true; |
| 190 try { | 212 try { |
| 191 port = int.parse(results[PORT_OPTION]); | 213 port = int.parse(results[PORT_OPTION]); |
| 192 } on FormatException { | 214 } on FormatException { |
| 193 print('Invalid port number: ${results[PORT_OPTION]}'); | 215 print('Invalid port number: ${results[PORT_OPTION]}'); |
| 194 print(''); | 216 print(''); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 208 | 230 |
| 209 DartSdk defaultSdk; | 231 DartSdk defaultSdk; |
| 210 if (results[SDK_OPTION] != null) { | 232 if (results[SDK_OPTION] != null) { |
| 211 defaultSdk = new DirectoryBasedDartSdk(new JavaFile(results[SDK_OPTION])); | 233 defaultSdk = new DirectoryBasedDartSdk(new JavaFile(results[SDK_OPTION])); |
| 212 } else { | 234 } else { |
| 213 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk, | 235 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk, |
| 214 // which will make a guess. | 236 // which will make a guess. |
| 215 defaultSdk = DirectoryBasedDartSdk.defaultSdk; | 237 defaultSdk = DirectoryBasedDartSdk.defaultSdk; |
| 216 } | 238 } |
| 217 | 239 |
| 218 socketServer = new SocketServer(analysisServerOptions, defaultSdk); | 240 socketServer = new SocketServer( |
| 241 analysisServerOptions, |
| 242 defaultSdk, |
| 243 instrumentationServer == null ? |
| 244 new NullInstrumentationServer() : |
| 245 instrumentationServer); |
| 219 httpServer = new HttpAnalysisServer(socketServer); | 246 httpServer = new HttpAnalysisServer(socketServer); |
| 220 stdioServer = new StdioAnalysisServer(socketServer); | 247 stdioServer = new StdioAnalysisServer(socketServer); |
| 221 | 248 |
| 222 if (serve_http) { | 249 if (serve_http) { |
| 223 httpServer.serveHttp(port); | 250 httpServer.serveHttp(port); |
| 224 } | 251 } |
| 225 | 252 |
| 226 if (results[INTERNAL_PRINT_TO_CONSOLE]) { | 253 if (results[INTERNAL_PRINT_TO_CONSOLE]) { |
| 227 stdioServer.serveStdio().then((_) { | 254 stdioServer.serveStdio().then((_) { |
| 228 if (serve_http) { | 255 if (serve_http) { |
| (...skipping 30 matching lines...) Expand all Loading... |
| 259 /** | 286 /** |
| 260 * Print information about how to use the server. | 287 * Print information about how to use the server. |
| 261 */ | 288 */ |
| 262 void _printUsage(ArgParser parser) { | 289 void _printUsage(ArgParser parser) { |
| 263 print('Usage: $BINARY_NAME [flags]'); | 290 print('Usage: $BINARY_NAME [flags]'); |
| 264 print(''); | 291 print(''); |
| 265 print('Supported flags are:'); | 292 print('Supported flags are:'); |
| 266 print(parser.usage); | 293 print(parser.usage); |
| 267 } | 294 } |
| 268 } | 295 } |
| OLD | NEW |