Skip to content

Commit b01ce30

Browse files
committed
Read the server logs in order to discover early startup log messages.
- Attach a platform log listener sooner (in bundle activation) - Cache status messages that arrive before client connection set up - Send cached / server log messages once client is connected Signed-off-by: Roland Grunberg <[email protected]>
1 parent 650d0d3 commit b01ce30

22 files changed

+524
-50
lines changed

org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/JavaClientConnection.java

-10
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
import java.util.concurrent.TimeUnit;
2121
import java.util.concurrent.TimeoutException;
2222

23-
import org.eclipse.jdt.ls.core.internal.handlers.LogHandler;
2423
import org.eclipse.jdt.ls.core.internal.lsp.ExecuteCommandProposedClient;
2524
import org.eclipse.lsp4j.ApplyWorkspaceEditParams;
2625
import org.eclipse.lsp4j.ApplyWorkspaceEditResponse;
@@ -76,13 +75,10 @@ public interface JavaLanguageClient extends LanguageClient, ExecuteCommandPropos
7675

7776
}
7877

79-
private final LogHandler logHandler;
8078
final JavaLanguageClient client;
8179

8280
public JavaClientConnection(JavaLanguageClient client) {
8381
this.client = client;
84-
logHandler = new LogHandler();
85-
logHandler.install(this);
8682
}
8783

8884
public Object executeClientCommand(Duration timeout, String id, Object... params) throws InterruptedException, ExecutionException, TimeoutException {
@@ -217,12 +213,6 @@ public CompletableFuture<Void> refreshInlayHints() {
217213
return this.client.refreshInlayHints();
218214
}
219215

220-
public void disconnect() {
221-
if (logHandler != null) {
222-
logHandler.uninstall();
223-
}
224-
}
225-
226216
public void telemetryEvent(Object object) {
227217
if (JavaLanguageServerPlugin.getPreferencesManager() != null
228218
&& JavaLanguageServerPlugin.getPreferencesManager().getPreferences().isTelemetryEnabled()) {

org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/JavaLanguageServerPlugin.java

+6
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.eclipse.jdt.ls.core.internal.corext.template.java.JavaLanguageServerTemplateStore;
5252
import org.eclipse.jdt.ls.core.internal.handlers.CompletionContributionService;
5353
import org.eclipse.jdt.ls.core.internal.handlers.JDTLanguageServer;
54+
import org.eclipse.jdt.ls.core.internal.handlers.LogHandler;
5455
import org.eclipse.jdt.ls.core.internal.managers.ContentProviderManager;
5556
import org.eclipse.jdt.ls.core.internal.managers.DigestStore;
5657
import org.eclipse.jdt.ls.core.internal.managers.ISourceDownloader;
@@ -127,6 +128,7 @@ public class JavaLanguageServerPlugin extends Plugin {
127128

128129
private ExecutorService executorService;
129130
private CompletionContributionService completionContributionService;
131+
private LogHandler logHandler;
130132

131133
public static LanguageServerApplication getLanguageServer() {
132134
return pluginInstance == null ? null : pluginInstance.languageServer;
@@ -147,6 +149,9 @@ public void start(BundleContext bundleContext) throws Exception {
147149
JavaLanguageServerPlugin.pluginInstance = this;
148150
setPreferenceNodeId();
149151

152+
logHandler = new LogHandler();
153+
logHandler.install();
154+
150155
if (JDTEnvironmentUtils.isSyntaxServer()) {
151156
disableServices();
152157
preferenceManager = new PreferenceManager();
@@ -353,6 +358,7 @@ private void startConnection() throws IOException {
353358
}
354359
protocol.connectClient(launcher.getRemoteProxy());
355360
launcher.startListening();
361+
logHandler.setClientConnection(pluginInstance.getClientConnection());
356362
}
357363

358364
/*

org.eclipse.jdt.ls.core/src/org/eclipse/jdt/ls/core/internal/LanguageServerApplication.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public Object start(IApplicationContext context) throws Exception {
5858
// Setting progressProvider is only allowed if the application is "owned" by the caller.
5959
// see Javadoc for setProgressProvider.
6060
// In case of JDT-LS integrated in Eclipse Workbench, the application is the workbench and this progressProvider
61-
// must not be overridden. In case of the LanguageServerApplication, we own it, so we can set.
61+
// must not be overridden. In case of the LanguageServerApplication, we own it, so we can set.
6262
Job.getJobManager().setProgressProvider(progressReporterManager);
6363
}
6464
}

0 commit comments

Comments
 (0)