提交 c0bddd3f 编写于 作者: I isidor

workbench/browser: TPromise.as -> Promise.resolve

上级 f3662d06
......@@ -106,7 +106,7 @@ export class ContributableActionProvider implements IActionProvider {
}
}
return TPromise.as(prepareActions(actions));
return Promise.resolve(prepareActions(actions));
}
hasSecondaryActions(tree: ITree, element: any): boolean {
......@@ -136,7 +136,7 @@ export class ContributableActionProvider implements IActionProvider {
}
}
return TPromise.as(prepareActions(actions));
return Promise.resolve(prepareActions(actions));
}
getActionItem(tree: ITree, element: any, action: Action): BaseActionItem {
......
......@@ -28,7 +28,7 @@ class ToggleCenteredLayout extends Action {
run(): TPromise<any> {
this.partService.centerEditorLayout(!this.partService.isEditorLayoutCentered());
return TPromise.as(null);
return Promise.resolve(null);
}
}
......
......@@ -52,7 +52,7 @@ export class ToggleEditorLayoutAction extends Action {
const newOrientation = (this.editorGroupService.orientation === GroupOrientation.VERTICAL) ? GroupOrientation.HORIZONTAL : GroupOrientation.VERTICAL;
this.editorGroupService.setGroupOrientation(newOrientation);
return TPromise.as(null);
return Promise.resolve(null);
}
dispose(): void {
......@@ -68,7 +68,7 @@ CommandsRegistry.registerCommand('_workbench.editor.setGroupOrientation', functi
editorGroupService.setGroupOrientation(orientation);
return TPromise.as<void>(null);
return Promise.resolve(null);
});
const registry = Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions);
......
......@@ -28,7 +28,7 @@ class ToggleZenMode extends Action {
run(): TPromise<any> {
this.partService.toggleZenMode();
return TPromise.as(null);
return Promise.resolve(null);
}
}
......
......@@ -122,7 +122,7 @@ export class GlobalRemoveRootFolderAction extends Action {
});
}
return TPromise.as(true);
return Promise.resolve(true);
}
}
......
......@@ -92,7 +92,7 @@ export abstract class Composite extends Component implements IComposite {
create(parent: HTMLElement): TPromise<void> {
this.parent = parent;
return TPromise.as(null);
return Promise.resolve(null);
}
updateStyles(): void {
......@@ -121,7 +121,7 @@ export abstract class Composite extends Component implements IComposite {
setVisible(visible: boolean): TPromise<void> {
this.visible = visible;
return TPromise.as(null);
return Promise.resolve(null);
}
/**
......
......@@ -225,7 +225,7 @@ export class ResourcesDropHandler {
}
}
return TPromise.as(false);
return Promise.resolve(false);
}
private handleDirtyEditorDrop(droppedDirtyEditor: IDraggedEditor): TPromise<boolean> {
......@@ -237,7 +237,7 @@ export class ResourcesDropHandler {
// Return early if the resource is already dirty in target or opened already
if (this.textFileService.isDirty(droppedDirtyEditor.resource) || this.editorService.isOpen({ resource: droppedDirtyEditor.resource })) {
return TPromise.as(false);
return Promise.resolve(false);
}
// Resolve the contents of the dropped dirty resource from source
......@@ -293,7 +293,7 @@ export class ResourcesDropHandler {
// Open in separate windows if we drop workspaces or just one folder
if (workspaces.length > 0 || folders.length === 1) {
workspacesToOpen = TPromise.as([...workspaces, ...folders].map(resources => resources));
workspacesToOpen = Promise.resolve([...workspaces, ...folders].map(resources => resources));
}
// Multiple folders: Create new workspace with folders and open
......
......@@ -43,13 +43,13 @@ export class ViewletActivityAction extends ActivityAction {
run(event: any): TPromise<any> {
if (event instanceof MouseEvent && event.button === 2) {
return TPromise.as(false); // do not run on right click
return Promise.resolve(false); // do not run on right click
}
// prevent accident trigger on a doubleclick (to help nervous people)
const now = Date.now();
if (now > this.lastRun /* https://github.com/Microsoft/vscode/issues/25830 */ && now - this.lastRun < ViewletActivityAction.preventDoubleClickDelay) {
return TPromise.as(true);
return Promise.resolve(true);
}
this.lastRun = now;
......@@ -155,7 +155,7 @@ export class GlobalActivityActionItem extends ActivityActionItem {
this.contextMenuService.showContextMenu({
getAnchor: () => location,
getActions: () => TPromise.as(actions),
getActions: () => Promise.resolve(actions),
onHide: () => dispose(actions)
});
}
......@@ -253,4 +253,4 @@ registerThemingParticipant((theme: ITheme, collector: ICssStyleCollector) => {
`);
}
}
});
\ No newline at end of file
});
......@@ -399,7 +399,7 @@ export class CompositeBar extends Widget implements ICompositeBar {
const event = new StandardMouseEvent(e);
this.contextMenuService.showContextMenu({
getAnchor: () => { return { x: event.posx, y: event.posy }; },
getActions: () => TPromise.as(this.getContextMenuActions())
getActions: () => Promise.resolve(this.getContextMenuActions())
});
}
......
......@@ -343,7 +343,7 @@ export class CompositeOverflowActivityAction extends ActivityAction {
run(event: any): TPromise<any> {
this.showMenu();
return TPromise.as(true);
return Promise.resolve(true);
}
}
......@@ -372,7 +372,7 @@ export class CompositeOverflowActivityActionItem extends ActivityActionItem {
this.contextMenuService.showContextMenu({
getAnchor: () => this.element,
getActions: () => TPromise.as(this.actions),
getActions: () => Promise.resolve(this.actions),
onHide: () => dispose(this.actions)
});
}
......@@ -597,7 +597,7 @@ export class CompositeActionItem extends ActivityActionItem {
this.contextMenuService.showContextMenu({
getAnchor: () => anchor,
getActionsContext: () => this.activity.id,
getActions: () => TPromise.as(actions)
getActions: () => Promise.resolve(actions)
});
}
......@@ -664,6 +664,6 @@ export class ToggleCompositePinnedAction extends Action {
this.compositeBar.pin(id);
}
return TPromise.as(true);
return Promise.resolve(true);
}
}
......@@ -106,7 +106,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
}
// Fullfill promise with composite that is being opened
return TPromise.as(this.activeComposite);
return Promise.resolve(this.activeComposite);
}
// Open
......@@ -124,7 +124,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
if (this.activeComposite) {
hidePromise = this.hideActiveComposite();
} else {
hidePromise = TPromise.as(null);
hidePromise = Promise.resolve(null);
}
return hidePromise.then(() => {
......@@ -137,7 +137,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
// Check if another composite opened meanwhile and return in that case
if ((this.currentCompositeOpenToken !== currentCompositeOpenToken) || (this.activeComposite && this.activeComposite.getId() !== composite.getId())) {
return TPromise.as(null);
return Promise.resolve(null);
}
// Check if composite already visible and just focus in that case
......@@ -147,7 +147,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
}
// Fullfill promise with composite that is being opened
return TPromise.as(composite);
return Promise.resolve(composite);
}
// Show Composite and Focus
......@@ -235,7 +235,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
// Composite already exists but is hidden
else {
createCompositePromise = TPromise.as(null);
createCompositePromise = Promise.resolve(null);
}
// Report progress for slow loading composites (but only if we did not create the composites before already)
......@@ -375,7 +375,7 @@ export abstract class CompositePart<T extends Composite> extends Part {
protected hideActiveComposite(): TPromise<Composite> {
if (!this.activeComposite) {
return TPromise.as(null); // Nothing to do
return Promise.resolve(null); // Nothing to do
}
const composite = this.activeComposite;
......
......@@ -228,7 +228,7 @@ export class FileDataSource implements IDataSource {
getChildren(tree: ITree, element: IWorkspace | IWorkspaceFolder | IFileStat | URI): TPromise<IWorkspaceFolder[] | IFileStat[]> {
if (IWorkspace.isIWorkspace(element)) {
return TPromise.as(element.folders).then(folders => {
return Promise.resolve(element.folders).then(folders => {
for (let child of folders) {
this._parents.set(element, child);
}
......@@ -252,7 +252,7 @@ export class FileDataSource implements IDataSource {
}
getParent(tree: ITree, element: IWorkspace | URI | IWorkspaceFolder | IFileStat): TPromise<IWorkspaceFolder | IFileStat> {
return TPromise.as(this._parents.get(element));
return Promise.resolve(this._parents.get(element));
}
}
......
......@@ -284,7 +284,7 @@ class ZoomStatusbarItem extends Themable implements IStatusbarItem {
DOM.addDisposableListener(this.statusBarItem, DOM.EventType.CLICK, () => {
this.contextMenuService.showContextMenu({
getAnchor: () => container,
getActions: () => TPromise.as(this.zoomActions)
getActions: () => Promise.resolve(this.zoomActions)
});
});
}
......@@ -567,7 +567,7 @@ class InlineImageView {
private static imageSrc(descriptor: IResourceDescriptor, fileService: IFileService): TPromise<string> {
if (descriptor.resource.scheme === Schemas.data) {
return TPromise.as(descriptor.resource.toString(true /* skip encoding */));
return Promise.resolve(descriptor.resource.toString(true /* skip encoding */));
}
return fileService.resolveContent(descriptor.resource, { encoding: 'base64' }).then(data => {
......
......@@ -14,7 +14,6 @@ import { Action, IAction, IRunEvent } from 'vs/base/common/actions';
import * as arrays from 'vs/base/common/arrays';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import { TPromise } from 'vs/base/common/winjs.base';
import 'vs/css!./media/titlecontrol';
import { getCodeEditor } from 'vs/editor/browser/editorBrowser';
import { localize } from 'vs/nls';
......@@ -304,7 +303,7 @@ export abstract class TitleControl extends Themable {
// Show it
this.contextMenuService.showContextMenu({
getAnchor: () => anchor,
getActions: () => TPromise.as(actions),
getActions: () => Promise.resolve(actions),
getActionsContext: () => ({ groupId: this.group.id, editorIndex: this.group.getIndexOfEditor(editor) } as IEditorCommandsContext),
getKeyBinding: (action) => this.getKeybinding(action),
onHide: () => {
......
......@@ -32,7 +32,7 @@ export class ClearNotificationAction extends Action {
run(notification: INotificationViewItem): TPromise<any> {
this.commandService.executeCommand(CLEAR_NOTIFICATION, notification);
return TPromise.as(void 0);
return Promise.resolve(void 0);
}
}
......@@ -52,7 +52,7 @@ export class ClearAllNotificationsAction extends Action {
run(notification: INotificationViewItem): TPromise<any> {
this.commandService.executeCommand(CLEAR_ALL_NOTIFICATIONS);
return TPromise.as(void 0);
return Promise.resolve(void 0);
}
}
......@@ -72,7 +72,7 @@ export class HideNotificationsCenterAction extends Action {
run(notification: INotificationViewItem): TPromise<any> {
this.commandService.executeCommand(HIDE_NOTIFICATIONS_CENTER);
return TPromise.as(void 0);
return Promise.resolve(void 0);
}
}
......@@ -92,7 +92,7 @@ export class ExpandNotificationAction extends Action {
run(notification: INotificationViewItem): TPromise<any> {
this.commandService.executeCommand(EXPAND_NOTIFICATION, notification);
return TPromise.as(void 0);
return Promise.resolve(void 0);
}
}
......@@ -112,7 +112,7 @@ export class CollapseNotificationAction extends Action {
run(notification: INotificationViewItem): TPromise<any> {
this.commandService.executeCommand(COLLAPSE_NOTIFICATION, notification);
return TPromise.as(void 0);
return Promise.resolve(void 0);
}
}
......@@ -150,7 +150,7 @@ export class CopyNotificationMessageAction extends Action {
run(notification: INotificationViewItem): TPromise<any> {
this.clipboardService.writeText(notification.message.raw);
return TPromise.as(void 0);
return Promise.resolve(void 0);
}
}
......@@ -176,6 +176,6 @@ export class NotificationActionRunner extends ActionRunner {
// Run and make sure to notify on any error again
super.runAction(action, context).then(null, error => this.notificationService.error(error));
return TPromise.as(void 0);
return Promise.resolve(void 0);
}
}
\ No newline at end of file
}
......@@ -18,7 +18,6 @@ import { NotificationsListDelegate, NotificationRenderer } from 'vs/workbench/br
import { NotificationActionRunner, CopyNotificationMessageAction } from 'vs/workbench/browser/parts/notifications/notificationsActions';
import { NotificationFocusedContext } from 'vs/workbench/browser/parts/notifications/notificationsCommands';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { TPromise } from 'vs/base/common/winjs.base';
export class NotificationsList extends Themable {
private listContainer: HTMLElement;
......@@ -86,7 +85,7 @@ export class NotificationsList extends Themable {
this._register((this.list.onContextMenu(e => {
this.contextMenuService.showContextMenu({
getAnchor: () => e.anchor,
getActions: () => TPromise.as([copyAction]),
getActions: () => Promise.resolve([copyAction]),
getActionsContext: () => e.element,
actionRunner
});
......
......@@ -79,7 +79,7 @@ class FocusPanelAction extends Action {
if (panel) {
panel.focus();
}
return TPromise.as(true);
return Promise.resolve(true);
}
}
......@@ -145,8 +145,8 @@ export class ToggleMaximizedPanelAction extends Action {
}
run(): TPromise<any> {
return (!this.partService.isVisible(Parts.PANEL_PART) ? this.partService.setPanelHidden(false) : TPromise.as(null))
.then(() => this.partService.toggleMaximizedPanel());
const thenable: Thenable<void> = !this.partService.isVisible(Parts.PANEL_PART) ? this.partService.setPanelHidden(false) : Promise.resolve(null);
return thenable.then(() => this.partService.toggleMaximizedPanel());
}
dispose(): void {
......
......@@ -167,7 +167,7 @@ export class PanelPart extends CompositePart<Panel> implements IPanelService {
openPanel(id: string, focus?: boolean): TPromise<Panel> {
if (this.blockOpeningPanel) {
return TPromise.as(null); // Workaround against a potential race condition
return Promise.resolve(null); // Workaround against a potential race condition
}
// First check if panel is hidden and show if so
......
......@@ -506,7 +506,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
const model = new QuickOpenModel([new PlaceholderQuickOpenEntry(placeHolderLabel)], this.actionProvider);
this.showModel(model, resolvedHandler.getAutoFocus(value, { model, quickNavigateConfiguration: this.quickOpenWidget.getQuickNavigateConfiguration() }), resolvedHandler.getAriaLabel());
return TPromise.as(null);
return Promise.resolve(null);
}
// Support extra class from handler
......@@ -594,7 +594,7 @@ export class QuickOpenController extends Component implements IQuickOpenService
}
// Otherwise load and create
return this.mapResolvedHandlersToPrefix[id] = TPromise.as(handler.instantiate(this.instantiationService));
return this.mapResolvedHandlersToPrefix[id] = Promise.resolve(handler.instantiate(this.instantiationService));
}
layout(dimension: Dimension): void {
......
......@@ -60,7 +60,7 @@ export class BaseQuickOpenNavigateAction extends Action {
this.quickOpenService.navigate(this.next, quickNavigate);
this.quickInputService.navigate(this.next, quickNavigate);
return TPromise.as(true);
return Promise.resolve(true);
}
}
......@@ -140,4 +140,4 @@ export class QuickOpenSelectPreviousAction extends BaseQuickOpenNavigateAction {
) {
super(id, label, false, false, quickOpenService, quickInputService, keybindingService);
}
}
\ No newline at end of file
}
......@@ -105,7 +105,7 @@ export class SidebarPart extends CompositePart<Viewlet> {
openViewlet(id: string, focus?: boolean): TPromise<Viewlet> {
if (this.blockOpeningViewlet) {
return TPromise.as(null); // Workaround against a potential race condition
return Promise.resolve(null); // Workaround against a potential race condition
}
// First check if sidebar is hidden and show if so
......@@ -150,7 +150,7 @@ export class SidebarPart extends CompositePart<Viewlet> {
const anchor: { x: number, y: number } = { x: event.posx, y: event.posy };
this.contextMenuService.showContextMenu({
getAnchor: () => anchor,
getActions: () => TPromise.as(contextMenuActions),
getActions: () => Promise.resolve(contextMenuActions),
getActionItem: action => this.actionItemProvider(action as Action),
actionRunner: activeViewlet.getActionRunner()
});
......@@ -185,7 +185,7 @@ class FocusSideBarAction extends Action {
if (viewlet) {
viewlet.focus();
}
return TPromise.as(true);
return Promise.resolve(true);
}
}
......
......@@ -288,7 +288,7 @@ class StatusBarEntryItem implements IStatusbarItem {
this.contextMenuService.showContextMenu({
getAnchor: () => el,
getActionsContext: () => this.entry.extensionId,
getActions: () => TPromise.as([manageExtensionAction])
getActions: () => Promise.resolve([manageExtensionAction])
});
}));
}
......
......@@ -463,7 +463,7 @@ export class TitlebarPart extends Part implements ITitleService {
if (actions.length) {
this.contextMenuService.showContextMenu({
getAnchor: () => anchor,
getActions: () => TPromise.as(actions),
getActions: () => Promise.resolve(actions),
onHide: () => actions.forEach(a => a.dispose())
});
}
......
......@@ -229,7 +229,7 @@ export class CustomTreeViewer extends Disposable implements ITreeViewer {
this._dataProvider = new class implements ITreeViewDataProvider {
getChildren(node?: ITreeItem): TPromise<ITreeItem[]> {
if (node && node.children) {
return TPromise.as(node.children);
return Promise.resolve(node.children);
}
const promise = node instanceof Root ? dataProvider.getChildren() : dataProvider.getChildren(node);
return promise.then(children => {
......@@ -362,7 +362,7 @@ export class CustomTreeViewer extends Disposable implements ITreeViewer {
this.elementsToRefresh.push(...elements);
}
}
return TPromise.as(null);
return Promise.resolve(null);
}
reveal(item: ITreeItem, parentChain: ITreeItem[], options?: { select?: boolean, focus?: boolean }): TPromise<void> {
......@@ -372,9 +372,9 @@ export class CustomTreeViewer extends Disposable implements ITreeViewer {
const focus = isUndefinedOrNull(options.focus) ? false : options.focus;
const root: Root = this.tree.getInput();
const promise = root.children ? TPromise.as(null) : this.refresh(); // Refresh if root is not populated
const promise: Thenable<void> = root.children ? Promise.resolve(null) : this.refresh(); // Refresh if root is not populated
return promise.then(() => {
var result = TPromise.as(null);
var result = Promise.resolve(null);
parentChain.forEach((e) => {
result = result.then(() => this.tree.expand(e));
});
......@@ -390,7 +390,7 @@ export class CustomTreeViewer extends Disposable implements ITreeViewer {
});
});
}
return TPromise.as(null);
return Promise.resolve(null);
}
private activate() {
......@@ -404,7 +404,7 @@ export class CustomTreeViewer extends Disposable implements ITreeViewer {
if (this.tree) {
return TPromise.join(elements.map(e => this.tree.refresh(e))).then(() => null);
}
return TPromise.as(null);
return Promise.resolve(null);
}
private onSelection({ payload }: any): void {
......@@ -447,7 +447,7 @@ class TreeDataSource implements IDataSource {
if (this.treeView.dataProvider) {
return this.progressService.withProgress({ location: this.container }, () => this.treeView.dataProvider.getChildren(node));
}
return TPromise.as([]);
return Promise.resolve([]);
}
shouldAutoexpand(tree: ITree, node: ITreeItem): boolean {
......@@ -455,7 +455,7 @@ class TreeDataSource implements IDataSource {
}
getParent(tree: ITree, node: any): TPromise<any> {
return TPromise.as(null);
return Promise.resolve(null);
}
}
......@@ -635,7 +635,7 @@ class TreeController extends WorkbenchTreeController {
getAnchor: () => anchor,
getActions: () => {
return TPromise.as(actions);
return Promise.resolve(actions);
},
getActionItem: (action) => {
......
......@@ -230,7 +230,7 @@ export class PanelViewlet extends Viewlet {
let anchor: { x: number, y: number } = { x: event.posx, y: event.posy };
this.contextMenuService.showContextMenu({
getAnchor: () => anchor,
getActions: () => TPromise.as(this.getContextMenuActions())
getActions: () => Promise.resolve(this.getContextMenuActions())
});
}
......
......@@ -535,7 +535,7 @@ export class ViewsService extends Disposable implements IViewsService {
});
}
}
return TPromise.as(null);
return Promise.resolve(null);
}
private onDidRegisterViewContainer(viewContainer: ViewContainer): void {
......@@ -614,4 +614,4 @@ export class ViewsService extends Disposable implements IViewsService {
private getStorageScope(): StorageScope {
return this.workspaceContextService.getWorkbenchState() === WorkbenchState.EMPTY ? StorageScope.GLOBAL : StorageScope.WORKSPACE;
}
}
\ No newline at end of file
}
......@@ -211,7 +211,7 @@ export abstract class ViewContainerViewlet extends PanelViewlet implements IView
if (focus) {
view.focus();
}
return TPromise.as(view);
return Promise.resolve(view);
}
movePanel(from: ViewletPanel, to: ViewletPanel): void {
......@@ -330,7 +330,7 @@ export abstract class ViewContainerViewlet extends PanelViewlet implements IView
let anchor: { x: number, y: number } = { x: event.posx, y: event.posy };
this.contextMenuService.showContextMenu({
getAnchor: () => anchor,
getActions: () => TPromise.as(actions)
getActions: () => Promise.resolve(actions)
});
}
......
......@@ -45,7 +45,7 @@ export class QuickOpenHandler {
* results in terms of performance when many items are shown.
*/
getResults(searchValue: string, token: CancellationToken): TPromise<IModel<any>> {
return TPromise.as(null);
return Promise.resolve(null);
}
/**
......@@ -331,6 +331,6 @@ export class QuickOpenAction extends Action {
// Show with prefix
this.quickOpenService.show(this.prefix);
return TPromise.as(null);
return Promise.resolve(null);
}
}
......@@ -145,7 +145,7 @@ export class ShowViewletAction extends Action {
// Otherwise pass focus to editor group
this.editorGroupService.activeGroup.focus();
return TPromise.as(true);
return Promise.resolve(true);
}
private otherViewletShowing(): boolean {
......@@ -168,7 +168,7 @@ export class CollapseAction extends Action {
constructor(viewer: ITree, enabled: boolean, clazz: string) {
super('workbench.action.collapse', nls.localize('collapse', "Collapse All"), clazz, enabled, (context: any) => {
if (viewer.getHighlight()) {
return TPromise.as(null); // Global action disabled if user is in edit mode from another action
return Promise.resolve(null); // Global action disabled if user is in edit mode from another action
}
viewer.collapseAll();
......@@ -177,7 +177,7 @@ export class CollapseAction extends Action {
viewer.domFocus();
viewer.focusFirst();
return TPromise.as(null);
return Promise.resolve(null);
});
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册