Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, 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 import 'dart:async'; | 5 import 'dart:async'; |
| 6 import 'dart:collection'; | 6 import 'dart:collection'; |
| 7 import 'dart:convert'; | 7 import 'dart:convert'; |
| 8 import 'dart:io'; | 8 import 'dart:io'; |
| 9 | 9 |
| 10 import 'package:analyzer_plugin/protocol/protocol_generated.dart'; | 10 import 'package:analyzer_plugin/protocol/protocol_generated.dart'; |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 254 */ | 254 */ |
| 255 String writeFile(String pathname, String contents) { | 255 String writeFile(String pathname, String contents) { |
| 256 new Directory(dirname(pathname)).createSync(recursive: true); | 256 new Directory(dirname(pathname)).createSync(recursive: true); |
| 257 File file = new File(pathname); | 257 File file = new File(pathname); |
| 258 file.writeAsStringSync(contents); | 258 file.writeAsStringSync(contents); |
| 259 return file.resolveSymbolicLinksSync(); | 259 return file.resolveSymbolicLinksSync(); |
| 260 } | 260 } |
| 261 } | 261 } |
| 262 | 262 |
| 263 /** | 263 /** |
| 264 * An error result from a server call. | |
|
Brian Wilkerson
2017/02/12 18:47:09
I was going to suggest changing "server" to "plugi
devoncarew
2017/02/12 19:22:47
Updated the dartdoc (call -> request).
I'm happy
| |
| 265 */ | |
| 266 class ServerErrorMessage { | |
| 267 final Map message; | |
| 268 | |
| 269 ServerErrorMessage(this.message); | |
| 270 | |
| 271 dynamic get error => message['error']; | |
| 272 } | |
| 273 | |
| 274 /** | |
| 264 * Wrapper class for Matcher which doesn't create the underlying Matcher object | 275 * Wrapper class for Matcher which doesn't create the underlying Matcher object |
| 265 * until it is needed. This is necessary in order to create matchers that can | 276 * until it is needed. This is necessary in order to create matchers that can |
| 266 * refer to themselves (so that recursive data structures can be represented). | 277 * refer to themselves (so that recursive data structures can be represented). |
| 267 */ | 278 */ |
| 268 class LazyMatcher implements Matcher { | 279 class LazyMatcher implements Matcher { |
| 269 /** | 280 /** |
| 270 * Callback that will be used to create the matcher the first time it is | 281 * Callback that will be used to create the matcher the first time it is |
| 271 * needed. | 282 * needed. |
| 272 */ | 283 */ |
| 273 final MatcherCreator _creator; | 284 final MatcherCreator _creator; |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 if (messageAsMap.containsKey('id')) { | 562 if (messageAsMap.containsKey('id')) { |
| 552 outOfTestExpect(messageAsMap['id'], isString); | 563 outOfTestExpect(messageAsMap['id'], isString); |
| 553 String id = message['id']; | 564 String id = message['id']; |
| 554 Completer completer = _pendingCommands[id]; | 565 Completer completer = _pendingCommands[id]; |
| 555 if (completer == null) { | 566 if (completer == null) { |
| 556 fail('Unexpected response from server: id=$id'); | 567 fail('Unexpected response from server: id=$id'); |
| 557 } else { | 568 } else { |
| 558 _pendingCommands.remove(id); | 569 _pendingCommands.remove(id); |
| 559 } | 570 } |
| 560 if (messageAsMap.containsKey('error')) { | 571 if (messageAsMap.containsKey('error')) { |
| 561 // TODO(paulberry): propagate the error info to the completer. | 572 completer.completeError(new ServerErrorMessage(messageAsMap)); |
| 562 completer.completeError(new UnimplementedError( | |
| 563 'Server responded with an error: ${JSON.encode(message)}')); | |
| 564 } else { | 573 } else { |
| 565 completer.complete(messageAsMap['result']); | 574 completer.complete(messageAsMap['result']); |
| 566 } | 575 } |
| 567 // Check that the message is well-formed. We do this after calling | 576 // Check that the message is well-formed. We do this after calling |
| 568 // completer.complete() or completer.completeError() so that we don't | 577 // completer.complete() or completer.completeError() so that we don't |
| 569 // stall the test in the event of an error. | 578 // stall the test in the event of an error. |
| 570 outOfTestExpect(message, isResponse); | 579 outOfTestExpect(message, isResponse); |
| 571 } else { | 580 } else { |
| 572 // Message is a notification. It should have an event and possibly | 581 // Message is a notification. It should have an event and possibly |
| 573 // params. | 582 // params. |
| (...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 941 void populateMismatches(item, List<MismatchDescriber> mismatches); | 950 void populateMismatches(item, List<MismatchDescriber> mismatches); |
| 942 | 951 |
| 943 /** | 952 /** |
| 944 * Create a [MismatchDescriber] describing a mismatch with a simple string. | 953 * Create a [MismatchDescriber] describing a mismatch with a simple string. |
| 945 */ | 954 */ |
| 946 MismatchDescriber simpleDescription(String description) => | 955 MismatchDescriber simpleDescription(String description) => |
| 947 (Description mismatchDescription) { | 956 (Description mismatchDescription) { |
| 948 mismatchDescription.add(description); | 957 mismatchDescription.add(description); |
| 949 }; | 958 }; |
| 950 } | 959 } |
| OLD | NEW |