From ef61f5fa01ea4ff32aa48d7e0e12677f07738f92 Mon Sep 17 00:00:00 2001 From: Roland Grunberg Date: Thu, 27 May 2021 16:37:46 -0400 Subject: [PATCH] Introduce syntaxServerExitsOnShutdown as an extended capability. - 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 syntaxServerExitsOnShutdown as true, the language server will exit immediately after the shutdown request Signed-off-by: Roland Grunberg --- .../core/internal/preferences/ClientPreferences.java | 4 ++++ .../internal/syntaxserver/SyntaxLanguageServer.java | 11 +++++++++++ 2 files changed, 15 insertions(+) diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/ClientPreferences.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/ClientPreferences.java index ae82d2329a..9d806a22ea 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/ClientPreferences.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/preferences/ClientPreferences.java @@ -263,6 +263,10 @@ public boolean isActionableRuntimeNotificationSupport() { return Boolean.parseBoolean(extendedClientCapabilities.getOrDefault("actionableRuntimeNotificationSupport", "false").toString()); } + public boolean isSyntaxServerExitsOnShutdown() { + return Boolean.parseBoolean(extendedClientCapabilities.getOrDefault("syntaxServerExitsOnShutdown", "false").toString()); + } + public boolean isGradleChecksumWrapperPromptSupport() { return Boolean.parseBoolean(extendedClientCapabilities.getOrDefault("gradleChecksumWrapperPromptSupport", "false").toString()); } diff --git a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/syntaxserver/SyntaxLanguageServer.java b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/syntaxserver/SyntaxLanguageServer.java index 90bfbfbd35..c28272da3f 100644 --- a/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/syntaxserver/SyntaxLanguageServer.java +++ b/org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/syntaxserver/SyntaxLanguageServer.java @@ -137,6 +137,17 @@ public CompletableFuture shutdown() { return computeAsync((monitor) -> { shutdownJob.schedule(); shutdownReceived = true; + if (preferenceManager.getClientPreferences().isSyntaxServerExitsOnShutdown()) { + exit(); + try { + /* + * Suppress annoying error message in client, by encouraging + * syntax server to exit before shutdown() can respond to client. + */ + Thread.sleep(1000); + } catch (InterruptedException e) { + } + } return new Object(); }); }