shutdown method
Graceful shutdown: shutdown request, exit notification, then wait
briefly for the process to leave before killing it (omp's shutdown
path). Always safe to call; errors during shutdown are swallowed.
Implementation
Future<void> shutdown() async {
if (status == LspClientStatus.closed) {
transport.kill();
_teardown('shutdown');
return;
}
try {
await request('shutdown', null, timeout: _shutdownTimeout);
} on Object {
// A wedged server must not block teardown.
}
notify('exit', null);
status = LspClientStatus.closed;
try {
await transport.exitCode.timeout(_exitTimeout);
} on Object {
transport.kill();
}
await _subscription?.cancel();
await _diagnosticsController.close();
_teardown('shutdown');
}