mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:29:47 +00:00
[analysis_server] Remove unused parameters and related TODOs
Change-Id: I5b3fac0efa23c9e535635651a8e8b09398770a40 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/313504 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
parent
21c18eb046
commit
4d34d7aa24
|
@ -95,20 +95,14 @@ class MockServerChannel implements ServerCommunicationChannel {
|
||||||
/// client, and return a future that will complete when a response associated
|
/// client, and return a future that will complete when a response associated
|
||||||
/// with the [request] has been received.
|
/// with the [request] has been received.
|
||||||
///
|
///
|
||||||
/// The value of the future will be the received response. If [throwOnError]
|
/// The value of the future will be the received response.
|
||||||
/// is `true` (the default) then the returned future will throw an exception
|
Future<Response> simulateRequestFromClient(Request request) {
|
||||||
/// if a server error is reported before the response has been received.
|
|
||||||
Future<Response> simulateRequestFromClient(Request request,
|
|
||||||
{bool throwOnError = true}) {
|
|
||||||
// TODO(brianwilkerson) Attempt to remove the `throwOnError` parameter and
|
|
||||||
// have the default behavior be the only behavior.
|
|
||||||
// No further requests should be sent after the connection is closed.
|
|
||||||
if (_closed) {
|
if (_closed) {
|
||||||
throw Exception('simulateRequestFromClient after connection closed');
|
throw Exception('simulateRequestFromClient after connection closed');
|
||||||
}
|
}
|
||||||
// Wrap send request in future to simulate WebSocket.
|
// Wrap send request in future to simulate WebSocket.
|
||||||
Future(() => requestController.add(request));
|
Future(() => requestController.add(request));
|
||||||
return waitForResponse(request, throwOnError: throwOnError);
|
return waitForResponse(request);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Send the given [response] to the server as if it had been sent from the
|
/// Send the given [response] to the server as if it had been sent from the
|
||||||
|
@ -124,28 +118,14 @@ class MockServerChannel implements ServerCommunicationChannel {
|
||||||
|
|
||||||
/// Return a future that will complete when a response associated with the
|
/// Return a future that will complete when a response associated with the
|
||||||
/// given [request] has been received. The value of the future will be the
|
/// given [request] has been received. The value of the future will be the
|
||||||
/// received response. If [throwOnError] is `true` (the default) then the
|
/// received response.
|
||||||
/// returned future will throw an exception if a server error is reported
|
|
||||||
/// before the response has been received.
|
|
||||||
///
|
///
|
||||||
/// Unlike [simulateRequestFromClient], this method assumes that the [request]
|
/// Unlike [simulateRequestFromClient], this method assumes that the [request]
|
||||||
/// has already been sent to the server.
|
/// has already been sent to the server.
|
||||||
Future<Response> waitForResponse(Request request,
|
Future<Response> waitForResponse(Request request) {
|
||||||
{bool throwOnError = true}) {
|
|
||||||
// TODO(brianwilkerson) Attempt to remove the `throwOnError` parameter and
|
|
||||||
// have the default behavior be the only behavior.
|
|
||||||
var id = request.id;
|
var id = request.id;
|
||||||
var response =
|
return responseController.stream
|
||||||
responseController.stream.firstWhere((response) => response.id == id);
|
.firstWhere((response) => response.id == id);
|
||||||
if (throwOnError) {
|
|
||||||
var completer = errorCompleter = Completer<Response>();
|
|
||||||
try {
|
|
||||||
return Future.any([response, completer.future]);
|
|
||||||
} finally {
|
|
||||||
errorCompleter = null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return response;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue