From c349bd636cc1f76089fa1cccf010676281a8c1e8 Mon Sep 17 00:00:00 2001 From: Matt Bowersox Date: Mon, 10 Nov 2025 11:40:25 -0600 Subject: [PATCH] Remove redundant wait for Java language server launch mode --- src/extension.ts | 4 +-- src/util/javaServerMode.ts | 70 -------------------------------------- 2 files changed, 2 insertions(+), 72 deletions(-) delete mode 100644 src/util/javaServerMode.ts diff --git a/src/extension.ts b/src/extension.ts index 4d2cbf2f..1659157a 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -10,7 +10,6 @@ import { LibertyProject, ProjectProvider } from "./liberty/libertyProject"; import { LanguageClientOptions } from "vscode-languageclient"; import { LanguageClient } from "vscode-languageclient/node"; import { workspace, commands, ExtensionContext, extensions, window, StatusBarAlignment, TextEditor } from "vscode"; -import { JAVA_EXTENSION_ID, waitForStandardMode } from "./util/javaServerMode"; import { localize } from "./util/i18nUtil"; import { RequirementsData, resolveRequirements, resolveLclsRequirements } from "./util/requirements"; import { prepareExecutable } from "./util/javaServerStarter"; @@ -18,6 +17,8 @@ import * as helperUtil from "./util/helperUtil"; import path = require('path'); import * as fs from "fs"; +const JAVA_EXTENSION_ID = "redhat.java"; + const LIBERTY_CLIENT_ID = "LANGUAGE_ID_LIBERTY"; const JAKARTA_CLIENT_ID = "LANGUAGE_ID_JAKARTA"; export const LIBERTY_LS_JAR = "liberty-langserver-2.3.2-jar-with-dependencies.jar"; @@ -37,7 +38,6 @@ export async function activate(context: vscode.ExtensionContext): Promise * If java ls was started in lightweight mode, It will prompt user to switch */ const api: JavaExtensionAPI = await getJavaExtensionAPI(); - await waitForStandardMode(api); const item = window.createStatusBarItem(StatusBarAlignment.Right, Number.MIN_VALUE); // item.name = "Liberty Language Server"; diff --git a/src/util/javaServerMode.ts b/src/util/javaServerMode.ts deleted file mode 100644 index 4d8c8046..00000000 --- a/src/util/javaServerMode.ts +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright 2019 Red Hat, Inc. and others. - - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - - * http://www.apache.org/licenses/LICENSE-2.0 - - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - */ - -import { window, commands } from "vscode"; -import { JavaExtensionAPI } from "../extension"; - -export const JAVA_EXTENSION_ID = "redhat.java"; - -export enum ServerMode { - STANDARD = "Standard", - LIGHTWEIGHT = "LightWeight", - HYBRID = "Hybrid", -} - -/** - * Waits for the java language server to launch in standard mode - * Before activating Tools for MicroProfile. - * If java ls was started in lightweight mode, It will prompt user to switch - * - * Referenced: - * https://github.com/redhat-developer/vscode-microprofile/blob/master/src/util/javaServerMode.ts - */ -export async function waitForStandardMode(api: JavaExtensionAPI): Promise { - // If hybrid, standard mode is being launched. Wait for standard mode then resolve. - if (api.serverMode === ServerMode.HYBRID) { - return new Promise((resolve) => { - api.onDidServerModeChange((mode: string) => { - if (mode === ServerMode.STANDARD) { - resolve(); - } - }); - }); - // If Lightweight. Prompt to switch then wait for Standard mode. - // Even if they do not select Yes on the prompt. This still waits for standard mode - // since standard mode switch can be triggered other ways. - } else if (api.serverMode === ServerMode.LIGHTWEIGHT) { - window.showInformationMessage( - "Liberty Tools for VS Code requires the Java language server to run in Standard mode. " + - "Do you want to switch it to Standard mode now?", - "Yes", - "Later" - ) - .then((answer) => { - if (answer === "Yes") { - commands.executeCommand("java.server.mode.switch", ServerMode.STANDARD, true); - } - }); - return new Promise((resolve) => { - api.onDidServerModeChange((mode: string) => { - if (mode === ServerMode.STANDARD) { - resolve(); - } - }); - }); - } -}