diff --git a/src/vs/base/common/actions.ts b/src/vs/base/common/actions.ts index 1a5e7e1acd1..424f4bfd18c 100644 --- a/src/vs/base/common/actions.ts +++ b/src/vs/base/common/actions.ts @@ -239,6 +239,12 @@ export class ActionRunner extends EventEmitter implements IActionRunner { } protected runAction(action: IAction, context?: any): TPromise { - return TPromise.as(context ? action.run(context) : action.run()); + const res = context ? action.run(context) : action.run(); + + if (TPromise.is(res)) { + return res; + } + + return TPromise.wrap(res); } } diff --git a/src/vs/base/common/async.ts b/src/vs/base/common/async.ts index c19feda0c94..956faf03d61 100644 --- a/src/vs/base/common/async.ts +++ b/src/vs/base/common/async.ts @@ -146,7 +146,7 @@ export class Throttler { // TODO@Joao: can the previous throttler be replaced with this? export class SimpleThrottler { - private current = TPromise.as(null); + private current = TPromise.wrap(null); queue(promiseTask: ITask>): TPromise { return this.current = this.current.then(() => promiseTask()); diff --git a/src/vs/base/common/winjs.base.d.ts b/src/vs/base/common/winjs.base.d.ts index a0ec0a59013..b176120a06b 100644 --- a/src/vs/base/common/winjs.base.d.ts +++ b/src/vs/base/common/winjs.base.d.ts @@ -29,6 +29,7 @@ export declare class Promise { public static as(value: null): Promise; public static as(value: undefined): Promise; + public static as(value: PromiseLike): PromiseLike; public static as>(value: SomePromise): SomePromise; public static as(value: T): Promise; diff --git a/src/vs/code/electron-main/main.ts b/src/vs/code/electron-main/main.ts index ea526f1c4c0..d225426b878 100644 --- a/src/vs/code/electron-main/main.ts +++ b/src/vs/code/electron-main/main.ts @@ -73,7 +73,7 @@ function setupIPC(accessor: ServicesAccessor): TPromise { const environmentService = accessor.get(IEnvironmentService); function allowSetForegroundWindow(service: LaunchChannelClient): TPromise { - let promise = TPromise.as(void 0); + let promise = TPromise.wrap(void 0); if (platform.isWindows) { promise = service.getMainProcessId() .then(processId => { diff --git a/src/vs/editor/common/commonCodeEditor.ts b/src/vs/editor/common/commonCodeEditor.ts index f9dc3df6ff3..b59e5fa0c82 100644 --- a/src/vs/editor/common/commonCodeEditor.ts +++ b/src/vs/editor/common/commonCodeEditor.ts @@ -713,7 +713,7 @@ export abstract class CommonCodeEditor extends Disposable implements editorCommo const action = this.getAction(handlerId); if (action) { - TPromise.as(action.run()).done(null, onUnexpectedError); + TPromise.as(action.run()).then(null, onUnexpectedError); return; } diff --git a/src/vs/editor/contrib/goToDeclaration/browser/goToDeclarationMouse.ts b/src/vs/editor/contrib/goToDeclaration/browser/goToDeclarationMouse.ts index 872ce48705f..56118e8aad9 100644 --- a/src/vs/editor/contrib/goToDeclaration/browser/goToDeclarationMouse.ts +++ b/src/vs/editor/contrib/goToDeclaration/browser/goToDeclarationMouse.ts @@ -103,7 +103,7 @@ class GotoDefinitionWithMouseEditorContribution implements editorCommon.IEditorC this.throttler.queue(() => { return state.validate(this.editor) ? this.findDefinition(mouseEvent.target) - : TPromise.as(null); + : TPromise.wrap(null); }).then(results => { if (!results || !results.length || !state.validate(this.editor)) { diff --git a/src/vs/editor/standalone/browser/simpleServices.ts b/src/vs/editor/standalone/browser/simpleServices.ts index a6c1766d569..43cf5921f94 100644 --- a/src/vs/editor/standalone/browser/simpleServices.ts +++ b/src/vs/editor/standalone/browser/simpleServices.ts @@ -539,7 +539,7 @@ export class StandaloneTelemetryService implements ITelemetryService { public isOptedIn = false; public publicLog(eventName: string, data?: any): TPromise { - return TPromise.as(null); + return TPromise.wrap(null); } public getTelemetryInfo(): TPromise { diff --git a/src/vs/monaco.d.ts b/src/vs/monaco.d.ts index 9142f59537b..af61f8b2a8d 100644 --- a/src/vs/monaco.d.ts +++ b/src/vs/monaco.d.ts @@ -61,6 +61,7 @@ declare module monaco { public static as(value: null): Promise; public static as(value: undefined): Promise; + public static as(value: PromiseLike): PromiseLike; public static as>(value: SomePromise): SomePromise; public static as(value: T): Promise; diff --git a/src/vs/platform/opener/browser/openerService.ts b/src/vs/platform/opener/browser/openerService.ts index 940eea38958..fa76e7730b4 100644 --- a/src/vs/platform/opener/browser/openerService.ts +++ b/src/vs/platform/opener/browser/openerService.ts @@ -39,7 +39,7 @@ export class OpenerService implements IOpenerService { this._telemetryService.publicLog('openerService', { scheme: resource.scheme }); const { scheme, path, query, fragment } = resource; - let promise: TPromise; + let promise: TPromise = TPromise.wrap(void 0); if (scheme === Schemas.http || scheme === Schemas.https || scheme === Schemas.mailto) { // open http or default mail application @@ -84,6 +84,6 @@ export class OpenerService implements IOpenerService { promise = this._editorService.openEditor({ resource, options: { selection, } }, options && options.openToSide); } - return TPromise.as(promise); + return promise; } } diff --git a/src/vs/platform/telemetry/common/telemetryUtils.ts b/src/vs/platform/telemetry/common/telemetryUtils.ts index e3a5e9ec26d..4f55ea15c23 100644 --- a/src/vs/platform/telemetry/common/telemetryUtils.ts +++ b/src/vs/platform/telemetry/common/telemetryUtils.ts @@ -17,11 +17,11 @@ import { ITelemetryService, ITelemetryInfo, ITelemetryData } from 'vs/platform/t export const NullTelemetryService = new class implements ITelemetryService { _serviceBrand: undefined; publicLog(eventName: string, data?: ITelemetryData) { - return TPromise.as(null); + return TPromise.wrap(null); } isOptedIn: true; getTelemetryInfo(): TPromise { - return TPromise.as({ + return TPromise.wrap({ instanceId: 'someValue.instanceId', sessionId: 'someValue.sessionId', machineId: 'someValue.machineId' diff --git a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts index 3008bbebe2b..3556feea70b 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadDebugService.ts @@ -66,12 +66,12 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape { } this.debugService.getConfigurationManager().registerDebugConfigurationProvider(handle, provider); - return TPromise.as(undefined); + return TPromise.wrap(undefined); } public $unregisterDebugConfigurationProvider(handle: number): TPromise { this.debugService.getConfigurationManager().unregisterDebugConfigurationProvider(handle); - return TPromise.as(undefined); + return TPromise.wrap(undefined); } public $startDebugging(folderUri: uri | undefined, nameOrConfiguration: string | IConfig): TPromise { @@ -100,6 +100,6 @@ export class MainThreadDebugService implements MainThreadDebugServiceShape { public $appendDebugConsole(value: string): TPromise { // Use warning as severity to get the orange color for messages coming from the debug extension this.debugService.logToRepl(value, severity.Warning); - return TPromise.as(undefined); + return TPromise.wrap(undefined); } } diff --git a/src/vs/workbench/api/electron-browser/mainThreadTask.ts b/src/vs/workbench/api/electron-browser/mainThreadTask.ts index be7d48776f7..20cccb38906 100644 --- a/src/vs/workbench/api/electron-browser/mainThreadTask.ts +++ b/src/vs/workbench/api/electron-browser/mainThreadTask.ts @@ -54,12 +54,12 @@ export class MainThreadTask implements MainThreadTaskShape { } }); this._activeHandles[handle] = true; - return TPromise.as(undefined); + return TPromise.wrap(undefined); } public $unregisterTaskProvider(handle: number): TPromise { this._taskService.unregisterTaskProvider(handle); delete this._activeHandles[handle]; - return TPromise.as(undefined); + return TPromise.wrap(undefined); } } diff --git a/src/vs/workbench/api/node/extHostExtensionActivator.ts b/src/vs/workbench/api/node/extHostExtensionActivator.ts index 4d674591ad1..9f2f643d18c 100644 --- a/src/vs/workbench/api/node/extHostExtensionActivator.ts +++ b/src/vs/workbench/api/node/extHostExtensionActivator.ts @@ -12,7 +12,7 @@ import { ExtensionDescriptionRegistry } from 'vs/workbench/services/extensions/n import { IExtensionDescription } from 'vs/platform/extensions/common/extensions'; const hasOwnProperty = Object.hasOwnProperty; -const NO_OP_VOID_PROMISE = TPromise.as(void 0); +const NO_OP_VOID_PROMISE = TPromise.wrap(void 0); export interface IExtensionMemento { get(key: string, defaultValue: T): T; diff --git a/src/vs/workbench/api/node/extHostExtensionService.ts b/src/vs/workbench/api/node/extHostExtensionService.ts index 809a99ec59b..f17d72feded 100644 --- a/src/vs/workbench/api/node/extHostExtensionService.ts +++ b/src/vs/workbench/api/node/extHostExtensionService.ts @@ -339,7 +339,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape { }); } - private static _callActivate(extensionModule: IExtensionModule, context: IExtensionContext, activationTimesBuilder: ExtensionActivationTimesBuilder): TPromise { + private static _callActivate(extensionModule: IExtensionModule, context: IExtensionContext, activationTimesBuilder: ExtensionActivationTimesBuilder): Thenable { // Make sure the extension's surface is not undefined extensionModule = extensionModule || { activate: undefined, @@ -351,7 +351,7 @@ export class ExtHostExtensionService implements ExtHostExtensionServiceShape { }); } - private static _callActivateOptional(extensionModule: IExtensionModule, context: IExtensionContext, activationTimesBuilder: ExtensionActivationTimesBuilder): TPromise { + private static _callActivateOptional(extensionModule: IExtensionModule, context: IExtensionContext, activationTimesBuilder: ExtensionActivationTimesBuilder): Thenable { if (typeof extensionModule.activate === 'function') { try { activationTimesBuilder.activateCallStart(); diff --git a/src/vs/workbench/browser/layout.ts b/src/vs/workbench/browser/layout.ts index 9a4245d5b17..87c49af6222 100644 --- a/src/vs/workbench/browser/layout.ts +++ b/src/vs/workbench/browser/layout.ts @@ -256,7 +256,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal let sidebarPosition = this.partService.getSideBarPosition(); let isSidebarVisible = this.partService.isVisible(Parts.SIDEBAR_PART); let newSashWidth = (sidebarPosition === Position.LEFT) ? startSidebarWidth + e.currentX - startX : startSidebarWidth - e.currentX + startX; - let promise = TPromise.as(null); + let promise = TPromise.wrap(null); // Sidebar visible if (isSidebarVisible) { @@ -295,7 +295,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal let doLayout = false; let isPanelVisible = this.partService.isVisible(Parts.PANEL_PART); let newSashHeight = startPanelHeight - (e.currentY - startY); - let promise = TPromise.as(null); + let promise = TPromise.wrap(null); // Panel visible if (isPanelVisible) { @@ -333,7 +333,7 @@ export class WorkbenchLayout implements IVerticalSashLayoutProvider, IHorizontal let doLayout = false; let isPanelVisible = this.partService.isVisible(Parts.PANEL_PART); let newSashWidth = startPanelWidth - (e.currentX - startXTwo); - let promise = TPromise.as(null); + let promise = TPromise.wrap(null); // Panel visible if (isPanelVisible) { diff --git a/src/vs/workbench/browser/parts/editor/baseEditor.ts b/src/vs/workbench/browser/parts/editor/baseEditor.ts index b581b9743c0..b38ca7a0638 100644 --- a/src/vs/workbench/browser/parts/editor/baseEditor.ts +++ b/src/vs/workbench/browser/parts/editor/baseEditor.ts @@ -52,7 +52,7 @@ export abstract class BaseEditor extends Panel implements IEditor { this._input = input; this._options = options; - return TPromise.as(null); + return TPromise.wrap(null); } /** diff --git a/src/vs/workbench/browser/parts/editor/binaryEditor.ts b/src/vs/workbench/browser/parts/editor/binaryEditor.ts index 665e11b5d6f..c377ac8d5cd 100644 --- a/src/vs/workbench/browser/parts/editor/binaryEditor.ts +++ b/src/vs/workbench/browser/parts/editor/binaryEditor.ts @@ -68,7 +68,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor { // Return early for same input unless we force to open const forceOpen = options && options.forceOpen; if (!forceOpen && input.matches(this.input)) { - return TPromise.as(null); + return TPromise.wrap(null); } // Otherwise set input and resolve diff --git a/src/vs/workbench/browser/parts/editor/editorPart.ts b/src/vs/workbench/browser/parts/editor/editorPart.ts index 24347e31208..14575627faa 100644 --- a/src/vs/workbench/browser/parts/editor/editorPart.ts +++ b/src/vs/workbench/browser/parts/editor/editorPart.ts @@ -336,7 +336,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService !this.editorGroupsControl || // too early this.editorGroupsControl.isDragging() // pending editor DND ) { - return TPromise.as(null); + return TPromise.wrap(null); } // Editor opening event (can be prevented and overridden) @@ -384,7 +384,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService // Return early if the editor is to be open inactive and there are other editors in this group to show if (!active) { - return TPromise.as(null); + return TPromise.wrap(null); } // Progress Monitor & Ref Counting @@ -401,7 +401,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService // Show editor const editor = this.doShowEditor(group, descriptor, input, options, ratio, monitor); if (!editor) { - return TPromise.as(null); // canceled or other error + return TPromise.wrap(null); // canceled or other error } // Set input to editor @@ -582,7 +582,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService public closeEditor(position: Position, input: EditorInput): TPromise { const group = this.stacks.groupAt(position); if (!group) { - return TPromise.as(null); + return TPromise.wrap(null); } // Check for dirty and veto @@ -719,7 +719,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService public closeEditors(position: Position, filter: { except?: EditorInput, direction?: Direction, unmodifiedOnly?: boolean } = Object.create(null)): TPromise { const group = this.stacks.groupAt(position); if (!group) { - return TPromise.as(null); + return TPromise.wrap(null); } let editors = group.getEditors(); diff --git a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts index bfc099a30fb..fced906900a 100644 --- a/src/vs/workbench/browser/parts/editor/textDiffEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textDiffEditor.ts @@ -120,7 +120,7 @@ export class TextDiffEditor extends BaseTextEditor { textOptions.apply(this.getControl(), ScrollType.Smooth); } - return TPromise.as(null); + return TPromise.wrap(null); } // Dispose previous diff navigator diff --git a/src/vs/workbench/browser/parts/editor/textResourceEditor.ts b/src/vs/workbench/browser/parts/editor/textResourceEditor.ts index cfabfc41b0e..a0628a8dac7 100644 --- a/src/vs/workbench/browser/parts/editor/textResourceEditor.ts +++ b/src/vs/workbench/browser/parts/editor/textResourceEditor.ts @@ -64,7 +64,7 @@ export class TextResourceEditor extends BaseTextEditor { textOptions.apply(this.getControl(), ScrollType.Smooth); } - return TPromise.as(null); + return TPromise.wrap(null); } // Remember view settings if input changes diff --git a/src/vs/workbench/browser/parts/panel/panelPart.ts b/src/vs/workbench/browser/parts/panel/panelPart.ts index 59db62eedd2..acddf2f4355 100644 --- a/src/vs/workbench/browser/parts/panel/panelPart.ts +++ b/src/vs/workbench/browser/parts/panel/panelPart.ts @@ -138,7 +138,7 @@ export class PanelPart extends CompositePart implements IPanelService { } // First check if panel is hidden and show if so - let promise = TPromise.as(null); + let promise = TPromise.wrap(null); if (!this.partService.isVisible(Parts.PANEL_PART)) { try { this.blockOpeningPanel = true; diff --git a/src/vs/workbench/browser/parts/sidebar/sidebarPart.ts b/src/vs/workbench/browser/parts/sidebar/sidebarPart.ts index 395f82e65cd..c909599b64c 100644 --- a/src/vs/workbench/browser/parts/sidebar/sidebarPart.ts +++ b/src/vs/workbench/browser/parts/sidebar/sidebarPart.ts @@ -103,7 +103,7 @@ export class SidebarPart extends CompositePart { } // First check if sidebar is hidden and show if so - let promise = TPromise.as(null); + let promise = TPromise.wrap(null); if (!this.partService.isVisible(Parts.SIDEBAR_PART)) { try { this.blockOpeningViewlet = true; diff --git a/src/vs/workbench/browser/parts/views/viewsViewlet.ts b/src/vs/workbench/browser/parts/views/viewsViewlet.ts index 3319af932d4..eb97ca2f10b 100644 --- a/src/vs/workbench/browser/parts/views/viewsViewlet.ts +++ b/src/vs/workbench/browser/parts/views/viewsViewlet.ts @@ -95,7 +95,7 @@ export abstract class ViewsViewletPanel extends ViewletPanel { this.updateTreeVisibility(this.tree, visible && this.isExpanded()); } - return TPromise.as(null); + return TPromise.wrap(null); } focus(): void { diff --git a/src/vs/workbench/electron-browser/workbench.ts b/src/vs/workbench/electron-browser/workbench.ts index bc7cac8d8da..9428d8e6fdb 100644 --- a/src/vs/workbench/electron-browser/workbench.ts +++ b/src/vs/workbench/electron-browser/workbench.ts @@ -794,7 +794,7 @@ export class Workbench implements IPartService { } // If sidebar becomes hidden, also hide the current active Viewlet if any - let promise = TPromise.as(null); + let promise = TPromise.wrap(null); if (hidden && this.sidebarPart.getActiveViewlet()) { promise = this.sidebarPart.hideActiveViewlet().then(() => { const activeEditor = this.editorPart.getActiveEditor(); @@ -845,7 +845,7 @@ export class Workbench implements IPartService { } // If panel part becomes hidden, also hide the current active panel if any - let promise = TPromise.as(null); + let promise = TPromise.wrap(null); if (hidden && this.panelPart.getActivePanel()) { promise = this.panelPart.hideActivePanel().then(() => { // Pass Focus to Editor if Panel part is now hidden diff --git a/src/vs/workbench/parts/debug/electron-browser/replViewer.ts b/src/vs/workbench/parts/debug/electron-browser/replViewer.ts index 848ec016c5f..d1224cbfe6a 100644 --- a/src/vs/workbench/parts/debug/electron-browser/replViewer.ts +++ b/src/vs/workbench/parts/debug/electron-browser/replViewer.ts @@ -41,7 +41,7 @@ export class ReplExpressionsDataSource implements IDataSource { return TPromise.as(element.getReplElements()); } if (element instanceof RawObjectReplElement) { - return TPromise.as(element.getChildren()); + return element.getChildren(); } if (element instanceof SimpleReplElement) { return TPromise.as(null); diff --git a/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts b/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts index 3fb83c894cd..4f1d8d3741d 100644 --- a/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts +++ b/src/vs/workbench/parts/files/browser/editors/textFileEditor.ts @@ -92,7 +92,7 @@ export class TextFileEditor extends BaseTextEditor { (options).apply(this.getControl(), ScrollType.Smooth); } - return TPromise.as(null); + return TPromise.wrap(null); } // Remember view settings if input changes diff --git a/src/vs/workbench/parts/files/browser/fileActions.ts b/src/vs/workbench/parts/files/browser/fileActions.ts index ccc0d2ba899..2efaf66b2ef 100644 --- a/src/vs/workbench/parts/files/browser/fileActions.ts +++ b/src/vs/workbench/parts/files/browser/fileActions.ts @@ -880,7 +880,7 @@ export class ImportFileAction extends BaseFileAction { // if the target exists and is dirty, make sure to revert it. otherwise the dirty contents // of the target file would replace the contents of the imported file. since we already // confirmed the overwrite before, this is OK. - let revertPromise = TPromise.as(null); + let revertPromise = TPromise.wrap(null); if (this.textFileService.isDirty(targetFile)) { revertPromise = this.textFileService.revertAll([targetFile], { soft: true }); } diff --git a/src/vs/workbench/parts/files/browser/views/explorerView.ts b/src/vs/workbench/parts/files/browser/views/explorerView.ts index 0969df39c49..70dd333879a 100644 --- a/src/vs/workbench/parts/files/browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/browser/views/explorerView.ts @@ -349,7 +349,7 @@ export class ExplorerView extends ViewsViewletPanel { // Return now if the workbench has not yet been created - in this case the workbench takes care of restoring last used editors if (!this.partService.isCreated()) { - return TPromise.as(null); + return TPromise.wrap(null); } // Otherwise restore last used file: By lastActiveFileResource diff --git a/src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts b/src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts index e5fd83df571..814bd641bf2 100644 --- a/src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts +++ b/src/vs/workbench/parts/quickopen/browser/gotoSymbolHandler.ts @@ -505,7 +505,7 @@ export class GotoSymbolHandler extends QuickOpenHandler { } } - return TPromise.as(null); + return TPromise.wrap(null); } public decorateOutline(fullRange: IRange, startRange: IRange, editor: IEditor, position: Position): void { diff --git a/src/vs/workbench/parts/search/browser/openSymbolHandler.ts b/src/vs/workbench/parts/search/browser/openSymbolHandler.ts index 4e552a9ca1a..24f7ec1e96e 100644 --- a/src/vs/workbench/parts/search/browser/openSymbolHandler.ts +++ b/src/vs/workbench/parts/search/browser/openSymbolHandler.ts @@ -86,7 +86,7 @@ class SymbolEntry extends EditorQuickOpenEntry { TPromise.as(this._bearingResolve) .then(_ => super.run(mode, context)) - .done(undefined, onUnexpectedError); + .then(undefined, onUnexpectedError); // hide if OPEN return mode === Mode.OPEN; diff --git a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts index b487239dcc2..8b2015f3031 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts @@ -960,12 +960,12 @@ class TaskService extends EventEmitter implements ITaskService { public customize(task: ContributedTask | CustomTask, properties?: CustomizationProperties, openConfig?: boolean): TPromise { let workspaceFolder = Task.getWorkspaceFolder(task); if (!workspaceFolder) { - return TPromise.as(undefined); + return TPromise.wrap(undefined); } let configuration = this.getConfiguration(workspaceFolder); if (configuration.hasParseErrors) { this.messageService.show(Severity.Warning, nls.localize('customizeParseErrors', 'The current task configuration has errors. Please fix the errors first before customizing a task.')); - return TPromise.as(undefined); + return TPromise.wrap(undefined); } let fileConfig = configuration.config; @@ -1734,7 +1734,7 @@ class TaskService extends EventEmitter implements ITaskService { : new Action( 'workbench.action.tasks.terminate', nls.localize('TerminateAction.label', "Terminate Task"), - undefined, true, () => { this.runTerminateCommand(); return TPromise.as(undefined); }); + undefined, true, () => { this.runTerminateCommand(); return TPromise.wrap(undefined); }); closeAction.closeFunction = this.messageService.show(buildError.severity, { message: buildError.message, actions: [action, closeAction] }); } else { this.messageService.show(buildError.severity, buildError.message); diff --git a/src/vs/workbench/services/editor/common/editorService.ts b/src/vs/workbench/services/editor/common/editorService.ts index 8100a8cd551..99e44460d97 100644 --- a/src/vs/workbench/services/editor/common/editorService.ts +++ b/src/vs/workbench/services/editor/common/editorService.ts @@ -185,7 +185,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { public openEditor(input: IResourceInputType, sideBySide?: boolean): TPromise; public openEditor(input: any, arg2?: any, arg3?: any): TPromise { if (!input) { - return TPromise.as(null); + return TPromise.wrap(null); } // Workbench Input Support @@ -200,7 +200,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { if (schema === network.Schemas.http || schema === network.Schemas.https) { window.open(resourceInput.resource.toString(true)); - return TPromise.as(null); + return TPromise.wrap(null); } } @@ -211,7 +211,7 @@ export class WorkbenchEditorService implements IWorkbenchEditorService { return this.doOpenEditor(typedInput, TextEditorOptions.from(textInput), arg2); } - return TPromise.as(null); + return TPromise.wrap(null); } private toOptions(options?: IEditorOptions | EditorOptions): EditorOptions { diff --git a/src/vs/workbench/services/extensions/electron-browser/extensionService.ts b/src/vs/workbench/services/extensions/electron-browser/extensionService.ts index 8e19e2df434..ce267529556 100644 --- a/src/vs/workbench/services/extensions/electron-browser/extensionService.ts +++ b/src/vs/workbench/services/extensions/electron-browser/extensionService.ts @@ -49,7 +49,7 @@ function messageWithSource2(source: string, message: string): string { } const hasOwnProperty = Object.hasOwnProperty; -const NO_OP_VOID_PROMISE = TPromise.as(void 0); +const NO_OP_VOID_PROMISE = TPromise.wrap(void 0); export class ExtensionService implements IExtensionService { public _serviceBrand: any; diff --git a/src/vs/workbench/services/files/node/fileService.ts b/src/vs/workbench/services/files/node/fileService.ts index 48910f60660..8b24b080656 100644 --- a/src/vs/workbench/services/files/node/fileService.ts +++ b/src/vs/workbench/services/files/node/fileService.ts @@ -483,7 +483,7 @@ export class FileService implements IFileService { } // 2.) make sure target is deleted before we move/copy unless this is a case rename of the same file - let deleteTargetPromise = TPromise.as(void 0); + let deleteTargetPromise = TPromise.wrap(void 0); if (exists && !isCaseRename) { if (isEqualOrParent(sourcePath, targetPath, !isLinux /* ignorecase */)) { return TPromise.wrapError(new Error(nls.localize('unableToMoveCopyError', "Unable to move/copy. File would replace folder it is contained in."))); // catch this corner case! @@ -499,7 +499,7 @@ export class FileService implements IFileService { // 4.) copy/move if (isSameFile) { - return TPromise.as(null); + return TPromise.wrap(null); } else if (keepCopy) { return nfcall(extfs.copy, sourcePath, targetPath); } else { diff --git a/src/vs/workbench/services/textfile/common/textFileEditorModel.ts b/src/vs/workbench/services/textfile/common/textFileEditorModel.ts index a01191f7cd2..6fb9c9a0c43 100644 --- a/src/vs/workbench/services/textfile/common/textFileEditorModel.ts +++ b/src/vs/workbench/services/textfile/common/textFileEditorModel.ts @@ -240,7 +240,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil */ public revert(soft?: boolean): TPromise { if (!this.isResolved()) { - return TPromise.as(null); + return TPromise.wrap(null); } // Cancel any running auto-save @@ -604,7 +604,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil */ public save(options: ISaveOptions = Object.create(null)): TPromise { if (!this.isResolved()) { - return TPromise.as(null); + return TPromise.wrap(null); } diag('save() - enter', this.resource, new Date()); @@ -643,7 +643,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil if ((!options.force && !this.dirty) || versionId !== this.versionId) { diag(`doSave(${versionId}) - exit - because not dirty and/or versionId is different (this.isDirty: ${this.dirty}, this.versionId: ${this.versionId})`, this.resource, new Date()); - return TPromise.as(null); + return TPromise.wrap(null); } // Return if currently saving by storing this save request as the next save that should happen. diff --git a/src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts b/src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts index 0adedb4a6a7..8b08605bebc 100644 --- a/src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts +++ b/src/vs/workbench/services/themes/electron-browser/workbenchThemeService.ts @@ -465,7 +465,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService { if (!types.isUndefinedOrNull(settingsTarget)) { return this.configurationWriter.writeConfiguration(ICON_THEME_SETTING, this.currentIconTheme.settingsId, settingsTarget).then(_ => this.currentIconTheme); } - return TPromise.as(this.currentIconTheme); + return TPromise.wrap(this.currentIconTheme); } private get configurationWriter(): ConfigurationWriter { @@ -480,7 +480,7 @@ export class WorkbenchThemeService implements IWorkbenchThemeService { function _applyIconTheme(this: any, data: FileIconThemeData, onApply: (theme: FileIconThemeData) => TPromise): TPromise { if (!data) { _applyRules('', iconThemeRulesClassName); - return TPromise.as(onApply(data)); + return onApply(data); } return data.ensureLoaded(this).then(styleSheetContent => { _applyRules(styleSheetContent, iconThemeRulesClassName); diff --git a/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts b/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts index e0fc023cb81..ed9ef12d055 100644 --- a/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts +++ b/src/vs/workbench/test/electron-browser/quickopen.perf.integrationTest.ts @@ -168,7 +168,7 @@ class TestTelemetryService implements ITelemetryService { public publicLog(eventName: string, data?: any): TPromise { this.events.push({ name: eventName, data: data }); - return TPromise.as(null); + return TPromise.wrap(null); } public getTelemetryInfo(): TPromise { diff --git a/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts b/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts index 056f00fdbd0..d96d93434e9 100644 --- a/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts +++ b/src/vs/workbench/test/electron-browser/textsearch.perf.integrationTest.ts @@ -156,11 +156,11 @@ class TestTelemetryService implements ITelemetryService { const event = { name: eventName, data: data }; this.events.push(event); this.emitter.fire(event); - return TPromise.as(null); + return TPromise.wrap(null); } public getTelemetryInfo(): TPromise { - return TPromise.as({ + return TPromise.wrap({ instanceId: 'someValue.instanceId', sessionId: 'someValue.sessionId', machineId: 'someValue.machineId'