sendRequest method
Sends a request to the LSP server and waits for a response. This is used for synchronous operations that require a reply from the server.
Implementation
@override
Future<Map<String, dynamic>> sendRequest({
required String method,
required Map<String, dynamic> params,
}) async {
final id = _nextId++;
final request = {
'jsonrpc': '2.0',
'id': id,
'method': method,
'params': params,
};
_channel.sink.add(jsonEncode(request));
return await _responseController.stream.firstWhere((response) {
return response['id'] == id;
}, orElse: () => throw TimeoutException('No response for request $id'));
}