diff --git a/src/vs/base/parts/quickopen/browser/quickOpenViewer.ts b/src/vs/base/parts/quickopen/browser/quickOpenViewer.ts index ef406fe4f17..fd8df5f680f 100644 --- a/src/vs/base/parts/quickopen/browser/quickOpenViewer.ts +++ b/src/vs/base/parts/quickopen/browser/quickOpenViewer.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import { isFunction } from 'vs/base/common/types'; import { ITree, IRenderer, IFilter, IDataSource, IAccessibilityProvider } from 'vs/base/parts/tree/browser/tree'; import { IModel } from 'vs/base/parts/quickopen/common/quickOpen'; @@ -37,12 +36,12 @@ export class DataSource implements IDataSource { return model && model === element && model.entries.length > 0; } - getChildren(tree: ITree, element: any): TPromise { + getChildren(tree: ITree, element: any): Thenable { const model = this.modelProvider.getModel(); return Promise.resolve(model === element ? model.entries : []); } - getParent(tree: ITree, element: any): TPromise { + getParent(tree: ITree, element: any): Thenable { return Promise.resolve(null); } } @@ -140,4 +139,4 @@ export class Renderer implements IRenderer { const model = this.modelProvider.getModel(); model.renderer.disposeTemplate(templateId, templateData); } -} \ No newline at end of file +} diff --git a/src/vs/base/parts/tree/browser/tree.ts b/src/vs/base/parts/tree/browser/tree.ts index 307b19f9584..311af266ab5 100644 --- a/src/vs/base/parts/tree/browser/tree.ts +++ b/src/vs/base/parts/tree/browser/tree.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import * as WinJS from 'vs/base/common/winjs.base'; import * as Touch from 'vs/base/browser/touch'; import * as Mouse from 'vs/base/browser/mouseEvent'; import * as Keyboard from 'vs/base/browser/keyboardEvent'; @@ -50,7 +49,7 @@ export interface ITree { /** * Sets the input of the tree. */ - setInput(element: any): WinJS.Promise; + setInput(element: any): Thenable; /** * Returns the tree's input. @@ -76,7 +75,7 @@ export interface ITree { * Refreshes an element. * Provide no arguments and it will refresh the input element. */ - refresh(element?: any, recursive?: boolean): WinJS.Promise; + refresh(element?: any, recursive?: boolean): Thenable; /** * Updates an element's width. @@ -87,36 +86,36 @@ export interface ITree { * Expands an element. * The returned promise returns a boolean for whether the element was expanded or not. */ - expand(element: any): WinJS.Promise; + expand(element: any): Thenable; /** * Expands several elements. * The returned promise returns a boolean array for whether the elements were expanded or not. */ - expandAll(elements?: any[]): WinJS.Promise; + expandAll(elements?: any[]): Thenable; /** * Collapses an element. * The returned promise returns a boolean for whether the element was collapsed or not. */ - collapse(element: any, recursive?: boolean): WinJS.Promise; + collapse(element: any, recursive?: boolean): Thenable; /** * Collapses several elements. * Provide no arguments and it will recursively collapse all elements in the tree * The returned promise returns a boolean for whether the elements were collapsed or not. */ - collapseAll(elements?: any[], recursive?: boolean): WinJS.Promise; + collapseAll(elements?: any[], recursive?: boolean): Thenable; /** * Toggles an element's expansion state. */ - toggleExpansion(element: any, recursive?: boolean): WinJS.Promise; + toggleExpansion(element: any, recursive?: boolean): Thenable; /** * Toggles several element's expansion state. */ - toggleExpansionAll(elements: any[]): WinJS.Promise; + toggleExpansionAll(elements: any[]): Thenable; /** * Returns whether an element is expanded or not. @@ -132,7 +131,7 @@ export interface ITree { * Reveals an element in the tree. The relativeTop is a value between 0 and 1. The closer to 0 the more the * element will scroll up to the top. */ - reveal(element: any, relativeTop?: number): WinJS.Promise; + reveal(element: any, relativeTop?: number): Thenable; /** * Returns the relative top position of any given element, if visible. @@ -378,12 +377,12 @@ export interface IDataSource { /** * Returns the element's children as an array in a promise. */ - getChildren(tree: ITree, element: any): WinJS.Promise; + getChildren(tree: ITree, element: any): Thenable; /** * Returns the element's parent in a promise. */ - getParent(tree: ITree, element: any): WinJS.Promise; + getParent(tree: ITree, element: any): Thenable; /** * Returns whether an element should be expanded when first added to the tree. diff --git a/src/vs/base/parts/tree/browser/treeImpl.ts b/src/vs/base/parts/tree/browser/treeImpl.ts index 63f217de9ec..24d1868227c 100644 --- a/src/vs/base/parts/tree/browser/treeImpl.ts +++ b/src/vs/base/parts/tree/browser/treeImpl.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import 'vs/css!./tree'; -import * as WinJS from 'vs/base/common/winjs.base'; import * as TreeDefaults from 'vs/base/parts/tree/browser/treeDefaults'; import * as Model from 'vs/base/parts/tree/browser/treeModel'; import * as View from './treeView'; @@ -150,7 +149,7 @@ export class Tree implements _.ITree { this.view.onHidden(); } - public setInput(element: any): WinJS.Promise { + public setInput(element: any): Thenable { return this.model.setInput(element); } @@ -158,7 +157,7 @@ export class Tree implements _.ITree { return this.model.getInput(); } - public refresh(element: any = null, recursive = true): WinJS.Promise { + public refresh(element: any = null, recursive = true): Thenable { return this.model.refresh(element, recursive); } @@ -167,27 +166,27 @@ export class Tree implements _.ITree { return this.view.updateWidth(item); } - public expand(element: any): WinJS.Promise { + public expand(element: any): Thenable { return this.model.expand(element); } - public expandAll(elements: any[]): WinJS.Promise { + public expandAll(elements: any[]): Thenable { return this.model.expandAll(elements); } - public collapse(element: any, recursive: boolean = false): WinJS.Promise { + public collapse(element: any, recursive: boolean = false): Thenable { return this.model.collapse(element, recursive); } - public collapseAll(elements: any[] | null = null, recursive: boolean = false): WinJS.Promise { + public collapseAll(elements: any[] | null = null, recursive: boolean = false): Thenable { return this.model.collapseAll(elements, recursive); } - public toggleExpansion(element: any, recursive: boolean = false): WinJS.Promise { + public toggleExpansion(element: any, recursive: boolean = false): Thenable { return this.model.toggleExpansion(element, recursive); } - public toggleExpansionAll(elements: any[]): WinJS.Promise { + public toggleExpansionAll(elements: any[]): Thenable { return this.model.toggleExpansionAll(elements); } @@ -199,7 +198,7 @@ export class Tree implements _.ITree { return this.model.getExpandedElements(); } - public reveal(element: any, relativeTop: number | null = null): WinJS.Promise { + public reveal(element: any, relativeTop: number | null = null): Thenable { return this.model.reveal(element, relativeTop); } diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index dd0332e524d..363b6cb1220 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -38,7 +38,6 @@ import pkg from 'vs/platform/node/package'; import { ProxyAuthHandler } from 'vs/code/electron-main/auth'; import { Disposable, toDisposable } from 'vs/base/common/lifecycle'; import { ConfigurationService } from 'vs/platform/configuration/node/configurationService'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IWindowsMainService, ICodeWindow } from 'vs/platform/windows/electron-main/windows'; import { IHistoryMainService } from 'vs/platform/history/common/history'; import { isUndefinedOrNull } from 'vs/base/common/types'; @@ -85,7 +84,7 @@ export class CodeApplication extends Disposable { private electronIpcServer: ElectronIPCServer; private sharedProcess: SharedProcess; - private sharedProcessClient: TPromise; + private sharedProcessClient: Thenable; constructor( private mainIpcServer: Server, @@ -173,7 +172,7 @@ export class CodeApplication extends Disposable { class ActiveConnection { private _authority: string; - private _client: TPromise>; + private _client: Thenable>; private _disposeRunner: RunOnceScheduler; constructor(authority: string, host: string, port: number) { @@ -190,7 +189,7 @@ export class CodeApplication extends Disposable { }); } - public getClient(): TPromise> { + public getClient(): Thenable> { this._disposeRunner.schedule(); return this._client; } @@ -382,7 +381,7 @@ export class CodeApplication extends Disposable { } } - startup(): TPromise { + startup(): Thenable { this.logService.debug('Starting VS Code'); this.logService.debug(`from: ${this.environmentService.appRoot}`); this.logService.debug('args:', this.environmentService.args); @@ -457,7 +456,7 @@ export class CodeApplication extends Disposable { } } - private resolveMachineId(): string | TPromise { + private resolveMachineId(): string | Thenable { const machineId = this.stateService.getItem(CodeApplication.MACHINE_ID_KEY); if (machineId) { return machineId; @@ -645,7 +644,7 @@ export class CodeApplication extends Disposable { const environmentService = accessor.get(IEnvironmentService); urlService.registerHandler({ - handleURL(uri: URI): TPromise { + handleURL(uri: URI): Thenable { if (windowsMainService.getWindowCount() === 0) { const cli = { ...environmentService.args, goto: true }; const [window] = windowsMainService.open({ context: OpenContext.API, cli, forceEmpty: true }); diff --git a/src/vs/code/electron-main/windows.ts b/src/vs/code/electron-main/windows.ts index 86122f673e8..e7ea37b2d9f 100644 --- a/src/vs/code/electron-main/windows.ts +++ b/src/vs/code/electron-main/windows.ts @@ -26,7 +26,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { IWindowsMainService, IOpenConfiguration, IWindowsCountChangedEvent, ICodeWindow, IWindowState as ISingleWindowState, WindowMode } from 'vs/platform/windows/electron-main/windows'; import { IHistoryMainService } from 'vs/platform/history/common/history'; import { IProcessEnvironment, isLinux, isMacintosh, isWindows } from 'vs/base/common/platform'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IWorkspacesMainService, IWorkspaceIdentifier, WORKSPACE_FILTER, IWorkspaceFolderCreationData, ISingleFolderWorkspaceIdentifier, isSingleFolderWorkspaceIdentifier } from 'vs/platform/workspaces/common/workspaces'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; import { mnemonicButtonLabel } from 'vs/base/common/labels'; @@ -1489,15 +1488,15 @@ export class WindowsManager implements IWindowsMainService { }); } - saveAndEnterWorkspace(win: ICodeWindow, path: string): TPromise { + saveAndEnterWorkspace(win: ICodeWindow, path: string): Thenable { return this.workspacesManager.saveAndEnterWorkspace(win, path).then(result => this.doEnterWorkspace(win, result)); } - enterWorkspace(win: ICodeWindow, path: string): TPromise { + enterWorkspace(win: ICodeWindow, path: string): Thenable { return this.workspacesManager.enterWorkspace(win, path).then(result => this.doEnterWorkspace(win, result)); } - createAndEnterWorkspace(win: ICodeWindow, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise { + createAndEnterWorkspace(win: ICodeWindow, folders?: IWorkspaceFolderCreationData[], path?: string): Thenable { return this.workspacesManager.createAndEnterWorkspace(win, folders, path).then(result => this.doEnterWorkspace(win, result)); } @@ -1853,7 +1852,7 @@ class Dialogs { }); } - private getFileOrFolderUris(options: IInternalNativeOpenDialogOptions): TPromise { + private getFileOrFolderUris(options: IInternalNativeOpenDialogOptions): Thenable { // Ensure dialog options if (!options.dialogOptions) { @@ -1985,7 +1984,7 @@ class WorkspacesManager { ) { } - saveAndEnterWorkspace(window: ICodeWindow, path: string): TPromise { + saveAndEnterWorkspace(window: ICodeWindow, path: string): Thenable { if (!window || !window.win || !window.isReady || !window.openedWorkspace || !path || !this.isValidTargetWorkspacePath(window, path)) { return Promise.resolve(null); // return early if the window is not ready or disposed or does not have a workspace } @@ -1993,7 +1992,7 @@ class WorkspacesManager { return this.doSaveAndOpenWorkspace(window, window.openedWorkspace, path); } - enterWorkspace(window: ICodeWindow, path: string): TPromise { + enterWorkspace(window: ICodeWindow, path: string): Thenable { if (!window || !window.win || !window.isReady) { return Promise.resolve(null); // return early if the window is not ready or disposed } @@ -2010,7 +2009,7 @@ class WorkspacesManager { } - createAndEnterWorkspace(window: ICodeWindow, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise { + createAndEnterWorkspace(window: ICodeWindow, folders?: IWorkspaceFolderCreationData[], path?: string): Thenable { if (!window || !window.win || !window.isReady) { return Promise.resolve(null); // return early if the window is not ready or disposed } @@ -2027,7 +2026,7 @@ class WorkspacesManager { } - private isValidTargetWorkspacePath(window: ICodeWindow, path?: string): TPromise { + private isValidTargetWorkspacePath(window: ICodeWindow, path?: string): Thenable { if (!path) { return Promise.resolve(true); } @@ -2053,8 +2052,8 @@ class WorkspacesManager { return Promise.resolve(true); // OK } - private doSaveAndOpenWorkspace(window: ICodeWindow, workspace: IWorkspaceIdentifier, path?: string): TPromise { - let savePromise: TPromise; + private doSaveAndOpenWorkspace(window: ICodeWindow, workspace: IWorkspaceIdentifier, path?: string): Thenable { + let savePromise: Thenable; if (path) { savePromise = this.workspacesMainService.saveWorkspace(workspace, path); } else { @@ -2099,7 +2098,7 @@ class WorkspacesManager { }); } - promptToSaveUntitledWorkspace(window: ICodeWindow, workspace: IWorkspaceIdentifier): TPromise { + promptToSaveUntitledWorkspace(window: ICodeWindow, workspace: IWorkspaceIdentifier): Thenable { enum ConfirmResult { SAVE, DONT_SAVE, diff --git a/src/vs/platform/list/browser/listService.ts b/src/vs/platform/list/browser/listService.ts index d9a4c4bbede..bf79fbd8adb 100644 --- a/src/vs/platform/list/browser/listService.ts +++ b/src/vs/platform/list/browser/listService.ts @@ -16,7 +16,6 @@ import { KeyCode } from 'vs/base/common/keyCodes'; import { combinedDisposable, Disposable, dispose, IDisposable, toDisposable } from 'vs/base/common/lifecycle'; import { ScrollbarVisibility } from 'vs/base/common/scrollable'; import { isUndefinedOrNull } from 'vs/base/common/types'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IFilter, ITree, ITreeConfiguration, ITreeOptions } from 'vs/base/parts/tree/browser/tree'; import { ClickBehavior, DefaultController, DefaultTreestyler, IControllerOptions, OpenMode } from 'vs/base/parts/tree/browser/treeDefaults'; import { Tree } from 'vs/base/parts/tree/browser/treeImpl'; @@ -795,7 +794,7 @@ export class HighlightingWorkbenchTree extends WorkbenchTree { this.disposables.push(this._onDidStartFilter); } - setInput(element: any): TPromise { + setInput(element: any): Thenable { this.input.setEnabled(false); return super.setInput(element).then(value => { if (!this.input.inputElement) { diff --git a/src/vs/platform/menubar/common/menubar.ts b/src/vs/platform/menubar/common/menubar.ts index 403d953349b..f43c83a4d9a 100644 --- a/src/vs/platform/menubar/common/menubar.ts +++ b/src/vs/platform/menubar/common/menubar.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { URI } from 'vs/base/common/uri'; @@ -12,7 +11,7 @@ export const IMenubarService = createDecorator('menubarService' export interface IMenubarService { _serviceBrand: any; - updateMenubar(windowId: number, menuData: IMenubarData): TPromise; + updateMenubar(windowId: number, menuData: IMenubarData): Thenable; } export interface IMenubarData { @@ -69,4 +68,4 @@ export function isMenubarMenuItemUriAction(menuItem: MenubarMenuItem): menuItem export function isMenubarMenuItemAction(menuItem: MenubarMenuItem): menuItem is IMenubarMenuItemAction { return !isMenubarMenuItemSubmenu(menuItem) && !isMenubarMenuItemSeparator(menuItem) && !isMenubarMenuItemUriAction(menuItem); -} \ No newline at end of file +} diff --git a/src/vs/platform/menubar/node/menubarIpc.ts b/src/vs/platform/menubar/node/menubarIpc.ts index a5315dbb973..70d61f0d879 100644 --- a/src/vs/platform/menubar/node/menubarIpc.ts +++ b/src/vs/platform/menubar/node/menubarIpc.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IMenubarService, IMenubarData } from 'vs/platform/menubar/common/menubar'; import { Event } from 'vs/base/common/event'; @@ -15,7 +14,7 @@ export class MenubarChannel implements IServerChannel { throw new Error(`Event not found: ${event}`); } - call(_, command: string, arg?: any): TPromise { + call(_, command: string, arg?: any): Thenable { switch (command) { case 'updateMenubar': return this.service.updateMenubar(arg[0], arg[1]); } @@ -30,7 +29,7 @@ export class MenubarChannelClient implements IMenubarService { constructor(private channel: IChannel) { } - updateMenubar(windowId: number, menuData: IMenubarData): TPromise { + updateMenubar(windowId: number, menuData: IMenubarData): Thenable { return this.channel.call('updateMenubar', [windowId, menuData]); } -} \ No newline at end of file +} diff --git a/src/vs/platform/remote/node/remoteAgentConnection.ts b/src/vs/platform/remote/node/remoteAgentConnection.ts index 852ae1d2011..9c053ad7d05 100644 --- a/src/vs/platform/remote/node/remoteAgentConnection.ts +++ b/src/vs/platform/remote/node/remoteAgentConnection.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import { Client, Protocol } from 'vs/base/parts/ipc/node/ipc.net'; import { IExtensionHostDebugParams } from 'vs/platform/environment/common/environment'; @@ -12,7 +11,7 @@ export interface RemoteAgentConnectionContext { clientId: string; } -export function connectRemoteAgentManagement(remoteAuthority: string, host: string, port: number, clientId: string): TPromise> { +export function connectRemoteAgentManagement(remoteAuthority: string, host: string, port: number, clientId: string): Thenable> { throw new Error(`Not implemented`); } @@ -21,6 +20,6 @@ export interface IExtensionHostConnectionResult { debugPort?: number; } -export function connectRemoteAgentExtensionHost(host: string, port: number, debugArguments: IExtensionHostDebugParams): TPromise { +export function connectRemoteAgentExtensionHost(host: string, port: number, debugArguments: IExtensionHostDebugParams): Thenable { throw new Error(`Not implemented`); } diff --git a/src/vs/platform/update/common/update.ts b/src/vs/platform/update/common/update.ts index 6486902fc01..5f9d514d8de 100644 --- a/src/vs/platform/update/common/update.ts +++ b/src/vs/platform/update/common/update.ts @@ -5,7 +5,6 @@ import { Event } from 'vs/base/common/event'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; -import { TPromise } from 'vs/base/common/winjs.base'; export interface IUpdate { version: string; @@ -77,7 +76,7 @@ export const State = { export interface IAutoUpdater extends Event.NodeEventEmitter { setFeedURL(url: string): void; checkForUpdates(): void; - applyUpdate?(): TPromise; + applyUpdate?(): Thenable; quitAndInstall(): void; } @@ -89,10 +88,10 @@ export interface IUpdateService { readonly onStateChange: Event; readonly state: State; - checkForUpdates(context: any): TPromise; - downloadUpdate(): TPromise; - applyUpdate(): TPromise; - quitAndInstall(): TPromise; + checkForUpdates(context: any): Thenable; + downloadUpdate(): Thenable; + applyUpdate(): Thenable; + quitAndInstall(): Thenable; - isLatestVersion(): TPromise; + isLatestVersion(): Thenable; } diff --git a/src/vs/platform/windows/common/windows.ts b/src/vs/platform/windows/common/windows.ts index befab9827a4..de4bfdff63e 100644 --- a/src/vs/platform/windows/common/windows.ts +++ b/src/vs/platform/windows/common/windows.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { Event } from 'vs/base/common/event'; import { ITelemetryData } from 'vs/platform/telemetry/common/telemetry'; @@ -103,72 +102,72 @@ export interface IWindowsService { onRecentlyOpenedChange: Event; // Dialogs - pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise; - pickFileAndOpen(options: INativeOpenDialogOptions): TPromise; - pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise; - pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise; - showMessageBox(windowId: number, options: MessageBoxOptions): TPromise; - showSaveDialog(windowId: number, options: SaveDialogOptions): TPromise; - showOpenDialog(windowId: number, options: OpenDialogOptions): TPromise; + pickFileFolderAndOpen(options: INativeOpenDialogOptions): Thenable; + pickFileAndOpen(options: INativeOpenDialogOptions): Thenable; + pickFolderAndOpen(options: INativeOpenDialogOptions): Thenable; + pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Thenable; + showMessageBox(windowId: number, options: MessageBoxOptions): Thenable; + showSaveDialog(windowId: number, options: SaveDialogOptions): Thenable; + showOpenDialog(windowId: number, options: OpenDialogOptions): Thenable; - reloadWindow(windowId: number, args?: ParsedArgs): TPromise; - openDevTools(windowId: number, options?: IDevToolsOptions): TPromise; - toggleDevTools(windowId: number): TPromise; - closeWorkspace(windowId: number): TPromise; - enterWorkspace(windowId: number, path: string): TPromise; - createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise; - saveAndEnterWorkspace(windowId: number, path: string): TPromise; - toggleFullScreen(windowId: number): TPromise; - setRepresentedFilename(windowId: number, fileName: string): TPromise; - addRecentlyOpened(files: URI[]): TPromise; - removeFromRecentlyOpened(paths: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | string)[]): TPromise; - clearRecentlyOpened(): TPromise; - getRecentlyOpened(windowId: number): TPromise; - focusWindow(windowId: number): TPromise; - closeWindow(windowId: number): TPromise; - isFocused(windowId: number): TPromise; - isMaximized(windowId: number): TPromise; - maximizeWindow(windowId: number): TPromise; - unmaximizeWindow(windowId: number): TPromise; - minimizeWindow(windowId: number): TPromise; - onWindowTitleDoubleClick(windowId: number): TPromise; - setDocumentEdited(windowId: number, flag: boolean): TPromise; - quit(): TPromise; - relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise; + reloadWindow(windowId: number, args?: ParsedArgs): Thenable; + openDevTools(windowId: number, options?: IDevToolsOptions): Thenable; + toggleDevTools(windowId: number): Thenable; + closeWorkspace(windowId: number): Thenable; + enterWorkspace(windowId: number, path: string): Thenable; + createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): Thenable; + saveAndEnterWorkspace(windowId: number, path: string): Thenable; + toggleFullScreen(windowId: number): Thenable; + setRepresentedFilename(windowId: number, fileName: string): Thenable; + addRecentlyOpened(files: URI[]): Thenable; + removeFromRecentlyOpened(paths: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | string)[]): Thenable; + clearRecentlyOpened(): Thenable; + getRecentlyOpened(windowId: number): Thenable; + focusWindow(windowId: number): Thenable; + closeWindow(windowId: number): Thenable; + isFocused(windowId: number): Thenable; + isMaximized(windowId: number): Thenable; + maximizeWindow(windowId: number): Thenable; + unmaximizeWindow(windowId: number): Thenable; + minimizeWindow(windowId: number): Thenable; + onWindowTitleDoubleClick(windowId: number): Thenable; + setDocumentEdited(windowId: number, flag: boolean): Thenable; + quit(): Thenable; + relaunch(options: { addArgs?: string[], removeArgs?: string[] }): Thenable; // macOS Native Tabs - newWindowTab(): TPromise; - showPreviousWindowTab(): TPromise; - showNextWindowTab(): TPromise; - moveWindowTabToNewWindow(): TPromise; - mergeAllWindowTabs(): TPromise; - toggleWindowTabsBar(): TPromise; + newWindowTab(): Thenable; + showPreviousWindowTab(): Thenable; + showNextWindowTab(): Thenable; + moveWindowTabToNewWindow(): Thenable; + mergeAllWindowTabs(): Thenable; + toggleWindowTabsBar(): Thenable; // macOS TouchBar - updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): TPromise; + updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): Thenable; // Shared process - whenSharedProcessReady(): TPromise; - toggleSharedProcess(): TPromise; + whenSharedProcessReady(): Thenable; + toggleSharedProcess(): Thenable; // Global methods - openWindow(windowId: number, paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): TPromise; - openNewWindow(options?: INewWindowOptions): TPromise; - showWindow(windowId: number): TPromise; - getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>; - getWindowCount(): TPromise; - log(severity: string, ...messages: string[]): TPromise; - showItemInFolder(path: string): TPromise; - getActiveWindowId(): TPromise; + openWindow(windowId: number, paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): Thenable; + openNewWindow(options?: INewWindowOptions): Thenable; + showWindow(windowId: number): Thenable; + getWindows(): Thenable<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>; + getWindowCount(): Thenable; + log(severity: string, ...messages: string[]): Thenable; + showItemInFolder(path: string): Thenable; + getActiveWindowId(): Thenable; // This needs to be handled from browser process to prevent // foreground ordering issues on Windows - openExternal(url: string): TPromise; + openExternal(url: string): Thenable; // TODO: this is a bit backwards - startCrashReporter(config: CrashReporterStartOptions): TPromise; + startCrashReporter(config: CrashReporterStartOptions): Thenable; - openAboutDialog(): TPromise; + openAboutDialog(): Thenable; resolveProxy(windowId: number, url: string): Promise; } @@ -190,35 +189,35 @@ export interface IWindowService { getConfiguration(): IWindowConfiguration; getCurrentWindowId(): number; - pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise; - pickFileAndOpen(options: INativeOpenDialogOptions): TPromise; - pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise; - pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise; - reloadWindow(args?: ParsedArgs): TPromise; - openDevTools(options?: IDevToolsOptions): TPromise; - toggleDevTools(): TPromise; - closeWorkspace(): TPromise; - updateTouchBar(items: ISerializableCommandAction[][]): TPromise; - enterWorkspace(path: string): TPromise; - createAndEnterWorkspace(folders?: IWorkspaceFolderCreationData[], path?: string): TPromise; - saveAndEnterWorkspace(path: string): TPromise; - toggleFullScreen(): TPromise; - setRepresentedFilename(fileName: string): TPromise; - getRecentlyOpened(): TPromise; - focusWindow(): TPromise; - closeWindow(): TPromise; - openWindow(paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): TPromise; - isFocused(): TPromise; - setDocumentEdited(flag: boolean): TPromise; - isMaximized(): TPromise; - maximizeWindow(): TPromise; - unmaximizeWindow(): TPromise; - minimizeWindow(): TPromise; - onWindowTitleDoubleClick(): TPromise; - show(): TPromise; - showMessageBox(options: MessageBoxOptions): TPromise; - showSaveDialog(options: SaveDialogOptions): TPromise; - showOpenDialog(options: OpenDialogOptions): TPromise; + pickFileFolderAndOpen(options: INativeOpenDialogOptions): Thenable; + pickFileAndOpen(options: INativeOpenDialogOptions): Thenable; + pickFolderAndOpen(options: INativeOpenDialogOptions): Thenable; + pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Thenable; + reloadWindow(args?: ParsedArgs): Thenable; + openDevTools(options?: IDevToolsOptions): Thenable; + toggleDevTools(): Thenable; + closeWorkspace(): Thenable; + updateTouchBar(items: ISerializableCommandAction[][]): Thenable; + enterWorkspace(path: string): Thenable; + createAndEnterWorkspace(folders?: IWorkspaceFolderCreationData[], path?: string): Thenable; + saveAndEnterWorkspace(path: string): Thenable; + toggleFullScreen(): Thenable; + setRepresentedFilename(fileName: string): Thenable; + getRecentlyOpened(): Thenable; + focusWindow(): Thenable; + closeWindow(): Thenable; + openWindow(paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): Thenable; + isFocused(): Thenable; + setDocumentEdited(flag: boolean): Thenable; + isMaximized(): Thenable; + maximizeWindow(): Thenable; + unmaximizeWindow(): Thenable; + minimizeWindow(): Thenable; + onWindowTitleDoubleClick(): Thenable; + show(): Thenable; + showMessageBox(options: MessageBoxOptions): Thenable; + showSaveDialog(options: SaveDialogOptions): Thenable; + showOpenDialog(options: OpenDialogOptions): Thenable; resolveProxy(url: string): Promise; } @@ -413,7 +412,7 @@ export interface IRunActionInWindowRequest { export class ActiveWindowManager implements IDisposable { private disposables: IDisposable[] = []; - private firstActiveWindowIdPromise: TPromise | null; + private firstActiveWindowIdPromise: Thenable | null; private _activeWindowId: number | undefined; constructor(@IWindowsService windowsService: IWindowsService) { @@ -432,7 +431,7 @@ export class ActiveWindowManager implements IDisposable { this._activeWindowId = windowId; } - getActiveClientId(): TPromise { + getActiveClientId(): Thenable { if (this.firstActiveWindowIdPromise) { return this.firstActiveWindowIdPromise; } diff --git a/src/vs/platform/windows/electron-browser/windowService.ts b/src/vs/platform/windows/electron-browser/windowService.ts index c3443eea2b4..2420fe22136 100644 --- a/src/vs/platform/windows/electron-browser/windowService.ts +++ b/src/vs/platform/windows/electron-browser/windowService.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import { Event } from 'vs/base/common/event'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IWindowService, IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, IWindowConfiguration, IDevToolsOptions } from 'vs/platform/windows/common/windows'; import { IRecentlyOpened } from 'vs/platform/history/common/history'; import { ISerializableCommandAction } from 'vs/platform/actions/common/actions'; @@ -50,127 +49,127 @@ export class WindowService extends Disposable implements IWindowService { return this.configuration; } - pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise { + pickFileFolderAndOpen(options: INativeOpenDialogOptions): Thenable { options.windowId = this.windowId; return this.windowsService.pickFileFolderAndOpen(options); } - pickFileAndOpen(options: INativeOpenDialogOptions): TPromise { + pickFileAndOpen(options: INativeOpenDialogOptions): Thenable { options.windowId = this.windowId; return this.windowsService.pickFileAndOpen(options); } - pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise { + pickFolderAndOpen(options: INativeOpenDialogOptions): Thenable { options.windowId = this.windowId; return this.windowsService.pickFolderAndOpen(options); } - pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise { + pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Thenable { options.windowId = this.windowId; return this.windowsService.pickWorkspaceAndOpen(options); } - reloadWindow(args?: ParsedArgs): TPromise { + reloadWindow(args?: ParsedArgs): Thenable { return this.windowsService.reloadWindow(this.windowId, args); } - openDevTools(options?: IDevToolsOptions): TPromise { + openDevTools(options?: IDevToolsOptions): Thenable { return this.windowsService.openDevTools(this.windowId, options); } - toggleDevTools(): TPromise { + toggleDevTools(): Thenable { return this.windowsService.toggleDevTools(this.windowId); } - closeWorkspace(): TPromise { + closeWorkspace(): Thenable { return this.windowsService.closeWorkspace(this.windowId); } - enterWorkspace(path: string): TPromise { + enterWorkspace(path: string): Thenable { return this.windowsService.enterWorkspace(this.windowId, path); } - createAndEnterWorkspace(folders?: IWorkspaceFolderCreationData[], path?: string): TPromise { + createAndEnterWorkspace(folders?: IWorkspaceFolderCreationData[], path?: string): Thenable { return this.windowsService.createAndEnterWorkspace(this.windowId, folders, path); } - saveAndEnterWorkspace(path: string): TPromise { + saveAndEnterWorkspace(path: string): Thenable { return this.windowsService.saveAndEnterWorkspace(this.windowId, path); } - openWindow(paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): TPromise { + openWindow(paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): Thenable { return this.windowsService.openWindow(this.windowId, paths, options); } - closeWindow(): TPromise { + closeWindow(): Thenable { return this.windowsService.closeWindow(this.windowId); } - toggleFullScreen(): TPromise { + toggleFullScreen(): Thenable { return this.windowsService.toggleFullScreen(this.windowId); } - setRepresentedFilename(fileName: string): TPromise { + setRepresentedFilename(fileName: string): Thenable { return this.windowsService.setRepresentedFilename(this.windowId, fileName); } - getRecentlyOpened(): TPromise { + getRecentlyOpened(): Thenable { return this.windowsService.getRecentlyOpened(this.windowId); } - focusWindow(): TPromise { + focusWindow(): Thenable { return this.windowsService.focusWindow(this.windowId); } - isFocused(): TPromise { + isFocused(): Thenable { return this.windowsService.isFocused(this.windowId); } - isMaximized(): TPromise { + isMaximized(): Thenable { return this.windowsService.isMaximized(this.windowId); } - maximizeWindow(): TPromise { + maximizeWindow(): Thenable { return this.windowsService.maximizeWindow(this.windowId); } - unmaximizeWindow(): TPromise { + unmaximizeWindow(): Thenable { return this.windowsService.unmaximizeWindow(this.windowId); } - minimizeWindow(): TPromise { + minimizeWindow(): Thenable { return this.windowsService.minimizeWindow(this.windowId); } - onWindowTitleDoubleClick(): TPromise { + onWindowTitleDoubleClick(): Thenable { return this.windowsService.onWindowTitleDoubleClick(this.windowId); } - setDocumentEdited(flag: boolean): TPromise { + setDocumentEdited(flag: boolean): Thenable { return this.windowsService.setDocumentEdited(this.windowId, flag); } - show(): TPromise { + show(): Thenable { return this.windowsService.showWindow(this.windowId); } - showMessageBox(options: Electron.MessageBoxOptions): TPromise { + showMessageBox(options: Electron.MessageBoxOptions): Thenable { return this.windowsService.showMessageBox(this.windowId, options); } - showSaveDialog(options: Electron.SaveDialogOptions): TPromise { + showSaveDialog(options: Electron.SaveDialogOptions): Thenable { return this.windowsService.showSaveDialog(this.windowId, options); } - showOpenDialog(options: Electron.OpenDialogOptions): TPromise { + showOpenDialog(options: Electron.OpenDialogOptions): Thenable { return this.windowsService.showOpenDialog(this.windowId, options); } - updateTouchBar(items: ISerializableCommandAction[][]): TPromise { + updateTouchBar(items: ISerializableCommandAction[][]): Thenable { return this.windowsService.updateTouchBar(this.windowId, items); } diff --git a/src/vs/platform/windows/electron-main/windows.ts b/src/vs/platform/windows/electron-main/windows.ts index ba8be0d16b8..291fdcab149 100644 --- a/src/vs/platform/windows/electron-main/windows.ts +++ b/src/vs/platform/windows/electron-main/windows.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import { OpenContext, IWindowConfiguration, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult, INewWindowOptions } from 'vs/platform/windows/common/windows'; import { ParsedArgs } from 'vs/platform/environment/common/environment'; import { Event } from 'vs/base/common/event'; @@ -97,9 +96,9 @@ export interface IWindowsMainService { // methods ready(initialUserEnv: IProcessEnvironment): void; reload(win: ICodeWindow, cli?: ParsedArgs): void; - enterWorkspace(win: ICodeWindow, path: string): TPromise; - createAndEnterWorkspace(win: ICodeWindow, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise; - saveAndEnterWorkspace(win: ICodeWindow, path: string): TPromise; + enterWorkspace(win: ICodeWindow, path: string): Thenable; + createAndEnterWorkspace(win: ICodeWindow, folders?: IWorkspaceFolderCreationData[], path?: string): Thenable; + saveAndEnterWorkspace(win: ICodeWindow, path: string): Thenable; closeWorkspace(win: ICodeWindow): void; open(openConfig: IOpenConfiguration): ICodeWindow[]; openExtensionDevelopmentHostWindow(openConfig: IOpenConfiguration): void; @@ -112,7 +111,7 @@ export interface IWindowsMainService { showOpenDialog(options: Electron.OpenDialogOptions, win?: ICodeWindow): Thenable; focusLastActive(cli: ParsedArgs, context: OpenContext): ICodeWindow; getLastActiveWindow(): ICodeWindow; - waitForWindowCloseOrLoad(windowId: number): TPromise; + waitForWindowCloseOrLoad(windowId: number): Thenable; openNewWindow(context: OpenContext, options?: INewWindowOptions): ICodeWindow[]; openNewTabbedWindow(context: OpenContext): ICodeWindow[]; sendToFocused(channel: string, ...args: any[]): void; @@ -142,6 +141,6 @@ export interface IOpenConfiguration { } export interface ISharedProcess { - whenReady(): TPromise; + whenReady(): Thenable; toggle(): void; } \ No newline at end of file diff --git a/src/vs/platform/windows/electron-main/windowsService.ts b/src/vs/platform/windows/electron-main/windowsService.ts index fd3bd7688b9..023e75089f0 100644 --- a/src/vs/platform/windows/electron-main/windowsService.ts +++ b/src/vs/platform/windows/electron-main/windowsService.ts @@ -5,7 +5,6 @@ import * as nls from 'vs/nls'; import * as os from 'os'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { assign } from 'vs/base/common/objects'; import { URI } from 'vs/base/common/uri'; @@ -60,25 +59,25 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable (id => this._activeWindowId = id, null, this.disposables); } - async pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise { + async pickFileFolderAndOpen(options: INativeOpenDialogOptions): Promise { this.logService.trace('windowsService#pickFileFolderAndOpen'); this.windowsMainService.pickFileFolderAndOpen(options); } - async pickFileAndOpen(options: INativeOpenDialogOptions): TPromise { + async pickFileAndOpen(options: INativeOpenDialogOptions): Promise { this.logService.trace('windowsService#pickFileAndOpen'); this.windowsMainService.pickFileAndOpen(options); } - async pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise { + async pickFolderAndOpen(options: INativeOpenDialogOptions): Promise { this.logService.trace('windowsService#pickFolderAndOpen'); this.windowsMainService.pickFolderAndOpen(options); } - async pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise { + async pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Promise { this.logService.trace('windowsService#pickWorkspaceAndOpen'); this.windowsMainService.pickWorkspaceAndOpen(options); @@ -102,19 +101,19 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable return this.withWindow(windowId, codeWindow => this.windowsMainService.showOpenDialog(options, codeWindow), () => this.windowsMainService.showOpenDialog(options))!; } - async reloadWindow(windowId: number, args: ParsedArgs): TPromise { + async reloadWindow(windowId: number, args: ParsedArgs): Promise { this.logService.trace('windowsService#reloadWindow', windowId); return this.withWindow(windowId, codeWindow => this.windowsMainService.reload(codeWindow, args)); } - async openDevTools(windowId: number, options?: IDevToolsOptions): TPromise { + async openDevTools(windowId: number, options?: IDevToolsOptions): Promise { this.logService.trace('windowsService#openDevTools', windowId); return this.withWindow(windowId, codeWindow => codeWindow.win.webContents.openDevTools(options)); } - async toggleDevTools(windowId: number): TPromise { + async toggleDevTools(windowId: number): Promise { this.logService.trace('windowsService#toggleDevTools', windowId); return this.withWindow(windowId, codeWindow => { @@ -127,157 +126,157 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable }); } - async updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): TPromise { + async updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): Promise { this.logService.trace('windowsService#updateTouchBar', windowId); return this.withWindow(windowId, codeWindow => codeWindow.updateTouchBar(items)); } - async closeWorkspace(windowId: number): TPromise { + async closeWorkspace(windowId: number): Promise { this.logService.trace('windowsService#closeWorkspace', windowId); return this.withWindow(windowId, codeWindow => this.windowsMainService.closeWorkspace(codeWindow)); } - async enterWorkspace(windowId: number, path: string): TPromise { + async enterWorkspace(windowId: number, path: string): Promise { this.logService.trace('windowsService#enterWorkspace', windowId); return this.withWindow(windowId, codeWindow => this.windowsMainService.enterWorkspace(codeWindow, path)); } - async createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise { + async createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): Promise { this.logService.trace('windowsService#createAndEnterWorkspace', windowId); return this.withWindow(windowId, codeWindow => this.windowsMainService.createAndEnterWorkspace(codeWindow, folders, path)); } - async saveAndEnterWorkspace(windowId: number, path: string): TPromise { + async saveAndEnterWorkspace(windowId: number, path: string): Promise { this.logService.trace('windowsService#saveAndEnterWorkspace', windowId); return this.withWindow(windowId, codeWindow => this.windowsMainService.saveAndEnterWorkspace(codeWindow, path)); } - async toggleFullScreen(windowId: number): TPromise { + async toggleFullScreen(windowId: number): Promise { this.logService.trace('windowsService#toggleFullScreen', windowId); return this.withWindow(windowId, codeWindow => codeWindow.toggleFullScreen()); } - async setRepresentedFilename(windowId: number, fileName: string): TPromise { + async setRepresentedFilename(windowId: number, fileName: string): Promise { this.logService.trace('windowsService#setRepresentedFilename', windowId); return this.withWindow(windowId, codeWindow => codeWindow.setRepresentedFilename(fileName)); } - async addRecentlyOpened(files: URI[]): TPromise { + async addRecentlyOpened(files: URI[]): Promise { this.logService.trace('windowsService#addRecentlyOpened'); this.historyService.addRecentlyOpened(void 0, files); } - async removeFromRecentlyOpened(paths: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | string)[]): TPromise { + async removeFromRecentlyOpened(paths: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI | string)[]): Promise { this.logService.trace('windowsService#removeFromRecentlyOpened'); this.historyService.removeFromRecentlyOpened(paths); } - async clearRecentlyOpened(): TPromise { + async clearRecentlyOpened(): Promise { this.logService.trace('windowsService#clearRecentlyOpened'); this.historyService.clearRecentlyOpened(); } - async getRecentlyOpened(windowId: number): TPromise { + async getRecentlyOpened(windowId: number): Promise { this.logService.trace('windowsService#getRecentlyOpened', windowId); return this.withWindow(windowId, codeWindow => this.historyService.getRecentlyOpened(codeWindow.config.workspace || codeWindow.config.folderUri, codeWindow.config.filesToOpen), () => this.historyService.getRecentlyOpened())!; } - async newWindowTab(): TPromise { + async newWindowTab(): Promise { this.logService.trace('windowsService#newWindowTab'); this.windowsMainService.openNewTabbedWindow(OpenContext.API); } - async showPreviousWindowTab(): TPromise { + async showPreviousWindowTab(): Promise { this.logService.trace('windowsService#showPreviousWindowTab'); Menu.sendActionToFirstResponder('selectPreviousTab:'); } - async showNextWindowTab(): TPromise { + async showNextWindowTab(): Promise { this.logService.trace('windowsService#showNextWindowTab'); Menu.sendActionToFirstResponder('selectNextTab:'); } - async moveWindowTabToNewWindow(): TPromise { + async moveWindowTabToNewWindow(): Promise { this.logService.trace('windowsService#moveWindowTabToNewWindow'); Menu.sendActionToFirstResponder('moveTabToNewWindow:'); } - async mergeAllWindowTabs(): TPromise { + async mergeAllWindowTabs(): Promise { this.logService.trace('windowsService#mergeAllWindowTabs'); Menu.sendActionToFirstResponder('mergeAllWindows:'); } - async toggleWindowTabsBar(): TPromise { + async toggleWindowTabsBar(): Promise { this.logService.trace('windowsService#toggleWindowTabsBar'); Menu.sendActionToFirstResponder('toggleTabBar:'); } - async focusWindow(windowId: number): TPromise { + async focusWindow(windowId: number): Promise { this.logService.trace('windowsService#focusWindow', windowId); return this.withWindow(windowId, codeWindow => codeWindow.win.focus()); } - async closeWindow(windowId: number): TPromise { + async closeWindow(windowId: number): Promise { this.logService.trace('windowsService#closeWindow', windowId); return this.withWindow(windowId, codeWindow => codeWindow.win.close()); } - async isFocused(windowId: number): TPromise { + async isFocused(windowId: number): Promise { this.logService.trace('windowsService#isFocused', windowId); return this.withWindow(windowId, codeWindow => codeWindow.win.isFocused(), () => false)!; } - async isMaximized(windowId: number): TPromise { + async isMaximized(windowId: number): Promise { this.logService.trace('windowsService#isMaximized', windowId); return this.withWindow(windowId, codeWindow => codeWindow.win.isMaximized(), () => false)!; } - async maximizeWindow(windowId: number): TPromise { + async maximizeWindow(windowId: number): Promise { this.logService.trace('windowsService#maximizeWindow', windowId); return this.withWindow(windowId, codeWindow => codeWindow.win.maximize()); } - async unmaximizeWindow(windowId: number): TPromise { + async unmaximizeWindow(windowId: number): Promise { this.logService.trace('windowsService#unmaximizeWindow', windowId); return this.withWindow(windowId, codeWindow => codeWindow.win.unmaximize()); } - async minimizeWindow(windowId: number): TPromise { + async minimizeWindow(windowId: number): Promise { this.logService.trace('windowsService#minimizeWindow', windowId); return this.withWindow(windowId, codeWindow => codeWindow.win.minimize()); } - async onWindowTitleDoubleClick(windowId: number): TPromise { + async onWindowTitleDoubleClick(windowId: number): Promise { this.logService.trace('windowsService#onWindowTitleDoubleClick', windowId); return this.withWindow(windowId, codeWindow => codeWindow.onWindowTitleDoubleClick()); } - async setDocumentEdited(windowId: number, flag: boolean): TPromise { + async setDocumentEdited(windowId: number, flag: boolean): Promise { this.logService.trace('windowsService#setDocumentEdited', windowId); return this.withWindow(windowId, codeWindow => { @@ -287,7 +286,7 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable }); } - async openWindow(windowId: number, paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): TPromise { + async openWindow(windowId: number, paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): Promise { this.logService.trace('windowsService#openWindow'); if (!paths || !paths.length) { return void 0; @@ -304,19 +303,19 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable }); } - async openNewWindow(options?: INewWindowOptions): TPromise { + async openNewWindow(options?: INewWindowOptions): Promise { this.logService.trace('windowsService#openNewWindow ' + JSON.stringify(options)); this.windowsMainService.openNewWindow(OpenContext.API, options); } - async showWindow(windowId: number): TPromise { + async showWindow(windowId: number): Promise { this.logService.trace('windowsService#showWindow', windowId); return this.withWindow(windowId, codeWindow => codeWindow.win.show()); } - async getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> { + async getWindows(): Promise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> { this.logService.trace('windowsService#getWindows'); const windows = this.windowsMainService.getWindows(); @@ -325,64 +324,64 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable return result; } - async getWindowCount(): TPromise { + async getWindowCount(): Promise { this.logService.trace('windowsService#getWindowCount'); return this.windowsMainService.getWindows().length; } - async log(severity: string, ...messages: string[]): TPromise { + async log(severity: string, ...messages: string[]): Promise { console[severity].apply(console, ...messages); } - async showItemInFolder(path: string): TPromise { + async showItemInFolder(path: string): Promise { this.logService.trace('windowsService#showItemInFolder'); shell.showItemInFolder(path); } - async getActiveWindowId(): TPromise { + async getActiveWindowId(): Promise { return this._activeWindowId; } - async openExternal(url: string): TPromise { + async openExternal(url: string): Promise { this.logService.trace('windowsService#openExternal'); return shell.openExternal(url); } - async startCrashReporter(config: Electron.CrashReporterStartOptions): TPromise { + async startCrashReporter(config: Electron.CrashReporterStartOptions): Promise { this.logService.trace('windowsService#startCrashReporter'); crashReporter.start(config); } - async quit(): TPromise { + async quit(): Promise { this.logService.trace('windowsService#quit'); this.windowsMainService.quit(); } - async relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise { + async relaunch(options: { addArgs?: string[], removeArgs?: string[] }): Promise { this.logService.trace('windowsService#relaunch'); this.lifecycleService.relaunch(options); } - async whenSharedProcessReady(): TPromise { + async whenSharedProcessReady(): Promise { this.logService.trace('windowsService#whenSharedProcessReady'); return this.sharedProcess.whenReady(); } - async toggleSharedProcess(): TPromise { + async toggleSharedProcess(): Promise { this.logService.trace('windowsService#toggleSharedProcess'); this.sharedProcess.toggle(); } - async openAboutDialog(): TPromise { + async openAboutDialog(): Promise { this.logService.trace('windowsService#openAboutDialog'); let version = app.getVersion(); @@ -426,7 +425,7 @@ export class WindowsService implements IWindowsService, IURLHandler, IDisposable }); } - async handleURL(uri: URI): TPromise { + async handleURL(uri: URI): Promise { // Catch file URLs if (uri.authority === Schemas.file && !!uri.path) { diff --git a/src/vs/platform/windows/node/windowsIpc.ts b/src/vs/platform/windows/node/windowsIpc.ts index 10a3c73d19f..ecacad043a0 100644 --- a/src/vs/platform/windows/node/windowsIpc.ts +++ b/src/vs/platform/windows/node/windowsIpc.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import { Event } from 'vs/base/common/event'; import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { IWindowsService, INativeOpenDialogOptions, IEnterWorkspaceResult, CrashReporterStartOptions, IMessageBoxResult, MessageBoxOptions, SaveDialogOptions, OpenDialogOptions, IDevToolsOptions, INewWindowOptions } from 'vs/platform/windows/common/windows'; @@ -136,83 +135,83 @@ export class WindowsChannelClient implements IWindowsService { get onWindowUnmaximize(): Event { return this.channel.listen('onWindowUnmaximize'); } get onRecentlyOpenedChange(): Event { return this.channel.listen('onRecentlyOpenedChange'); } - pickFileFolderAndOpen(options: INativeOpenDialogOptions): TPromise { + pickFileFolderAndOpen(options: INativeOpenDialogOptions): Thenable { return this.channel.call('pickFileFolderAndOpen', options); } - pickFileAndOpen(options: INativeOpenDialogOptions): TPromise { + pickFileAndOpen(options: INativeOpenDialogOptions): Thenable { return this.channel.call('pickFileAndOpen', options); } - pickFolderAndOpen(options: INativeOpenDialogOptions): TPromise { + pickFolderAndOpen(options: INativeOpenDialogOptions): Thenable { return this.channel.call('pickFolderAndOpen', options); } - pickWorkspaceAndOpen(options: INativeOpenDialogOptions): TPromise { + pickWorkspaceAndOpen(options: INativeOpenDialogOptions): Thenable { return this.channel.call('pickWorkspaceAndOpen', options); } - showMessageBox(windowId: number, options: MessageBoxOptions): TPromise { + showMessageBox(windowId: number, options: MessageBoxOptions): Thenable { return this.channel.call('showMessageBox', [windowId, options]); } - showSaveDialog(windowId: number, options: SaveDialogOptions): TPromise { + showSaveDialog(windowId: number, options: SaveDialogOptions): Thenable { return this.channel.call('showSaveDialog', [windowId, options]); } - showOpenDialog(windowId: number, options: OpenDialogOptions): TPromise { + showOpenDialog(windowId: number, options: OpenDialogOptions): Thenable { return this.channel.call('showOpenDialog', [windowId, options]); } - reloadWindow(windowId: number, args?: ParsedArgs): TPromise { + reloadWindow(windowId: number, args?: ParsedArgs): Thenable { return this.channel.call('reloadWindow', [windowId, args]); } - openDevTools(windowId: number, options?: IDevToolsOptions): TPromise { + openDevTools(windowId: number, options?: IDevToolsOptions): Thenable { return this.channel.call('openDevTools', [windowId, options]); } - toggleDevTools(windowId: number): TPromise { + toggleDevTools(windowId: number): Thenable { return this.channel.call('toggleDevTools', windowId); } - closeWorkspace(windowId: number): TPromise { + closeWorkspace(windowId: number): Thenable { return this.channel.call('closeWorkspace', windowId); } - enterWorkspace(windowId: number, path: string): TPromise { + enterWorkspace(windowId: number, path: string): Thenable { return this.channel.call('enterWorkspace', [windowId, path]); } - createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): TPromise { + createAndEnterWorkspace(windowId: number, folders?: IWorkspaceFolderCreationData[], path?: string): Thenable { return this.channel.call('createAndEnterWorkspace', [windowId, folders, path]); } - saveAndEnterWorkspace(windowId: number, path: string): TPromise { + saveAndEnterWorkspace(windowId: number, path: string): Thenable { return this.channel.call('saveAndEnterWorkspace', [windowId, path]); } - toggleFullScreen(windowId: number): TPromise { + toggleFullScreen(windowId: number): Thenable { return this.channel.call('toggleFullScreen', windowId); } - setRepresentedFilename(windowId: number, fileName: string): TPromise { + setRepresentedFilename(windowId: number, fileName: string): Thenable { return this.channel.call('setRepresentedFilename', [windowId, fileName]); } - addRecentlyOpened(files: URI[]): TPromise { + addRecentlyOpened(files: URI[]): Thenable { return this.channel.call('addRecentlyOpened', files); } - removeFromRecentlyOpened(paths: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI)[]): TPromise { + removeFromRecentlyOpened(paths: (IWorkspaceIdentifier | ISingleFolderWorkspaceIdentifier | URI)[]): Thenable { return this.channel.call('removeFromRecentlyOpened', paths); } - clearRecentlyOpened(): TPromise { + clearRecentlyOpened(): Thenable { return this.channel.call('clearRecentlyOpened'); } - getRecentlyOpened(windowId: number): TPromise { + getRecentlyOpened(windowId: number): Thenable { return this.channel.call('getRecentlyOpened', windowId) .then((recentlyOpened: IRecentlyOpened) => { recentlyOpened.workspaces = recentlyOpened.workspaces.map(workspace => isWorkspaceIdentifier(workspace) ? workspace : URI.revive(workspace)); @@ -221,127 +220,127 @@ export class WindowsChannelClient implements IWindowsService { }); } - newWindowTab(): TPromise { + newWindowTab(): Thenable { return this.channel.call('newWindowTab'); } - showPreviousWindowTab(): TPromise { + showPreviousWindowTab(): Thenable { return this.channel.call('showPreviousWindowTab'); } - showNextWindowTab(): TPromise { + showNextWindowTab(): Thenable { return this.channel.call('showNextWindowTab'); } - moveWindowTabToNewWindow(): TPromise { + moveWindowTabToNewWindow(): Thenable { return this.channel.call('moveWindowTabToNewWindow'); } - mergeAllWindowTabs(): TPromise { + mergeAllWindowTabs(): Thenable { return this.channel.call('mergeAllWindowTabs'); } - toggleWindowTabsBar(): TPromise { + toggleWindowTabsBar(): Thenable { return this.channel.call('toggleWindowTabsBar'); } - focusWindow(windowId: number): TPromise { + focusWindow(windowId: number): Thenable { return this.channel.call('focusWindow', windowId); } - closeWindow(windowId: number): TPromise { + closeWindow(windowId: number): Thenable { return this.channel.call('closeWindow', windowId); } - isFocused(windowId: number): TPromise { + isFocused(windowId: number): Thenable { return this.channel.call('isFocused', windowId); } - isMaximized(windowId: number): TPromise { + isMaximized(windowId: number): Thenable { return this.channel.call('isMaximized', windowId); } - maximizeWindow(windowId: number): TPromise { + maximizeWindow(windowId: number): Thenable { return this.channel.call('maximizeWindow', windowId); } - unmaximizeWindow(windowId: number): TPromise { + unmaximizeWindow(windowId: number): Thenable { return this.channel.call('unmaximizeWindow', windowId); } - minimizeWindow(windowId: number): TPromise { + minimizeWindow(windowId: number): Thenable { return this.channel.call('minimizeWindow', windowId); } - onWindowTitleDoubleClick(windowId: number): TPromise { + onWindowTitleDoubleClick(windowId: number): Thenable { return this.channel.call('onWindowTitleDoubleClick', windowId); } - setDocumentEdited(windowId: number, flag: boolean): TPromise { + setDocumentEdited(windowId: number, flag: boolean): Thenable { return this.channel.call('setDocumentEdited', [windowId, flag]); } - quit(): TPromise { + quit(): Thenable { return this.channel.call('quit'); } - relaunch(options: { addArgs?: string[], removeArgs?: string[] }): TPromise { + relaunch(options: { addArgs?: string[], removeArgs?: string[] }): Thenable { return this.channel.call('relaunch', [options]); } - whenSharedProcessReady(): TPromise { + whenSharedProcessReady(): Thenable { return this.channel.call('whenSharedProcessReady'); } - toggleSharedProcess(): TPromise { + toggleSharedProcess(): Thenable { return this.channel.call('toggleSharedProcess'); } - openWindow(windowId: number, paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): TPromise { + openWindow(windowId: number, paths: URI[], options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean, args?: ParsedArgs }): Thenable { return this.channel.call('openWindow', [windowId, paths, options]); } - openNewWindow(options?: INewWindowOptions): TPromise { + openNewWindow(options?: INewWindowOptions): Thenable { return this.channel.call('openNewWindow', options); } - showWindow(windowId: number): TPromise { + showWindow(windowId: number): Thenable { return this.channel.call('showWindow', windowId); } - getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> { + getWindows(): Thenable<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> { return this.channel.call<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]>('getWindows').then(result => { result.forEach(win => win.folderUri = win.folderUri ? URI.revive(win.folderUri) : win.folderUri); return result; }); } - getWindowCount(): TPromise { + getWindowCount(): Thenable { return this.channel.call('getWindowCount'); } - log(severity: string, ...messages: string[]): TPromise { + log(severity: string, ...messages: string[]): Thenable { return this.channel.call('log', [severity, messages]); } - showItemInFolder(path: string): TPromise { + showItemInFolder(path: string): Thenable { return this.channel.call('showItemInFolder', path); } - getActiveWindowId(): TPromise { + getActiveWindowId(): Thenable { return this.channel.call('getActiveWindowId'); } - openExternal(url: string): TPromise { + openExternal(url: string): Thenable { return this.channel.call('openExternal', url); } - startCrashReporter(config: CrashReporterStartOptions): TPromise { + startCrashReporter(config: CrashReporterStartOptions): Thenable { return this.channel.call('startCrashReporter', config); } - updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): TPromise { + updateTouchBar(windowId: number, items: ISerializableCommandAction[][]): Thenable { return this.channel.call('updateTouchBar', [windowId, items]); } - openAboutDialog(): TPromise { + openAboutDialog(): Thenable { return this.channel.call('openAboutDialog'); } diff --git a/src/vs/platform/workspaces/common/workspaces.ts b/src/vs/platform/workspaces/common/workspaces.ts index 31e0d076f35..d7617021103 100644 --- a/src/vs/platform/workspaces/common/workspaces.ts +++ b/src/vs/platform/workspaces/common/workspaces.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; -import { TPromise } from 'vs/base/common/winjs.base'; import { localize } from 'vs/nls'; import { Event } from 'vs/base/common/event'; import { IWorkspaceFolder, IWorkspace } from 'vs/platform/workspace/common/workspace'; @@ -81,11 +80,11 @@ export interface IWorkspacesMainService extends IWorkspacesService { onWorkspaceSaved: Event; onUntitledWorkspaceDeleted: Event; - saveWorkspace(workspace: IWorkspaceIdentifier, target: string): TPromise; + saveWorkspace(workspace: IWorkspaceIdentifier, target: string): Thenable; createWorkspaceSync(folders?: IWorkspaceFolderCreationData[]): IWorkspaceIdentifier; - resolveWorkspace(path: string): TPromise; + resolveWorkspace(path: string): Thenable; resolveWorkspaceSync(path: string): IResolvedWorkspace | null; @@ -101,7 +100,7 @@ export interface IWorkspacesMainService extends IWorkspacesService { export interface IWorkspacesService { _serviceBrand: any; - createWorkspace(folders?: IWorkspaceFolderCreationData[]): TPromise; + createWorkspace(folders?: IWorkspaceFolderCreationData[]): Thenable; } export function isSingleFolderWorkspaceIdentifier(obj: any): obj is ISingleFolderWorkspaceIdentifier { @@ -137,4 +136,4 @@ export type IWorkspaceInitializationPayload = IMultiFolderWorkspaceInitializatio export function isSingleFolderWorkspaceInitializationPayload(obj: any): obj is ISingleFolderWorkspaceInitializationPayload { return isSingleFolderWorkspaceIdentifier((obj.folder as ISingleFolderWorkspaceIdentifier)); -} \ No newline at end of file +} diff --git a/src/vs/platform/workspaces/electron-main/workspacesMainService.ts b/src/vs/platform/workspaces/electron-main/workspacesMainService.ts index 37b8973e465..84d82b8529f 100644 --- a/src/vs/platform/workspaces/electron-main/workspacesMainService.ts +++ b/src/vs/platform/workspaces/electron-main/workspacesMainService.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import { IWorkspacesMainService, IWorkspaceIdentifier, WORKSPACE_EXTENSION, IWorkspaceSavedEvent, UNTITLED_WORKSPACE_NAME, IResolvedWorkspace, IStoredWorkspaceFolder, isRawFileWorkspaceFolder, isStoredWorkspaceFolder, IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces'; -import { TPromise } from 'vs/base/common/winjs.base'; import { isParent } from 'vs/platform/files/common/files'; import { IEnvironmentService } from 'vs/platform/environment/common/environment'; import { extname, join, dirname, isAbsolute, resolve } from 'path'; @@ -50,7 +49,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain this.workspacesHome = environmentService.workspacesHome; } - resolveWorkspace(path: string): TPromise { + resolveWorkspace(path: string): Thenable { if (!this.isWorkspacePath(path)) { return Promise.resolve(null); // does not look like a valid workspace config file } @@ -115,7 +114,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain return isParent(path, this.environmentService.workspacesHome, !isLinux /* ignore case */); } - createWorkspace(folders?: IWorkspaceFolderCreationData[]): TPromise { + createWorkspace(folders?: IWorkspaceFolderCreationData[]): Thenable { const { workspace, configParent, storedWorkspace } = this.createUntitledWorkspace(folders); return mkdirp(configParent).then(() => { @@ -187,7 +186,7 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain return this.isInsideWorkspacesHome(workspace.configPath); } - saveWorkspace(workspace: IWorkspaceIdentifier, targetConfigPath: string): TPromise { + saveWorkspace(workspace: IWorkspaceIdentifier, targetConfigPath: string): Thenable { // Return early if target is same as source if (isEqual(workspace.configPath, targetConfigPath, !isLinux)) { @@ -293,4 +292,4 @@ export class WorkspacesMainService extends Disposable implements IWorkspacesMain return untitledWorkspaces; } -} \ No newline at end of file +} diff --git a/src/vs/platform/workspaces/node/workspacesIpc.ts b/src/vs/platform/workspaces/node/workspacesIpc.ts index f69ba502696..b59519ccaa0 100644 --- a/src/vs/platform/workspaces/node/workspacesIpc.ts +++ b/src/vs/platform/workspaces/node/workspacesIpc.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import { IChannel, IServerChannel } from 'vs/base/parts/ipc/node/ipc'; import { IWorkspacesService, IWorkspaceIdentifier, IWorkspaceFolderCreationData, IWorkspacesMainService } from 'vs/platform/workspaces/common/workspaces'; import { URI } from 'vs/base/common/uri'; @@ -45,7 +44,7 @@ export class WorkspacesChannelClient implements IWorkspacesService { constructor(private channel: IChannel) { } - createWorkspace(folders?: IWorkspaceFolderCreationData[]): TPromise { + createWorkspace(folders?: IWorkspaceFolderCreationData[]): Thenable { return this.channel.call('createWorkspace', folders); } -} \ No newline at end of file +} diff --git a/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts b/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts index 23ce7a08111..9c844bfb451 100644 --- a/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts +++ b/src/vs/workbench/browser/parts/editor/breadcrumbsPicker.ts @@ -14,7 +14,6 @@ import { dispose, IDisposable } from 'vs/base/common/lifecycle'; import { join } from 'vs/base/common/paths'; import { basename, dirname, isEqual } from 'vs/base/common/resources'; import { URI } from 'vs/base/common/uri'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IDataSource, IFilter, IRenderer, ISorter, ITree } from 'vs/base/parts/tree/browser/tree'; import 'vs/css!./media/breadcrumbscontrol'; import { OutlineElement, OutlineModel, TreeElement } from 'vs/editor/contrib/documentSymbols/outlineModel'; @@ -228,7 +227,7 @@ export class FileDataSource implements IDataSource { return URI.isUri(element) || IWorkspace.isIWorkspace(element) || IWorkspaceFolder.isIWorkspaceFolder(element) || element.isDirectory; } - getChildren(tree: ITree, element: IWorkspace | IWorkspaceFolder | IFileStat | URI): TPromise { + getChildren(tree: ITree, element: IWorkspace | IWorkspaceFolder | IFileStat | URI): Thenable { if (IWorkspace.isIWorkspace(element)) { return Promise.resolve(element.folders).then(folders => { for (let child of folders) { @@ -253,7 +252,7 @@ export class FileDataSource implements IDataSource { }); } - getParent(tree: ITree, element: IWorkspace | URI | IWorkspaceFolder | IFileStat): TPromise { + getParent(tree: ITree, element: IWorkspace | URI | IWorkspaceFolder | IFileStat): Thenable { return Promise.resolve(this._parents.get(element)); } } diff --git a/src/vs/workbench/browser/parts/editor/editorControl.ts b/src/vs/workbench/browser/parts/editor/editorControl.ts index 0d24bf623be..397a1b12c2c 100644 --- a/src/vs/workbench/browser/parts/editor/editorControl.ts +++ b/src/vs/workbench/browser/parts/editor/editorControl.ts @@ -8,7 +8,6 @@ import { EditorInput, EditorOptions } from 'vs/workbench/common/editor'; import { Dimension, show, hide, addClass } from 'vs/base/browser/dom'; import { Registry } from 'vs/platform/registry/common/platform'; import { IEditorRegistry, Extensions as EditorExtensions, IEditorDescriptor } from 'vs/workbench/browser/editor'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IPartService } from 'vs/workbench/services/part/common/partService'; import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor'; import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation'; @@ -57,7 +56,7 @@ export class EditorControl extends Disposable { return this._activeControl; } - openEditor(editor: EditorInput, options?: EditorOptions): TPromise { + openEditor(editor: EditorInput, options?: EditorOptions): Thenable { // Editor control const descriptor = Registry.as(EditorExtensions.Editors).getEditor(editor); @@ -146,7 +145,7 @@ export class EditorControl extends Disposable { this._onDidSizeConstraintsChange.fire(); } - private doSetInput(control: BaseEditor, editor: EditorInput, options: EditorOptions): TPromise { + private doSetInput(control: BaseEditor, editor: EditorInput, options: EditorOptions): Thenable { // If the input did not change, return early and only apply the options // unless the options instruct us to force open it even if it is the same diff --git a/src/vs/workbench/browser/parts/editor/editorGroupView.ts b/src/vs/workbench/browser/parts/editor/editorGroupView.ts index 8ce9fe7d64f..6d1863f93f2 100644 --- a/src/vs/workbench/browser/parts/editor/editorGroupView.ts +++ b/src/vs/workbench/browser/parts/editor/editorGroupView.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import 'vs/css!./media/editorgroupview'; -import { TPromise } from 'vs/base/common/winjs.base'; import { EditorGroup, IEditorOpenOptions, EditorCloseEvent, ISerializedEditorGroup, isSerializedEditorGroup } from 'vs/workbench/common/editor/editorGroup'; import { EditorInput, EditorOptions, GroupIdentifier, ConfirmResult, SideBySideEditorInput, CloseDirection, IEditorCloseEvent, EditorGroupActiveEditorDirtyContext, IEditor } from 'vs/workbench/common/editor'; import { Event, Emitter, Relay } from 'vs/base/common/event'; @@ -112,7 +111,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { private ignoreOpenEditorErrors: boolean; private disposedEditorsWorker: RunOnceWorker; - private mapEditorToPendingConfirmation: Map> = new Map>(); + private mapEditorToPendingConfirmation: Map> = new Map>(); constructor( private accessor: IEditorGroupsAccessor, @@ -725,7 +724,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { //#region openEditor() - openEditor(editor: EditorInput, options?: EditorOptions): TPromise { + openEditor(editor: EditorInput, options?: EditorOptions): Thenable { // Guard against invalid inputs if (!editor) { @@ -744,7 +743,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { return this.doOpenEditor(editor, options); } - private doOpenEditor(editor: EditorInput, options?: EditorOptions): TPromise { + private doOpenEditor(editor: EditorInput, options?: EditorOptions): Thenable { // Determine options const openEditorOptions: IEditorOpenOptions = { @@ -785,10 +784,10 @@ export class EditorGroupView extends Themable implements IEditorGroupView { return this.doShowEditor(editor, openEditorOptions.active, options); } - private doShowEditor(editor: EditorInput, active: boolean, options?: EditorOptions): TPromise { + private doShowEditor(editor: EditorInput, active: boolean, options?: EditorOptions): Thenable { // Show in editor control if the active editor changed - let openEditorPromise: TPromise; + let openEditorPromise: Thenable; if (active) { openEditorPromise = this.editorControl.openEditor(editor, options).then(result => { @@ -848,7 +847,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { //#region openEditors() - openEditors(editors: { editor: EditorInput, options?: EditorOptions }[]): TPromise { + openEditors(editors: { editor: EditorInput, options?: EditorOptions }[]): Thenable { if (!editors.length) { return Promise.resolve(null); } @@ -959,7 +958,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { //#region closeEditor() - closeEditor(editor: EditorInput = this.activeEditor): TPromise { + closeEditor(editor: EditorInput = this.activeEditor): Thenable { if (!editor) { return Promise.resolve(); } @@ -1075,7 +1074,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { this._group.closeEditor(editor); } - private handleDirty(editors: EditorInput[]): TPromise { + private handleDirty(editors: EditorInput[]): Thenable { if (!editors.length) { return Promise.resolve(false); // no veto } @@ -1105,7 +1104,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { }); } - private doHandleDirty(editor: EditorInput): TPromise { + private doHandleDirty(editor: EditorInput): Thenable { if ( !editor.isDirty() || // editor must be dirty this.accessor.groups.some(groupView => groupView !== this && groupView.group.contains(editor, true /* support side by side */)) || // editor is opened in other group @@ -1152,7 +1151,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { //#region closeEditors() - closeEditors(args: EditorInput[] | ICloseEditorsFilter): TPromise { + closeEditors(args: EditorInput[] | ICloseEditorsFilter): Thenable { if (this.isEmpty()) { return Promise.resolve(); } @@ -1225,7 +1224,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { //#region closeAllEditors() - closeAllEditors(): TPromise { + closeAllEditors(): Thenable { if (this.isEmpty()) { // If the group is empty and the request is to close all editors, we still close @@ -1270,7 +1269,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { //#region replaceEditors() - replaceEditors(editors: EditorReplacement[]): TPromise { + replaceEditors(editors: EditorReplacement[]): Thenable { // Extract active vs. inactive replacements let activeReplacement: EditorReplacement; @@ -1420,7 +1419,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView { } class EditorOpeningEvent implements IEditorOpeningEvent { - private override: () => TPromise; + private override: () => Thenable; constructor( private _group: GroupIdentifier, @@ -1441,11 +1440,11 @@ class EditorOpeningEvent implements IEditorOpeningEvent { return this._options; } - prevent(callback: () => TPromise): void { + prevent(callback: () => Thenable): void { this.override = callback; } - isPrevented(): () => TPromise { + isPrevented(): () => Thenable { return this.override; } } diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts index 898b49f23fd..37bc456e121 100644 --- a/src/vs/workbench/common/editor.ts +++ b/src/vs/workbench/common/editor.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import { Event, Emitter } from 'vs/base/common/event'; import * as objects from 'vs/base/common/objects'; import * as types from 'vs/base/common/types'; @@ -312,7 +311,7 @@ export interface IEditorInput extends IDisposable { /** * Reverts this input. */ - revert(options?: IRevertOptions): TPromise; + revert(options?: IRevertOptions): Thenable; /** * Returns if the other object matches this input. @@ -415,21 +414,21 @@ export abstract class EditorInput extends Disposable implements IEditorInput { /** * Subclasses should bring up a proper dialog for the user if the editor is dirty and return the result. */ - confirmSave(): TPromise { + confirmSave(): Thenable { return Promise.resolve(ConfirmResult.DONT_SAVE); } /** * Saves the editor if it is dirty. Subclasses return a promise with a boolean indicating the success of the operation. */ - save(): TPromise { + save(): Thenable { return Promise.resolve(true); } /** * Reverts the editor if it is dirty. Subclasses return a promise with a boolean indicating the success of the operation. */ - revert(options?: IRevertOptions): TPromise { + revert(options?: IRevertOptions): Thenable { return Promise.resolve(true); } @@ -547,15 +546,15 @@ export class SideBySideEditorInput extends EditorInput { return this.master.isDirty(); } - confirmSave(): TPromise { + confirmSave(): Thenable { return this.master.confirmSave(); } - save(): TPromise { + save(): Thenable { return this.master.save(); } - revert(): TPromise { + revert(): Thenable { return this.master.revert(); } diff --git a/src/vs/workbench/common/editor/resourceEditorInput.ts b/src/vs/workbench/common/editor/resourceEditorInput.ts index 2e6bb6d673c..aa6410fbc83 100644 --- a/src/vs/workbench/common/editor/resourceEditorInput.ts +++ b/src/vs/workbench/common/editor/resourceEditorInput.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import { EditorInput, ITextEditorModel } from 'vs/workbench/common/editor'; import { URI } from 'vs/base/common/uri'; import { IReference } from 'vs/base/common/lifecycle'; @@ -20,7 +19,7 @@ export class ResourceEditorInput extends EditorInput { static readonly ID: string = 'workbench.editors.resourceEditorInput'; - private modelReference: TPromise>; + private modelReference: Thenable>; private resource: URI; private name: string; private description: string; diff --git a/src/vs/workbench/common/editor/untitledEditorInput.ts b/src/vs/workbench/common/editor/untitledEditorInput.ts index 9e3ab4342ba..94392e03a4f 100644 --- a/src/vs/workbench/common/editor/untitledEditorInput.ts +++ b/src/vs/workbench/common/editor/untitledEditorInput.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import { URI } from 'vs/base/common/uri'; import { suggestFilename } from 'vs/base/common/mime'; import { memoize } from 'vs/base/common/decorators'; @@ -28,7 +27,7 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport private _hasAssociatedFilePath: boolean; private cachedModel: UntitledEditorModel; - private modelResolve: TPromise; + private modelResolve: Thenable; private readonly _onDidModelChangeContent: Emitter = this._register(new Emitter()); get onDidModelChangeContent(): Event { return this._onDidModelChangeContent.event; } @@ -163,15 +162,15 @@ export class UntitledEditorInput extends EditorInput implements IEncodingSupport return this.hasAssociatedFilePath; } - confirmSave(): TPromise { + confirmSave(): Thenable { return this.textFileService.confirmSave([this.resource]); } - save(): TPromise { + save(): Thenable { return this.textFileService.save(this.resource); } - revert(): TPromise { + revert(): Thenable { if (this.cachedModel) { this.cachedModel.revert(); } diff --git a/src/vs/workbench/electron-browser/window.ts b/src/vs/workbench/electron-browser/window.ts index 19cf3053d8e..7466b83fde2 100644 --- a/src/vs/workbench/electron-browser/window.ts +++ b/src/vs/workbench/electron-browser/window.ts @@ -411,7 +411,7 @@ export class ElectronWindow extends Themable { } private openResources(resources: (IResourceInput | IUntitledResourceInput)[], diffMode: boolean): void { - this.lifecycleService.when(LifecyclePhase.Ready).then(() => { + this.lifecycleService.when(LifecyclePhase.Ready).then((): Thenable => { // In diffMode we open 2 resources as diff if (diffMode && resources.length === 2) { diff --git a/src/vs/workbench/parts/files/common/editors/fileEditorInput.ts b/src/vs/workbench/parts/files/common/editors/fileEditorInput.ts index 7ba0d07c57e..0fa6fce1e2f 100644 --- a/src/vs/workbench/parts/files/common/editors/fileEditorInput.ts +++ b/src/vs/workbench/parts/files/common/editors/fileEditorInput.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import { localize } from 'vs/nls'; -import { TPromise } from 'vs/base/common/winjs.base'; import { memoize } from 'vs/base/common/decorators'; import * as paths from 'vs/base/common/paths'; import * as resources from 'vs/base/common/resources'; @@ -29,7 +28,7 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput { private preferredEncoding: string; private forceOpenAsBinary: boolean; private forceOpenAsText: boolean; - private textModelReference: TPromise>; + private textModelReference: Thenable>; private name: string; /** @@ -223,15 +222,15 @@ export class FileEditorInput extends EditorInput implements IFileEditorInput { return model.isDirty(); } - confirmSave(): TPromise { + confirmSave(): Thenable { return this.textFileService.confirmSave([this.resource]); } - save(): TPromise { + save(): Thenable { return this.textFileService.save(this.resource); } - revert(options?: IRevertOptions): TPromise { + revert(options?: IRevertOptions): Thenable { return this.textFileService.revert(this.resource, options); } diff --git a/src/vs/workbench/parts/files/common/files.ts b/src/vs/workbench/parts/files/common/files.ts index 36660df4223..142464b90c2 100644 --- a/src/vs/workbench/parts/files/common/files.ts +++ b/src/vs/workbench/parts/files/common/files.ts @@ -11,7 +11,6 @@ import { ExplorerItem, OpenEditor } from 'vs/workbench/parts/files/common/explor import { ContextKeyExpr, RawContextKey } from 'vs/platform/contextkey/common/contextkey'; import { ITextModelContentProvider } from 'vs/editor/common/services/resolverService'; import { IDisposable, dispose } from 'vs/base/common/lifecycle'; -import { TPromise } from 'vs/base/common/winjs.base'; import { ITextModel } from 'vs/editor/common/model'; import { IModelService } from 'vs/editor/common/services/modelService'; import { IModeService, ILanguageSelection } from 'vs/editor/common/services/modeService'; @@ -36,7 +35,7 @@ export interface IExplorerViewlet extends IViewlet { } export interface IExplorerView { - select(resource: URI, reveal?: boolean): TPromise; + select(resource: URI, reveal?: boolean): Thenable; } /** @@ -155,7 +154,7 @@ export class FileOnDiskContentProvider implements ITextModelContentProvider { ) { } - provideTextContent(resource: URI): TPromise { + provideTextContent(resource: URI): Thenable { const fileOnDiskResource = resource.with({ scheme: Schemas.file }); // Make sure our file from disk is resolved up to date @@ -179,7 +178,7 @@ export class FileOnDiskContentProvider implements ITextModelContentProvider { }); } - private resolveEditorModel(resource: URI, createAsNeeded = true): TPromise { + private resolveEditorModel(resource: URI, createAsNeeded = true): Thenable { const fileOnDiskResource = resource.with({ scheme: Schemas.file }); return this.textFileService.resolveTextContent(fileOnDiskResource).then(content => { diff --git a/src/vs/workbench/parts/files/electron-browser/fileActions.ts b/src/vs/workbench/parts/files/electron-browser/fileActions.ts index a261d9c43dc..3c76c5c912e 100644 --- a/src/vs/workbench/parts/files/electron-browser/fileActions.ts +++ b/src/vs/workbench/parts/files/electron-browser/fileActions.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import 'vs/css!./media/fileactions'; -import { TPromise } from 'vs/base/common/winjs.base'; import * as nls from 'vs/nls'; import * as types from 'vs/base/common/types'; import { isWindows, isLinux } from 'vs/base/common/platform'; @@ -99,7 +98,7 @@ export class BaseErrorReportingAction extends Action { this._notificationService.error(toErrorMessage(error, false)); } - protected onErrorWithRetry(error: any, retry: () => TPromise): void { + protected onErrorWithRetry(error: any, retry: () => Thenable): void { this._notificationService.prompt(Severity.Error, toErrorMessage(error, false), [{ label: nls.localize('retry', "Retry"), @@ -168,7 +167,7 @@ class TriggerRenameFileAction extends BaseFileAction { return this.renameAction.validateFileName(this.element.parent, name); } - public run(context?: any): TPromise { + public run(context?: any): Thenable { if (!context) { return Promise.reject(new Error('No context provided to BaseEnableFileRenameAction.')); } @@ -235,7 +234,7 @@ export abstract class BaseRenameAction extends BaseFileAction { return super._isEnabled() && this.element && !this.element.isReadonly; } - public run(context?: any): TPromise { + public run(context?: any): Thenable { if (!context) { return Promise.reject(new Error('No context provided to BaseRenameFileAction.')); } @@ -278,7 +277,7 @@ export abstract class BaseRenameAction extends BaseFileAction { return validateFileName(parent, name); } - public abstract runAction(newName: string): TPromise; + public abstract runAction(newName: string): Thenable; } class RenameFileAction extends BaseRenameAction { @@ -296,7 +295,7 @@ class RenameFileAction extends BaseRenameAction { this._updateEnablement(); } - public runAction(newName: string): TPromise { + public runAction(newName: string): Thenable { const parentResource = this.element.parent.resource; const targetResource = resources.joinPath(parentResource, newName); @@ -333,7 +332,7 @@ export class BaseNewAction extends BaseFileAction { this.renameAction = editableAction; } - public run(context?: any): TPromise { + public run(context?: any): Thenable { if (!context) { return Promise.reject(new Error('No context provided to BaseNewAction.')); } @@ -457,7 +456,7 @@ export class GlobalNewUntitledFileAction extends Action { super(id, label); } - public run(): TPromise { + public run(): Thenable { return this.editorService.openEditor({ options: { pinned: true } } as IUntitledResourceInput); // untitled are always pinned } } @@ -492,7 +491,7 @@ class CreateFileAction extends BaseCreateAction { this._updateEnablement(); } - public runAction(fileName: string): TPromise { + public runAction(fileName: string): Thenable { const resource = this.element.parent.resource; return this.fileService.createFile(resources.joinPath(resource, fileName)).then(stat => { return this.editorService.openEditor({ resource: stat.resource, options: { pinned: true } }); @@ -519,7 +518,7 @@ class CreateFolderAction extends BaseCreateAction { this._updateEnablement(); } - public runAction(fileName: string): TPromise { + public runAction(fileName: string): Thenable { const resource = this.element.parent.resource; return this.fileService.createFolder(resources.joinPath(resource, fileName)).then(void 0, (error) => { this.onErrorWithRetry(error, () => this.runAction(fileName)); @@ -555,7 +554,7 @@ class BaseDeleteFileAction extends BaseFileAction { return super._isEnabled() && this.elements && this.elements.every(e => !e.isReadonly); } - public run(): TPromise { + public run(): Thenable { // Remove highlight if (this.tree) { @@ -572,7 +571,7 @@ class BaseDeleteFileAction extends BaseFileAction { const distinctElements = resources.distinctParents(this.elements, e => e.resource); // Handle dirty - let confirmDirtyPromise: TPromise = Promise.resolve(true); + let confirmDirtyPromise: Thenable = Promise.resolve(true); const dirty = this.textFileService.getDirty().filter(d => distinctElements.some(e => resources.isEqualOrParent(d, e.resource, !isLinux /* ignorecase */))); if (dirty.length) { let message: string; @@ -609,7 +608,7 @@ class BaseDeleteFileAction extends BaseFileAction { return null; } - let confirmDeletePromise: TPromise; + let confirmDeletePromise: Thenable; // Check if we need to ask for confirmation at all if (this.skipConfirm || (this.useTrash && this.configurationService.getValue(BaseDeleteFileAction.CONFIRM_DELETE_SETTING_KEY) === false)) { @@ -645,7 +644,7 @@ class BaseDeleteFileAction extends BaseFileAction { return confirmDeletePromise.then(confirmation => { // Check for confirmation checkbox - let updateConfirmSettingsPromise: TPromise = Promise.resolve(void 0); + let updateConfirmSettingsPromise: Thenable = Promise.resolve(void 0); if (confirmation.confirmed && confirmation.checkboxChecked === true) { updateConfirmSettingsPromise = this.configurationService.updateValue(BaseDeleteFileAction.CONFIRM_DELETE_SETTING_KEY, false, ConfigurationTarget.USER); } @@ -782,7 +781,7 @@ export class AddFilesAction extends BaseFileAction { this._updateEnablement(); } - public run(resourcesToAdd: URI[]): TPromise { + public run(resourcesToAdd: URI[]): Thenable { const addPromise = Promise.resolve(null).then(() => { if (resourcesToAdd && resourcesToAdd.length > 0) { @@ -808,7 +807,7 @@ export class AddFilesAction extends BaseFileAction { targetNames.add(isLinux ? child.name : child.name.toLowerCase()); }); - let overwritePromise: TPromise = Promise.resolve({ confirmed: true }); + let overwritePromise: Thenable = Promise.resolve({ confirmed: true }); if (resourcesToAdd.some(resource => { return targetNames.has(!resources.hasToIgnoreCase(resource) ? resources.basename(resource) : resources.basename(resource).toLowerCase()); })) { @@ -828,7 +827,7 @@ export class AddFilesAction extends BaseFileAction { } // Run add in sequence - const addPromisesFactory: ITask>[] = []; + const addPromisesFactory: ITask>[] = []; resourcesToAdd.forEach(resource => { addPromisesFactory.push(() => { const sourceFile = resource; @@ -891,7 +890,7 @@ class CopyFileAction extends BaseFileAction { this._updateEnablement(); } - public run(): TPromise { + public run(): Thenable { // Write to clipboard as file/folder to copy this.clipboardService.writeResources(this.elements.map(e => e.resource)); @@ -933,7 +932,7 @@ class PasteFileAction extends BaseFileAction { this._updateEnablement(); } - public run(fileToPaste: URI): TPromise { + public run(fileToPaste: URI): Thenable { // Check if target is ancestor of pasted folder if (this.element.resource.toString() !== fileToPaste.toString() && resources.isEqualOrParent(this.element.resource, fileToPaste, !isLinux /* ignorecase */)) { @@ -995,7 +994,7 @@ export class DuplicateFileAction extends BaseFileAction { this._updateEnablement(); } - public run(): TPromise { + public run(): Thenable { // Remove highlight if (this.tree) { @@ -1114,7 +1113,7 @@ export class GlobalCompareResourcesAction extends Action { super(id, label); } - public run(): TPromise { + public run(): Thenable { const activeInput = this.editorService.activeEditor; const activeResource = activeInput ? activeInput.getResource() : void 0; if (activeResource) { @@ -1171,7 +1170,7 @@ export class ToggleAutoSaveAction extends Action { super(id, label); } - public run(): TPromise { + public run(): Thenable { const setting = this.configurationService.inspect('files.autoSave'); let userAutoSaveConfig = setting.user; if (types.isUndefinedOrNull(userAutoSaveConfig)) { @@ -1211,7 +1210,7 @@ export abstract class BaseSaveAllAction extends BaseErrorReportingAction { } protected abstract includeUntitled(): boolean; - protected abstract doRun(context: any): TPromise; + protected abstract doRun(context: any): Thenable; private registerListeners(): void { @@ -1233,7 +1232,7 @@ export abstract class BaseSaveAllAction extends BaseErrorReportingAction { } } - public run(context?: any): TPromise { + public run(context?: any): Thenable { return this.doRun(context).then(() => true, error => { this.onError(error); return null; @@ -1256,7 +1255,7 @@ export class SaveAllAction extends BaseSaveAllAction { return 'explorer-action save-all'; } - protected doRun(context: any): TPromise { + protected doRun(context: any): Thenable { return this.commandService.executeCommand(SAVE_ALL_COMMAND_ID); } @@ -1274,7 +1273,7 @@ export class SaveAllInGroupAction extends BaseSaveAllAction { return 'explorer-action save-all'; } - protected doRun(context: any): TPromise { + protected doRun(context: any): Thenable { return this.commandService.executeCommand(SAVE_ALL_IN_GROUP_COMMAND_ID, {}, context); } @@ -1292,7 +1291,7 @@ export class CloseGroupAction extends Action { super(id, label, 'action-close-all-files'); } - public run(context?: any): TPromise { + public run(context?: any): Thenable { return this.commandService.executeCommand(CLOSE_EDITORS_AND_GROUP_COMMAND_ID, {}, context); } } @@ -1310,7 +1309,7 @@ export class FocusFilesExplorer extends Action { super(id, label); } - public run(): TPromise { + public run(): Thenable { return this.viewletService.openViewlet(VIEWLET_ID, true).then((viewlet: ExplorerViewlet) => { const view = viewlet.getExplorerView(); if (view) { @@ -1336,7 +1335,7 @@ export class ShowActiveFileInExplorer extends Action { super(id, label); } - public run(): TPromise { + public run(): Thenable { const resource = toResource(this.editorService.activeEditor, { supportSideBySide: true }); if (resource) { this.commandService.executeCommand(REVEAL_IN_EXPLORER_COMMAND_ID, resource); @@ -1361,7 +1360,7 @@ export class CollapseExplorerView extends Action { super(id, label); } - public run(): TPromise { + public run(): Thenable { return this.viewletService.openViewlet(VIEWLET_ID, true).then((viewlet: ExplorerViewlet) => { const explorerView = viewlet.getExplorerView(); if (explorerView) { @@ -1389,7 +1388,7 @@ export class RefreshExplorerView extends Action { super(id, label); } - public run(): TPromise { + public run(): Thenable { return this.viewletService.openViewlet(VIEWLET_ID, true).then((viewlet: ExplorerViewlet) => { const explorerView = viewlet.getExplorerView(); if (explorerView) { @@ -1414,7 +1413,7 @@ export class ShowOpenedFileInNewWindow extends Action { super(id, label); } - public run(): TPromise { + public run(): Thenable { const fileResource = toResource(this.editorService.activeEditor, { supportSideBySide: true, filter: Schemas.file /* todo@remote */ }); if (fileResource) { this.windowService.openWindow([fileResource], { forceNewWindow: true, forceOpenWorkspaceAsFile: true }); @@ -1511,7 +1510,7 @@ export class CompareWithClipboardAction extends Action { this.enabled = true; } - public run(): TPromise { + public run(): Thenable { const resource: URI = toResource(this.editorService.activeEditor, { supportSideBySide: true }); if (resource && (this.fileService.canHandleResource(resource) || resource.scheme === Schemas.untitled)) { if (!this.registrationDisposal) { @@ -1546,7 +1545,7 @@ class ClipboardContentProvider implements ITextModelContentProvider { @IModelService private modelService: IModelService ) { } - provideTextContent(resource: URI): TPromise { + provideTextContent(resource: URI): Thenable { const model = this.modelService.createModel(this.clipboardService.readText(), this.modeService.create('text/plain'), resource); return Promise.resolve(model); @@ -1571,7 +1570,7 @@ function getContext(listWidget: ListWidget, viewletService: IViewletService): IE // TODO@isidor these commands are calling into actions due to the complex inheritance action structure. // It should be the other way around, that actions call into commands. -function openExplorerAndRunAction(accessor: ServicesAccessor, constructor: IConstructorSignature2): TPromise { +function openExplorerAndRunAction(accessor: ServicesAccessor, constructor: IConstructorSignature2): Thenable { const instantationService = accessor.get(IInstantiationService); const listService = accessor.get(IListService); const viewletService = accessor.get(IViewletService); diff --git a/src/vs/workbench/parts/files/electron-browser/fileCommands.ts b/src/vs/workbench/parts/files/electron-browser/fileCommands.ts index 53f7cc2a0a6..2ade215a719 100644 --- a/src/vs/workbench/parts/files/electron-browser/fileCommands.ts +++ b/src/vs/workbench/parts/files/electron-browser/fileCommands.ts @@ -5,7 +5,6 @@ import * as nls from 'vs/nls'; import * as paths from 'vs/base/common/paths'; -import { TPromise } from 'vs/base/common/winjs.base'; import { URI } from 'vs/base/common/uri'; import { toResource, IEditorCommandsContext } from 'vs/workbench/common/editor'; import { IWindowsService, IWindowService } from 'vs/platform/windows/common/windows'; @@ -91,7 +90,7 @@ function save( untitledEditorService: IUntitledEditorService, textFileService: ITextFileService, editorGroupService: IEditorGroupsService -): TPromise { +): Thenable { function ensureForcedSave(options?: ISaveOptions): ISaveOptions { if (!options) { @@ -125,7 +124,7 @@ function save( } // Special case: an untitled file with associated path gets saved directly unless "saveAs" is true - let savePromise: TPromise; + let savePromise: Thenable; if (!isSaveAs && resource.scheme === Schemas.untitled && untitledEditorService.hasAssociatedFilePath(resource)) { savePromise = textFileService.save(resource, options).then((result) => { if (result) { @@ -185,7 +184,7 @@ function save( } function saveAll(saveAllArguments: any, editorService: IEditorService, untitledEditorService: IUntitledEditorService, - textFileService: ITextFileService, editorGroupService: IEditorGroupsService): TPromise { + textFileService: ITextFileService, editorGroupService: IEditorGroupsService): Thenable { // Store some properties per untitled file to restore later after save is completed const groupIdToUntitledResourceInput = new Map(); diff --git a/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts b/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts index 451ccb71d02..3e748e0774f 100644 --- a/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts +++ b/src/vs/workbench/parts/files/electron-browser/views/emptyView.ts @@ -7,7 +7,6 @@ import * as nls from 'vs/nls'; import * as errors from 'vs/base/common/errors'; import * as env from 'vs/base/common/platform'; import * as DOM from 'vs/base/browser/dom'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IAction } from 'vs/base/common/actions'; import { Button } from 'vs/base/browser/ui/button/button'; import { IActionItem } from 'vs/base/browser/ui/actionbar/actionbar'; @@ -124,7 +123,7 @@ export class EmptyView extends ViewletPanel { // no-op } - public setVisible(visible: boolean): TPromise { + public setVisible(visible: boolean): Thenable { return Promise.resolve(null); } @@ -134,7 +133,7 @@ export class EmptyView extends ViewletPanel { } } - protected reveal(element: any, relativeTop?: number): TPromise { + protected reveal(element: any, relativeTop?: number): Thenable { return Promise.resolve(null); } diff --git a/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts b/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts index c3fbbc65e91..5a1a8d9a1a9 100644 --- a/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts +++ b/src/vs/workbench/parts/files/electron-browser/views/explorerView.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import * as nls from 'vs/nls'; -import { TPromise } from 'vs/base/common/winjs.base'; import { URI } from 'vs/base/common/uri'; import * as perf from 'vs/base/common/performance'; import { ThrottledDelayer, Delayer } from 'vs/base/common/async'; @@ -733,7 +732,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView /** * Refresh the contents of the explorer to get up to date data from the disk about the file structure. */ - public refresh(): TPromise { + public refresh(): Thenable { if (!this.explorerViewer || this.explorerViewer.getHighlight()) { return Promise.resolve(null); } @@ -762,7 +761,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView }); } - private doRefresh(targetsToExpand: URI[] = []): TPromise { + private doRefresh(targetsToExpand: URI[] = []): Thenable { const targetsToResolve = this.model.roots.map(root => ({ root, resource: root.resource, options: { resolveTo: [] } })); // First time refresh: Receive target through active editor input or selection and also include settings from previous session @@ -801,7 +800,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView return promise; } - private resolveRoots(targetsToResolve: { root: ExplorerItem, resource: URI, options: { resolveTo: any[] } }[], targetsToExpand: URI[]): TPromise { + private resolveRoots(targetsToResolve: { root: ExplorerItem, resource: URI, options: { resolveTo: any[] } }[], targetsToExpand: URI[]): Thenable { // Display roots only when multi folder workspace let input = this.contextService.getWorkbenchState() === WorkbenchState.FOLDER ? this.model.roots[0] : this.model; @@ -864,7 +863,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView // There is a remote root, resolve the roots sequantally let statsToExpand: ExplorerItem[] = []; let delayer = new Delayer(100); - let delayerPromise: TPromise; + let delayerPromise: Thenable; return Promise.all(targetsToResolve.map((target, index) => this.fileService.resolveFile(target.resource, target.options) .then(result => result.isDirectory ? ExplorerItem.create(result, target.root, target.options.resolveTo) : errorRoot(target.resource, target.root), () => errorRoot(target.resource, target.root)) .then(modelStat => { @@ -920,7 +919,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView * Selects and reveal the file element provided by the given resource if its found in the explorer. Will try to * resolve the path from the disk in case the explorer is not yet expanded to the file yet. */ - public select(resource: URI, reveal: boolean = this.autoReveal): TPromise { + public select(resource: URI, reveal: boolean = this.autoReveal): Thenable { // Require valid path if (!resource) { @@ -968,7 +967,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView : undefined; } - private doSelect(fileStat: ExplorerItem, reveal: boolean): TPromise { + private doSelect(fileStat: ExplorerItem, reveal: boolean): Thenable { if (!fileStat) { return Promise.resolve(null); } @@ -983,7 +982,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView } // Reveal depending on flag - let revealPromise: TPromise; + let revealPromise: Thenable; if (reveal) { revealPromise = this.reveal(fileStat, 0.5); } else { @@ -999,7 +998,7 @@ export class ExplorerView extends TreeViewsViewletPanel implements IExplorerView }); } - private reveal(element: any, relativeTop?: number): TPromise { + private reveal(element: any, relativeTop?: number): Thenable { if (!this.tree) { return Promise.resolve(null); // return early if viewlet has not yet been created } diff --git a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts index c54fdec00f8..d610251a59c 100644 --- a/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts +++ b/src/vs/workbench/parts/files/electron-browser/views/explorerViewer.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import * as nls from 'vs/nls'; import * as objects from 'vs/base/common/objects'; import * as DOM from 'vs/base/browser/dom'; @@ -76,7 +75,7 @@ export class FileDataSource implements IDataSource { return stat instanceof Model || (stat instanceof ExplorerItem && (stat.isDirectory || stat.isRoot)); } - public getChildren(tree: ITree, stat: ExplorerItem | Model): TPromise { + public getChildren(tree: ITree, stat: ExplorerItem | Model): Thenable { if (stat instanceof Model) { return Promise.resolve(stat.roots); } @@ -121,7 +120,7 @@ export class FileDataSource implements IDataSource { } } - public getParent(tree: ITree, stat: ExplorerItem | Model): TPromise { + public getParent(tree: ITree, stat: ExplorerItem | Model): Thenable { if (!stat) { return Promise.resolve(null); // can be null if nothing selected in the tree } @@ -174,7 +173,7 @@ export class ActionRunner extends BaseActionRunner implements IActionRunner { this.viewletState = state; } - public run(action: IAction, context?: any): TPromise { + public run(action: IAction, context?: any): Thenable { return super.run(action, { viewletState: this.viewletState }); } } @@ -931,7 +930,7 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop { } } - private handleExternalDrop(tree: ITree, data: DesktopDragAndDropData, target: ExplorerItem | Model, originalEvent: DragMouseEvent): TPromise { + private handleExternalDrop(tree: ITree, data: DesktopDragAndDropData, target: ExplorerItem | Model, originalEvent: DragMouseEvent): Thenable { const droppedResources = extractResources(originalEvent.browserEvent as DragEvent, true); // Check for dropped external files to be folders @@ -945,7 +944,7 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop { if (folders.length > 0) { // If we are in no-workspace context, ask for confirmation to create a workspace - let confirmedPromise: TPromise = Promise.resolve({ confirmed: true }); + let confirmedPromise: Thenable = Promise.resolve({ confirmed: true }); if (this.contextService.getWorkbenchState() !== WorkbenchState.WORKSPACE) { confirmedPromise = this.dialogService.confirm({ message: folders.length > 1 ? nls.localize('dropFolders', "Do you want to add the folders to the workspace?") : nls.localize('dropFolder', "Do you want to add the folder to the workspace?"), @@ -974,11 +973,11 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop { }); } - private handleExplorerDrop(tree: ITree, data: IDragAndDropData, target: ExplorerItem | Model, originalEvent: DragMouseEvent): TPromise { + private handleExplorerDrop(tree: ITree, data: IDragAndDropData, target: ExplorerItem | Model, originalEvent: DragMouseEvent): Thenable { const sources: ExplorerItem[] = resources.distinctParents(data.getData(), s => s.resource); const isCopy = (originalEvent.ctrlKey && !isMacintosh) || (originalEvent.altKey && isMacintosh); - let confirmPromise: TPromise; + let confirmPromise: Thenable; // Handle confirm setting const confirmDragAndDrop = !isCopy && this.configurationService.getValue(FileDragAndDrop.CONFIRM_DND_SETTING_KEY); @@ -1001,7 +1000,7 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop { return confirmPromise.then(res => { // Check for confirmation checkbox - let updateConfirmSettingsPromise: TPromise = Promise.resolve(void 0); + let updateConfirmSettingsPromise: Thenable = Promise.resolve(void 0); if (res.confirmed && res.checkboxChecked === true) { updateConfirmSettingsPromise = this.configurationService.updateValue(FileDragAndDrop.CONFIRM_DND_SETTING_KEY, false, ConfigurationTarget.USER); } @@ -1017,7 +1016,7 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop { }); } - private doHandleRootDrop(roots: ExplorerItem[], target: ExplorerItem | Model): TPromise { + private doHandleRootDrop(roots: ExplorerItem[], target: ExplorerItem | Model): Thenable { if (roots.length === 0) { return Promise.resolve(undefined); } @@ -1049,7 +1048,7 @@ export class FileDragAndDrop extends SimpleFileResourceDragAndDrop { return this.workspaceEditingService.updateFolders(0, workspaceCreationData.length, workspaceCreationData); } - private doHandleExplorerDrop(tree: ITree, source: ExplorerItem, target: ExplorerItem | Model, isCopy: boolean): TPromise { + private doHandleExplorerDrop(tree: ITree, source: ExplorerItem, target: ExplorerItem | Model, isCopy: boolean): Thenable { if (!(target instanceof ExplorerItem)) { return Promise.resolve(void 0); } diff --git a/src/vs/workbench/parts/tasks/browser/quickOpen.ts b/src/vs/workbench/parts/tasks/browser/quickOpen.ts index 2c8f21108c2..b048d933ecd 100644 --- a/src/vs/workbench/parts/tasks/browser/quickOpen.ts +++ b/src/vs/workbench/parts/tasks/browser/quickOpen.ts @@ -5,7 +5,6 @@ import * as nls from 'vs/nls'; import * as Filters from 'vs/base/common/filters'; -import { TPromise } from 'vs/base/common/winjs.base'; import { Action, IAction } from 'vs/base/common/actions'; import { IStringDictionary } from 'vs/base/common/collections'; @@ -68,7 +67,7 @@ export class TaskGroupEntry extends Model.QuickOpenEntryGroup { export abstract class QuickOpenHandler extends Quickopen.QuickOpenHandler { - private tasks: TPromise<(CustomTask | ContributedTask)[]>; + private tasks: Thenable<(CustomTask | ContributedTask)[]>; constructor( protected quickOpenService: IQuickOpenService, @@ -149,7 +148,7 @@ export abstract class QuickOpenHandler extends Quickopen.QuickOpenHandler { } } - protected abstract getTasks(): TPromise<(CustomTask | ContributedTask)[]>; + protected abstract getTasks(): Thenable<(CustomTask | ContributedTask)[]>; protected abstract createEntry(task: CustomTask | ContributedTask, highlights: Model.IHighlight[]): TaskEntry; diff --git a/src/vs/workbench/parts/tasks/browser/taskQuickOpen.ts b/src/vs/workbench/parts/tasks/browser/taskQuickOpen.ts index f948cb249a5..d00939691db 100644 --- a/src/vs/workbench/parts/tasks/browser/taskQuickOpen.ts +++ b/src/vs/workbench/parts/tasks/browser/taskQuickOpen.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import * as nls from 'vs/nls'; -import { TPromise } from 'vs/base/common/winjs.base'; import * as QuickOpen from 'vs/base/parts/quickopen/common/quickOpen'; import * as Model from 'vs/base/parts/quickopen/browser/quickOpenModel'; import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen'; @@ -33,7 +32,7 @@ export class QuickOpenHandler extends base.QuickOpenHandler { public static readonly ID = 'workbench.picker.tasks'; - private activationPromise: TPromise; + private activationPromise: Thenable; constructor( @IQuickOpenService quickOpenService: IQuickOpenService, @@ -48,7 +47,7 @@ export class QuickOpenHandler extends base.QuickOpenHandler { return nls.localize('tasksAriaLabel', "Type the name of a task to run"); } - protected getTasks(): TPromise<(CustomTask | ContributedTask)[]> { + protected getTasks(): Thenable<(CustomTask | ContributedTask)[]> { return this.activationPromise.then(() => { return this.taskService.tasks().then(tasks => tasks.filter((task): task is CustomTask | ContributedTask => ContributedTask.is(task) || CustomTask.is(task))); }); diff --git a/src/vs/workbench/parts/tasks/common/taskService.ts b/src/vs/workbench/parts/tasks/common/taskService.ts index c531ebcabd1..fc9f1743174 100644 --- a/src/vs/workbench/parts/tasks/common/taskService.ts +++ b/src/vs/workbench/parts/tasks/common/taskService.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import { Action } from 'vs/base/common/actions'; import { Event } from 'vs/base/common/event'; import { LinkedMap } from 'vs/base/common/map'; @@ -20,7 +19,7 @@ export { ITaskSummary, Task, TaskTerminateResponse }; export const ITaskService = createDecorator('taskService'); export interface ITaskProvider { - provideTasks(validTypes: IStringDictionary): TPromise; + provideTasks(validTypes: IStringDictionary): Thenable; } export interface ProblemMatcherRunOptions { @@ -56,29 +55,29 @@ export interface ITaskService { supportsMultipleTaskExecutions: boolean; configureAction(): Action; - build(): TPromise; - runTest(): TPromise; - run(task: Task, options?: ProblemMatcherRunOptions): TPromise; + build(): Thenable; + runTest(): Thenable; + run(task: Task, options?: ProblemMatcherRunOptions): Thenable; inTerminal(): boolean; - isActive(): TPromise; - getActiveTasks(): TPromise; + isActive(): Thenable; + getActiveTasks(): Thenable; restart(task: Task): void; - terminate(task: Task): TPromise; - terminateAll(): TPromise; - tasks(filter?: TaskFilter): TPromise; - getWorkspaceTasks(runSource?: TaskRunSource): TPromise>; + terminate(task: Task): Thenable; + terminateAll(): Thenable; + tasks(filter?: TaskFilter): Thenable; + getWorkspaceTasks(runSource?: TaskRunSource): Thenable>; /** * @param alias The task's name, label or defined identifier. */ - getTask(workspaceFolder: IWorkspaceFolder | string, alias: string | TaskIdentifier, compareId?: boolean): TPromise; - getTasksForGroup(group: string): TPromise; + getTask(workspaceFolder: IWorkspaceFolder | string, alias: string | TaskIdentifier, compareId?: boolean): Thenable; + getTasksForGroup(group: string): Thenable; getRecentlyUsedTasks(): LinkedMap; createSorter(): TaskSorter; needsFolderQualification(); canCustomize(task: ContributedTask | CustomTask): boolean; - customize(task: ContributedTask | CustomTask, properties?: {}, openConfig?: boolean): TPromise; - openConfig(task: CustomTask | undefined): TPromise; + customize(task: ContributedTask | CustomTask, properties?: {}, openConfig?: boolean): Thenable; + openConfig(task: CustomTask | undefined): Thenable; registerTaskProvider(taskProvider: ITaskProvider): IDisposable; diff --git a/src/vs/workbench/parts/tasks/common/taskSystem.ts b/src/vs/workbench/parts/tasks/common/taskSystem.ts index 5287e7b99cc..02e97de4540 100644 --- a/src/vs/workbench/parts/tasks/common/taskSystem.ts +++ b/src/vs/workbench/parts/tasks/common/taskSystem.ts @@ -5,7 +5,6 @@ import { URI } from 'vs/base/common/uri'; import Severity from 'vs/base/common/severity'; -import { TPromise } from 'vs/base/common/winjs.base'; import { TerminateResponse } from 'vs/base/common/processes'; import { Event } from 'vs/base/common/event'; import { Platform } from 'vs/base/common/platform'; @@ -82,7 +81,7 @@ export const enum TaskExecuteKind { export interface ITaskExecuteResult { kind: TaskExecuteKind; - promise: TPromise; + promise: Thenable; task: Task; started?: { restartOnFileChanges?: string; @@ -130,11 +129,11 @@ export interface ITaskSystem { onDidStateChange: Event; run(task: Task, resolver: ITaskResolver): ITaskExecuteResult; rerun(): ITaskExecuteResult | undefined; - isActive(): TPromise; + isActive(): Thenable; isActiveSync(): boolean; getActiveTasks(): Task[]; canAutoTerminate(): boolean; - terminate(task: Task): TPromise; - terminateAll(): TPromise; + terminate(task: Task): Thenable; + terminateAll(): Thenable; revealTask(task: Task): boolean; } \ No newline at end of file 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 b519ef96e4b..8e1b885f769 100644 --- a/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts +++ b/src/vs/workbench/parts/tasks/electron-browser/task.contribution.ts @@ -9,7 +9,6 @@ import * as nls from 'vs/nls'; import * as semver from 'semver'; import { QuickOpenHandler } from 'vs/workbench/parts/tasks/browser/taskQuickOpen'; -import { TPromise } from 'vs/base/common/winjs.base'; import Severity from 'vs/base/common/severity'; import * as Objects from 'vs/base/common/objects'; import { URI } from 'vs/base/common/uri'; @@ -454,7 +453,7 @@ class TaskService extends Disposable implements ITaskService { private _providers: Map; private _taskSystemInfos: Map; - private _workspaceTasksPromise: TPromise>; + private _workspaceTasksPromise: Thenable>; private _taskSystem: ITaskSystem; private _taskSystemListener: IDisposable; @@ -701,7 +700,7 @@ class TaskService extends Disposable implements ITaskService { this._taskSystemInfos.set(key, info); } - public getTask(folder: IWorkspaceFolder | string, identifier: string | TaskIdentifier, compareId: boolean = false): TPromise { + public getTask(folder: IWorkspaceFolder | string, identifier: string | TaskIdentifier, compareId: boolean = false): Thenable { let name = Types.isString(folder) ? folder : folder.name; if (this.ignoredWorkspaceFolders.some(ignored => ignored.name === name)) { return Promise.reject(new Error(nls.localize('TaskServer.folderIgnored', 'The folder {0} is ignored since it uses task version 0.1.0', name))); @@ -729,7 +728,7 @@ class TaskService extends Disposable implements ITaskService { }); } - public tasks(filter?: TaskFilter): TPromise { + public tasks(filter?: TaskFilter): Thenable { let range = filter && filter.version ? filter.version : undefined; let engine = this.executionEngine; @@ -765,14 +764,14 @@ class TaskService extends Disposable implements ITaskService { return new TaskSorter(this.contextService.getWorkspace() ? this.contextService.getWorkspace().folders : []); } - public isActive(): TPromise { + public isActive(): Thenable { if (!this._taskSystem) { return Promise.resolve(false); } return this._taskSystem.isActive(); } - public getActiveTasks(): TPromise { + public getActiveTasks(): Thenable { if (!this._taskSystem) { return Promise.resolve([]); } @@ -815,7 +814,7 @@ class TaskService extends Disposable implements ITaskService { this.openerService.open(URI.parse('https://go.microsoft.com/fwlink/?LinkId=733558')); } - public build(): TPromise { + public build(): Thenable { return this.getGroupedTasks().then((tasks) => { let runnable = this.createRunnableTask(tasks, TaskGroup.Build); if (!runnable || !runnable.task) { @@ -832,7 +831,7 @@ class TaskService extends Disposable implements ITaskService { }); } - public runTest(): TPromise { + public runTest(): Thenable { return this.getGroupedTasks().then((tasks) => { let runnable = this.createRunnableTask(tasks, TaskGroup.Test); if (!runnable || !runnable.task) { @@ -849,7 +848,7 @@ class TaskService extends Disposable implements ITaskService { }); } - public run(task: Task, options?: ProblemMatcherRunOptions): TPromise { + public run(task: Task, options?: ProblemMatcherRunOptions): Thenable { return this.getGroupedTasks().then((grouped) => { if (!task) { throw new TaskError(Severity.Info, nls.localize('TaskServer.noTask', 'Requested task {0} to execute not found.', task.name), TaskErrors.TaskNotFound); @@ -892,7 +891,7 @@ class TaskService extends Disposable implements ITaskService { return false; } - private attachProblemMatcher(task: ContributedTask | CustomTask): TPromise { + private attachProblemMatcher(task: ContributedTask | CustomTask): Thenable { interface ProblemMatcherPickEntry extends IQuickPickItem { matcher: NamedProblemMatcher; never?: boolean; @@ -955,7 +954,7 @@ class TaskService extends Disposable implements ITaskService { return Promise.resolve(task); } - public getTasksForGroup(group: string): TPromise { + public getTasksForGroup(group: string): Thenable { return this.getGroupedTasks().then((groups) => { let result: Task[] = []; groups.forEach((tasks) => { @@ -986,7 +985,7 @@ class TaskService extends Disposable implements ITaskService { return false; } - public customize(task: ContributedTask | CustomTask, properties?: CustomizationProperties, openConfig?: boolean): TPromise { + public customize(task: ContributedTask | CustomTask, properties?: CustomizationProperties, openConfig?: boolean): Thenable { let workspaceFolder = Task.getWorkspaceFolder(task); if (!workspaceFolder) { return Promise.resolve(undefined); @@ -1030,7 +1029,7 @@ class TaskService extends Disposable implements ITaskService { } } - let promise: TPromise; + let promise: Thenable; if (!fileConfig) { let value = { version: '2.0.0', @@ -1094,7 +1093,7 @@ class TaskService extends Disposable implements ITaskService { }); } - private writeConfiguration(workspaceFolder: IWorkspaceFolder, key: string, value: any): TPromise { + private writeConfiguration(workspaceFolder: IWorkspaceFolder, key: string, value: any): Thenable { if (this.contextService.getWorkbenchState() === WorkbenchState.FOLDER) { return this.configurationService.updateValue(key, value, { resource: workspaceFolder.uri }, ConfigurationTarget.WORKSPACE); } else if (this.contextService.getWorkbenchState() === WorkbenchState.WORKSPACE) { @@ -1104,7 +1103,7 @@ class TaskService extends Disposable implements ITaskService { } } - public openConfig(task: CustomTask | undefined): TPromise { + public openConfig(task: CustomTask | undefined): Thenable { let resource: URI; if (task) { resource = Task.getWorkspaceFolder(task).toResource(task._source.config.file); @@ -1230,7 +1229,7 @@ class TaskService extends Disposable implements ITaskService { }; } - private executeTask(task: Task, resolver: ITaskResolver): TPromise { + private executeTask(task: Task, resolver: ITaskResolver): Thenable { return ProblemMatcherRegistry.onReady().then(() => { return this.textFileService.saveAll().then((value) => { // make sure all dirty files are saved let executeResult = this.getTaskSystem().run(task, resolver); @@ -1239,7 +1238,7 @@ class TaskService extends Disposable implements ITaskService { }); } - private handleExecuteResult(executeResult: ITaskExecuteResult): TPromise { + private handleExecuteResult(executeResult: ITaskExecuteResult): Thenable { let key = Task.getRecentlyUsedKey(executeResult.task); if (key) { this.getRecentlyUsedTasks().set(key, key, Touch.AsOld); @@ -1287,14 +1286,14 @@ class TaskService extends Disposable implements ITaskService { }); } - public terminate(task: Task): TPromise { + public terminate(task: Task): Thenable { if (!this._taskSystem) { return Promise.resolve({ success: true, task: undefined }); } return this._taskSystem.terminate(task); } - public terminateAll(): TPromise { + public terminateAll(): Thenable { if (!this._taskSystem) { return Promise.resolve([]); } @@ -1334,7 +1333,7 @@ class TaskService extends Disposable implements ITaskService { return this._taskSystem; } - private getGroupedTasks(): TPromise { + private getGroupedTasks(): Thenable { return Promise.all([this.extensionService.activateByEvent('onCommand:workbench.action.tasks.runTask'), TaskDefinitionRegistry.onReady()]).then(() => { let validTypes: IStringDictionary = Object.create(null); TaskDefinitionRegistry.all().forEach(definition => validTypes[definition.taskType] = true); @@ -1501,7 +1500,7 @@ class TaskService extends Disposable implements ITaskService { return result; } - public getWorkspaceTasks(runSource: TaskRunSource = TaskRunSource.User): TPromise> { + public getWorkspaceTasks(runSource: TaskRunSource = TaskRunSource.User): Thenable> { if (this._workspaceTasksPromise) { return this._workspaceTasksPromise; } @@ -1522,11 +1521,11 @@ class TaskService extends Disposable implements ITaskService { }); } - private computeWorkspaceTasks(runSource: TaskRunSource = TaskRunSource.User): TPromise> { + private computeWorkspaceTasks(runSource: TaskRunSource = TaskRunSource.User): Thenable> { if (this.workspaceFolders.length === 0) { return Promise.resolve(new Map()); } else { - let promises: TPromise[] = []; + let promises: Thenable[] = []; for (let folder of this.workspaceFolders) { promises.push(this.computeWorkspaceFolderTasks(folder, runSource).then((value) => value, () => undefined)); } @@ -1725,7 +1724,7 @@ class TaskService extends Disposable implements ITaskService { }; } - public beforeShutdown(): boolean | TPromise { + public beforeShutdown(): boolean | Thenable { if (!this._taskSystem) { return false; } @@ -1738,7 +1737,7 @@ class TaskService extends Disposable implements ITaskService { return false; } - let terminatePromise: TPromise; + let terminatePromise: Thenable; if (this._taskSystem.canAutoTerminate()) { terminatePromise = Promise.resolve({ confirmed: true }); } else { @@ -1902,8 +1901,8 @@ class TaskService extends Disposable implements ITaskService { return entries; } - private showQuickPick(tasks: TPromise | Task[], placeHolder: string, defaultEntry?: TaskQuickPickEntry, group: boolean = false, sort: boolean = false, selectedEntry?: TaskQuickPickEntry): TPromise { - let _createEntries = (): TPromise => { + private showQuickPick(tasks: Thenable | Task[], placeHolder: string, defaultEntry?: TaskQuickPickEntry, group: boolean = false, sort: boolean = false, selectedEntry?: TaskQuickPickEntry): Thenable { + let _createEntries = (): Thenable => { if (Array.isArray(tasks)) { return Promise.resolve(this.createTaskQuickPickEntries(tasks, group, sort, selectedEntry)); } else { @@ -1930,7 +1929,7 @@ class TaskService extends Disposable implements ITaskService { }).then(entry => entry ? entry.task : undefined); } - private showIgnoredFoldersMessage(): TPromise { + private showIgnoredFoldersMessage(): Thenable { if (this.ignoredWorkspaceFolders.length === 0 || !this.showIgnoreMessage) { return Promise.resolve(undefined); } @@ -2136,7 +2135,7 @@ class TaskService extends Disposable implements ITaskService { if (!this.canRunCommand()) { return; } - let runQuickPick = (promise?: TPromise) => { + let runQuickPick = (promise?: Thenable) => { this.showQuickPick(promise || this.getActiveTasks(), nls.localize('TaskService.tastToTerminate', 'Select task to terminate'), { @@ -2153,7 +2152,7 @@ class TaskService extends Disposable implements ITaskService { }; if (this.inTerminal()) { let identifier = this.getTaskIdentifier(arg); - let promise: TPromise; + let promise: Thenable; if (identifier !== void 0) { promise = this.getActiveTasks(); promise.then((tasks) => { @@ -2192,7 +2191,7 @@ class TaskService extends Disposable implements ITaskService { if (!this.canRunCommand()) { return; } - let runQuickPick = (promise?: TPromise) => { + let runQuickPick = (promise?: Thenable) => { this.showQuickPick(promise || this.getActiveTasks(), nls.localize('TaskService.tastToRestart', 'Select the task to restart'), { @@ -2209,7 +2208,7 @@ class TaskService extends Disposable implements ITaskService { }; if (this.inTerminal()) { let identifier = this.getTaskIdentifier(arg); - let promise: TPromise; + let promise: Thenable; if (identifier !== void 0) { promise = this.getActiveTasks(); promise.then((tasks) => { @@ -2249,7 +2248,7 @@ class TaskService extends Disposable implements ITaskService { if (!this.canRunCommand()) { return undefined; } - let taskPromise: TPromise; + let taskPromise: Thenable; if (this.schemaVersion === JsonSchemaVersion.V2_0_0) { taskPromise = this.getGroupedTasks(); } else { @@ -2315,7 +2314,7 @@ class TaskService extends Disposable implements ITaskService { return candidate && !!candidate.task; } - let stats = this.contextService.getWorkspace().folders.map>((folder) => { + let stats = this.contextService.getWorkspace().folders.map>((folder) => { return this.fileService.resolveFile(folder.toResource('.vscode/tasks.json')).then(stat => stat, () => undefined); }); diff --git a/src/vs/workbench/services/backup/common/backup.ts b/src/vs/workbench/services/backup/common/backup.ts index a9ff80f9b9b..1d7c2cadbb5 100644 --- a/src/vs/workbench/services/backup/common/backup.ts +++ b/src/vs/workbench/services/backup/common/backup.ts @@ -5,7 +5,6 @@ import { URI as Uri } from 'vs/base/common/uri'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IResolveContentOptions, IUpdateContentOptions, ITextSnapshot } from 'vs/platform/files/common/files'; import { ITextBufferFactory } from 'vs/editor/common/model'; @@ -23,7 +22,7 @@ export interface IBackupFileService { /** * Finds out if there are any backups stored. */ - hasBackups(): TPromise; + hasBackups(): Thenable; /** * Loads the backup resource for a particular resource within the current workspace. @@ -31,7 +30,7 @@ export interface IBackupFileService { * @param resource The resource that is backed up. * @return The backup resource if any. */ - loadBackupResource(resource: Uri): TPromise; + loadBackupResource(resource: Uri): Thenable; /** * Given a resource, returns the associated backup resource. @@ -48,14 +47,14 @@ export interface IBackupFileService { * @param content The content of the resource as snapshot. * @param versionId The version id of the resource to backup. */ - backupResource(resource: Uri, content: ITextSnapshot, versionId?: number): TPromise; + backupResource(resource: Uri, content: ITextSnapshot, versionId?: number): Thenable; /** * Gets a list of file backups for the current workspace. * * @return The list of backups. */ - getWorkspaceFileBackups(): TPromise; + getWorkspaceFileBackups(): Thenable; /** * Resolves the backup for the given resource. @@ -63,18 +62,18 @@ export interface IBackupFileService { * @param value The contents from a backup resource as stream. * @return The backup file's backed up content as text buffer factory. */ - resolveBackupContent(backup: Uri): TPromise; + resolveBackupContent(backup: Uri): Thenable; /** * Discards the backup associated with a resource if it exists.. * * @param resource The resource whose backup is being discarded discard to back up. */ - discardResourceBackup(resource: Uri): TPromise; + discardResourceBackup(resource: Uri): Thenable; /** * Discards all backups associated with the current workspace and prevents further backups from * being made. */ - discardAllWorkspaceBackups(): TPromise; + discardAllWorkspaceBackups(): Thenable; } diff --git a/src/vs/workbench/services/backup/node/backupFileService.ts b/src/vs/workbench/services/backup/node/backupFileService.ts index f8d1d12e56a..1d7b890e388 100644 --- a/src/vs/workbench/services/backup/node/backupFileService.ts +++ b/src/vs/workbench/services/backup/node/backupFileService.ts @@ -10,14 +10,13 @@ import { URI as Uri } from 'vs/base/common/uri'; import { ResourceQueue } from 'vs/base/common/async'; import { IBackupFileService, BACKUP_FILE_UPDATE_OPTIONS, BACKUP_FILE_RESOLVE_OPTIONS } from 'vs/workbench/services/backup/common/backup'; import { IFileService, ITextSnapshot } from 'vs/platform/files/common/files'; -import { TPromise } from 'vs/base/common/winjs.base'; import { readToMatchingString } from 'vs/base/node/stream'; import { ITextBufferFactory } from 'vs/editor/common/model'; import { createTextBufferFactoryFromStream, createTextBufferFactoryFromSnapshot } from 'vs/editor/common/model/textModel'; import { keys } from 'vs/base/common/map'; export interface IBackupFilesModel { - resolve(backupRoot: string): TPromise; + resolve(backupRoot: string): Thenable; add(resource: Uri, versionId?: number): void; has(resource: Uri, versionId?: number): boolean; @@ -51,7 +50,7 @@ export class BackupSnapshot implements ITextSnapshot { export class BackupFilesModel implements IBackupFilesModel { private cache: { [resource: string]: number /* version ID */ } = Object.create(null); - resolve(backupRoot: string): TPromise { + resolve(backupRoot: string): Thenable { return pfs.readDirsInDir(backupRoot).then(backupSchemas => { // For all supported schemas @@ -114,7 +113,7 @@ export class BackupFileService implements IBackupFileService { private backupWorkspacePath: string; private isShuttingDown: boolean; - private ready: TPromise; + private ready: Thenable; private ioOperationQueues: ResourceQueue; // queue IO operations to ensure write order constructor( @@ -133,19 +132,19 @@ export class BackupFileService implements IBackupFileService { this.ready = this.init(); } - private init(): TPromise { + private init(): Thenable { const model = new BackupFilesModel(); return model.resolve(this.backupWorkspacePath); } - hasBackups(): TPromise { + hasBackups(): Thenable { return this.ready.then(model => { return model.count() > 0; }); } - loadBackupResource(resource: Uri): TPromise { + loadBackupResource(resource: Uri): Thenable { return this.ready.then(model => { // Return directly if we have a known backup with that resource @@ -158,7 +157,7 @@ export class BackupFileService implements IBackupFileService { }); } - backupResource(resource: Uri, content: ITextSnapshot, versionId?: number): TPromise { + backupResource(resource: Uri, content: ITextSnapshot, versionId?: number): Thenable { if (this.isShuttingDown) { return Promise.resolve(); } @@ -178,7 +177,7 @@ export class BackupFileService implements IBackupFileService { }); } - discardResourceBackup(resource: Uri): TPromise { + discardResourceBackup(resource: Uri): Thenable { return this.ready.then(model => { const backupResource = this.toBackupResource(resource); @@ -188,7 +187,7 @@ export class BackupFileService implements IBackupFileService { }); } - discardAllWorkspaceBackups(): TPromise { + discardAllWorkspaceBackups(): Thenable { this.isShuttingDown = true; return this.ready.then(model => { @@ -196,9 +195,9 @@ export class BackupFileService implements IBackupFileService { }); } - getWorkspaceFileBackups(): TPromise { + getWorkspaceFileBackups(): Thenable { return this.ready.then(model => { - const readPromises: TPromise[] = []; + const readPromises: Thenable[] = []; model.get().forEach(fileBackup => { readPromises.push( @@ -210,7 +209,7 @@ export class BackupFileService implements IBackupFileService { }); } - resolveBackupContent(backup: Uri): TPromise { + resolveBackupContent(backup: Uri): Thenable { return this.fileService.resolveStreamContent(backup, BACKUP_FILE_RESOLVE_OPTIONS).then(content => { // Add a filter method to filter out everything until the meta marker @@ -248,11 +247,11 @@ export class InMemoryBackupFileService implements IBackupFileService { private backups: Map = new Map(); - hasBackups(): TPromise { + hasBackups(): Thenable { return Promise.resolve(this.backups.size > 0); } - loadBackupResource(resource: Uri): TPromise { + loadBackupResource(resource: Uri): Thenable { const backupResource = this.toBackupResource(resource); if (this.backups.has(backupResource.toString())) { return Promise.resolve(backupResource); @@ -261,14 +260,14 @@ export class InMemoryBackupFileService implements IBackupFileService { return Promise.resolve(); } - backupResource(resource: Uri, content: ITextSnapshot, versionId?: number): TPromise { + backupResource(resource: Uri, content: ITextSnapshot, versionId?: number): Thenable { const backupResource = this.toBackupResource(resource); this.backups.set(backupResource.toString(), content); return Promise.resolve(); } - resolveBackupContent(backupResource: Uri): TPromise { + resolveBackupContent(backupResource: Uri): Thenable { const snapshot = this.backups.get(backupResource.toString()); if (snapshot) { return Promise.resolve(createTextBufferFactoryFromSnapshot(snapshot)); @@ -277,17 +276,17 @@ export class InMemoryBackupFileService implements IBackupFileService { return Promise.resolve(); } - getWorkspaceFileBackups(): TPromise { + getWorkspaceFileBackups(): Thenable { return Promise.resolve(keys(this.backups).map(key => Uri.parse(key))); } - discardResourceBackup(resource: Uri): TPromise { + discardResourceBackup(resource: Uri): Thenable { this.backups.delete(this.toBackupResource(resource).toString()); return Promise.resolve(); } - discardAllWorkspaceBackups(): TPromise { + discardAllWorkspaceBackups(): Thenable { this.backups.clear(); return Promise.resolve(); diff --git a/src/vs/workbench/services/configurationResolver/common/configurationResolver.ts b/src/vs/workbench/services/configurationResolver/common/configurationResolver.ts index 5b4016cdcd0..f0a9488c435 100644 --- a/src/vs/workbench/services/configurationResolver/common/configurationResolver.ts +++ b/src/vs/workbench/services/configurationResolver/common/configurationResolver.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import { IStringDictionary } from 'vs/base/common/collections'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; @@ -31,13 +30,13 @@ export interface IConfigurationResolverService { * @param section For example, 'tasks' or 'debug'. Used for resolving inputs. * @param variables Aliases for commands. */ - resolveWithInteractionReplace(folder: IWorkspaceFolder, config: any, section?: string, variables?: IStringDictionary): TPromise; + resolveWithInteractionReplace(folder: IWorkspaceFolder, config: any, section?: string, variables?: IStringDictionary): Thenable; /** * Similar to resolveWithInteractionReplace, except without the replace. Returns a map of variables and their resolution. * Keys in the map will be of the format input:variableName or command:variableName. */ - resolveWithInteraction(folder: IWorkspaceFolder, config: any, section?: string, variables?: IStringDictionary): TPromise>; + resolveWithInteraction(folder: IWorkspaceFolder, config: any, section?: string, variables?: IStringDictionary): Thenable>; } export const enum ConfiguredInputType { diff --git a/src/vs/workbench/services/configurationResolver/electron-browser/configurationResolverService.ts b/src/vs/workbench/services/configurationResolver/electron-browser/configurationResolverService.ts index dfbf5687758..7e34b197669 100644 --- a/src/vs/workbench/services/configurationResolver/electron-browser/configurationResolverService.ts +++ b/src/vs/workbench/services/configurationResolver/electron-browser/configurationResolverService.ts @@ -10,7 +10,6 @@ import * as platform from 'vs/base/common/platform'; import * as Objects from 'vs/base/common/objects'; import * as Types from 'vs/base/common/types'; import { Schemas } from 'vs/base/common/network'; -import { TPromise } from 'vs/base/common/winjs.base'; import { sequence } from 'vs/base/common/async'; import { toResource } from 'vs/workbench/common/editor'; import { IStringDictionary, forEach, fromMap } from 'vs/base/common/collections'; @@ -83,7 +82,7 @@ export class ConfigurationResolverService extends AbstractVariableResolverServic }, envVariables); } - public resolveWithInteractionReplace(folder: IWorkspaceFolder, config: any, section?: string, variables?: IStringDictionary): TPromise { + public resolveWithInteractionReplace(folder: IWorkspaceFolder, config: any, section?: string, variables?: IStringDictionary): Thenable { // resolve any non-interactive variables config = this.resolveAny(folder, config); @@ -100,7 +99,7 @@ export class ConfigurationResolverService extends AbstractVariableResolverServic }); } - public resolveWithInteraction(folder: IWorkspaceFolder, config: any, section?: string, variables?: IStringDictionary): TPromise> { + public resolveWithInteraction(folder: IWorkspaceFolder, config: any, section?: string, variables?: IStringDictionary): Thenable> { // resolve any non-interactive variables const resolved = this.resolveAnyMap(folder, config); config = resolved.newConfig; @@ -144,7 +143,7 @@ export class ConfigurationResolverService extends AbstractVariableResolverServic * @param configuration * @param variableToCommandMap Aliases for commands */ - private resolveWithCommands(configuration: any, variableToCommandMap: IStringDictionary): TPromise> { + private resolveWithCommands(configuration: any, variableToCommandMap: IStringDictionary): Thenable> { if (!configuration) { return Promise.resolve(undefined); } @@ -156,7 +155,7 @@ export class ConfigurationResolverService extends AbstractVariableResolverServic let cancelled = false; const commandValueMapping: IStringDictionary = Object.create(null); - const factory: { (): TPromise }[] = commands.map(commandVariable => { + const factory: { (): Thenable }[] = commands.map(commandVariable => { return () => { let commandId = variableToCommandMap ? variableToCommandMap[commandVariable] : undefined; if (!commandId) { diff --git a/src/vs/workbench/services/configurationResolver/node/variableResolver.ts b/src/vs/workbench/services/configurationResolver/node/variableResolver.ts index 8e98ac239b1..6f47dc5b3ea 100644 --- a/src/vs/workbench/services/configurationResolver/node/variableResolver.ts +++ b/src/vs/workbench/services/configurationResolver/node/variableResolver.ts @@ -14,7 +14,6 @@ import { localize } from 'vs/nls'; import { URI as uri } from 'vs/base/common/uri'; import { IConfigurationResolverService } from 'vs/workbench/services/configurationResolver/common/configurationResolver'; import { IWorkspaceFolder } from 'vs/platform/workspace/common/workspace'; -import { TPromise } from 'vs/base/common/winjs.base'; export interface IVariableResolveContext { getFolderUri(folderName: string): uri | undefined; @@ -83,11 +82,11 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe return { newConfig, resolvedVariables }; } - public resolveWithInteractionReplace(folder: IWorkspaceFolder, config: any): TPromise { + public resolveWithInteractionReplace(folder: IWorkspaceFolder, config: any): Thenable { throw new Error('resolveWithInteractionReplace not implemented.'); } - public resolveWithInteraction(folder: IWorkspaceFolder, config: any): TPromise { + public resolveWithInteraction(folder: IWorkspaceFolder, config: any): Thenable { throw new Error('resolveWithInteraction not implemented.'); } diff --git a/src/vs/workbench/services/editor/browser/editorService.ts b/src/vs/workbench/services/editor/browser/editorService.ts index 38a47fab82d..710eae571f9 100644 --- a/src/vs/workbench/services/editor/browser/editorService.ts +++ b/src/vs/workbench/services/editor/browser/editorService.ts @@ -18,7 +18,6 @@ import { URI } from 'vs/base/common/uri'; import { basename } from 'vs/base/common/paths'; import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput'; import { localize } from 'vs/nls'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IEditorGroupsService, IEditorGroup, GroupsOrder, IEditorReplacement, GroupChangeKind, preferredSideBySideGroupDirection } from 'vs/workbench/services/group/common/editorGroupsService'; import { IResourceEditor, ACTIVE_GROUP_TYPE, SIDE_GROUP_TYPE, SIDE_GROUP, IResourceEditorReplacement, IOpenEditorOverrideHandler } from 'vs/workbench/services/editor/common/editorService'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; @@ -216,11 +215,11 @@ export class EditorService extends Disposable implements EditorServiceImpl { //#region openEditor() - openEditor(editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise; - openEditor(editor: IResourceInput | IUntitledResourceInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise; - openEditor(editor: IResourceDiffInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise; - openEditor(editor: IResourceSideBySideInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise; - openEditor(editor: IEditorInput | IResourceEditor, optionsOrGroup?: IEditorOptions | ITextEditorOptions | IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE, group?: GroupIdentifier): TPromise { + openEditor(editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; + openEditor(editor: IResourceInput | IUntitledResourceInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; + openEditor(editor: IResourceDiffInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; + openEditor(editor: IResourceSideBySideInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; + openEditor(editor: IEditorInput | IResourceEditor, optionsOrGroup?: IEditorOptions | ITextEditorOptions | IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE, group?: GroupIdentifier): Thenable { // Typed Editor Support if (editor instanceof EditorInput) { @@ -243,7 +242,7 @@ export class EditorService extends Disposable implements EditorServiceImpl { return Promise.resolve(null); } - protected doOpenEditor(group: IEditorGroup, editor: IEditorInput, options?: IEditorOptions): TPromise { + protected doOpenEditor(group: IEditorGroup, editor: IEditorInput, options?: IEditorOptions): Thenable { return group.openEditor(editor, options); } @@ -328,9 +327,9 @@ export class EditorService extends Disposable implements EditorServiceImpl { //#region openEditors() - openEditors(editors: IEditorInputWithOptions[], group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise; - openEditors(editors: IResourceEditor[], group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise; - openEditors(editors: (IEditorInputWithOptions | IResourceEditor)[], group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise { + openEditors(editors: IEditorInputWithOptions[], group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; + openEditors(editors: IResourceEditor[], group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; + openEditors(editors: (IEditorInputWithOptions | IResourceEditor)[], group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable { // Convert to typed editors and options const typedEditors: IEditorInputWithOptions[] = []; @@ -361,7 +360,7 @@ export class EditorService extends Disposable implements EditorServiceImpl { } // Open in targets - const result: TPromise[] = []; + const result: Thenable[] = []; mapGroupToEditors.forEach((editorsWithOptions, group) => { result.push(group.openEditors(editorsWithOptions)); }); @@ -437,9 +436,9 @@ export class EditorService extends Disposable implements EditorServiceImpl { //#region replaceEditors() - replaceEditors(editors: IResourceEditorReplacement[], group: IEditorGroup | GroupIdentifier): TPromise; - replaceEditors(editors: IEditorReplacement[], group: IEditorGroup | GroupIdentifier): TPromise; - replaceEditors(editors: (IEditorReplacement | IResourceEditorReplacement)[], group: IEditorGroup | GroupIdentifier): TPromise { + replaceEditors(editors: IResourceEditorReplacement[], group: IEditorGroup | GroupIdentifier): Thenable; + replaceEditors(editors: IEditorReplacement[], group: IEditorGroup | GroupIdentifier): Thenable; + replaceEditors(editors: (IEditorReplacement | IResourceEditorReplacement)[], group: IEditorGroup | GroupIdentifier): Thenable { const typedEditors: IEditorReplacement[] = []; editors.forEach(replaceEditorArg => { @@ -600,7 +599,7 @@ export class EditorService extends Disposable implements EditorServiceImpl { } export interface IEditorOpenHandler { - (group: IEditorGroup, editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions): TPromise; + (group: IEditorGroup, editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions): Thenable; } /** @@ -632,7 +631,7 @@ export class DelegatingEditorService extends EditorService { this.editorOpenHandler = handler; } - protected doOpenEditor(group: IEditorGroup, editor: IEditorInput, options?: IEditorOptions): TPromise { + protected doOpenEditor(group: IEditorGroup, editor: IEditorInput, options?: IEditorOptions): Thenable { if (!this.editorOpenHandler) { return super.doOpenEditor(group, editor, options); } diff --git a/src/vs/workbench/services/editor/common/editorService.ts b/src/vs/workbench/services/editor/common/editorService.ts index b48072b4ee3..ad2df382382 100644 --- a/src/vs/workbench/services/editor/common/editorService.ts +++ b/src/vs/workbench/services/editor/common/editorService.ts @@ -9,7 +9,6 @@ import { IEditorInput, IEditor, GroupIdentifier, IEditorInputWithOptions, IUntit import { Event } from 'vs/base/common/event'; import { IEditor as ICodeEditor } from 'vs/editor/common/editorCommon'; import { IEditorGroup, IEditorReplacement } from 'vs/workbench/services/group/common/editorGroupsService'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IDisposable } from 'vs/base/common/lifecycle'; export const IEditorService = createDecorator('editorService'); @@ -37,7 +36,7 @@ export interface IOpenEditorOverride { * If defined, will prevent the opening of an editor and replace the resulting * promise with the provided promise for the openEditor() call. */ - override?: TPromise; + override?: Thenable; } export interface IEditorService { @@ -115,10 +114,10 @@ export interface IEditorService { * @returns the editor that opened or NULL if the operation failed or the editor was not * opened to be active. */ - openEditor(editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise; - openEditor(editor: IResourceInput | IUntitledResourceInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise; - openEditor(editor: IResourceDiffInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise; - openEditor(editor: IResourceSideBySideInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise; + openEditor(editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; + openEditor(editor: IResourceInput | IUntitledResourceInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; + openEditor(editor: IResourceDiffInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; + openEditor(editor: IResourceSideBySideInput, group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable; /** * Open editors in an editor group. @@ -131,8 +130,8 @@ export interface IEditorService { * @returns the editors that opened. The array can be empty or have less elements for editors * that failed to open or were instructed to open as inactive. */ - openEditors(editors: IEditorInputWithOptions[], group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise>; - openEditors(editors: IResourceEditor[], group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): TPromise>; + openEditors(editors: IEditorInputWithOptions[], group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable>; + openEditors(editors: IResourceEditor[], group?: IEditorGroup | GroupIdentifier | SIDE_GROUP_TYPE | ACTIVE_GROUP_TYPE): Thenable>; /** * Replaces editors in an editor group with the provided replacement. @@ -142,8 +141,8 @@ export interface IEditorService { * @returns a promise that is resolved when the replaced active * editor (if any) has finished loading. */ - replaceEditors(editors: IResourceEditorReplacement[], group: IEditorGroup | GroupIdentifier): TPromise; - replaceEditors(editors: IEditorReplacement[], group: IEditorGroup | GroupIdentifier): TPromise; + replaceEditors(editors: IResourceEditorReplacement[], group: IEditorGroup | GroupIdentifier): Thenable; + replaceEditors(editors: IEditorReplacement[], group: IEditorGroup | GroupIdentifier): Thenable; /** * Find out if the provided editor (or resource of an editor) is opened in any or diff --git a/src/vs/workbench/services/group/common/editorGroupsService.ts b/src/vs/workbench/services/group/common/editorGroupsService.ts index bcd28c0c2da..091977929c5 100644 --- a/src/vs/workbench/services/group/common/editorGroupsService.ts +++ b/src/vs/workbench/services/group/common/editorGroupsService.ts @@ -7,7 +7,6 @@ import { Event } from 'vs/base/common/event'; import { createDecorator, ServiceIdentifier, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation'; import { IEditorInput, IEditor, GroupIdentifier, IEditorInputWithOptions, CloseDirection } from 'vs/workbench/common/editor'; import { IEditorOptions, ITextEditorOptions } from 'vs/platform/editor/common/editor'; -import { TPromise } from 'vs/base/common/winjs.base'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; export const IEditorGroupsService = createDecorator('editorGroupsService'); @@ -380,7 +379,7 @@ export interface IEditorGroup { * @returns a promise that resolves around an IEditor instance unless * the call failed, or the editor was not opened as active editor. */ - openEditor(editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions): TPromise; + openEditor(editor: IEditorInput, options?: IEditorOptions | ITextEditorOptions): Thenable; /** * Opens editors in this group. @@ -390,7 +389,7 @@ export interface IEditorGroup { * a group can only ever have one active editor, even if many editors are * opened, the result will only be one editor. */ - openEditors(editors: IEditorInputWithOptions[]): TPromise; + openEditors(editors: IEditorInputWithOptions[]): Thenable; /** * Find out if the provided editor is opened in the group. @@ -430,7 +429,7 @@ export interface IEditorGroup { * * @returns a promise when the editor is closed. */ - closeEditor(editor?: IEditorInput): TPromise; + closeEditor(editor?: IEditorInput): Thenable; /** * Closes specific editors in this group. This may trigger a confirmation dialog if @@ -438,7 +437,7 @@ export interface IEditorGroup { * * @returns a promise when all editors are closed. */ - closeEditors(editors: IEditorInput[] | ICloseEditorsFilter): TPromise; + closeEditors(editors: IEditorInput[] | ICloseEditorsFilter): Thenable; /** * Closes all editors from the group. This may trigger a confirmation dialog if @@ -446,7 +445,7 @@ export interface IEditorGroup { * * @returns a promise when all editors are closed. */ - closeAllEditors(): TPromise; + closeAllEditors(): Thenable; /** * Replaces editors in this group with the provided replacement. @@ -456,7 +455,7 @@ export interface IEditorGroup { * @returns a promise that is resolved when the replaced active * editor (if any) has finished loading. */ - replaceEditors(editors: IEditorReplacement[]): TPromise; + replaceEditors(editors: IEditorReplacement[]): Thenable; /** * Set an editor to be pinned. A pinned editor is not replaced diff --git a/src/vs/workbench/services/scm/common/scm.ts b/src/vs/workbench/services/scm/common/scm.ts index 2789023ffd3..915c7c8230f 100644 --- a/src/vs/workbench/services/scm/common/scm.ts +++ b/src/vs/workbench/services/scm/common/scm.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import { URI } from 'vs/base/common/uri'; import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; import { Event } from 'vs/base/common/event'; @@ -13,7 +12,7 @@ import { ColorIdentifier } from 'vs/platform/theme/common/colorRegistry'; import { ISequence } from 'vs/base/common/sequence'; export interface IBaselineResourceProvider { - getBaselineResource(resource: URI): TPromise; + getBaselineResource(resource: URI): Thenable; } export const ISCMService = createDecorator('scm'); @@ -64,7 +63,7 @@ export interface ISCMProvider extends IDisposable { readonly statusBarCommands?: Command[]; readonly onDidChange: Event; - getOriginalResource(uri: URI): TPromise; + getOriginalResource(uri: URI): Thenable; } export const enum InputValidationType { @@ -79,7 +78,7 @@ export interface IInputValidation { } export interface IInputValidator { - (value: string, cursorPosition: number): TPromise; + (value: string, cursorPosition: number): Thenable; } export interface ISCMInput { diff --git a/src/vs/workbench/services/textfile/common/textFileEditorModel.ts b/src/vs/workbench/services/textfile/common/textFileEditorModel.ts index ddd51c5163a..2d7cc54f0c2 100644 --- a/src/vs/workbench/services/textfile/common/textFileEditorModel.ts +++ b/src/vs/workbench/services/textfile/common/textFileEditorModel.ts @@ -6,7 +6,6 @@ import * as path from 'vs/base/common/paths'; import * as nls from 'vs/nls'; import { Event, Emitter } from 'vs/base/common/event'; -import { TPromise } from 'vs/base/common/winjs.base'; import { guessMimeTypes } from 'vs/base/common/mime'; import { toErrorMessage } from 'vs/base/common/errorMessage'; import { URI } from 'vs/base/common/uri'; @@ -71,7 +70,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil private saveSequentializer: SaveSequentializer; private disposed: boolean; private lastSaveAttemptTime: number; - private createTextEditorModelPromise: TPromise; + private createTextEditorModelPromise: Thenable; private inConflictMode: boolean; private inOrphanMode: boolean; private inErrorMode: boolean; @@ -205,7 +204,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil return this.versionId; } - revert(soft?: boolean): TPromise { + revert(soft?: boolean): Thenable { if (!this.isResolved()) { return Promise.resolve(null); } @@ -216,7 +215,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil // Unset flags const undo = this.setDirty(false); - let loadPromise: TPromise; + let loadPromise: Thenable; if (soft) { loadPromise = Promise.resolve(); } else { @@ -236,7 +235,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil }); } - load(options?: ILoadOptions): TPromise { + load(options?: ILoadOptions): Thenable { this.logService.trace('load() - enter', this.resource); // It is very important to not reload the model when the model is dirty. @@ -257,7 +256,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil return this.loadFromFile(options); } - private loadFromBackup(options?: ILoadOptions): TPromise { + private loadFromBackup(options?: ILoadOptions): Thenable { return this.backupFileService.loadBackupResource(this.resource).then(backup => { // Make sure meanwhile someone else did not suceed or start loading @@ -285,7 +284,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil }); } - private loadFromFile(options?: ILoadOptions): TPromise { + private loadFromFile(options?: ILoadOptions): Thenable { const forceReadFromDisk = options && options.forceReadFromDisk; const allowBinary = this.isResolved() /* always allow if we resolved previously */ || (options && options.allowBinary); @@ -348,7 +347,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil }); } - private loadWithContent(content: IRawTextContent, options?: ILoadOptions, backup?: URI): TPromise { + private loadWithContent(content: IRawTextContent, options?: ILoadOptions, backup?: URI): Thenable { return this.doLoadWithContent(content, backup).then(model => { // Telemetry: We log the fileGet telemetry event after the model has been loaded to ensure a good mimetype const settingsType = this.getTypeIfSettings(); @@ -374,7 +373,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil }); } - private doLoadWithContent(content: IRawTextContent, backup?: URI): TPromise { + private doLoadWithContent(content: IRawTextContent, backup?: URI): Thenable { this.logService.trace('load() - resolved content', this.resource); // Update our resolved disk stat model @@ -436,7 +435,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil this.updateSavedVersionId(); } - private doCreateTextModel(resource: URI, value: ITextBufferFactory, backup: URI): TPromise { + private doCreateTextModel(resource: URI, value: ITextBufferFactory, backup: URI): Thenable { this.logService.trace('load() - created text editor model', this.resource); this.createTextEditorModelPromise = this.doLoadBackup(backup).then(backupContent => { @@ -484,7 +483,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil this._register(this.textEditorModel.onDidChangeContent(() => this.onModelContentChanged())); } - private doLoadBackup(backup: URI): TPromise { + private doLoadBackup(backup: URI): Thenable { if (!backup) { return Promise.resolve(null); } @@ -582,7 +581,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil } } - save(options: ISaveOptions = Object.create(null)): TPromise { + save(options: ISaveOptions = Object.create(null)): Thenable { if (!this.isResolved()) { return Promise.resolve(null); } @@ -595,7 +594,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil return this.doSave(this.versionId, options); } - private doSave(versionId: number, options: ISaveOptions): TPromise { + private doSave(versionId: number, options: ISaveOptions): Thenable { if (isUndefinedOrNull(options.reason)) { options.reason = SaveReason.EXPLICIT; } @@ -834,7 +833,7 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil return telemetryData; } - private doTouch(versionId: number): TPromise { + private doTouch(versionId: number): Thenable { return this.saveSequentializer.setPending(versionId, this.fileService.updateContent(this.lastResolvedDiskStat.resource, this.createSnapshot(), { mtime: this.lastResolvedDiskStat.mtime, encoding: this.getEncoding(), diff --git a/src/vs/workbench/services/textfile/common/textFileEditorModelManager.ts b/src/vs/workbench/services/textfile/common/textFileEditorModelManager.ts index ebb03778ef9..ba4e37af07f 100644 --- a/src/vs/workbench/services/textfile/common/textFileEditorModelManager.ts +++ b/src/vs/workbench/services/textfile/common/textFileEditorModelManager.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import { Event, Emitter } from 'vs/base/common/event'; -import { TPromise } from 'vs/base/common/winjs.base'; import { URI } from 'vs/base/common/uri'; import { TextFileEditorModel } from 'vs/workbench/services/textfile/common/textFileEditorModel'; import { dispose, IDisposable, Disposable } from 'vs/base/common/lifecycle'; @@ -48,7 +47,7 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE private mapResourceToStateChangeListener: ResourceMap; private mapResourceToModelContentChangeListener: ResourceMap; private mapResourceToModel: ResourceMap; - private mapResourceToPendingModelLoaders: ResourceMap>; + private mapResourceToPendingModelLoaders: ResourceMap>; constructor( @ILifecycleService private lifecycleService: ILifecycleService, @@ -60,7 +59,7 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE this.mapResourceToDisposeListener = new ResourceMap(); this.mapResourceToStateChangeListener = new ResourceMap(); this.mapResourceToModelContentChangeListener = new ResourceMap(); - this.mapResourceToPendingModelLoaders = new ResourceMap>(); + this.mapResourceToPendingModelLoaders = new ResourceMap>(); this.registerListeners(); } @@ -122,7 +121,7 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE return this.mapResourceToModel.get(resource); } - loadOrCreate(resource: URI, options?: IModelLoadOrCreateOptions): TPromise { + loadOrCreate(resource: URI, options?: IModelLoadOrCreateOptions): Thenable { // Return early if model is currently being loaded const pendingLoad = this.mapResourceToPendingModelLoaders.get(resource); @@ -130,7 +129,7 @@ export class TextFileEditorModelManager extends Disposable implements ITextFileE return pendingLoad; } - let modelPromise: TPromise; + let modelPromise: Thenable; // Model exists let model = this.get(resource); diff --git a/src/vs/workbench/services/textfile/common/textFileService.ts b/src/vs/workbench/services/textfile/common/textFileService.ts index 737380cf747..e2d4b35294e 100644 --- a/src/vs/workbench/services/textfile/common/textFileService.ts +++ b/src/vs/workbench/services/textfile/common/textFileService.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import * as nls from 'vs/nls'; -import { TPromise } from 'vs/base/common/winjs.base'; import { URI } from 'vs/base/common/uri'; import * as paths from 'vs/base/common/paths'; import * as errors from 'vs/base/common/errors'; @@ -97,11 +96,11 @@ export abstract class TextFileService extends Disposable implements ITextFileSer return this._models; } - abstract resolveTextContent(resource: URI, options?: IResolveContentOptions): TPromise; + abstract resolveTextContent(resource: URI, options?: IResolveContentOptions): Thenable; - abstract promptForPath(resource: URI, defaultPath: URI): TPromise; + abstract promptForPath(resource: URI, defaultPath: URI): Thenable; - abstract confirmSave(resources?: URI[]): TPromise; + abstract confirmSave(resources?: URI[]): Thenable; private registerListeners(): void { @@ -117,7 +116,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer })); } - private beforeShutdown(reason: ShutdownReason): boolean | TPromise { + private beforeShutdown(reason: ShutdownReason): boolean | Thenable { // Dirty files need treatment on shutdown const dirty = this.getDirty(); @@ -146,7 +145,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer return this.noVeto({ cleanUpBackups: true }); } - private handleDirtyBeforeShutdown(dirty: URI[], reason: ShutdownReason): boolean | TPromise { + private handleDirtyBeforeShutdown(dirty: URI[], reason: ShutdownReason): boolean | Thenable { // If hot exit is enabled, backup dirty files and allow to exit without confirmation if (this.isHotExitEnabled) { @@ -169,7 +168,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer return this.confirmBeforeShutdown(); } - private backupBeforeShutdown(dirtyToBackup: URI[], textFileEditorModelManager: ITextFileEditorModelManager, reason: ShutdownReason): TPromise { + private backupBeforeShutdown(dirtyToBackup: URI[], textFileEditorModelManager: ITextFileEditorModelManager, reason: ShutdownReason): Thenable { return this.windowsService.getWindowCount().then(windowCount => { // When quit is requested skip the confirm callback and attempt to backup all workspaces. @@ -215,7 +214,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer }); } - private backupAll(dirtyToBackup: URI[], textFileEditorModelManager: ITextFileEditorModelManager): TPromise { + private backupAll(dirtyToBackup: URI[], textFileEditorModelManager: ITextFileEditorModelManager): Thenable { // split up between files and untitled const filesToBackup: ITextFileEditorModel[] = []; @@ -231,7 +230,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer return this.doBackupAll(filesToBackup, untitledToBackup); } - private doBackupAll(dirtyFileModels: ITextFileEditorModel[], untitledResources: URI[]): TPromise { + private doBackupAll(dirtyFileModels: ITextFileEditorModel[], untitledResources: URI[]): Thenable { // Handle file resources first return Promise.all(dirtyFileModels.map(model => this.backupFileService.backupResource(model.getResource(), model.createSnapshot(), model.getVersionId()))).then(results => { @@ -251,7 +250,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer }); } - private confirmBeforeShutdown(): boolean | TPromise { + private confirmBeforeShutdown(): boolean | Thenable { return this.confirmSave().then(confirm => { // Save @@ -284,7 +283,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer }); } - private noVeto(options: { cleanUpBackups: boolean }): boolean | TPromise { + private noVeto(options: { cleanUpBackups: boolean }): boolean | Thenable { if (!options.cleanUpBackups) { return false; } @@ -296,7 +295,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer return this.cleanupBackupsBeforeShutdown().then(() => false, () => false); } - protected cleanupBackupsBeforeShutdown(): TPromise { + protected cleanupBackupsBeforeShutdown(): Thenable { if (this.environmentService.isExtensionDevelopment) { return Promise.resolve(void 0); } @@ -381,7 +380,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer return this.untitledEditorService.getDirty().some(dirty => !resource || dirty.toString() === resource.toString()); } - save(resource: URI, options?: ISaveOptions): TPromise { + save(resource: URI, options?: ISaveOptions): Thenable { // Run a forced save if we detect the file is not dirty so that save participants can still run if (options && options.force && this.fileService.canHandleResource(resource) && !this.isDirty(resource)) { @@ -400,9 +399,9 @@ export abstract class TextFileService extends Disposable implements ITextFileSer return this.saveAll([resource], options).then(result => result.results.length === 1 && result.results[0].success); } - saveAll(includeUntitled?: boolean, options?: ISaveOptions): TPromise; - saveAll(resources: URI[], options?: ISaveOptions): TPromise; - saveAll(arg1?: any, options?: ISaveOptions): TPromise { + saveAll(includeUntitled?: boolean, options?: ISaveOptions): Thenable; + saveAll(resources: URI[], options?: ISaveOptions): Thenable; + saveAll(arg1?: any, options?: ISaveOptions): Thenable { // get all dirty let toSave: URI[] = []; @@ -426,7 +425,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer return this.doSaveAll(filesToSave, untitledToSave, options); } - private doSaveAll(fileResources: URI[], untitledResources: URI[], options?: ISaveOptions): TPromise { + private doSaveAll(fileResources: URI[], untitledResources: URI[], options?: ISaveOptions): Thenable { // Handle files first that can just be saved return this.doSaveAllFiles(fileResources, options).then(async result => { @@ -460,7 +459,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer } // Handle untitled - const untitledSaveAsPromises: TPromise[] = []; + const untitledSaveAsPromises: Thenable[] = []; targetsForUntitled.forEach((target, index) => { const untitledSaveAsPromise = this.saveAs(untitledResources[index], target).then(uri => { result.results.push({ @@ -477,7 +476,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer }); } - private doSaveAllFiles(resources?: URI[], options: ISaveOptions = Object.create(null)): TPromise { + private doSaveAllFiles(resources?: URI[], options: ISaveOptions = Object.create(null)): Thenable { const dirtyFileModels = this.getDirtyFileModels(Array.isArray(resources) ? resources : void 0 /* Save All */) .filter(model => { if ((model.hasState(ModelState.CONFLICT) || model.hasState(ModelState.ERROR)) && (options.reason === SaveReason.AUTO || options.reason === SaveReason.FOCUS_CHANGE || options.reason === SaveReason.WINDOW_CHANGE)) { @@ -524,10 +523,10 @@ export abstract class TextFileService extends Disposable implements ITextFileSer return this.getFileModels(arg1).filter(model => model.isDirty()); } - saveAs(resource: URI, target?: URI, options?: ISaveOptions): TPromise { + saveAs(resource: URI, target?: URI, options?: ISaveOptions): Thenable { // Get to target resource - let targetPromise: TPromise; + let targetPromise: Thenable; if (target) { targetPromise = Promise.resolve(target); } else { @@ -554,10 +553,10 @@ export abstract class TextFileService extends Disposable implements ITextFileSer }); } - private doSaveAs(resource: URI, target?: URI, options?: ISaveOptions): TPromise { + private doSaveAs(resource: URI, target?: URI, options?: ISaveOptions): Thenable { // Retrieve text model from provided resource if any - let modelPromise: TPromise = Promise.resolve(null); + let modelPromise: Thenable = Promise.resolve(null); if (this.fileService.canHandleResource(resource)) { modelPromise = Promise.resolve(this._models.get(resource)); } else if (resource.scheme === Schemas.untitled && this.untitledEditorService.exists(resource)) { @@ -584,8 +583,8 @@ export abstract class TextFileService extends Disposable implements ITextFileSer }); } - private doSaveTextFileAs(sourceModel: ITextFileEditorModel | UntitledEditorModel, resource: URI, target: URI, options?: ISaveOptions): TPromise { - let targetModelResolver: TPromise; + private doSaveTextFileAs(sourceModel: ITextFileEditorModel | UntitledEditorModel, resource: URI, target: URI, options?: ISaveOptions): Thenable { + let targetModelResolver: Thenable; // Prefer an existing model if it is already loaded for the given target resource const targetModel = this.models.get(target); @@ -638,11 +637,11 @@ export abstract class TextFileService extends Disposable implements ITextFileSer return URI.file(untitledFileName); } - revert(resource: URI, options?: IRevertOptions): TPromise { + revert(resource: URI, options?: IRevertOptions): Thenable { return this.revertAll([resource], options).then(result => result.results.length === 1 && result.results[0].success); } - revertAll(resources?: URI[], options?: IRevertOptions): TPromise { + revertAll(resources?: URI[], options?: IRevertOptions): Thenable { // Revert files first return this.doRevertAllFiles(resources, options).then(operation => { @@ -655,7 +654,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer }); } - private doRevertAllFiles(resources?: URI[], options?: IRevertOptions): TPromise { + private doRevertAllFiles(resources?: URI[], options?: IRevertOptions): Thenable { const fileModels = options && options.force ? this.getFileModels(resources) : this.getDirtyFileModels(resources); const mapResourceToResult = new ResourceMap(); @@ -687,7 +686,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer })).then(r => ({ results: mapResourceToResult.values() })); } - create(resource: URI, contents?: string, options?: { overwrite?: boolean }): TPromise { + create(resource: URI, contents?: string, options?: { overwrite?: boolean }): Thenable { const existingModel = this.models.get(resource); return this.fileService.createFile(resource, contents, options).then(() => { @@ -704,14 +703,14 @@ export abstract class TextFileService extends Disposable implements ITextFileSer }); } - delete(resource: URI, options?: { useTrash?: boolean, recursive?: boolean }): TPromise { + delete(resource: URI, options?: { useTrash?: boolean, recursive?: boolean }): Thenable { const dirtyFiles = this.getDirty().filter(dirty => isEqualOrParent(dirty, resource, !platform.isLinux /* ignorecase */)); return this.revertAll(dirtyFiles, { soft: true }).then(() => this.fileService.del(resource, options)); } - move(source: URI, target: URI, overwrite?: boolean): TPromise { - const waitForPromises: TPromise[] = []; + move(source: URI, target: URI, overwrite?: boolean): Thenable { + const waitForPromises: Thenable[] = []; // Event this._onWillMove.fire({ @@ -728,7 +727,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer return Promise.all(waitForPromises).then(() => { // Handle target models if existing (if target URI is a folder, this can be multiple) - let handleTargetModelPromise: TPromise = Promise.resolve(); + let handleTargetModelPromise: Thenable = Promise.resolve(); const dirtyTargetModels = this.getDirtyFileModels().filter(model => isEqualOrParent(model.getResource(), target, false /* do not ignorecase, see https://github.com/Microsoft/vscode/issues/56384 */)); if (dirtyTargetModels.length) { handleTargetModelPromise = this.revertAll(dirtyTargetModels.map(targetModel => targetModel.getResource()), { soft: true }); @@ -737,7 +736,7 @@ export abstract class TextFileService extends Disposable implements ITextFileSer return handleTargetModelPromise.then(() => { // Handle dirty source models if existing (if source URI is a folder, this can be multiple) - let handleDirtySourceModels: TPromise; + let handleDirtySourceModels: Thenable; const dirtySourceModels = this.getDirtyFileModels().filter(model => isEqualOrParent(model.getResource(), source, !platform.isLinux /* ignorecase */)); const dirtyTargetModels: URI[] = []; if (dirtySourceModels.length) { diff --git a/src/vs/workbench/services/textfile/common/textfiles.ts b/src/vs/workbench/services/textfile/common/textfiles.ts index 4f199003e89..21857f98d8d 100644 --- a/src/vs/workbench/services/textfile/common/textfiles.ts +++ b/src/vs/workbench/services/textfile/common/textfiles.ts @@ -3,7 +3,6 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ -import { TPromise } from 'vs/base/common/winjs.base'; import { URI } from 'vs/base/common/uri'; import { Event } from 'vs/base/common/event'; import { IDisposable } from 'vs/base/common/lifecycle'; @@ -194,7 +193,7 @@ export interface ITextFileEditorModelManager { getAll(resource?: URI): ITextFileEditorModel[]; - loadOrCreate(resource: URI, options?: IModelLoadOrCreateOptions): TPromise; + loadOrCreate(resource: URI, options?: IModelLoadOrCreateOptions): Thenable; disposeModel(model: ITextFileEditorModel): void; } @@ -241,11 +240,11 @@ export interface ITextFileEditorModel extends ITextEditorModel, IEncodingSupport updatePreferredEncoding(encoding: string): void; - save(options?: ISaveOptions): TPromise; + save(options?: ISaveOptions): Thenable; load(options?: ILoadOptions): Thenable; - revert(soft?: boolean): TPromise; + revert(soft?: boolean): Thenable; createSnapshot(): ITextSnapshot; @@ -281,7 +280,7 @@ export interface ITextFileService extends IDisposable { /** * Resolve the contents of a file identified by the resource. */ - resolveTextContent(resource: URI, options?: IResolveContentOptions): TPromise; + resolveTextContent(resource: URI, options?: IResolveContentOptions): Thenable; /** * A resource is dirty if it has unsaved changes or is an untitled file not yet saved. @@ -306,7 +305,7 @@ export interface ITextFileService extends IDisposable { * @param options optional save options * @return true if the resource was saved. */ - save(resource: URI, options?: ISaveOptions): TPromise; + save(resource: URI, options?: ISaveOptions): Thenable; /** * Saves the provided resource asking the user for a file name or using the provided one. @@ -316,7 +315,7 @@ export interface ITextFileService extends IDisposable { * @param options optional save options * @return true if the file was saved. */ - saveAs(resource: URI, targetResource?: URI, options?: ISaveOptions): TPromise; + saveAs(resource: URI, targetResource?: URI, options?: ISaveOptions): Thenable; /** * Saves the set of resources and returns a promise with the operation result. @@ -324,8 +323,8 @@ export interface ITextFileService extends IDisposable { * @param resources can be null to save all. * @param includeUntitled to save all resources and optionally exclude untitled ones. */ - saveAll(includeUntitled?: boolean, options?: ISaveOptions): TPromise; - saveAll(resources: URI[], options?: ISaveOptions): TPromise; + saveAll(includeUntitled?: boolean, options?: ISaveOptions): Thenable; + saveAll(resources: URI[], options?: ISaveOptions): Thenable; /** * Reverts the provided resource. @@ -333,28 +332,28 @@ export interface ITextFileService extends IDisposable { * @param resource the resource of the file to revert. * @param force to force revert even when the file is not dirty */ - revert(resource: URI, options?: IRevertOptions): TPromise; + revert(resource: URI, options?: IRevertOptions): Thenable; /** * Reverts all the provided resources and returns a promise with the operation result. */ - revertAll(resources?: URI[], options?: IRevertOptions): TPromise; + revertAll(resources?: URI[], options?: IRevertOptions): Thenable; /** * Create a file. If the file exists it will be overwritten with the contents if * the options enable to overwrite. */ - create(resource: URI, contents?: string, options?: { overwrite?: boolean }): TPromise; + create(resource: URI, contents?: string, options?: { overwrite?: boolean }): Thenable; /** * Delete a file. If the file is dirty, it will get reverted and then deleted from disk. */ - delete(resource: URI, options?: { useTrash?: boolean, recursive?: boolean }): TPromise; + delete(resource: URI, options?: { useTrash?: boolean, recursive?: boolean }): Thenable; /** * Move a file. If the file is dirty, its contents will be preserved and restored. */ - move(source: URI, target: URI, overwrite?: boolean): TPromise; + move(source: URI, target: URI, overwrite?: boolean): Thenable; /** * Brings up the confirm dialog to either save, don't save or cancel. @@ -362,7 +361,7 @@ export interface ITextFileService extends IDisposable { * @param resources the resources of the files to ask for confirmation or null if * confirming for all dirty resources. */ - confirmSave(resources?: URI[]): TPromise; + confirmSave(resources?: URI[]): Thenable; /** * Convinient fast access to the current auto save mode. diff --git a/src/vs/workbench/services/textfile/electron-browser/textFileService.ts b/src/vs/workbench/services/textfile/electron-browser/textFileService.ts index e2be2f12bf1..ec9da978174 100644 --- a/src/vs/workbench/services/textfile/electron-browser/textFileService.ts +++ b/src/vs/workbench/services/textfile/electron-browser/textFileService.ts @@ -4,7 +4,6 @@ *--------------------------------------------------------------------------------------------*/ import * as nls from 'vs/nls'; -import { TPromise } from 'vs/base/common/winjs.base'; import * as paths from 'vs/base/common/paths'; import * as strings from 'vs/base/common/strings'; import { isWindows } from 'vs/base/common/platform'; @@ -56,7 +55,7 @@ export class TextFileService extends AbstractTextFileService { super(lifecycleService, contextService, configurationService, fileService, untitledEditorService, instantiationService, notificationService, environmentService, backupFileService, windowsService, windowService, historyService, contextKeyService, modelService); } - resolveTextContent(resource: URI, options?: IResolveContentOptions): TPromise { + resolveTextContent(resource: URI, options?: IResolveContentOptions): Thenable { return this.fileService.resolveStreamContent(resource, options).then(streamContent => { return createTextBufferFactoryFromStream(streamContent.value).then(res => { const r: IRawTextContent = { @@ -73,7 +72,7 @@ export class TextFileService extends AbstractTextFileService { }); } - confirmSave(resources?: URI[]): TPromise { + confirmSave(resources?: URI[]): Thenable { if (this.environmentService.isExtensionDevelopment) { return Promise.resolve(ConfirmResult.DONT_SAVE); // no veto when we are in extension dev mode because we cannot assum we run interactive (e.g. tests) } @@ -104,7 +103,7 @@ export class TextFileService extends AbstractTextFileService { }); } - promptForPath(resource: URI, defaultUri: URI): TPromise { + promptForPath(resource: URI, defaultUri: URI): Thenable { // Help user to find a name for the file by opening it first return this.editorService.openEditor({ resource, options: { revealIfOpened: true, preserveFocus: true, } }).then(() => { diff --git a/src/vs/workbench/services/textfile/test/textFileService.test.ts b/src/vs/workbench/services/textfile/test/textFileService.test.ts index e2c623480dc..a5af3f11c99 100644 --- a/src/vs/workbench/services/textfile/test/textFileService.test.ts +++ b/src/vs/workbench/services/textfile/test/textFileService.test.ts @@ -6,7 +6,6 @@ import * as assert from 'assert'; import * as sinon from 'sinon'; import * as platform from 'vs/base/common/platform'; import { URI } from 'vs/base/common/uri'; -import { TPromise } from 'vs/base/common/winjs.base'; import { ILifecycleService, BeforeShutdownEvent, ShutdownReason } from 'vs/platform/lifecycle/common/lifecycle'; import { workbenchInstantiationService, TestLifecycleService, TestTextFileService, TestWindowsService, TestContextService, TestFileService } from 'vs/workbench/test/workbenchTestServices'; import { toResource } from 'vs/base/test/common/utils'; @@ -39,10 +38,10 @@ class ServiceAccessor { class BeforeShutdownEventImpl implements BeforeShutdownEvent { - public value: boolean | TPromise; + public value: boolean | Thenable; public reason = ShutdownReason.CLOSE; - veto(value: boolean | TPromise): void { + veto(value: boolean | Thenable): void { this.value = value; } } @@ -148,7 +147,7 @@ suite('Files - TextFileService', () => { const event = new BeforeShutdownEventImpl(); accessor.lifecycleService.fireWillShutdown(event); - return (>event.value).then(veto => { + return (>event.value).then(veto => { assert.ok(!veto); assert.ok(!model.isDirty()); }); @@ -427,7 +426,7 @@ suite('Files - TextFileService', () => { }); }); - function hotExitTest(this: any, setting: string, shutdownReason: ShutdownReason, multipleWindows: boolean, workspace: true, shouldVeto: boolean): TPromise { + function hotExitTest(this: any, setting: string, shutdownReason: ShutdownReason, multipleWindows: boolean, workspace: true, shouldVeto: boolean): Thenable { model = instantiationService.createInstance(TextFileEditorModel, toResource.call(this, '/path/file.txt'), 'utf8'); (accessor.textFileService.models).add(model.getResource(), model); @@ -454,7 +453,7 @@ suite('Files - TextFileService', () => { event.reason = shutdownReason; accessor.lifecycleService.fireWillShutdown(event); - return (>event.value).then(veto => { + return (>event.value).then(veto => { // When hot exit is set, backups should never be cleaned since the confirm result is cancel assert.ok(!service.cleanupBackupsBeforeShutdownCalled); assert.equal(veto, shouldVeto); @@ -462,4 +461,4 @@ suite('Files - TextFileService', () => { }); } }); -}); \ No newline at end of file +}); diff --git a/src/vs/workbench/services/untitled/common/untitledEditorService.ts b/src/vs/workbench/services/untitled/common/untitledEditorService.ts index 8d32b6cadcc..7629337e713 100644 --- a/src/vs/workbench/services/untitled/common/untitledEditorService.ts +++ b/src/vs/workbench/services/untitled/common/untitledEditorService.ts @@ -11,7 +11,6 @@ import { IFilesConfiguration } from 'vs/platform/files/common/files'; import { IConfigurationService } from 'vs/platform/configuration/common/configuration'; import { Event, Emitter } from 'vs/base/common/event'; import { ResourceMap } from 'vs/base/common/map'; -import { TPromise } from 'vs/base/common/winjs.base'; import { UntitledEditorModel } from 'vs/workbench/common/editor/untitledEditorModel'; import { Schemas } from 'vs/base/common/network'; import { Disposable } from 'vs/base/common/lifecycle'; @@ -86,7 +85,7 @@ export interface IUntitledEditorService { * It is valid to pass in a file resource. In that case the path will be used as identifier. * The use case is to be able to create a new file with a specific path with VSCode. */ - loadOrCreate(options: IModelLoadOrCreateOptions): TPromise; + loadOrCreate(options: IModelLoadOrCreateOptions): Thenable; /** * A check to find out if a untitled resource has a file path associated or not. diff --git a/src/vs/workbench/test/workbenchTestServices.ts b/src/vs/workbench/test/workbenchTestServices.ts index 0ef727eedd7..aa1f83507cf 100644 --- a/src/vs/workbench/test/workbenchTestServices.ts +++ b/src/vs/workbench/test/workbenchTestServices.ts @@ -5,7 +5,6 @@ import 'vs/workbench/parts/files/electron-browser/files.contribution'; // load our contribution into the test import { FileEditorInput } from 'vs/workbench/parts/files/common/editors/fileEditorInput'; -import { TPromise } from 'vs/base/common/winjs.base'; import { TestInstantiationService } from 'vs/platform/instantiation/test/common/instantiationServiceMock'; import * as paths from 'vs/base/common/paths'; import * as resources from 'vs/base/common/resources'; @@ -205,7 +204,7 @@ export class TestTextFileService extends TextFileService { this.resolveTextContentError = error; } - public resolveTextContent(resource: URI, options?: IResolveContentOptions): TPromise { + public resolveTextContent(resource: URI, options?: IResolveContentOptions): Thenable { if (this.resolveTextContentError) { const error = this.resolveTextContentError; this.resolveTextContentError = null; @@ -225,11 +224,11 @@ export class TestTextFileService extends TextFileService { }); } - public promptForPath(_resource: URI, _defaultPath: URI): TPromise { + public promptForPath(_resource: URI, _defaultPath: URI): Thenable { return Promise.resolve(this.promptPath); } - public confirmSave(_resources?: URI[]): TPromise { + public confirmSave(_resources?: URI[]): Thenable { return Promise.resolve(this.confirmResult); } @@ -237,7 +236,7 @@ export class TestTextFileService extends TextFileService { super.onFilesConfigurationChange(configuration); } - protected cleanupBackupsBeforeShutdown(): TPromise { + protected cleanupBackupsBeforeShutdown(): Thenable { this.cleanupBackupsBeforeShutdownCalled = true; return Promise.resolve(); } @@ -386,11 +385,11 @@ export class TestDialogService implements IDialogService { public _serviceBrand: any; - public confirm(_confirmation: IConfirmation): TPromise { + public confirm(_confirmation: IConfirmation): Thenable { return Promise.resolve({ confirmed: false }); } - public show(_severity: Severity, _message: string, _buttons: string[], _options?: IDialogOptions): TPromise { + public show(_severity: Severity, _message: string, _buttons: string[], _options?: IDialogOptions): Thenable { return Promise.resolve(0); } } @@ -408,22 +407,22 @@ export class TestFileDialogService implements IFileDialogService { public defaultWorkspacePath(_schemeFilter: string): URI { return void 0; } - public pickFileFolderAndOpen(_options: IPickAndOpenOptions): TPromise { + public pickFileFolderAndOpen(_options: IPickAndOpenOptions): Thenable { return Promise.resolve(0); } - public pickFileAndOpen(_options: IPickAndOpenOptions): TPromise { + public pickFileAndOpen(_options: IPickAndOpenOptions): Thenable { return Promise.resolve(0); } - public pickFolderAndOpen(_options: IPickAndOpenOptions): TPromise { + public pickFolderAndOpen(_options: IPickAndOpenOptions): Thenable { return Promise.resolve(0); } - public pickWorkspaceAndOpen(_options: IPickAndOpenOptions): TPromise { + public pickWorkspaceAndOpen(_options: IPickAndOpenOptions): Thenable { return Promise.resolve(0); } - public showSaveDialog(_options: ISaveDialogOptions): TPromise { + public showSaveDialog(_options: ISaveDialogOptions): Thenable { return Promise.resolve(); } - public showOpenDialog(_options: IOpenDialogOptions): TPromise { + public showOpenDialog(_options: IOpenDialogOptions): Thenable { return Promise.resolve(); } } @@ -486,13 +485,13 @@ export class TestPartService implements IPartService { return false; } - public setSideBarHidden(_hidden: boolean): TPromise { return Promise.resolve(null); } + public setSideBarHidden(_hidden: boolean): Thenable { return Promise.resolve(null); } public isPanelHidden(): boolean { return false; } - public setPanelHidden(_hidden: boolean): TPromise { return Promise.resolve(null); } + public setPanelHidden(_hidden: boolean): Thenable { return Promise.resolve(null); } public toggleMaximizedPanel(): void { } @@ -512,7 +511,7 @@ export class TestPartService implements IPartService { return 0; } - public setPanelPosition(_position: PartPosition): TPromise { + public setPanelPosition(_position: PartPosition): Thenable { return Promise.resolve(null); } @@ -649,11 +648,11 @@ export class TestEditorGroup implements IEditorGroupView { return -1; } - openEditor(_editor: IEditorInput, _options?: IEditorOptions): TPromise { + openEditor(_editor: IEditorInput, _options?: IEditorOptions): Thenable { return Promise.resolve(null); } - openEditors(_editors: IEditorInputWithOptions[]): TPromise { + openEditors(_editors: IEditorInputWithOptions[]): Thenable { return Promise.resolve(null); } @@ -673,19 +672,19 @@ export class TestEditorGroup implements IEditorGroupView { copyEditor(_editor: IEditorInput, _target: IEditorGroup, _options?: ICopyEditorOptions): void { } - closeEditor(_editor?: IEditorInput): TPromise { + closeEditor(_editor?: IEditorInput): Thenable { return Promise.resolve(); } - closeEditors(_editors: IEditorInput[] | { except?: IEditorInput; direction?: CloseDirection; savedOnly?: boolean; }): TPromise { + closeEditors(_editors: IEditorInput[] | { except?: IEditorInput; direction?: CloseDirection; savedOnly?: boolean; }): Thenable { return Promise.resolve(); } - closeAllEditors(): TPromise { + closeAllEditors(): Thenable { return Promise.resolve(); } - replaceEditors(_editors: IEditorReplacement[]): TPromise { + replaceEditors(_editors: IEditorReplacement[]): Thenable { return Promise.resolve(); } @@ -796,7 +795,7 @@ export class TestFileService implements IFileService { this._onAfterOperation.fire(event); } - resolveFile(resource: URI, _options?: IResolveFileOptions): TPromise { + resolveFile(resource: URI, _options?: IResolveFileOptions): Thenable { return Promise.resolve({ resource, etag: Date.now().toString(), @@ -807,15 +806,15 @@ export class TestFileService implements IFileService { }); } - resolveFiles(toResolve: { resource: URI, options?: IResolveFileOptions }[]): TPromise { + resolveFiles(toResolve: { resource: URI, options?: IResolveFileOptions }[]): Thenable { return Promise.all(toResolve.map(resourceAndOption => this.resolveFile(resourceAndOption.resource, resourceAndOption.options))).then(stats => stats.map(stat => ({ stat, success: true }))); } - existsFile(_resource: URI): TPromise { + existsFile(_resource: URI): Thenable { return Promise.resolve(null); } - resolveContent(resource: URI, _options?: IResolveContentOptions): TPromise { + resolveContent(resource: URI, _options?: IResolveContentOptions): Thenable { return Promise.resolve({ resource: resource, value: this.content, @@ -826,7 +825,7 @@ export class TestFileService implements IFileService { }); } - resolveStreamContent(resource: URI, _options?: IResolveContentOptions): TPromise { + resolveStreamContent(resource: URI, _options?: IResolveContentOptions): Thenable { return Promise.resolve({ resource: resource, value: { @@ -846,7 +845,7 @@ export class TestFileService implements IFileService { }); } - updateContent(resource: URI, _value: string | ITextSnapshot, _options?: IUpdateContentOptions): TPromise { + updateContent(resource: URI, _value: string | ITextSnapshot, _options?: IUpdateContentOptions): Thenable { return timeout(0).then(() => ({ resource, etag: 'index.txt', @@ -857,15 +856,15 @@ export class TestFileService implements IFileService { })); } - moveFile(_source: URI, _target: URI, _overwrite?: boolean): TPromise { + moveFile(_source: URI, _target: URI, _overwrite?: boolean): Thenable { return Promise.resolve(null); } - copyFile(_source: URI, _target: URI, _overwrite?: boolean): TPromise { + copyFile(_source: URI, _target: URI, _overwrite?: boolean): Thenable { return Promise.resolve(null); } - createFile(_resource: URI, _content?: string, _options?: ICreateFileOptions): TPromise { + createFile(_resource: URI, _content?: string, _options?: ICreateFileOptions): Thenable { return Promise.resolve(null); } @@ -873,7 +872,7 @@ export class TestFileService implements IFileService { return Promise.resolve([]); } - createFolder(_resource: URI): TPromise { + createFolder(_resource: URI): Thenable { return Promise.resolve(null); } @@ -891,7 +890,7 @@ export class TestFileService implements IFileService { return resource.scheme === 'file'; } - del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): TPromise { + del(_resource: URI, _options?: { useTrash?: boolean, recursive?: boolean }): Thenable { return Promise.resolve(null); } @@ -912,15 +911,15 @@ export class TestFileService implements IFileService { export class TestBackupFileService implements IBackupFileService { public _serviceBrand: any; - public hasBackups(): TPromise { + public hasBackups(): Thenable { return Promise.resolve(false); } - public hasBackup(_resource: URI): TPromise { + public hasBackup(_resource: URI): Thenable { return Promise.resolve(false); } - public loadBackupResource(resource: URI): TPromise { + public loadBackupResource(resource: URI): Thenable { return this.hasBackup(resource).then(hasBackup => { if (hasBackup) { return this.toBackupResource(resource); @@ -930,11 +929,11 @@ export class TestBackupFileService implements IBackupFileService { }); } - public registerResourceForBackup(_resource: URI): TPromise { + public registerResourceForBackup(_resource: URI): Thenable { return Promise.resolve(); } - public deregisterResourceForBackup(_resource: URI): TPromise { + public deregisterResourceForBackup(_resource: URI): Thenable { return Promise.resolve(); } @@ -942,11 +941,11 @@ export class TestBackupFileService implements IBackupFileService { return null; } - public backupResource(_resource: URI, _content: ITextSnapshot): TPromise { + public backupResource(_resource: URI, _content: ITextSnapshot): Thenable { return Promise.resolve(); } - public getWorkspaceFileBackups(): TPromise { + public getWorkspaceFileBackups(): Thenable { return Promise.resolve([]); } @@ -957,15 +956,15 @@ export class TestBackupFileService implements IBackupFileService { return textBuffer.getValueInRange(range, EndOfLinePreference.TextDefined); } - public resolveBackupContent(_backup: URI): TPromise { + public resolveBackupContent(_backup: URI): Thenable { return Promise.resolve(null); } - public discardResourceBackup(_resource: URI): TPromise { + public discardResourceBackup(_resource: URI): Thenable { return Promise.resolve(); } - public discardAllWorkspaceBackups(): TPromise { + public discardAllWorkspaceBackups(): Thenable { return Promise.resolve(); } } @@ -1004,11 +1003,11 @@ export class TestWindowService implements IWindowService { hasFocus = true; - isFocused(): TPromise { + isFocused(): Thenable { return Promise.resolve(false); } - isMaximized(): TPromise { + isMaximized(): Thenable { return Promise.resolve(false); } @@ -1020,111 +1019,111 @@ export class TestWindowService implements IWindowService { return 0; } - pickFileFolderAndOpen(_options: INativeOpenDialogOptions): TPromise { + pickFileFolderAndOpen(_options: INativeOpenDialogOptions): Thenable { return Promise.resolve(); } - pickFileAndOpen(_options: INativeOpenDialogOptions): TPromise { + pickFileAndOpen(_options: INativeOpenDialogOptions): Thenable { return Promise.resolve(); } - pickFolderAndOpen(_options: INativeOpenDialogOptions): TPromise { + pickFolderAndOpen(_options: INativeOpenDialogOptions): Thenable { return Promise.resolve(); } - pickWorkspaceAndOpen(_options: INativeOpenDialogOptions): TPromise { + pickWorkspaceAndOpen(_options: INativeOpenDialogOptions): Thenable { return Promise.resolve(); } - reloadWindow(): TPromise { + reloadWindow(): Thenable { return Promise.resolve(); } - openDevTools(): TPromise { + openDevTools(): Thenable { return Promise.resolve(); } - toggleDevTools(): TPromise { + toggleDevTools(): Thenable { return Promise.resolve(); } - closeWorkspace(): TPromise { + closeWorkspace(): Thenable { return Promise.resolve(); } - enterWorkspace(_path: string): TPromise { + enterWorkspace(_path: string): Thenable { return Promise.resolve(); } - createAndEnterWorkspace(_folders?: IWorkspaceFolderCreationData[], _path?: string): TPromise { + createAndEnterWorkspace(_folders?: IWorkspaceFolderCreationData[], _path?: string): Thenable { return Promise.resolve(); } - saveAndEnterWorkspace(_path: string): TPromise { + saveAndEnterWorkspace(_path: string): Thenable { return Promise.resolve(); } - toggleFullScreen(): TPromise { + toggleFullScreen(): Thenable { return Promise.resolve(); } - setRepresentedFilename(_fileName: string): TPromise { + setRepresentedFilename(_fileName: string): Thenable { return Promise.resolve(); } - getRecentlyOpened(): TPromise { + getRecentlyOpened(): Thenable { return Promise.resolve(); } - focusWindow(): TPromise { + focusWindow(): Thenable { return Promise.resolve(); } - maximizeWindow(): TPromise { + maximizeWindow(): Thenable { return Promise.resolve(); } - unmaximizeWindow(): TPromise { + unmaximizeWindow(): Thenable { return Promise.resolve(); } - minimizeWindow(): TPromise { + minimizeWindow(): Thenable { return Promise.resolve(); } - openWindow(_paths: URI[], _options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): TPromise { + openWindow(_paths: URI[], _options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): Thenable { return Promise.resolve(); } - closeWindow(): TPromise { + closeWindow(): Thenable { return Promise.resolve(); } - setDocumentEdited(_flag: boolean): TPromise { + setDocumentEdited(_flag: boolean): Thenable { return Promise.resolve(); } - onWindowTitleDoubleClick(): TPromise { + onWindowTitleDoubleClick(): Thenable { return Promise.resolve(); } - show(): TPromise { + show(): Thenable { return Promise.resolve(); } - showMessageBox(_options: Electron.MessageBoxOptions): TPromise { + showMessageBox(_options: Electron.MessageBoxOptions): Thenable { return Promise.resolve({ button: 0 }); } - showSaveDialog(_options: Electron.SaveDialogOptions): TPromise { + showSaveDialog(_options: Electron.SaveDialogOptions): Thenable { return Promise.resolve(void 0); } - showOpenDialog(_options: Electron.OpenDialogOptions): TPromise { + showOpenDialog(_options: Electron.OpenDialogOptions): Thenable { return Promise.resolve(void 0); } - updateTouchBar(_items: ISerializableCommandAction[][]): TPromise { + updateTouchBar(_items: ISerializableCommandAction[][]): Thenable { return Promise.resolve(); } @@ -1144,7 +1143,7 @@ export class TestLifecycleService implements ILifecycleService { private _onWillShutdown = new Emitter(); private _onShutdown = new Emitter(); - when(): TPromise { + when(): Thenable { return Promise.resolve(); } @@ -1185,211 +1184,211 @@ export class TestWindowsService implements IWindowsService { onWindowUnmaximize: Event; onRecentlyOpenedChange: Event; - isFocused(_windowId: number): TPromise { + isFocused(_windowId: number): Thenable { return Promise.resolve(false); } - pickFileFolderAndOpen(_options: INativeOpenDialogOptions): TPromise { + pickFileFolderAndOpen(_options: INativeOpenDialogOptions): Thenable { return Promise.resolve(); } - pickFileAndOpen(_options: INativeOpenDialogOptions): TPromise { + pickFileAndOpen(_options: INativeOpenDialogOptions): Thenable { return Promise.resolve(); } - pickFolderAndOpen(_options: INativeOpenDialogOptions): TPromise { + pickFolderAndOpen(_options: INativeOpenDialogOptions): Thenable { return Promise.resolve(); } - pickWorkspaceAndOpen(_options: INativeOpenDialogOptions): TPromise { + pickWorkspaceAndOpen(_options: INativeOpenDialogOptions): Thenable { return Promise.resolve(); } - reloadWindow(_windowId: number): TPromise { + reloadWindow(_windowId: number): Thenable { return Promise.resolve(); } - openDevTools(_windowId: number): TPromise { + openDevTools(_windowId: number): Thenable { return Promise.resolve(); } - toggleDevTools(_windowId: number): TPromise { + toggleDevTools(_windowId: number): Thenable { return Promise.resolve(); } - closeWorkspace(_windowId: number): TPromise { + closeWorkspace(_windowId: number): Thenable { return Promise.resolve(); } - enterWorkspace(_windowId: number, _path: string): TPromise { + enterWorkspace(_windowId: number, _path: string): Thenable { return Promise.resolve(); } - createAndEnterWorkspace(_windowId: number, _folders?: IWorkspaceFolderCreationData[], _path?: string): TPromise { + createAndEnterWorkspace(_windowId: number, _folders?: IWorkspaceFolderCreationData[], _path?: string): Thenable { return Promise.resolve(); } - saveAndEnterWorkspace(_windowId: number, _path: string): TPromise { + saveAndEnterWorkspace(_windowId: number, _path: string): Thenable { return Promise.resolve(); } - toggleFullScreen(_windowId: number): TPromise { + toggleFullScreen(_windowId: number): Thenable { return Promise.resolve(); } - setRepresentedFilename(_windowId: number, _fileName: string): TPromise { + setRepresentedFilename(_windowId: number, _fileName: string): Thenable { return Promise.resolve(); } - addRecentlyOpened(_files: URI[]): TPromise { + addRecentlyOpened(_files: URI[]): Thenable { return Promise.resolve(); } - removeFromRecentlyOpened(_paths: URI[]): TPromise { + removeFromRecentlyOpened(_paths: URI[]): Thenable { return Promise.resolve(); } - clearRecentlyOpened(): TPromise { + clearRecentlyOpened(): Thenable { return Promise.resolve(); } - getRecentlyOpened(_windowId: number): TPromise { + getRecentlyOpened(_windowId: number): Thenable { return Promise.resolve(); } - focusWindow(_windowId: number): TPromise { + focusWindow(_windowId: number): Thenable { return Promise.resolve(); } - closeWindow(_windowId: number): TPromise { + closeWindow(_windowId: number): Thenable { return Promise.resolve(); } - isMaximized(_windowId: number): TPromise { + isMaximized(_windowId: number): Thenable { return Promise.resolve(); } - maximizeWindow(_windowId: number): TPromise { + maximizeWindow(_windowId: number): Thenable { return Promise.resolve(); } - minimizeWindow(_windowId: number): TPromise { + minimizeWindow(_windowId: number): Thenable { return Promise.resolve(); } - unmaximizeWindow(_windowId: number): TPromise { + unmaximizeWindow(_windowId: number): Thenable { return Promise.resolve(); } - onWindowTitleDoubleClick(_windowId: number): TPromise { + onWindowTitleDoubleClick(_windowId: number): Thenable { return Promise.resolve(); } - setDocumentEdited(_windowId: number, _flag: boolean): TPromise { + setDocumentEdited(_windowId: number, _flag: boolean): Thenable { return Promise.resolve(); } - quit(): TPromise { + quit(): Thenable { return Promise.resolve(); } - relaunch(_options: { addArgs?: string[], removeArgs?: string[] }): TPromise { + relaunch(_options: { addArgs?: string[], removeArgs?: string[] }): Thenable { return Promise.resolve(); } - whenSharedProcessReady(): TPromise { + whenSharedProcessReady(): Thenable { return Promise.resolve(); } - toggleSharedProcess(): TPromise { + toggleSharedProcess(): Thenable { return Promise.resolve(); } // Global methods - openWindow(_windowId: number, _paths: URI[], _options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): TPromise { + openWindow(_windowId: number, _paths: URI[], _options?: { forceNewWindow?: boolean, forceReuseWindow?: boolean, forceOpenWorkspaceAsFile?: boolean }): Thenable { return Promise.resolve(); } - openNewWindow(): TPromise { + openNewWindow(): Thenable { return Promise.resolve(); } - showWindow(_windowId: number): TPromise { + showWindow(_windowId: number): Thenable { return Promise.resolve(); } - getWindows(): TPromise<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> { + getWindows(): Thenable<{ id: number; workspace?: IWorkspaceIdentifier; folderUri?: ISingleFolderWorkspaceIdentifier; title: string; filename?: string; }[]> { return Promise.resolve(); } - getWindowCount(): TPromise { + getWindowCount(): Thenable { return Promise.resolve(this.windowCount); } - log(_severity: string, ..._messages: string[]): TPromise { + log(_severity: string, ..._messages: string[]): Thenable { return Promise.resolve(); } - showItemInFolder(_path: string): TPromise { + showItemInFolder(_path: string): Thenable { return Promise.resolve(); } - newWindowTab(): TPromise { + newWindowTab(): Thenable { return Promise.resolve(); } - showPreviousWindowTab(): TPromise { + showPreviousWindowTab(): Thenable { return Promise.resolve(); } - showNextWindowTab(): TPromise { + showNextWindowTab(): Thenable { return Promise.resolve(); } - moveWindowTabToNewWindow(): TPromise { + moveWindowTabToNewWindow(): Thenable { return Promise.resolve(); } - mergeAllWindowTabs(): TPromise { + mergeAllWindowTabs(): Thenable { return Promise.resolve(); } - toggleWindowTabsBar(): TPromise { + toggleWindowTabsBar(): Thenable { return Promise.resolve(); } - updateTouchBar(_windowId: number, _items: ISerializableCommandAction[][]): TPromise { + updateTouchBar(_windowId: number, _items: ISerializableCommandAction[][]): Thenable { return Promise.resolve(); } - getActiveWindowId(): TPromise { + getActiveWindowId(): Thenable { return Promise.resolve(undefined); } // This needs to be handled from browser process to prevent // foreground ordering issues on Windows - openExternal(_url: string): TPromise { + openExternal(_url: string): Thenable { return Promise.resolve(true); } // TODO: this is a bit backwards - startCrashReporter(_config: Electron.CrashReporterStartOptions): TPromise { + startCrashReporter(_config: Electron.CrashReporterStartOptions): Thenable { return Promise.resolve(); } - showMessageBox(_windowId: number, _options: Electron.MessageBoxOptions): TPromise { + showMessageBox(_windowId: number, _options: Electron.MessageBoxOptions): Thenable { return Promise.resolve(); } - showSaveDialog(_windowId: number, _options: Electron.SaveDialogOptions): TPromise { + showSaveDialog(_windowId: number, _options: Electron.SaveDialogOptions): Thenable { return Promise.resolve(); } - showOpenDialog(_windowId: number, _options: Electron.OpenDialogOptions): TPromise { + showOpenDialog(_windowId: number, _options: Electron.OpenDialogOptions): Thenable { return Promise.resolve(); } - openAboutDialog(): TPromise { + openAboutDialog(): Thenable { return Promise.resolve(); }