import * as vscode from "vscode" ; import { ExtensionName } from "./Interfaces/Api" ; import { WorkbenchExtension } from "../WorkbenchExtension" ; import { RemoteEnvNotSupportedError } from "../common/Error/OperationFailedErrors/RemoteEnvNotSupportedError" ; import { OperationFailedError } from "../common/Error/OperationFailedErrors/OperationFailedError" ; import { checkExtensionAvailable } from "./Apis" ; import { DependentExtensionNotFoundError } from "../common/Error/OperationFailedErrors/DependentExtensionNotFoundError" ; export class RemoteExtension { static isRemote ( context ) { const extension = WorkbenchExtension . getExtension ( context ) ; if ( ! extension ) { throw new OperationFailedError ( "check whether is remote" , "Failed to get workbench extension" , "" ) ; } return extension . extensionKind === vscode . ExtensionKind . Workspace ; } returns returns static async isAvailable ( ) { return await checkExtensionAvailable ( ExtensionName . Remote ) ; } static async checkRemoteExtension ( operation ) { const res = await RemoteExtension . isAvailable ( ) ; if ( ! res ) { throw new DependentExtensionNotFoundError ( operation , ExtensionName . Remote ) ; } } /**
     * Ensure we are not in remote environment before running a command.
     * If in remote environment, throw error.
     */ static ensureLocalBeforeRunCommand ( operation , context ) { if ( RemoteExtension . isRemote ( context ) ) { throw new RemoteEnvNotSupportedError ( operation ) ; } } }