Skip to content

Commit fe5ef2e

Browse files
authored
fix: Do not activate the Java Language Server (#535)
1 parent 6363daf commit fe5ef2e

File tree

1 file changed

+28
-18
lines changed

1 file changed

+28
-18
lines changed

src/extension.ts

Lines changed: 28 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,40 @@ async function activateExtension(_operationId: string, context: ExtensionContext
3232
context.subscriptions.push(syncHandler);
3333
context.subscriptions.push(tasks.registerTaskProvider(ExportJarTaskProvider.exportJarType, new ExportJarTaskProvider()));
3434

35-
const javaLanguageSupport: Extension<any> | undefined = extensions.getExtension(ExtensionName.JAVA_LANGUAGE_SUPPORT);
36-
if (!javaLanguageSupport) {
37-
return;
38-
}
39-
javaLanguageSupport.activate().then(() => {
40-
const extensionApi: any = javaLanguageSupport.exports;
41-
if (!extensionApi) {
35+
const pollingJLS = () => {
36+
const javaLanguageSupport: Extension<any> | undefined = extensions.getExtension(ExtensionName.JAVA_LANGUAGE_SUPPORT);
37+
if (!javaLanguageSupport) {
4238
return;
4339
}
4440

45-
if (extensionApi.onDidClasspathUpdate) {
46-
const onDidClasspathUpdate: Event<Uri> = extensionApi.onDidClasspathUpdate;
47-
context.subscriptions.push(onDidClasspathUpdate(async () => {
48-
syncHandler.updateFileWatcher(Settings.autoRefresh());
49-
}));
50-
}
41+
if (javaLanguageSupport.isActive) {
42+
const extensionApi: any = javaLanguageSupport.exports;
43+
if (!extensionApi) {
44+
return;
45+
}
46+
47+
if (extensionApi.onDidClasspathUpdate) {
48+
const onDidClasspathUpdate: Event<Uri> = extensionApi.onDidClasspathUpdate;
49+
context.subscriptions.push(onDidClasspathUpdate(async () => {
50+
syncHandler.updateFileWatcher(Settings.autoRefresh());
51+
}));
52+
}
5153

52-
if (extensionApi.onDidServerModeChange) {
53-
const onDidServerModeChange: Event<string> = extensionApi.onDidServerModeChange;
54-
context.subscriptions.push(onDidServerModeChange(async () => {
54+
if (extensionApi.serverMode === "Standard") {
5555
syncHandler.updateFileWatcher(Settings.autoRefresh());
56-
}));
56+
} else {
57+
if (extensionApi.onDidServerModeChange) {
58+
const onDidServerModeChange: Event<string> = extensionApi.onDidServerModeChange;
59+
context.subscriptions.push(onDidServerModeChange(async () => {
60+
syncHandler.updateFileWatcher(Settings.autoRefresh());
61+
}));
62+
}
63+
}
64+
} else {
65+
setTimeout(pollingJLS, 3 * 1000 /*ms*/);
5766
}
58-
});
67+
};
68+
pollingJLS();
5969
}
6070

6171
// this method is called when your extension is deactivated

0 commit comments

Comments
 (0)