Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for language server exit & shutdown. #44900

Merged
merged 4 commits into from
Jun 11, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ public AbstractLanguageServerClient(LanguageServerProtocol languageServerProtoco

public Task<Connection> ActivateAsync(CancellationToken token)
{
Contract.ThrowIfFalse(_languageServer == null, "This language server has already been initialized");
NTaylorMullen marked this conversation as resolved.
Show resolved Hide resolved

var (clientStream, serverStream) = FullDuplexStream.CreatePair();
_languageServer = new InProcLanguageServer(serverStream, serverStream, _languageServerProtocol, _workspace, _diagnosticService, clientName: _diagnosticsClientName);
return Task.FromResult(new Connection(clientStream, clientStream));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,31 @@ public async Task InitializedAsync()
}

[JsonRpcMethod(Methods.ShutdownName)]
public object? Shutdown(CancellationToken _) => null;
public Task ShutdownAsync(CancellationToken _)
{
_diagnosticService.DiagnosticsUpdated -= DiagnosticService_DiagnosticsUpdated;

return Task.CompletedTask;
}

[JsonRpcMethod(Methods.ExitName)]
public Task ExitAsync(CancellationToken _)
{
try
NTaylorMullen marked this conversation as resolved.
Show resolved Hide resolved
{
if (!_jsonRpc.IsDisposed)
{
_jsonRpc.Dispose();
NTaylorMullen marked this conversation as resolved.
Show resolved Hide resolved
}
}
catch (Exception)
{
// Swallow exceptions thrown by disposing our JsonRpc object. Disconnected events can potentially throw their own exceptions so
// we purposefully ignore all of those exceptions in an effort to shutdown gracefully.
}
NTaylorMullen marked this conversation as resolved.
Show resolved Hide resolved

return Task.CompletedTask;
}

[JsonRpcMethod(Methods.ExitName)]
NTaylorMullen marked this conversation as resolved.
Show resolved Hide resolved
public void Exit()
Expand Down