import * as vscode from "vscode" ; import { JavaExtensionNotActivatedError } from "../utils/errorUtils" ; const JAVA_EXTENSION_ID = "redhat.java" ; const JAVA_EXECUTE_WORKSPACE_COMMAND = "java.execute.workspaceCommand" ; export function executeJavaLanguageServerCommand ( ... rest ) { if ( ! isJavaExtEnabled ( ) ) { throw new JavaExtensionNotActivatedError ( `Cannot execute command ${ JAVA_EXECUTE_WORKSPACE_COMMAND }, VS Code Java Extension is not enabled.` ) ; } return vscode . commands . executeCommand ( JAVA_EXECUTE_WORKSPACE_COMMAND , ... rest ) ; } export function isJavaExtEnabled ( ) { const javaExt = getJavaExtension ( ) ; return ! ! javaExt ; } export function isJavaExtActivated ( ) { const javaExt = getJavaExtension ( ) ; return ! ! javaExt && javaExt . isActive ; } export function getJavaExtension ( ) { return vscode . extensions . getExtension ( JAVA_EXTENSION_ID ) ; } export function isJavaLangugageServerStarndard ( ) { const javaExt = getJavaExtension ( ) ; return javaExt ?. exports ?. api ?. serverMode === "Standard" ; }