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

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

Issue 1119983004: Add an option to enable the new task model (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
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 library driver; 5 library driver;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:io'; 8 import 'dart:io';
9 import 'dart:math'; 9 import 'dart:math';
10 10
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 static const String CLIENT_VERSION = "client-version"; 197 static const String CLIENT_VERSION = "client-version";
198 198
199 /** 199 /**
200 * The name of the option used to enable incremental resolution of API 200 * The name of the option used to enable incremental resolution of API
201 * changes. 201 * changes.
202 */ 202 */
203 static const String ENABLE_INCREMENTAL_RESOLUTION_API = 203 static const String ENABLE_INCREMENTAL_RESOLUTION_API =
204 "enable-incremental-resolution-api"; 204 "enable-incremental-resolution-api";
205 205
206 /** 206 /**
207 * The name of the option used to enable instrumentation.
208 */
209 static const String ENABLE_INSTRUMENTATION_OPTION = "enable-instrumentation";
210
211 /**
212 * The name of the option used to enable the use of the new task model.
213 */
214 static const String ENABLE_NEW_TASK_MODEL = "enable-new-task-model";
215
216 /**
217 * The name of the option used to set the file read mode.
218 */
219 static const String FILE_READ_MODE = "file-read-mode";
220
221 /**
222 * The name of the option used to print usage information.
223 */
224 static const String HELP_OPTION = "help";
225
226 /**
207 * The name of the option used to describe the incremental resolution logger. 227 * The name of the option used to describe the incremental resolution logger.
208 */ 228 */
209 static const String INCREMENTAL_RESOLUTION_LOG = "incremental-resolution-log"; 229 static const String INCREMENTAL_RESOLUTION_LOG = "incremental-resolution-log";
210 230
211 /** 231 /**
212 * The name of the option used to enable validation of incremental resolution 232 * The name of the option used to enable validation of incremental resolution
213 * results. 233 * results.
214 */ 234 */
215 static const String INCREMENTAL_RESOLUTION_VALIDATION = 235 static const String INCREMENTAL_RESOLUTION_VALIDATION =
216 "incremental-resolution-validation"; 236 "incremental-resolution-validation";
217 237
218 /** 238 /**
219 * The name of the option used to cause instrumentation to also be written to 239 * The name of the option used to cause instrumentation to also be written to
220 * a local file. 240 * a local file.
221 */ 241 */
222 static const String INSTRUMENTATION_LOG_FILE = "instrumentation-log-file"; 242 static const String INSTRUMENTATION_LOG_FILE = "instrumentation-log-file";
223 243
224 /** 244 /**
225 * The name of the option used to enable instrumentation. 245 * The name of the option used to specify if [print] should print to the
246 * console instead of being intercepted.
226 */ 247 */
227 static const String ENABLE_INSTRUMENTATION_OPTION = "enable-instrumentation"; 248 static const String INTERNAL_DELAY_FREQUENCY = 'internal-delay-frequency';
228
229 /**
230 * The name of the option used to print usage information.
231 */
232 static const String HELP_OPTION = "help";
233 249
234 /** 250 /**
235 * The name of the option used to specify if [print] should print to the 251 * The name of the option used to specify if [print] should print to the
236 * console instead of being intercepted. 252 * console instead of being intercepted.
237 */ 253 */
238 static const String INTERNAL_PRINT_TO_CONSOLE = "internal-print-to-console"; 254 static const String INTERNAL_PRINT_TO_CONSOLE = "internal-print-to-console";
239 255
240 /** 256 /**
241 * The name of the option used to specify if [print] should print to the 257 * The name of the flag used to disable error notifications.
242 * console instead of being intercepted.
243 */ 258 */
244 static const String INTERNAL_DELAY_FREQUENCY = 'internal-delay-frequency'; 259 static const String NO_ERROR_NOTIFICATION = "no-error-notification";
260
261 /**
262 * The name of the flag used to disable the index.
263 */
264 static const String NO_INDEX = "no-index";
245 265
246 /** 266 /**
247 * The option for specifying the http diagnostic port. 267 * The option for specifying the http diagnostic port.
248 * If specified, users can review server status and performance information 268 * If specified, users can review server status and performance information
249 * by opening a web browser on http://localhost:<port> 269 * by opening a web browser on http://localhost:<port>
250 */ 270 */
251 static const String PORT_OPTION = "port"; 271 static const String PORT_OPTION = "port";
252 272
253 /** 273 /**
254 * The path to the SDK. 274 * The path to the SDK.
255 * TODO(paulberry): get rid of this once the 'analysis.updateSdks' request is 275 * TODO(paulberry): get rid of this once the 'analysis.updateSdks' request is
256 * operational. 276 * operational.
257 */ 277 */
258 static const String SDK_OPTION = "sdk"; 278 static const String SDK_OPTION = "sdk";
259 279
260 /** 280 /**
261 * The name of the flag used to disable error notifications.
262 */
263 static const String NO_ERROR_NOTIFICATION = "no-error-notification";
264
265 /**
266 * The name of the flag used to disable the index.
267 */
268 static const String NO_INDEX = "no-index";
269
270 /**
271 * The name of the option used to set the file read mode.
272 */
273 static const String FILE_READ_MODE = "file-read-mode";
274
275 /**
276 * The instrumentation server that is to be used by the analysis server. 281 * The instrumentation server that is to be used by the analysis server.
277 */ 282 */
278 InstrumentationServer instrumentationServer; 283 InstrumentationServer instrumentationServer;
279 284
280 /** 285 /**
281 * The plugins that are defined outside the analysis_server package. 286 * The plugins that are defined outside the analysis_server package.
282 */ 287 */
283 List<Plugin> _userDefinedPlugins = <Plugin>[]; 288 List<Plugin> _userDefinedPlugins = <Plugin>[];
284 289
285 SocketServer socketServer; 290 SocketServer socketServer;
(...skipping 15 matching lines...) Expand all
301 * Use the given command-line [arguments] to start this server. 306 * Use the given command-line [arguments] to start this server.
302 */ 307 */
303 void start(List<String> arguments) { 308 void start(List<String> arguments) {
304 CommandLineParser parser = _createArgParser(); 309 CommandLineParser parser = _createArgParser();
305 ArgResults results = parser.parse(arguments, <String, String>{}); 310 ArgResults results = parser.parse(arguments, <String, String>{});
306 if (results[HELP_OPTION]) { 311 if (results[HELP_OPTION]) {
307 _printUsage(parser.parser); 312 _printUsage(parser.parser);
308 return; 313 return;
309 } 314 }
310 315
311 // TODO(brianwilkerson) Enable this after it is possible for an
312 // instrumentation server to be provided.
313 // if (results[ENABLE_INSTRUMENTATION_OPTION]) {
314 // if (instrumentationServer == null) {
315 // print('Exiting server: enabled instrumentation without providing an in strumentation server');
316 // print('');
317 // _printUsage(parser);
318 // return;
319 // }
320 // } else {
321 // if (instrumentationServer != null) {
322 // print('Exiting server: providing an instrumentation server without ena bling instrumentation');
323 // print('');
324 // _printUsage(parser);
325 // return;
326 // }
327 // }
328
329 // TODO (danrubel) Remove this workaround 316 // TODO (danrubel) Remove this workaround
330 // once the underlying VM and dart:io issue has been fixed. 317 // once the underlying VM and dart:io issue has been fixed.
331 if (results[INTERNAL_DELAY_FREQUENCY] != null) { 318 if (results[INTERNAL_DELAY_FREQUENCY] != null) {
332 AnalysisServer.performOperationDelayFreqency = 319 AnalysisServer.performOperationDelayFreqency =
333 int.parse(results[INTERNAL_DELAY_FREQUENCY], onError: (_) => 0); 320 int.parse(results[INTERNAL_DELAY_FREQUENCY], onError: (_) => 0);
334 } 321 }
335 322
336 int port; 323 int port;
337 bool serve_http = false; 324 bool serve_http = false;
338 if (results[PORT_OPTION] != null) { 325 if (results[PORT_OPTION] != null) {
(...skipping 21 matching lines...) Expand all
360 _initIncrementalLogger(results[INCREMENTAL_RESOLUTION_LOG]); 347 _initIncrementalLogger(results[INCREMENTAL_RESOLUTION_LOG]);
361 348
362 DartSdk defaultSdk; 349 DartSdk defaultSdk;
363 if (results[SDK_OPTION] != null) { 350 if (results[SDK_OPTION] != null) {
364 defaultSdk = new DirectoryBasedDartSdk(new JavaFile(results[SDK_OPTION])); 351 defaultSdk = new DirectoryBasedDartSdk(new JavaFile(results[SDK_OPTION]));
365 } else { 352 } else {
366 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk, 353 // No path to the SDK provided; use DirectoryBasedDartSdk.defaultSdk,
367 // which will make a guess. 354 // which will make a guess.
368 defaultSdk = DirectoryBasedDartSdk.defaultSdk; 355 defaultSdk = DirectoryBasedDartSdk.defaultSdk;
369 } 356 }
370 357 //
358 // Initialize the instrumentation service.
359 //
371 if (instrumentationServer != null) { 360 if (instrumentationServer != null) {
372 String filePath = results[INSTRUMENTATION_LOG_FILE]; 361 String filePath = results[INSTRUMENTATION_LOG_FILE];
373 if (filePath != null) { 362 if (filePath != null) {
374 instrumentationServer = new MulticastInstrumentationServer( 363 instrumentationServer = new MulticastInstrumentationServer(
375 [instrumentationServer, new FileInstrumentationServer(filePath)]); 364 [instrumentationServer, new FileInstrumentationServer(filePath)]);
376 } 365 }
377 } 366 }
378 InstrumentationService service = 367 InstrumentationService service =
379 new InstrumentationService(instrumentationServer); 368 new InstrumentationService(instrumentationServer);
380 service.logVersion(_readUuid(service), results[CLIENT_ID], 369 service.logVersion(_readUuid(service), results[CLIENT_ID],
381 results[CLIENT_VERSION], AnalysisServer.VERSION, defaultSdk.sdkVersion); 370 results[CLIENT_VERSION], AnalysisServer.VERSION, defaultSdk.sdkVersion);
382 AnalysisEngine.instance.instrumentationService = service; 371 AnalysisEngine.instance.instrumentationService = service;
383 // 372 //
373 // Enable the new task model, if appropriate.
374 //
375 if (results[ENABLE_NEW_TASK_MODEL]) {
376 AnalysisEngine.instance.useTaskModel = true;
377 }
378 //
384 // Process all of the plugins so that extensions are registered. 379 // Process all of the plugins so that extensions are registered.
385 // 380 //
386 ServerPlugin serverPlugin = new ServerPlugin(); 381 ServerPlugin serverPlugin = new ServerPlugin();
387 List<Plugin> plugins = <Plugin>[]; 382 List<Plugin> plugins = <Plugin>[];
388 plugins.add(AnalysisEngine.instance.enginePlugin); 383 plugins.add(AnalysisEngine.instance.enginePlugin);
389 plugins.add(serverPlugin); 384 plugins.add(serverPlugin);
390 plugins.addAll(_userDefinedPlugins); 385 plugins.addAll(_userDefinedPlugins);
391 ExtensionManager manager = new ExtensionManager(); 386 ExtensionManager manager = new ExtensionManager();
392 manager.processPlugins(plugins); 387 manager.processPlugins(plugins);
393 388 //
389 // Create the sockets and start listening for requests.
390 //
394 socketServer = new SocketServer( 391 socketServer = new SocketServer(
395 analysisServerOptions, defaultSdk, service, serverPlugin); 392 analysisServerOptions, defaultSdk, service, serverPlugin);
396 httpServer = new HttpAnalysisServer(socketServer); 393 httpServer = new HttpAnalysisServer(socketServer);
397 stdioServer = new StdioAnalysisServer(socketServer); 394 stdioServer = new StdioAnalysisServer(socketServer);
398 socketServer.userDefinedPlugins = _userDefinedPlugins; 395 socketServer.userDefinedPlugins = _userDefinedPlugins;
399 396
400 if (serve_http) { 397 if (serve_http) {
401 httpServer.serveHttp(port); 398 httpServer.serveHttp(port);
402 } 399 }
403 400
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
452 help: "an identifier used to identify the client"); 449 help: "an identifier used to identify the client");
453 parser.addOption(CLIENT_VERSION, help: "the version of the client"); 450 parser.addOption(CLIENT_VERSION, help: "the version of the client");
454 parser.addFlag(ENABLE_INCREMENTAL_RESOLUTION_API, 451 parser.addFlag(ENABLE_INCREMENTAL_RESOLUTION_API,
455 help: "enable using incremental resolution for API changes", 452 help: "enable using incremental resolution for API changes",
456 defaultsTo: false, 453 defaultsTo: false,
457 negatable: false); 454 negatable: false);
458 parser.addFlag(ENABLE_INSTRUMENTATION_OPTION, 455 parser.addFlag(ENABLE_INSTRUMENTATION_OPTION,
459 help: "enable sending instrumentation information to a server", 456 help: "enable sending instrumentation information to a server",
460 defaultsTo: false, 457 defaultsTo: false,
461 negatable: false); 458 negatable: false);
459 parser.addFlag(ENABLE_NEW_TASK_MODEL,
460 help: "enable the use of the new task model",
461 defaultsTo: false,
462 hide: true,
463 negatable: false);
462 parser.addFlag(HELP_OPTION, 464 parser.addFlag(HELP_OPTION,
463 help: "print this help message without starting a server", 465 help: "print this help message without starting a server",
464 defaultsTo: false, 466 defaultsTo: false,
465 negatable: false); 467 negatable: false);
466 parser.addOption(INCREMENTAL_RESOLUTION_LOG, 468 parser.addOption(INCREMENTAL_RESOLUTION_LOG,
467 help: "the description of the incremental resolution log"); 469 help: "the description of the incremental resolution log");
468 parser.addFlag(INCREMENTAL_RESOLUTION_VALIDATION, 470 parser.addFlag(INCREMENTAL_RESOLUTION_VALIDATION,
469 help: "enable validation of incremental resolution results (slow)", 471 help: "enable validation of incremental resolution results (slow)",
470 defaultsTo: false, 472 defaultsTo: false,
471 negatable: false); 473 negatable: false);
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 uuidFile.parent.createSync(recursive: true); 537 uuidFile.parent.createSync(recursive: true);
536 uuidFile.writeAsStringSync(uuid); 538 uuidFile.writeAsStringSync(uuid);
537 } catch (exception, stackTrace) { 539 } catch (exception, stackTrace) {
538 service.logPriorityException(exception, stackTrace); 540 service.logPriorityException(exception, stackTrace);
539 // Slightly alter the uuid to indicate it was not persisted 541 // Slightly alter the uuid to indicate it was not persisted
540 uuid = 'temp-$uuid'; 542 uuid = 'temp-$uuid';
541 } 543 }
542 return uuid; 544 return uuid;
543 } 545 }
544 } 546 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698