Merge from vscode 1eb87b0e9ce9886afeaecec22b31abd0d9b7939f (#7282)

* Merge from vscode 1eb87b0e9ce9886afeaecec22b31abd0d9b7939f

* fix various icon issues

* fix preview features
This commit is contained in:
Anthony Dresser
2019-09-19 21:50:52 -07:00
committed by GitHub
parent 9d3d64eef3
commit db498db0a8
459 changed files with 10195 additions and 7528 deletions

View File

@@ -0,0 +1,48 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { Event } from 'vs/base/common/event';
import { IChannel, IServerChannel } from 'vs/base/parts/ipc/common/ipc';
//
// Use both `SimpleServiceProxyChannel` and `createSimpleChannelProxy`
// for a very basic process <=> process communication over methods.
//
export class SimpleServiceProxyChannel implements IServerChannel {
private service: { [key: string]: unknown };
constructor(service: unknown) {
this.service = service as { [key: string]: unknown };
}
listen<T>(_: unknown, event: string): Event<T> {
throw new Error(`Events are currently unsupported by SimpleServiceProxyChannel: ${event}`);
}
call(_: unknown, command: string, args: any[]): Promise<any> {
const target = this.service[command];
if (typeof target === 'function') {
return target.apply(this.service, args);
}
throw new Error(`Method not found: ${command}`);
}
}
export function createSimpleChannelProxy<T>(channel: IChannel): T {
return new Proxy({}, {
get(_target, propKey, _receiver) {
if (typeof propKey === 'string') {
return function (...args: any[]) {
return channel.call(propKey, args);
};
}
throw new Error(`Unable to provide main channel proxy implementation for: ${String(propKey)}`);
}
}) as T;
}