| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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 server.operation; | 5 library server.operation; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart'; | 9 import 'package:analysis_server/src/protocol.dart'; |
| 10 import 'package:logging/logging.dart'; | 10 import 'package:logging/logging.dart'; |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 Stopwatch stopwatch = new Stopwatch(); | 80 Stopwatch stopwatch = new Stopwatch(); |
| 81 String originalId = json['id']; | 81 String originalId = json['id']; |
| 82 String method = json['method']; | 82 String method = json['method']; |
| 83 json['clientRequestTime'] = new DateTime.now().millisecondsSinceEpoch; | 83 json['clientRequestTime'] = new DateTime.now().millisecondsSinceEpoch; |
| 84 driver.logger.log(Level.FINE, 'Sending request: $method\n $json'); | 84 driver.logger.log(Level.FINE, 'Sending request: $method\n $json'); |
| 85 stopwatch.start(); | 85 stopwatch.start(); |
| 86 | 86 |
| 87 void recordResult(bool success, result) { | 87 void recordResult(bool success, result) { |
| 88 Duration elapsed = stopwatch.elapsed; | 88 Duration elapsed = stopwatch.elapsed; |
| 89 driver.results.record(method, elapsed, success: success); | 89 driver.results.record(method, elapsed, success: success); |
| 90 driver.logger.log( | 90 driver.logger |
| 91 Level.FINE, 'Response received: $method : $elapsed\n $result'); | 91 .log(Level.FINE, 'Response received: $method : $elapsed\n $result'); |
| 92 } | 92 } |
| 93 | 93 |
| 94 driver.send(method, json['params']).then((Map<String, dynamic> result) { | 94 driver.send(method, json['params']).then((Map<String, dynamic> result) { |
| 95 recordResult(true, result); | 95 recordResult(true, result); |
| 96 processResult(originalId, result, stopwatch); | 96 processResult(originalId, result, stopwatch); |
| 97 }).catchError((exception) { | 97 }).catchError((exception) { |
| 98 recordResult(false, exception); | 98 recordResult(false, exception); |
| 99 converter.processErrorResponse(originalId, exception); | 99 converter.processErrorResponse(originalId, exception); |
| 100 }); | 100 }); |
| 101 return null; | 101 return null; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 subscription.cancel(); | 226 subscription.cancel(); |
| 227 timer.cancel(); | 227 timer.cancel(); |
| 228 String message = 'gave up waiting for analysis to complete'; | 228 String message = 'gave up waiting for analysis to complete'; |
| 229 driver.logger.log(Level.WARNING, message); | 229 driver.logger.log(Level.WARNING, message); |
| 230 completer.completeError(message); | 230 completer.completeError(message); |
| 231 } | 231 } |
| 232 }); | 232 }); |
| 233 return completer.future; | 233 return completer.future; |
| 234 } | 234 } |
| 235 } | 235 } |
| OLD | NEW |