Skip to content
This repository has been archived by the owner on Apr 4, 2023. It is now read-only.

Commit

Permalink
Intercept uri arguments and set container name into file scheme
Browse files Browse the repository at this point in the history
Signed-off-by: Vladyslav Zhukovskyi <[email protected]>
  • Loading branch information
vzhukovs committed Nov 27, 2019
1 parent 2170465 commit 964304e
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 964304e

Please sign in to comment.