Skip to content

Commit

Permalink
Add support for exiting immediately from a shutdown() request.
Browse files Browse the repository at this point in the history
- In languageclient 7.x, the client fails to send the necessary exit()
  once a shutdown() response is received from the language server
- When client defines shouldLanguageServerExitOnShutdown as true, the
  language server will exit immediately after the shutdown request

Signed-off-by: Roland Grunberg <[email protected]>
  • Loading branch information
rgrunber committed Jun 24, 2021
1 parent 36bab63 commit 211593c
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,9 @@ private synchronized void updateSettings(Object initOptions, boolean initLogs) {
@Override
public CompletableFuture<Object> shutdown() {
xmlLanguageService.dispose();
if (capabilityManager.getClientCapabilities().getExtendedCapabilities().shouldLanguageServerExitOnShutdown()) {
delayer.schedule(() -> exit(0) , 1, TimeUnit.SECONDS);
}
return computeAsync(cc -> new Object());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ public class ExtendedClientCapabilities {

private boolean openSettingsCommandSupport;

private boolean shouldLanguageServerExitOnShutdown;

public ExtendedCodeLensCapabilities getCodeLens() {
return codeLens;
}
Expand Down Expand Up @@ -75,4 +77,24 @@ public void setOpenSettingsCommandSupport(boolean openSettingsCommandSupport) {
this.openSettingsCommandSupport = openSettingsCommandSupport;
}

/**
* Sets the boolean permitting language server to exit on client
* shutdown() request, without waiting for client to call exit()
*
* @param shouldLanguageServerExitOnShutdown
*/
public void setShouldLanguageServerExitOnShutdown(boolean shouldLanguageServerExitOnShutdown) {
this.shouldLanguageServerExitOnShutdown = shouldLanguageServerExitOnShutdown;
}

/**
* Returns true if the client should exit on shutdown() request and
* avoid waiting for an exit() request
*
* @return true if the language server should exit on shutdown() request
*/
public boolean shouldLanguageServerExitOnShutdown() {
return shouldLanguageServerExitOnShutdown;
}

}

0 comments on commit 211593c

Please sign in to comment.