From 964304ee7fb581466aff7a5ace48baf168f37b00 Mon Sep 17 00:00:00 2001 From: Vladyslav Zhukovskyi Date: Wed, 27 Nov 2019 13:43:16 +0200 Subject: [PATCH] Intercept uri arguments and set container name into file scheme Signed-off-by: Vladyslav Zhukovskyi --- .../node/execute-command-container-aware.ts | 25 +++++++++++++++++++ .../src/node/plugin-remote-init.ts | 3 +++ 2 files changed, 28 insertions(+) create mode 100644 extensions/eclipse-che-theia-plugin-remote/src/node/execute-command-container-aware.ts diff --git a/extensions/eclipse-che-theia-plugin-remote/src/node/execute-command-container-aware.ts b/extensions/eclipse-che-theia-plugin-remote/src/node/execute-command-container-aware.ts new file mode 100644 index 000000000..355c6cbe6 --- /dev/null +++ b/extensions/eclipse-che-theia-plugin-remote/src/node/execute-command-container-aware.ts @@ -0,0 +1,25 @@ +/********************************************************************* + * Copyright (c) 2019 Red Hat, Inc. + * + * This program and the accompanying materials are made + * available under the terms of the Eclipse Public License 2.0 + * which is available at https://www.eclipse.org/legal/epl-2.0/ + * + * SPDX-License-Identifier: EPL-2.0 + **********************************************************************/ +import { CommandRegistryImpl } from '@theia/plugin-ext/lib/plugin/command-registry'; +import { overrideUri } from './che-content-aware-utils'; + +export class ExecuteCommandContainerAware { + static makeExecuteCommandContainerAware(commandRegistryExt: CommandRegistryImpl) { + const executeCommandContainerAware = new ExecuteCommandContainerAware(); + executeCommandContainerAware.overrideExecuteCommand(commandRegistryExt); + } + + overrideExecuteCommand(commandRegistryExt: CommandRegistryImpl) { + const originalExecuteCommand = commandRegistryExt.executeCommand.bind(commandRegistryExt); + // tslint:disable-next-line:no-any + const executeCommand = (id: string, ...args: any[]) => originalExecuteCommand(id, ...args.map(arg => arg.scheme ? overrideUri(arg) : arg)); + commandRegistryExt.executeCommand = executeCommand; + } +} diff --git a/extensions/eclipse-che-theia-plugin-remote/src/node/plugin-remote-init.ts b/extensions/eclipse-che-theia-plugin-remote/src/node/plugin-remote-init.ts index 1177a8fc3..4aaa8bde2 100644 --- a/extensions/eclipse-che-theia-plugin-remote/src/node/plugin-remote-init.ts +++ b/extensions/eclipse-che-theia-plugin-remote/src/node/plugin-remote-init.ts @@ -36,6 +36,7 @@ import { Deferred } from '@theia/core/lib/common/promise-util'; import { DocumentContainerAware } from './document-container-aware'; import { LanguagesContainerAware } from './languages-container-aware'; import { PluginManagerExtImpl } from '@theia/plugin-ext/lib/plugin/plugin-manager'; +import { ExecuteCommandContainerAware } from './execute-command-container-aware'; interface CheckAliveWS extends ws { alive: boolean; @@ -214,6 +215,8 @@ to pick-up automatically a free port`)); DocumentContainerAware.makeDocumentContainerAware((webSocketClient.rpc as any).locals.get(MAIN_RPC_CONTEXT.DOCUMENTS_EXT.id)); // tslint:disable-next-line:no-any LanguagesContainerAware.makeLanguagesContainerAware((webSocketClient.rpc as any).locals.get(MAIN_RPC_CONTEXT.LANGUAGES_EXT.id)); + // tslint:disable-next-line:no-any + ExecuteCommandContainerAware.makeExecuteCommandContainerAware((webSocketClient.rpc as any).locals.get(MAIN_RPC_CONTEXT.COMMAND_REGISTRY_EXT.id)); let channelName = ''; if (process.env.CHE_MACHINE_NAME) {