-
Notifications
You must be signed in to change notification settings - Fork 210
/
Copy pathclasspath.ts
40 lines (30 loc) · 1.82 KB
/
classpath.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
import * as VSCode from 'vscode';
import { RequestType } from 'vscode-languageclient';
import { LanguageClient } from 'vscode-languageclient/node';
const JDT_SERVER_STANDARD_MODE = 'Standard'
const CMD_STS_ENABLE_CLASSPATH_LISTENER = 'sts.vscode-spring-boot.enableClasspathListening';
export function registerClasspathService(client : LanguageClient) : void {
const javaExt = VSCode.extensions.getExtension('redhat.java');
const javaApi = javaExt?.exports;
let addRequest = new RequestType<ClasspathListenerParams, ClasspathListenerResponse, void>("sts/addClasspathListener");
client.onRequest(addRequest, async (params: ClasspathListenerParams) => {
if (javaApi?.serverMode === 'LightWeight') {
throw new Error('Classpath listener not supported while Java Language Server is in LightWeight mode');
}
return <ClasspathListenerResponse> await VSCode.commands.executeCommand("java.execute.workspaceCommand", "sts.java.addClasspathListener", params.callbackCommandId);
});
let removeRequest = new RequestType<ClasspathListenerParams, ClasspathListenerResponse, void>("sts/removeClasspathListener");
client.onRequest(removeRequest, async (params: ClasspathListenerParams) => {
return <ClasspathListenerResponse> await VSCode.commands.executeCommand("java.execute.workspaceCommand", "sts.java.removeClasspathListener", params.callbackCommandId);
});
if (javaApi) {
VSCode.commands.executeCommand(CMD_STS_ENABLE_CLASSPATH_LISTENER, javaApi.serverMode === JDT_SERVER_STANDARD_MODE);
javaApi.onDidServerModeChange(e => VSCode.commands.executeCommand(CMD_STS_ENABLE_CLASSPATH_LISTENER, javaApi.serverMode === JDT_SERVER_STANDARD_MODE));
}
}
interface ClasspathListenerParams {
callbackCommandId: string
}
interface ClasspathListenerResponse {
}