| 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'; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 245 * Execute the given [callback] within a zone that will capture any unhandled | 245 * Execute the given [callback] within a zone that will capture any unhandled |
| 246 * exceptions and both report them to the client and send them to the given | 246 * exceptions and both report them to the client and send them to the given |
| 247 * instrumentation [service]. If a [print] function is provided, then also | 247 * instrumentation [service]. If a [print] function is provided, then also |
| 248 * capture any data printed by the callback and redirect it to the function. | 248 * capture any data printed by the callback and redirect it to the function. |
| 249 */ | 249 */ |
| 250 dynamic _captureExceptions(InstrumentationService service, dynamic callback(), | 250 dynamic _captureExceptions(InstrumentationService service, dynamic callback(), |
| 251 {void print(String line)}) { | 251 {void print(String line)}) { |
| 252 Function errorFunction = | 252 Function errorFunction = |
| 253 (Zone self, ZoneDelegate parent, Zone zone, dynamic exception, | 253 (Zone self, ZoneDelegate parent, Zone zone, dynamic exception, |
| 254 StackTrace stackTrace) { | 254 StackTrace stackTrace) { |
| 255 service.logException(exception, stackTrace); | 255 service.logPriorityException(exception, stackTrace); |
| 256 socketServer.analysisServer.reportException(exception, stackTrace); | 256 socketServer.analysisServer.reportException(exception, stackTrace); |
| 257 throw exception; | 257 throw exception; |
| 258 }; | 258 }; |
| 259 Function printFunction = print == null ? | 259 Function printFunction = print == null ? |
| 260 null : | 260 null : |
| 261 (Zone self, ZoneDelegate parent, Zone zone, String line) { | 261 (Zone self, ZoneDelegate parent, Zone zone, String line) { |
| 262 // Note: we don't pass the line on to stdout, because that is reserved | 262 // Note: we don't pass the line on to stdout, because that is reserved |
| 263 // for communication to the client. | 263 // for communication to the client. |
| 264 print(line); | 264 print(line); |
| 265 }; | 265 }; |
| 266 ZoneSpecification zoneSpecification = new ZoneSpecification( | 266 ZoneSpecification zoneSpecification = new ZoneSpecification( |
| 267 handleUncaughtError: errorFunction, | 267 handleUncaughtError: errorFunction, |
| 268 print: printFunction); | 268 print: printFunction); |
| 269 return runZoned(callback, zoneSpecification: zoneSpecification); | 269 return runZoned(callback, zoneSpecification: zoneSpecification); |
| 270 } | 270 } |
| 271 | 271 |
| 272 /** | 272 /** |
| 273 * Print information about how to use the server. | 273 * Print information about how to use the server. |
| 274 */ | 274 */ |
| 275 void _printUsage(ArgParser parser) { | 275 void _printUsage(ArgParser parser) { |
| 276 print('Usage: $BINARY_NAME [flags]'); | 276 print('Usage: $BINARY_NAME [flags]'); |
| 277 print(''); | 277 print(''); |
| 278 print('Supported flags are:'); | 278 print('Supported flags are:'); |
| 279 print(parser.usage); | 279 print(parser.usage); |
| 280 } | 280 } |
| 281 } | 281 } |
| OLD | NEW |