Re-work java services registration for VSCode
This commit is contained in:
@@ -12,11 +12,6 @@ export function registerClasspathService(client : LanguageClient) : void {
|
||||
const javaExt = VSCode.extensions.getExtension('redhat.java');
|
||||
const javaApi = javaExt?.exports;
|
||||
|
||||
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));
|
||||
}
|
||||
|
||||
let addRequest = new RequestType<ClasspathListenerParams, ClasspathListenerResponse, void>("sts/addClasspathListener");
|
||||
client.onRequest(addRequest, async (params: ClasspathListenerParams) => {
|
||||
if (javaApi?.serverMode === 'LightWeight') {
|
||||
@@ -30,6 +25,11 @@ export function registerClasspathService(client : LanguageClient) : void {
|
||||
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 {
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import {activate, ActivatorOptions} from './launch-util';
|
||||
import {JVM} from '@pivotal-tools/jvm-launch-utils';
|
||||
import { registerClasspathService } from './classpath';
|
||||
import {registerJavaDataService} from "./java-data";
|
||||
|
||||
export {activate, JVM, ActivatorOptions};
|
||||
export {activate, JVM, ActivatorOptions, registerClasspathService, registerJavaDataService};
|
||||
|
||||
@@ -18,9 +18,7 @@ import * as P2C from 'vscode-languageclient/lib/common/protocolConverter';
|
||||
import {HighlightService, HighlightParams} from './highlight-service';
|
||||
import { log } from 'util';
|
||||
import { JVM, findJvm, findJdk } from '@pivotal-tools/jvm-launch-utils';
|
||||
import { registerClasspathService } from './classpath';
|
||||
import {HighlightCodeLensProvider} from "./code-lens-service";
|
||||
import {registerJavaDataService} from "./java-data";
|
||||
|
||||
const p2c = P2C.createConverter(undefined, false, false);
|
||||
|
||||
@@ -42,7 +40,6 @@ export interface ActivatorOptions {
|
||||
highlightCodeLensSettingKey?: string;
|
||||
explodedLsJarData?: ExplodedLsJarData;
|
||||
vmArgs?: string[];
|
||||
requiresJavaLs?: boolean;
|
||||
}
|
||||
|
||||
export interface ExplodedLsJarData {
|
||||
@@ -392,10 +389,6 @@ function setupLanguageClient(context: VSCode.ExtensionContext, createServer: Ser
|
||||
}
|
||||
return {applied: true};
|
||||
});
|
||||
if (options.requiresJavaLs) {
|
||||
registerClasspathService(client);
|
||||
registerJavaDataService(client);
|
||||
}
|
||||
return Promise.resolve(client);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user