mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-24 18:49:00 +01:00
Let IRPCProtocol#getProxy return Proxied<T> which enforces functions returning promises
fyi @sandy081 had to remove the overload of `MainThreadOutputServiceShape#$update` because I couldn't get this to work with mapped types fyi @Tyriar this fixed an actual issue with terminals
This commit is contained in:
@@ -151,7 +151,7 @@ export interface MainThreadClipboardShape extends IDisposable {
|
||||
export interface MainThreadCommandsShape extends IDisposable {
|
||||
$registerCommand(id: string): void;
|
||||
$unregisterCommand(id: string): void;
|
||||
$executeCommand<T>(id: string, args: any[] | SerializableObjectWithBuffers<any[]>, retry: boolean): Promise<T | undefined>;
|
||||
$executeCommand(id: string, args: any[] | SerializableObjectWithBuffers<any[]>, retry: boolean): Promise<unknown | undefined>;
|
||||
$getCommands(): Promise<string[]>;
|
||||
}
|
||||
|
||||
@@ -472,8 +472,7 @@ export interface MainThreadMessageServiceShape extends IDisposable {
|
||||
|
||||
export interface MainThreadOutputServiceShape extends IDisposable {
|
||||
$register(label: string, log: boolean, file: UriComponents, extensionId: string): Promise<string>;
|
||||
$update(channelId: string, mode: OutputChannelUpdateMode.Append): Promise<void>;
|
||||
$update(channelId: string, mode: OutputChannelUpdateMode, till: number): Promise<void>;
|
||||
$update(channelId: string, mode: OutputChannelUpdateMode, till?: number): Promise<void>;
|
||||
$reveal(channelId: string, preserveFocus: boolean): Promise<void>;
|
||||
$close(channelId: string): Promise<void>;
|
||||
$dispose(channelId: string): Promise<void>;
|
||||
@@ -1231,7 +1230,7 @@ export interface MainThreadTimelineShape extends IDisposable {
|
||||
// -- extension host
|
||||
|
||||
export interface ExtHostCommandsShape {
|
||||
$executeContributedCommand<T>(id: string, ...args: any[]): Promise<T>;
|
||||
$executeContributedCommand(id: string, ...args: any[]): Promise<unknown>;
|
||||
$getContributedCommandHandlerDescriptions(): Promise<{ [id: string]: string | ICommandHandlerDescription; }>;
|
||||
}
|
||||
|
||||
@@ -1817,7 +1816,7 @@ export interface ExtHostTerminalServiceShape {
|
||||
$acceptProcessShutdown(id: number, immediate: boolean): void;
|
||||
$acceptProcessRequestInitialCwd(id: number): void;
|
||||
$acceptProcessRequestCwd(id: number): void;
|
||||
$acceptProcessRequestLatency(id: number): number;
|
||||
$acceptProcessRequestLatency(id: number): Promise<number>;
|
||||
$provideLinks(id: number, line: string): Promise<ITerminalLinkDto[]>;
|
||||
$activateLink(id: number, linkId: number): void;
|
||||
$initEnvironmentVariableCollections(collections: [string, ISerializableEnvironmentVariableCollection][]): void;
|
||||
|
||||
@@ -196,7 +196,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
|
||||
});
|
||||
|
||||
try {
|
||||
const result = await this.#proxy.$executeCommand<T>(id, hasBuffers ? new SerializableObjectWithBuffers(toArgs) : toArgs, retry);
|
||||
const result = await this.#proxy.$executeCommand(id, hasBuffers ? new SerializableObjectWithBuffers(toArgs) : toArgs, retry);
|
||||
return revive<any>(result);
|
||||
} catch (e) {
|
||||
// Rerun the command when it wasn't known, had arguments, and when retry
|
||||
@@ -211,7 +211,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
|
||||
}
|
||||
}
|
||||
|
||||
private async _executeContributedCommand<T>(id: string, args: any[], annotateError: boolean): Promise<T> {
|
||||
private async _executeContributedCommand<T = unknown>(id: string, args: any[], annotateError: boolean): Promise<T> {
|
||||
const command = this._commands.get(id);
|
||||
if (!command) {
|
||||
throw new Error('Unknown command');
|
||||
@@ -254,7 +254,7 @@ export class ExtHostCommands implements ExtHostCommandsShape {
|
||||
}
|
||||
}
|
||||
|
||||
$executeContributedCommand<T>(id: string, ...args: any[]): Promise<T> {
|
||||
$executeContributedCommand(id: string, ...args: any[]): Promise<unknown> {
|
||||
this._logService.trace('ExtHostCommands#$executeContributedCommand', id);
|
||||
|
||||
if (!this._commands.has(id)) {
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { ProxyIdentifier, IRPCProtocol } from 'vs/workbench/services/extensions/common/proxyIdentifier';
|
||||
import { ProxyIdentifier, IRPCProtocol, Proxied } from 'vs/workbench/services/extensions/common/proxyIdentifier';
|
||||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
|
||||
export const IExtHostRpcService = createDecorator<IExtHostRpcService>('IExtHostRpcService');
|
||||
@@ -15,7 +15,7 @@ export interface IExtHostRpcService extends IRPCProtocol {
|
||||
export class ExtHostRpcService implements IExtHostRpcService {
|
||||
readonly _serviceBrand: undefined;
|
||||
|
||||
readonly getProxy: <T>(identifier: ProxyIdentifier<T>) => T;
|
||||
readonly getProxy: <T>(identifier: ProxyIdentifier<T>) => Proxied<T>;
|
||||
readonly set: <T, R extends T> (identifier: ProxyIdentifier<T>, instance: R) => R;
|
||||
readonly assertRegistered: (identifiers: ProxyIdentifier<any>[]) => void;
|
||||
readonly drain: () => Promise<void>;
|
||||
|
||||
@@ -632,8 +632,8 @@ export abstract class BaseExtHostTerminalService extends Disposable implements I
|
||||
this._terminalProcesses.get(id)?.getCwd().then(cwd => this._proxy.$sendProcessProperty(id, { type: ProcessPropertyType.Cwd, value: cwd }));
|
||||
}
|
||||
|
||||
public $acceptProcessRequestLatency(id: number): number {
|
||||
return id;
|
||||
public $acceptProcessRequestLatency(id: number): Promise<number> {
|
||||
return Promise.resolve(id);
|
||||
}
|
||||
|
||||
public registerLinkProvider(provider: vscode.TerminalLinkProvider): vscode.Disposable {
|
||||
|
||||
Reference in New Issue
Block a user