From 72484fd03a605e439aad9d94e1ff852e80c0abbc Mon Sep 17 00:00:00 2001 From: Joao Moreno Date: Mon, 10 Sep 2018 16:39:20 +0200 Subject: [PATCH] remove TPromise from ipc.ts related to #56137 --- src/vs/base/parts/ipc/node/ipc.cp.ts | 10 +- src/vs/base/parts/ipc/node/ipc.ts | 106 +++++---- src/vs/platform/dialogs/node/dialogIpc.ts | 12 +- src/vs/platform/driver/node/driver.ts | 106 ++++----- .../node/extensionManagementIpc.ts | 38 ++-- .../localizations/node/localizationsIpc.ts | 8 +- .../platform/telemetry/node/telemetryIpc.ts | 6 +- src/vs/platform/url/node/urlIpc.ts | 16 +- src/vs/platform/windows/node/windowsIpc.ts | 206 +++++++++--------- .../platform/workspaces/node/workspacesIpc.ts | 8 +- 10 files changed, 257 insertions(+), 259 deletions(-) diff --git a/src/vs/base/parts/ipc/node/ipc.cp.ts b/src/vs/base/parts/ipc/node/ipc.cp.ts index 26a94b51063..c8be4be5bad 100644 --- a/src/vs/base/parts/ipc/node/ipc.cp.ts +++ b/src/vs/base/parts/ipc/node/ipc.cp.ts @@ -6,7 +6,7 @@ import { ChildProcess, fork, ForkOptions } from 'child_process'; import { IDisposable, toDisposable, dispose } from 'vs/base/common/lifecycle'; import { TPromise } from 'vs/base/common/winjs.base'; -import { Delayer, always } from 'vs/base/common/async'; +import { Delayer, always, createCancelablePromise } from 'vs/base/common/async'; import { deepClone, assign } from 'vs/base/common/objects'; import { Emitter, fromNodeEventEmitter, Event } from 'vs/base/common/event'; import { createQueuedSender } from 'vs/base/node/processes'; @@ -100,8 +100,8 @@ export class Client implements IChannelClient, IDisposable { const that = this; return { - call(command: string, arg?: any, cancellationToken?: CancellationToken) { - return that.requestPromise(channelName, command, arg, cancellationToken); + call(command: string, arg?: any, cancellationToken?: CancellationToken): Thenable { + return that.requestPromise(channelName, command, arg, cancellationToken); }, listen(event: string, arg?: any) { return that.requestEvent(channelName, event, arg); @@ -109,7 +109,7 @@ export class Client implements IChannelClient, IDisposable { } as T; } - protected requestPromise(channelName: string, name: string, arg?: any, cancellationToken = CancellationToken.None): TPromise { + protected requestPromise(channelName: string, name: string, arg?: any, cancellationToken = CancellationToken.None): Thenable { if (!this.disposeDelayer) { return TPromise.wrapError(new Error('disposed')); } @@ -121,7 +121,7 @@ export class Client implements IChannelClient, IDisposable { this.disposeDelayer.cancel(); const channel = this.getCachedChannel(channelName); - const result: TPromise = channel.call(name, arg, cancellationToken); + const result = createCancelablePromise(token => channel.call(name, arg, token)); const cancellationTokenListener = cancellationToken.onCancellationRequested(() => result.cancel()); const disposable = toDisposable(() => result.cancel()); diff --git a/src/vs/base/parts/ipc/node/ipc.ts b/src/vs/base/parts/ipc/node/ipc.ts index 2557767fe4f..1d354dd28c2 100644 --- a/src/vs/base/parts/ipc/node/ipc.ts +++ b/src/vs/base/parts/ipc/node/ipc.ts @@ -5,8 +5,7 @@ 'use strict'; -import { TPromise } from 'vs/base/common/winjs.base'; -import { IDisposable, toDisposable, Disposable } from 'vs/base/common/lifecycle'; +import { IDisposable, toDisposable, combinedDisposable } from 'vs/base/common/lifecycle'; import { Event, Emitter, once, filterEvent, toNativePromise, Relay } from 'vs/base/common/event'; import { always, CancelablePromise, createCancelablePromise, timeout } from 'vs/base/common/async'; import { CancellationToken, CancellationTokenSource } from 'vs/base/common/cancellation'; @@ -61,7 +60,7 @@ enum State { * with at most one single return value. */ export interface IChannel { - call(command: string, arg?: any, cancellationToken?: CancellationToken): TPromise; + call(command: string, arg?: any, cancellationToken?: CancellationToken): Thenable; listen(event: string, arg?: any): Event; } @@ -87,8 +86,8 @@ export interface IChannelClient { * channels (each from a separate client) to pick from. */ export interface IClientRouter { - routeCall(command: string, arg?: any, cancellationToken?: CancellationToken): TPromise; - routeEvent(event: string, arg?: any): TPromise; + routeCall(command: string, arg?: any, cancellationToken?: CancellationToken): Thenable; + routeEvent(event: string, arg?: any): Thenable; } /** @@ -206,40 +205,36 @@ export class ChannelServer implements IChannelServer, IDisposable { private onPromise(request: IRawPromiseRequest): void { const channel = this.channels.get(request.channelName); const cancellationTokenSource = new CancellationTokenSource(); - let promise: TPromise; + let promise: Thenable; try { promise = channel.call(request.name, request.arg, cancellationTokenSource.token); } catch (err) { - promise = TPromise.wrapError(err); + promise = Promise.reject(err); } const id = request.id; - const requestPromise = promise.then(data => { + promise.then(data => { this.sendResponse({ id, data, type: ResponseType.PromiseSuccess }); this.activeRequests.delete(request.id); - }, data => { - if (data instanceof Error) { + }, err => { + if (err instanceof Error) { this.sendResponse({ id, data: { - message: data.message, - name: data.name, - stack: data.stack ? (data.stack.split ? data.stack.split('\n') : data.stack) : void 0 + message: err.message, + name: err.name, + stack: err.stack ? (err.stack.split ? err.stack.split('\n') : err.stack) : void 0 }, type: ResponseType.PromiseError }); } else { - this.sendResponse({ id, data, type: ResponseType.PromiseErrorObj }); + this.sendResponse({ id, data: err, type: ResponseType.PromiseErrorObj }); } this.activeRequests.delete(request.id); }); - const disposable = toDisposable(() => { - cancellationTokenSource.cancel(); - requestPromise.cancel(); - }); - + const disposable = toDisposable(() => cancellationTokenSource.cancel()); this.activeRequests.set(request.id, disposable); } @@ -298,20 +293,23 @@ export class ChannelClient implements IChannelClient, IDisposable { } as T; } - private requestPromise(channelName: string, name: string, arg?: any, cancellationToken = CancellationToken.None): TPromise { + private requestPromise(channelName: string, name: string, arg?: any, cancellationToken = CancellationToken.None): Thenable { const id = this.lastRequestId++; const type = RequestType.Promise; const request: IRawRequest = { id, type, channelName, name, arg }; if (cancellationToken.isCancellationRequested) { - return TPromise.wrapError(errors.canceled()); + return Promise.reject(errors.canceled()); } - let uninitializedPromise: CancelablePromise | null = null; - let cancellationTokenListener: IDisposable = Disposable.None; + let disposable: IDisposable; - const result = new TPromise((c, e) => { - uninitializedPromise = createCancelablePromise(_ => this.whenInitialized()); + const result = new Promise((c, e) => { + if (cancellationToken.isCancellationRequested) { + return e(errors.canceled()); + } + + let uninitializedPromise = createCancelablePromise(_ => this.whenInitialized()); uninitializedPromise.then(() => { uninitializedPromise = null; @@ -340,24 +338,24 @@ export class ChannelClient implements IChannelClient, IDisposable { this.handlers.set(id, handler); this.sendRequest(request); }); - }, () => { - if (uninitializedPromise) { - uninitializedPromise.cancel(); - uninitializedPromise = null; - } else { - this.sendRequest({ id, type: RequestType.PromiseCancel }); - } + + const cancel = () => { + if (uninitializedPromise) { + uninitializedPromise.cancel(); + uninitializedPromise = null; + } else { + this.sendRequest({ id, type: RequestType.PromiseCancel }); + } + + e(errors.canceled()); + }; + + const cancellationTokenListener = cancellationToken.onCancellationRequested(cancel); + disposable = combinedDisposable([toDisposable(cancel), cancellationTokenListener]); }); - cancellationTokenListener = cancellationToken.onCancellationRequested(() => result.cancel()); - - const disposable = toDisposable(() => result.cancel()); this.activeRequests.add(disposable); - - always(result, () => { - cancellationTokenListener.dispose(); - this.activeRequests.delete(disposable); - }); + always(result, () => this.activeRequests.delete(disposable)); return result; } @@ -530,18 +528,18 @@ export class IPCServer implements IChannelServer, IRoutingChannelClient, IDispos this.channels.set(channelName, channel); } - private getClient(clientId: string): TPromise { + private getClient(clientId: string): Thenable { if (!clientId) { - return TPromise.wrapError(new Error('Client id should be provided')); + return Promise.reject(new Error('Client id should be provided')); } const client = this.channelClients.get(clientId); if (client) { - return TPromise.as(client); + return Promise.resolve(client); } - return new TPromise(c => { + return new Promise(c => { const onClient = once(filterEvent(this.onClientAdded.event, id => id === clientId)); onClient(() => c(this.channelClients.get(clientId))); }); @@ -588,13 +586,13 @@ export class IPCClient implements IChannelClient, IChannelServer, IDisposable { } } -export function getDelayedChannel(promise: TPromise): T { +export function getDelayedChannel(promise: Thenable): T { return { - call(command: string, arg?: any, cancellationToken?: CancellationToken) { + call(command: string, arg?: any, cancellationToken?: CancellationToken): Thenable { return promise.then(c => c.call(command, arg, cancellationToken)); }, - listen(event: string, arg: any) { + listen(event: string, arg?: any): Event { const relay = new Relay(); promise.then(c => relay.input = c.listen(event, arg)); return relay.event; @@ -606,25 +604,25 @@ export function getNextTickChannel(channel: T): T { let didTick = false; return { - call(command: string, arg?: any, cancellationToken?: CancellationToken) { + call(command: string, arg?: any, cancellationToken?: CancellationToken): Thenable { if (didTick) { return channel.call(command, arg, cancellationToken); } - return TPromise.wrap(timeout(0)) + return timeout(0) .then(() => didTick = true) - .then(() => channel.call(command, arg, cancellationToken)); + .then(() => channel.call(command, arg, cancellationToken)); }, - listen(event: string, arg?: any): Event { + listen(event: string, arg?: any): Event { if (didTick) { - return channel.listen(event, arg); + return channel.listen(event, arg); } - const relay = new Relay(); + const relay = new Relay(); timeout(0) .then(() => didTick = true) - .then(() => relay.input = channel.listen(event, arg)); + .then(() => relay.input = channel.listen(event, arg)); return relay.event; } diff --git a/src/vs/platform/dialogs/node/dialogIpc.ts b/src/vs/platform/dialogs/node/dialogIpc.ts index 06a2376ea0c..c392844d3f4 100644 --- a/src/vs/platform/dialogs/node/dialogIpc.ts +++ b/src/vs/platform/dialogs/node/dialogIpc.ts @@ -12,9 +12,9 @@ import Severity from 'vs/base/common/severity'; import { Event } from 'vs/base/common/event'; export interface IDialogChannel extends IChannel { - call(command: 'show'): TPromise; - call(command: 'confirm'): TPromise; - call(command: string, arg?: any): TPromise; + call(command: 'show'): Thenable; + call(command: 'confirm'): Thenable; + call(command: string, arg?: any): Thenable; } export class DialogChannel implements IDialogChannel { @@ -25,7 +25,7 @@ export class DialogChannel implements IDialogChannel { throw new Error('No event found'); } - call(command: string, args?: any[]): TPromise { + call(command: string, args?: any[]): Thenable { switch (command) { case 'show': return this.dialogService.show(args[0], args[1], args[2]); case 'confirm': return this.dialogService.confirm(args[0]); @@ -41,10 +41,10 @@ export class DialogChannelClient implements IDialogService { constructor(private channel: IDialogChannel) { } show(severity: Severity, message: string, options: string[]): TPromise { - return this.channel.call('show', [severity, message, options]); + return TPromise.wrap(this.channel.call('show', [severity, message, options])); } confirm(confirmation: IConfirmation): TPromise { - return this.channel.call('confirm', [confirmation]); + return TPromise.wrap(this.channel.call('confirm', [confirmation])); } } \ No newline at end of file diff --git a/src/vs/platform/driver/node/driver.ts b/src/vs/platform/driver/node/driver.ts index 5e1da358de0..2195bcb9a67 100644 --- a/src/vs/platform/driver/node/driver.ts +++ b/src/vs/platform/driver/node/driver.ts @@ -47,20 +47,20 @@ export interface IDriver { //*END export interface IDriverChannel extends IChannel { - call(command: 'getWindowIds'): TPromise; - call(command: 'capturePage'): TPromise; - call(command: 'reloadWindow', arg: number): TPromise; - call(command: 'dispatchKeybinding', arg: [number, string]): TPromise; - call(command: 'click', arg: [number, string, number | undefined, number | undefined]): TPromise; - call(command: 'doubleClick', arg: [number, string]): TPromise; - call(command: 'setValue', arg: [number, string, string]): TPromise; - call(command: 'getTitle', arg: [number]): TPromise; - call(command: 'isActiveElement', arg: [number, string]): TPromise; - call(command: 'getElements', arg: [number, string, boolean]): TPromise; - call(command: 'typeInEditor', arg: [number, string, string]): TPromise; - call(command: 'getTerminalBuffer', arg: [number, string]): TPromise; - call(command: 'writeInTerminal', arg: [number, string, string]): TPromise; - call(command: string, arg: any): TPromise; + call(command: 'getWindowIds'): Thenable; + call(command: 'capturePage'): Thenable; + call(command: 'reloadWindow', arg: number): Thenable; + call(command: 'dispatchKeybinding', arg: [number, string]): Thenable; + call(command: 'click', arg: [number, string, number | undefined, number | undefined]): Thenable; + call(command: 'doubleClick', arg: [number, string]): Thenable; + call(command: 'setValue', arg: [number, string, string]): Thenable; + call(command: 'getTitle', arg: [number]): Thenable; + call(command: 'isActiveElement', arg: [number, string]): Thenable; + call(command: 'getElements', arg: [number, string, boolean]): Thenable; + call(command: 'typeInEditor', arg: [number, string, string]): Thenable; + call(command: 'getTerminalBuffer', arg: [number, string]): Thenable; + call(command: 'writeInTerminal', arg: [number, string, string]): Thenable; + call(command: string, arg: any): Thenable; } export class DriverChannel implements IDriverChannel { @@ -99,55 +99,55 @@ export class DriverChannelClient implements IDriver { constructor(private channel: IDriverChannel) { } getWindowIds(): TPromise { - return this.channel.call('getWindowIds'); + return TPromise.wrap(this.channel.call('getWindowIds')); } capturePage(windowId: number): TPromise { - return this.channel.call('capturePage', windowId); + return TPromise.wrap(this.channel.call('capturePage', windowId)); } reloadWindow(windowId: number): TPromise { - return this.channel.call('reloadWindow', windowId); + return TPromise.wrap(this.channel.call('reloadWindow', windowId)); } dispatchKeybinding(windowId: number, keybinding: string): TPromise { - return this.channel.call('dispatchKeybinding', [windowId, keybinding]); + return TPromise.wrap(this.channel.call('dispatchKeybinding', [windowId, keybinding])); } click(windowId: number, selector: string, xoffset: number | undefined, yoffset: number | undefined): TPromise { - return this.channel.call('click', [windowId, selector, xoffset, yoffset]); + return TPromise.wrap(this.channel.call('click', [windowId, selector, xoffset, yoffset])); } doubleClick(windowId: number, selector: string): TPromise { - return this.channel.call('doubleClick', [windowId, selector]); + return TPromise.wrap(this.channel.call('doubleClick', [windowId, selector])); } setValue(windowId: number, selector: string, text: string): TPromise { - return this.channel.call('setValue', [windowId, selector, text]); + return TPromise.wrap(this.channel.call('setValue', [windowId, selector, text])); } getTitle(windowId: number): TPromise { - return this.channel.call('getTitle', [windowId]); + return TPromise.wrap(this.channel.call('getTitle', [windowId])); } isActiveElement(windowId: number, selector: string): TPromise { - return this.channel.call('isActiveElement', [windowId, selector]); + return TPromise.wrap(this.channel.call('isActiveElement', [windowId, selector])); } getElements(windowId: number, selector: string, recursive: boolean): TPromise { - return this.channel.call('getElements', [windowId, selector, recursive]); + return TPromise.wrap(this.channel.call('getElements', [windowId, selector, recursive])); } typeInEditor(windowId: number, selector: string, text: string): TPromise { - return this.channel.call('typeInEditor', [windowId, selector, text]); + return TPromise.wrap(this.channel.call('typeInEditor', [windowId, selector, text])); } getTerminalBuffer(windowId: number, selector: string): TPromise { - return this.channel.call('getTerminalBuffer', [windowId, selector]); + return TPromise.wrap(this.channel.call('getTerminalBuffer', [windowId, selector])); } writeInTerminal(windowId: number, selector: string, text: string): TPromise { - return this.channel.call('writeInTerminal', [windowId, selector, text]); + return TPromise.wrap(this.channel.call('writeInTerminal', [windowId, selector, text])); } } @@ -161,9 +161,9 @@ export interface IWindowDriverRegistry { } export interface IWindowDriverRegistryChannel extends IChannel { - call(command: 'registerWindowDriver', arg: number): TPromise; - call(command: 'reloadWindowDriver', arg: number): TPromise; - call(command: string, arg: any): TPromise; + call(command: 'registerWindowDriver', arg: number): Thenable; + call(command: 'reloadWindowDriver', arg: number): Thenable; + call(command: string, arg: any): Thenable; } export class WindowDriverRegistryChannel implements IWindowDriverRegistryChannel { @@ -174,7 +174,7 @@ export class WindowDriverRegistryChannel implements IWindowDriverRegistryChannel throw new Error('No event found'); } - call(command: string, arg?: any): TPromise { + call(command: string, arg?: any): Thenable { switch (command) { case 'registerWindowDriver': return this.registry.registerWindowDriver(arg); case 'reloadWindowDriver': return this.registry.reloadWindowDriver(arg); @@ -191,11 +191,11 @@ export class WindowDriverRegistryChannelClient implements IWindowDriverRegistry constructor(private channel: IWindowDriverRegistryChannel) { } registerWindowDriver(windowId: number): TPromise { - return this.channel.call('registerWindowDriver', windowId); + return TPromise.wrap(this.channel.call('registerWindowDriver', windowId)); } reloadWindowDriver(windowId: number): TPromise { - return this.channel.call('reloadWindowDriver', windowId); + return TPromise.wrap(this.channel.call('reloadWindowDriver', windowId)); } } @@ -212,16 +212,16 @@ export interface IWindowDriver { } export interface IWindowDriverChannel extends IChannel { - call(command: 'click', arg: [string, number | undefined, number | undefined]): TPromise; - call(command: 'doubleClick', arg: string): TPromise; - call(command: 'setValue', arg: [string, string]): TPromise; - call(command: 'getTitle'): TPromise; - call(command: 'isActiveElement', arg: string): TPromise; - call(command: 'getElements', arg: [string, boolean]): TPromise; - call(command: 'typeInEditor', arg: [string, string]): TPromise; - call(command: 'getTerminalBuffer', arg: string): TPromise; - call(command: 'writeInTerminal', arg: [string, string]): TPromise; - call(command: string, arg: any): TPromise; + call(command: 'click', arg: [string, number | undefined, number | undefined]): Thenable; + call(command: 'doubleClick', arg: string): Thenable; + call(command: 'setValue', arg: [string, string]): Thenable; + call(command: 'getTitle'): Thenable; + call(command: 'isActiveElement', arg: string): Thenable; + call(command: 'getElements', arg: [string, boolean]): Thenable; + call(command: 'typeInEditor', arg: [string, string]): Thenable; + call(command: 'getTerminalBuffer', arg: string): Thenable; + call(command: 'writeInTerminal', arg: [string, string]): Thenable; + call(command: string, arg: any): Thenable; } export class WindowDriverChannel implements IWindowDriverChannel { @@ -232,7 +232,7 @@ export class WindowDriverChannel implements IWindowDriverChannel { throw new Error('No event found'); } - call(command: string, arg?: any): TPromise { + call(command: string, arg?: any): Thenable { switch (command) { case 'click': return this.driver.click(arg[0], arg[1], arg[2]); case 'doubleClick': return this.driver.doubleClick(arg); @@ -256,39 +256,39 @@ export class WindowDriverChannelClient implements IWindowDriver { constructor(private channel: IWindowDriverChannel) { } click(selector: string, xoffset?: number, yoffset?: number): TPromise { - return this.channel.call('click', [selector, xoffset, yoffset]); + return TPromise.wrap(this.channel.call('click', [selector, xoffset, yoffset])); } doubleClick(selector: string): TPromise { - return this.channel.call('doubleClick', selector); + return TPromise.wrap(this.channel.call('doubleClick', selector)); } setValue(selector: string, text: string): TPromise { - return this.channel.call('setValue', [selector, text]); + return TPromise.wrap(this.channel.call('setValue', [selector, text])); } getTitle(): TPromise { - return this.channel.call('getTitle'); + return TPromise.wrap(this.channel.call('getTitle')); } isActiveElement(selector: string): TPromise { - return this.channel.call('isActiveElement', selector); + return TPromise.wrap(this.channel.call('isActiveElement', selector)); } getElements(selector: string, recursive: boolean): TPromise { - return this.channel.call('getElements', [selector, recursive]); + return TPromise.wrap(this.channel.call('getElements', [selector, recursive])); } typeInEditor(selector: string, text: string): TPromise { - return this.channel.call('typeInEditor', [selector, text]); + return TPromise.wrap(this.channel.call('typeInEditor', [selector, text])); } getTerminalBuffer(selector: string): TPromise { - return this.channel.call('getTerminalBuffer', selector); + return TPromise.wrap(this.channel.call('getTerminalBuffer', selector)); } writeInTerminal(selector: string, text: string): TPromise { - return this.channel.call('writeInTerminal', [selector, text]); + return TPromise.wrap(this.channel.call('writeInTerminal', [selector, text])); } } diff --git a/src/vs/platform/extensionManagement/node/extensionManagementIpc.ts b/src/vs/platform/extensionManagement/node/extensionManagementIpc.ts index 3f3fdb0c94a..5c20a9e30b0 100644 --- a/src/vs/platform/extensionManagement/node/extensionManagementIpc.ts +++ b/src/vs/platform/extensionManagement/node/extensionManagementIpc.ts @@ -18,15 +18,15 @@ export interface IExtensionManagementChannel extends IChannel { listen(event: 'onUninstallExtension'): Event; listen(event: 'onDidUninstallExtension'): Event; - call(command: 'zip', args: [ILocalExtension]): TPromise; - call(command: 'unzip', args: [URI, LocalExtensionType]): TPromise; - call(command: 'install', args: [URI]): TPromise; - call(command: 'installFromGallery', args: [IGalleryExtension]): TPromise; - call(command: 'uninstall', args: [ILocalExtension, boolean]): TPromise; - call(command: 'reinstallFromGallery', args: [ILocalExtension]): TPromise; - call(command: 'getInstalled', args: [LocalExtensionType]): TPromise; - call(command: 'getExtensionsReport'): TPromise; - call(command: 'updateMetadata', args: [ILocalExtension, IGalleryMetadata]): TPromise; + call(command: 'zip', args: [ILocalExtension]): Thenable; + call(command: 'unzip', args: [URI, LocalExtensionType]): Thenable; + call(command: 'install', args: [URI]): Thenable; + call(command: 'installFromGallery', args: [IGalleryExtension]): Thenable; + call(command: 'uninstall', args: [ILocalExtension, boolean]): Thenable; + call(command: 'reinstallFromGallery', args: [ILocalExtension]): Thenable; + call(command: 'getInstalled', args: [LocalExtensionType]): Thenable; + call(command: 'getExtensionsReport'): Thenable; + call(command: 'updateMetadata', args: [ILocalExtension, IGalleryMetadata]): Thenable; } export class ExtensionManagementChannel implements IExtensionManagementChannel { @@ -54,7 +54,7 @@ export class ExtensionManagementChannel implements IExtensionManagementChannel { throw new Error('Invalid listen'); } - call(command: string, args?: any): TPromise { + call(command: string, args?: any): Thenable { switch (command) { case 'zip': return this.service.zip(this._transform(args[0])); case 'unzip': return this.service.unzip(URI.revive(args[0]), args[1]); @@ -87,41 +87,41 @@ export class ExtensionManagementChannelClient implements IExtensionManagementSer get onDidUninstallExtension(): Event { return this.channel.listen('onDidUninstallExtension'); } zip(extension: ILocalExtension): TPromise { - return this.channel.call('zip', [this._transformOutgoing(extension)]).then(result => URI.revive(this.uriTransformer.transformIncoming(result))); + return TPromise.wrap(this.channel.call('zip', [this._transformOutgoing(extension)]).then(result => URI.revive(this.uriTransformer.transformIncoming(result)))); } unzip(zipLocation: URI, type: LocalExtensionType): TPromise { - return this.channel.call('unzip', [this.uriTransformer.transformOutgoing(zipLocation), type]); + return TPromise.wrap(this.channel.call('unzip', [this.uriTransformer.transformOutgoing(zipLocation), type])); } install(vsix: URI): TPromise { - return this.channel.call('install', [this.uriTransformer.transformOutgoing(vsix)]); + return TPromise.wrap(this.channel.call('install', [this.uriTransformer.transformOutgoing(vsix)])); } installFromGallery(extension: IGalleryExtension): TPromise { - return this.channel.call('installFromGallery', [extension]); + return TPromise.wrap(this.channel.call('installFromGallery', [extension])); } uninstall(extension: ILocalExtension, force = false): TPromise { - return this.channel.call('uninstall', [this._transformOutgoing(extension), force]); + return TPromise.wrap(this.channel.call('uninstall', [this._transformOutgoing(extension), force])); } reinstallFromGallery(extension: ILocalExtension): TPromise { - return this.channel.call('reinstallFromGallery', [this._transformOutgoing(extension)]); + return TPromise.wrap(this.channel.call('reinstallFromGallery', [this._transformOutgoing(extension)])); } getInstalled(type: LocalExtensionType = null): TPromise { - return this.channel.call('getInstalled', [type]) + return TPromise.wrap(this.channel.call('getInstalled', [type])) .then(extensions => extensions.map(extension => this._transformIncoming(extension))); } updateMetadata(local: ILocalExtension, metadata: IGalleryMetadata): TPromise { - return this.channel.call('updateMetadata', [this._transformOutgoing(local), metadata]) + return TPromise.wrap(this.channel.call('updateMetadata', [this._transformOutgoing(local), metadata])) .then(extension => this._transformIncoming(extension)); } getExtensionsReport(): TPromise { - return this.channel.call('getExtensionsReport'); + return TPromise.wrap(this.channel.call('getExtensionsReport')); } private _transformIncoming(extension: ILocalExtension): ILocalExtension { diff --git a/src/vs/platform/localizations/node/localizationsIpc.ts b/src/vs/platform/localizations/node/localizationsIpc.ts index 386f26d66e5..e58a97bd985 100644 --- a/src/vs/platform/localizations/node/localizationsIpc.ts +++ b/src/vs/platform/localizations/node/localizationsIpc.ts @@ -14,8 +14,8 @@ export interface ILocalizationsChannel extends IChannel { listen(event: 'onDidLanguagesChange'): Event; listen(event: string, arg?: any): Event; - call(command: 'getLanguageIds'): TPromise; - call(command: string, arg?: any): TPromise; + call(command: 'getLanguageIds'): Thenable; + call(command: string, arg?: any): Thenable; } export class LocalizationsChannel implements ILocalizationsChannel { @@ -34,7 +34,7 @@ export class LocalizationsChannel implements ILocalizationsChannel { throw new Error('No event found'); } - call(command: string, arg?: any): TPromise { + call(command: string, arg?: any): Thenable { switch (command) { case 'getLanguageIds': return this.service.getLanguageIds(arg); } @@ -51,6 +51,6 @@ export class LocalizationsChannelClient implements ILocalizationsService { get onDidLanguagesChange(): Event { return this.channel.listen('onDidLanguagesChange'); } getLanguageIds(type?: LanguageType): TPromise { - return this.channel.call('getLanguageIds', type); + return TPromise.wrap(this.channel.call('getLanguageIds', type)); } } \ No newline at end of file diff --git a/src/vs/platform/telemetry/node/telemetryIpc.ts b/src/vs/platform/telemetry/node/telemetryIpc.ts index be47fdc8bed..bbe1c20c9c6 100644 --- a/src/vs/platform/telemetry/node/telemetryIpc.ts +++ b/src/vs/platform/telemetry/node/telemetryIpc.ts @@ -16,8 +16,8 @@ export interface ITelemetryLog { } export interface ITelemetryAppenderChannel extends IChannel { - call(command: 'log', data: ITelemetryLog): TPromise; - call(command: string, arg: any): TPromise; + call(command: 'log', data: ITelemetryLog): Thenable; + call(command: string, arg: any): Thenable; } export class TelemetryAppenderChannel implements ITelemetryAppenderChannel { @@ -28,7 +28,7 @@ export class TelemetryAppenderChannel implements ITelemetryAppenderChannel { throw new Error('No events'); } - call(command: string, { eventName, data }: ITelemetryLog): TPromise { + call(command: string, { eventName, data }: ITelemetryLog): Thenable { this.appender.log(eventName, data); return TPromise.as(null); } diff --git a/src/vs/platform/url/node/urlIpc.ts b/src/vs/platform/url/node/urlIpc.ts index 34f91c5e64c..7122ab17100 100644 --- a/src/vs/platform/url/node/urlIpc.ts +++ b/src/vs/platform/url/node/urlIpc.ts @@ -13,8 +13,8 @@ import { Event } from 'vs/base/common/event'; import { IURLService, IURLHandler } from 'vs/platform/url/common/url'; export interface IURLServiceChannel extends IChannel { - call(command: 'open', url: string): TPromise; - call(command: string, arg?: any): TPromise; + call(command: 'open', url: string): Thenable; + call(command: string, arg?: any): Thenable; } export class URLServiceChannel implements IURLServiceChannel { @@ -25,7 +25,7 @@ export class URLServiceChannel implements IURLServiceChannel { throw new Error('No events'); } - call(command: string, arg?: any): TPromise { + call(command: string, arg?: any): Thenable { switch (command) { case 'open': return this.service.open(URI.revive(arg)); } @@ -40,7 +40,7 @@ export class URLServiceChannelClient implements IURLService { constructor(private channel: IChannel) { } open(url: URI): TPromise { - return this.channel.call('open', url.toJSON()); + return TPromise.wrap(this.channel.call('open', url.toJSON())); } registerHandler(handler: IURLHandler): IDisposable { @@ -49,8 +49,8 @@ export class URLServiceChannelClient implements IURLService { } export interface IURLHandlerChannel extends IChannel { - call(command: 'handleURL', arg: any): TPromise; - call(command: string, arg?: any): TPromise; + call(command: 'handleURL', arg: any): Thenable; + call(command: string, arg?: any): Thenable; } export class URLHandlerChannel implements IURLHandlerChannel { @@ -61,7 +61,7 @@ export class URLHandlerChannel implements IURLHandlerChannel { throw new Error('No events'); } - call(command: string, arg?: any): TPromise { + call(command: string, arg?: any): Thenable { switch (command) { case 'handleURL': return this.handler.handleURL(URI.revive(arg)); } @@ -74,6 +74,6 @@ export class URLHandlerChannelClient implements IURLHandler { constructor(private channel: IChannel) { } handleURL(uri: URI): TPromise { - return this.channel.call('handleURL', uri.toJSON()); + return TPromise.wrap(this.channel.call('handleURL', uri.toJSON())); } } \ No newline at end of file diff --git a/src/vs/platform/windows/node/windowsIpc.ts b/src/vs/platform/windows/node/windowsIpc.ts index 9d882d0c928..f5546a01615 100644 --- a/src/vs/platform/windows/node/windowsIpc.ts +++ b/src/vs/platform/windows/node/windowsIpc.ts @@ -24,57 +24,57 @@ export interface IWindowsChannel extends IChannel { listen(event: 'onRecentlyOpenedChange'): Event; listen(event: string, arg?: any): Event; - call(command: 'pickFileFolderAndOpen', arg: INativeOpenDialogOptions): TPromise; - call(command: 'pickFileAndOpen', arg: INativeOpenDialogOptions): TPromise; - call(command: 'pickFolderAndOpen', arg: INativeOpenDialogOptions): TPromise; - call(command: 'pickWorkspaceAndOpen', arg: INativeOpenDialogOptions): TPromise; - call(command: 'showMessageBox', arg: [number, MessageBoxOptions]): TPromise; - call(command: 'showSaveDialog', arg: [number, SaveDialogOptions]): TPromise; - call(command: 'showOpenDialog', arg: [number, OpenDialogOptions]): TPromise; - call(command: 'reloadWindow', arg: [number, ParsedArgs]): TPromise; - call(command: 'openDevTools', arg: [number, IDevToolsOptions]): TPromise; - call(command: 'toggleDevTools', arg: number): TPromise; - call(command: 'closeWorkspace', arg: number): TPromise; - call(command: 'enterWorkspace', arg: [number, string]): TPromise; - call(command: 'createAndEnterWorkspace', arg: [number, IWorkspaceFolderCreationData[], string]): TPromise; - call(command: 'saveAndEnterWorkspace', arg: [number, string]): TPromise; - call(command: 'toggleFullScreen', arg: number): TPromise; - call(command: 'setRepresentedFilename', arg: [number, string]): TPromise; - call(command: 'addRecentlyOpened', arg: UriComponents[]): TPromise; - call(command: 'removeFromRecentlyOpened', arg: (IWorkspaceIdentifier | UriComponents | string)[]): TPromise; - call(command: 'clearRecentlyOpened'): TPromise; - call(command: 'getRecentlyOpened', arg: number): TPromise; - call(command: 'newWindowTab'): TPromise; - call(command: 'showPreviousWindowTab'): TPromise; - call(command: 'showNextWindowTab'): TPromise; - call(command: 'moveWindowTabToNewWindow'): TPromise; - call(command: 'mergeAllWindowTabs'): TPromise; - call(command: 'toggleWindowTabsBar'): TPromise; - call(command: 'updateTouchBar', arg: [number, ISerializableCommandAction[][]]): TPromise; - call(command: 'focusWindow', arg: number): TPromise; - call(command: 'closeWindow', arg: number): TPromise; - call(command: 'isFocused', arg: number): TPromise; - call(command: 'isMaximized', arg: number): TPromise; - call(command: 'maximizeWindow', arg: number): TPromise; - call(command: 'unmaximizeWindow', arg: number): TPromise; - call(command: 'minimizeWindow', arg: number): TPromise; - call(command: 'onWindowTitleDoubleClick', arg: number): TPromise; - call(command: 'setDocumentEdited', arg: [number, boolean]): TPromise; - call(command: 'quit'): TPromise; - call(command: 'openWindow', arg: [number, URI[], { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }]): TPromise; - call(command: 'openNewWindow'): TPromise; - call(command: 'showWindow', arg: number): TPromise; - call(command: 'getWindows'): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>; - call(command: 'getWindowCount'): TPromise; - call(command: 'relaunch', arg: [{ addArgs?: string[], removeArgs?: string[] }]): TPromise; - call(command: 'whenSharedProcessReady'): TPromise; - call(command: 'toggleSharedProcess'): TPromise; - call(command: 'log', arg: [string, string[]]): TPromise; - call(command: 'showItemInFolder', arg: string): TPromise; - call(command: 'getActiveWindowId'): TPromise; - call(command: 'openExternal', arg: string): TPromise; - call(command: 'startCrashReporter', arg: CrashReporterStartOptions): TPromise; - call(command: 'openAboutDialog'): TPromise; + call(command: 'pickFileFolderAndOpen', arg: INativeOpenDialogOptions): Thenable; + call(command: 'pickFileAndOpen', arg: INativeOpenDialogOptions): Thenable; + call(command: 'pickFolderAndOpen', arg: INativeOpenDialogOptions): Thenable; + call(command: 'pickWorkspaceAndOpen', arg: INativeOpenDialogOptions): Thenable; + call(command: 'showMessageBox', arg: [number, MessageBoxOptions]): Thenable; + call(command: 'showSaveDialog', arg: [number, SaveDialogOptions]): Thenable; + call(command: 'showOpenDialog', arg: [number, OpenDialogOptions]): Thenable; + call(command: 'reloadWindow', arg: [number, ParsedArgs]): Thenable; + call(command: 'openDevTools', arg: [number, IDevToolsOptions]): Thenable; + call(command: 'toggleDevTools', arg: number): Thenable; + call(command: 'closeWorkspace', arg: number): Thenable; + call(command: 'enterWorkspace', arg: [number, string]): Thenable; + call(command: 'createAndEnterWorkspace', arg: [number, IWorkspaceFolderCreationData[], string]): Thenable; + call(command: 'saveAndEnterWorkspace', arg: [number, string]): Thenable; + call(command: 'toggleFullScreen', arg: number): Thenable; + call(command: 'setRepresentedFilename', arg: [number, string]): Thenable; + call(command: 'addRecentlyOpened', arg: UriComponents[]): Thenable; + call(command: 'removeFromRecentlyOpened', arg: (IWorkspaceIdentifier | UriComponents | string)[]): Thenable; + call(command: 'clearRecentlyOpened'): Thenable; + call(command: 'getRecentlyOpened', arg: number): Thenable; + call(command: 'newWindowTab'): Thenable; + call(command: 'showPreviousWindowTab'): Thenable; + call(command: 'showNextWindowTab'): Thenable; + call(command: 'moveWindowTabToNewWindow'): Thenable; + call(command: 'mergeAllWindowTabs'): Thenable; + call(command: 'toggleWindowTabsBar'): Thenable; + call(command: 'updateTouchBar', arg: [number, ISerializableCommandAction[][]]): Thenable; + call(command: 'focusWindow', arg: number): Thenable; + call(command: 'closeWindow', arg: number): Thenable; + call(command: 'isFocused', arg: number): Thenable; + call(command: 'isMaximized', arg: number): Thenable; + call(command: 'maximizeWindow', arg: number): Thenable; + call(command: 'unmaximizeWindow', arg: number): Thenable; + call(command: 'minimizeWindow', arg: number): Thenable; + call(command: 'onWindowTitleDoubleClick', arg: number): Thenable; + call(command: 'setDocumentEdited', arg: [number, boolean]): Thenable; + call(command: 'quit'): Thenable; + call(command: 'openWindow', arg: [number, URI[], { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }]): Thenable; + call(command: 'openNewWindow'): Thenable; + call(command: 'showWindow', arg: number): Thenable; + call(command: 'getWindows'): Thenable<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>; + call(command: 'getWindowCount'): Thenable; + call(command: 'relaunch', arg: [{ addArgs?: string[], removeArgs?: string[] }]): Thenable; + call(command: 'whenSharedProcessReady'): Thenable; + call(command: 'toggleSharedProcess'): Thenable; + call(command: 'log', arg: [string, string[]]): Thenable; + call(command: 'showItemInFolder', arg: string): Thenable; + call(command: 'getActiveWindowId'): Thenable; + call(command: 'openExternal', arg: string): Thenable; + call(command: 'startCrashReporter', arg: CrashReporterStartOptions): Thenable; + call(command: 'openAboutDialog'): Thenable; } export class WindowsChannel implements IWindowsChannel { @@ -108,7 +108,7 @@ export class WindowsChannel implements IWindowsChannel { throw new Error('No event found'); } - call(command: string, arg?: any): TPromise { + call(command: string, arg?: any): Thenable { switch (command) { case 'pickFileFolderAndOpen': return this.service.pickFileFolderAndOpen(arg); case 'pickFileAndOpen': return this.service.pickFileAndOpen(arg); @@ -199,83 +199,83 @@ export class WindowsChannelClient implements IWindowsService { get onRecentlyOpenedChange(): Event { return this.channel.listen('onRecentlyOpenedChange'); } pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise { - return this.channel.call('pickFileFolderAndOpen', options); + return TPromise.wrap(this.channel.call('pickFileFolderAndOpen', options)); } pickFileAndOpen(options: INativeOpenDialogOptions): TPromise { - return this.channel.call('pickFileAndOpen', options); + return TPromise.wrap(this.channel.call('pickFileAndOpen', options)); } pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise { - return this.channel.call('pickFolderAndOpen', options); + return TPromise.wrap(this.channel.call('pickFolderAndOpen', options)); } pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise { - return this.channel.call('pickWorkspaceAndOpen', options); + return TPromise.wrap(this.channel.call('pickWorkspaceAndOpen', options)); } showMessageBox(windowId: number, options: MessageBoxOptions): TPromise { - return this.channel.call('showMessageBox', [windowId, options]); + return TPromise.wrap(this.channel.call('showMessageBox', [windowId, options])); } showSaveDialog(windowId: number, options: SaveDialogOptions): TPromise { - return this.channel.call('showSaveDialog', [windowId, options]); + return TPromise.wrap(this.channel.call('showSaveDialog', [windowId, options])); } showOpenDialog(windowId: number, options: OpenDialogOptions): TPromise { - return this.channel.call('showOpenDialog', [windowId, options]); + return TPromise.wrap(this.channel.call('showOpenDialog', [windowId, options])); } reloadWindow(windowId: number, args?: ParsedArgs): TPromise { - return this.channel.call('reloadWindow', [windowId, args]); + return TPromise.wrap(this.channel.call('reloadWindow', [windowId, args])); } openDevTools(windowId: number, options?: IDevToolsOptions): TPromise { - return this.channel.call('openDevTools', [windowId, options]); + return TPromise.wrap(this.channel.call('openDevTools', [windowId, options])); } toggleDevTools(windowId: number): TPromise { - return this.channel.call('toggleDevTools', windowId); + return TPromise.wrap(this.channel.call('toggleDevTools', windowId)); } closeWorkspace(windowId: number): TPromise { - return this.channel.call('closeWorkspace', windowId); + return TPromise.wrap(this.channel.call('closeWorkspace', windowId)); } enterWorkspace(windowId: number, path: string): TPromise { - return this.channel.call('enterWorkspace', [windowId, path]); + return TPromise.wrap(this.channel.call('enterWorkspace', [windowId, path])); } createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise { - return this.channel.call('createAndEnterWorkspace', [windowId, folders, path]); + return TPromise.wrap(this.channel.call('createAndEnterWorkspace', [windowId, folders, path])); } saveAndEnterWorkspace(windowId: number, path: string): TPromise { - return this.channel.call('saveAndEnterWorkspace', [windowId, path]); + return TPromise.wrap(this.channel.call('saveAndEnterWorkspace', [windowId, path])); } toggleFullScreen(windowId: number): TPromise { - return this.channel.call('toggleFullScreen', windowId); + return TPromise.wrap(this.channel.call('toggleFullScreen', windowId)); } setRepresentedFilename(windowId: number, fileName: string): TPromise { - return this.channel.call('setRepresentedFilename', [windowId, fileName]); + return TPromise.wrap(this.channel.call('setRepresentedFilename', [windowId, fileName])); } addRecentlyOpened(files: URI[]): TPromise { - return this.channel.call('addRecentlyOpened', files); + return TPromise.wrap(this.channel.call('addRecentlyOpened', files)); } removeFromRecentlyOpened(paths: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI)[]): TPromise { - return this.channel.call('removeFromRecentlyOpened', paths); + return TPromise.wrap(this.channel.call('removeFromRecentlyOpened', paths)); } clearRecentlyOpened(): TPromise { - return this.channel.call('clearRecentlyOpened'); + return TPromise.wrap(this.channel.call('clearRecentlyOpened')); } getRecentlyOpened(windowId: number): TPromise { - return this.channel.call('getRecentlyOpened', windowId) + return TPromise.wrap(this.channel.call('getRecentlyOpened', windowId)) .then(recentlyOpened => { recentlyOpened.workspaces = recentlyOpened.workspaces.map(workspace => isWorkspaceIdentifier(workspace) ? workspace : URI.revive(workspace)); recentlyOpened.files = recentlyOpened.files.map(URI.revive); @@ -284,126 +284,126 @@ export class WindowsChannelClient implements IWindowsService { } newWindowTab(): TPromise { - return this.channel.call('newWindowTab'); + return TPromise.wrap(this.channel.call('newWindowTab')); } showPreviousWindowTab(): TPromise { - return this.channel.call('showPreviousWindowTab'); + return TPromise.wrap(this.channel.call('showPreviousWindowTab')); } showNextWindowTab(): TPromise { - return this.channel.call('showNextWindowTab'); + return TPromise.wrap(this.channel.call('showNextWindowTab')); } moveWindowTabToNewWindow(): TPromise { - return this.channel.call('moveWindowTabToNewWindow'); + return TPromise.wrap(this.channel.call('moveWindowTabToNewWindow')); } mergeAllWindowTabs(): TPromise { - return this.channel.call('mergeAllWindowTabs'); + return TPromise.wrap(this.channel.call('mergeAllWindowTabs')); } toggleWindowTabsBar(): TPromise { - return this.channel.call('toggleWindowTabsBar'); + return TPromise.wrap(this.channel.call('toggleWindowTabsBar')); } focusWindow(windowId: number): TPromise { - return this.channel.call('focusWindow', windowId); + return TPromise.wrap(this.channel.call('focusWindow', windowId)); } closeWindow(windowId: number): TPromise { - return this.channel.call('closeWindow', windowId); + return TPromise.wrap(this.channel.call('closeWindow', windowId)); } isFocused(windowId: number): TPromise { - return this.channel.call('isFocused', windowId); + return TPromise.wrap(this.channel.call('isFocused', windowId)); } isMaximized(windowId: number): TPromise { - return this.channel.call('isMaximized', windowId); + return TPromise.wrap(this.channel.call('isMaximized', windowId)); } maximizeWindow(windowId: number): TPromise { - return this.channel.call('maximizeWindow', windowId); + return TPromise.wrap(this.channel.call('maximizeWindow', windowId)); } unmaximizeWindow(windowId: number): TPromise { - return this.channel.call('unmaximizeWindow', windowId); + return TPromise.wrap(this.channel.call('unmaximizeWindow', windowId)); } minimizeWindow(windowId: number): TPromise { - return this.channel.call('minimizeWindow', windowId); + return TPromise.wrap(this.channel.call('minimizeWindow', windowId)); } onWindowTitleDoubleClick(windowId: number): TPromise { - return this.channel.call('onWindowTitleDoubleClick', windowId); + return TPromise.wrap(this.channel.call('onWindowTitleDoubleClick', windowId)); } setDocumentEdited(windowId: number, flag: boolean): TPromise { - return this.channel.call('setDocumentEdited', [windowId, flag]); + return TPromise.wrap(this.channel.call('setDocumentEdited', [windowId, flag])); } quit(): TPromise { - return this.channel.call('quit'); + return TPromise.wrap(this.channel.call('quit')); } relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise { - return this.channel.call('relaunch', [options]); + return TPromise.wrap(this.channel.call('relaunch', [options])); } whenSharedProcessReady(): TPromise { - return this.channel.call('whenSharedProcessReady'); + return TPromise.wrap(this.channel.call('whenSharedProcessReady')); } toggleSharedProcess(): TPromise { - return this.channel.call('toggleSharedProcess'); + return TPromise.wrap(this.channel.call('toggleSharedProcess')); } openWindow(windowId: number, paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): TPromise { - return this.channel.call('openWindow', [windowId, paths, options]); + return TPromise.wrap(this.channel.call('openWindow', [windowId, paths, options])); } openNewWindow(): TPromise { - return this.channel.call('openNewWindow'); + return TPromise.wrap(this.channel.call('openNewWindow')); } showWindow(windowId: number): TPromise { - return this.channel.call('showWindow', windowId); + return TPromise.wrap(this.channel.call('showWindow', windowId)); } getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> { - return this.channel.call('getWindows').then(result => { result.forEach(win => win.folderUri = win.folderUri ? URI.revive(win.folderUri) : win.folderUri); return result; }); + return TPromise.wrap(this.channel.call('getWindows').then(result => { result.forEach(win => win.folderUri = win.folderUri ? URI.revive(win.folderUri) : win.folderUri); return result; })); } getWindowCount(): TPromise { - return this.channel.call('getWindowCount'); + return TPromise.wrap(this.channel.call('getWindowCount')); } log(severity: string, ...messages: string[]): TPromise { - return this.channel.call('log', [severity, messages]); + return TPromise.wrap(this.channel.call('log', [severity, messages])); } showItemInFolder(path: string): TPromise { - return this.channel.call('showItemInFolder', path); + return TPromise.wrap(this.channel.call('showItemInFolder', path)); } getActiveWindowId(): TPromise { - return this.channel.call('getActiveWindowId'); + return TPromise.wrap(this.channel.call('getActiveWindowId')); } openExternal(url: string): TPromise { - return this.channel.call('openExternal', url); + return TPromise.wrap(this.channel.call('openExternal', url)); } startCrashReporter(config: CrashReporterStartOptions): TPromise { - return this.channel.call('startCrashReporter', config); + return TPromise.wrap(this.channel.call('startCrashReporter', config)); } updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): TPromise { - return this.channel.call('updateTouchBar', [windowId, items]); + return TPromise.wrap(this.channel.call('updateTouchBar', [windowId, items])); } openAboutDialog(): TPromise { - return this.channel.call('openAboutDialog'); + return TPromise.wrap(this.channel.call('openAboutDialog')); } } diff --git a/src/vs/platform/workspaces/node/workspacesIpc.ts b/src/vs/platform/workspaces/node/workspacesIpc.ts index 8a101fc26dc..6ef88453c47 100644 --- a/src/vs/platform/workspaces/node/workspacesIpc.ts +++ b/src/vs/platform/workspaces/node/workspacesIpc.ts @@ -12,8 +12,8 @@ import { URI } from 'vs/base/common/uri'; import { Event } from 'vs/base/common/event'; export interface IWorkspacesChannel extends IChannel { - call(command: 'createWorkspace', arg: [IWorkspaceFolderCreationData[]]): TPromise; - call(command: string, arg?: any): TPromise; + call(command: 'createWorkspace', arg: [IWorkspaceFolderCreationData[]]): Thenable; + call(command: string, arg?: any): Thenable; } export class WorkspacesChannel implements IWorkspacesChannel { @@ -24,7 +24,7 @@ export class WorkspacesChannel implements IWorkspacesChannel { throw new Error('No events'); } - call(command: string, arg?: any): TPromise { + call(command: string, arg?: any): Thenable { switch (command) { case 'createWorkspace': { const rawFolders: IWorkspaceFolderCreationData[] = arg; @@ -53,6 +53,6 @@ export class WorkspacesChannelClient implements IWorkspacesService { constructor(private channel: IWorkspacesChannel) { } createWorkspace(folders?: IWorkspaceFolderCreationData[]): TPromise { - return this.channel.call('createWorkspace', folders); + return TPromise.wrap(this.channel.call('createWorkspace', folders)); } } \ No newline at end of file