提交 79591ff8 编写于 作者: J Johannes Rieken

debt - remove TPromise from action provider interface because it is never async, #53526

上级 36ad2cc2
......@@ -4,7 +4,6 @@
*--------------------------------------------------------------------------------------------*/
import * as nls from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base';
import * as types from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
import { ITree, IActionProvider } from 'vs/base/parts/tree/browser/tree';
......@@ -289,16 +288,16 @@ class NoActionProvider implements IActionProvider {
return false;
}
getActions(tree: ITree, element: any): TPromise<IAction[]> {
return TPromise.as(null);
getActions(tree: ITree, element: any): IAction[] {
return null;
}
hasSecondaryActions(tree: ITree, element: any): boolean {
return false;
}
getSecondaryActions(tree: ITree, element: any): TPromise<IAction[]> {
return TPromise.as(null);
getSecondaryActions(tree: ITree, element: any): IAction[] {
return null;
}
getActionItem(tree: ITree, element: any, action: Action): IActionItem {
......@@ -421,13 +420,12 @@ class Renderer implements IRenderer<QuickOpenEntry> {
data.actionBar.context = entry; // make sure the context is the current element
this.actionProvider.getActions(null, entry).then((actions) => {
if (data.actionBar.isEmpty() && actions && actions.length > 0) {
data.actionBar.push(actions, { icon: true, label: false });
} else if (!data.actionBar.isEmpty() && (!actions || actions.length === 0)) {
data.actionBar.clear();
}
});
const actions = this.actionProvider.getActions(null, entry);
if (data.actionBar.isEmpty() && actions && actions.length > 0) {
data.actionBar.push(actions, { icon: true, label: false });
} else if (!data.actionBar.isEmpty() && (!actions || actions.length === 0)) {
data.actionBar.clear();
}
// Entry group class
if (entry instanceof QuickOpenEntryGroup && entry.getGroupLabel()) {
......@@ -620,4 +618,4 @@ export function compareEntries(elementA: QuickOpenEntry, elementB: QuickOpenEntr
}
return compareAnything(nameA, nameB, lookFor);
}
\ No newline at end of file
}
......@@ -731,7 +731,7 @@ export interface IActionProvider {
/**
* Returns a promise of an array with the actions of the element that should show up in place right to the element in the tree.
*/
getActions(tree: ITree, element: any): WinJS.TPromise<IAction[]>;
getActions(tree: ITree, element: any): IAction[];
/**
* Returns whether or not the element has secondary actions. These show up once the user has expanded the element's action bar.
......@@ -741,7 +741,7 @@ export interface IActionProvider {
/**
* Returns a promise of an array with the secondary actions of the element that should show up once the user has expanded the element's action bar.
*/
getSecondaryActions(tree: ITree, element: any): WinJS.TPromise<IAction[]>;
getSecondaryActions(tree: ITree, element: any): IAction[];
/**
* Returns an action item to render an action.
......
......@@ -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 { Registry } from 'vs/platform/registry/common/platform';
import { Action, IAction } from 'vs/base/common/actions';
import { BaseActionItem, Separator } from 'vs/base/browser/ui/actionbar/actionbar';
......@@ -92,7 +91,7 @@ export class ContributableActionProvider implements IActionProvider {
return false;
}
getActions(tree: ITree, element: any): TPromise<IAction[]> {
getActions(tree: ITree, element: any): IAction[] {
const actions: IAction[] = [];
const context = this.toContext(tree, element);
......@@ -105,7 +104,7 @@ export class ContributableActionProvider implements IActionProvider {
}
}
return Promise.resolve(prepareActions(actions));
return prepareActions(actions);
}
hasSecondaryActions(tree: ITree, element: any): boolean {
......@@ -122,7 +121,7 @@ export class ContributableActionProvider implements IActionProvider {
return false;
}
getSecondaryActions(tree: ITree, element: any): TPromise<IAction[]> {
getSecondaryActions(tree: ITree, element: any): IAction[] {
const actions: IAction[] = [];
const context = this.toContext(tree, element);
......@@ -135,7 +134,7 @@ export class ContributableActionProvider implements IActionProvider {
}
}
return Promise.resolve(prepareActions(actions));
return prepareActions(actions);
}
getActionItem(tree: ITree, element: any, action: Action): BaseActionItem {
......
......@@ -218,10 +218,11 @@ export class BaseDebugController extends WorkbenchTreeController {
const anchor = { x: event.posx, y: event.posy };
this.contextMenuService.showContextMenu({
getAnchor: () => anchor,
getActions: () => this.actionProvider.getSecondaryActions(tree, element).then(actions => {
getActions: () => {
const actions = this.actionProvider.getSecondaryActions(tree, element);
fillInContextMenuActions(this.contributedContextMenu, { arg: this.getContext(element) }, actions, this.contextMenuService);
return actions;
}),
return Promise.resolve(actions);
},
onHide: (wasCancelled?: boolean) => {
if (wasCancelled) {
tree.domFocus();
......
......@@ -256,15 +256,15 @@ class CallStackActionProvider implements IActionProvider {
return false;
}
getActions(tree: ITree, element: any): Promise<IAction[]> {
return Promise.resolve([]);
getActions(tree: ITree, element: any): IAction[] {
return [];
}
hasSecondaryActions(tree: ITree, element: any): boolean {
return element !== tree.getInput();
}
getSecondaryActions(tree: ITree, element: any): Promise<IAction[]> {
getSecondaryActions(tree: ITree, element: any): IAction[] {
const actions: IAction[] = [];
if (element instanceof DebugSession) {
actions.push(this.instantiationService.createInstance(RestartAction, RestartAction.ID, RestartAction.LABEL));
......@@ -289,7 +289,7 @@ class CallStackActionProvider implements IActionProvider {
actions.push(new CopyStackTraceAction(CopyStackTraceAction.ID, CopyStackTraceAction.LABEL));
}
return Promise.resolve(actions);
return actions;
}
getActionItem(tree: ITree, element: any, action: IAction): IActionItem {
......
......@@ -324,15 +324,15 @@ export class ReplExpressionsActionProvider implements IActionProvider {
return false;
}
public getActions(tree: ITree, element: any): Promise<IAction[]> {
return Promise.resolve([]);
public getActions(tree: ITree, element: any): IAction[] {
return [];
}
public hasSecondaryActions(tree: ITree, element: any): boolean {
return true;
}
public getSecondaryActions(tree: ITree, element: any): Promise<IAction[]> {
public getSecondaryActions(tree: ITree, element: any): IAction[] {
const actions: IAction[] = [];
actions.push(new CopyAction(CopyAction.ID, CopyAction.LABEL));
actions.push(new CopyAllAction(CopyAllAction.ID, CopyAllAction.LABEL, tree));
......@@ -340,7 +340,7 @@ export class ReplExpressionsActionProvider implements IActionProvider {
actions.push(new Separator());
actions.push(this.clearReplAction);
return Promise.resolve(actions);
return actions;
}
public getActionItem(tree: ITree, element: any, action: IAction): IActionItem {
......
......@@ -156,8 +156,8 @@ class VariablesActionProvider implements IActionProvider {
return false;
}
public getActions(tree: ITree, element: any): Promise<IAction[]> {
return Promise.resolve([]);
public getActions(tree: ITree, element: any): IAction[] {
return [];
}
public hasSecondaryActions(tree: ITree, element: any): boolean {
......@@ -165,7 +165,7 @@ class VariablesActionProvider implements IActionProvider {
return element instanceof Variable && !!element.value;
}
public getSecondaryActions(tree: ITree, element: any): Promise<IAction[]> {
public getSecondaryActions(tree: ITree, element: any): IAction[] {
const actions: IAction[] = [];
const variable = <Variable>element;
actions.push(new SetValueAction(SetValueAction.ID, SetValueAction.LABEL, variable, this.debugService, this.keybindingService));
......@@ -174,7 +174,7 @@ class VariablesActionProvider implements IActionProvider {
actions.push(new Separator());
actions.push(new AddToWatchExpressionsAction(AddToWatchExpressionsAction.ID, AddToWatchExpressionsAction.LABEL, variable, this.debugService, this.keybindingService));
return Promise.resolve(actions);
return actions;
}
public getActionItem(tree: ITree, element: any, action: IAction): IActionItem {
......
......@@ -144,11 +144,11 @@ class WatchExpressionsActionProvider implements IActionProvider {
return true;
}
public getActions(tree: ITree, element: any): Promise<IAction[]> {
return Promise.resolve([]);
public getActions(tree: ITree, element: any): IAction[] {
return [];
}
public getSecondaryActions(tree: ITree, element: any): Promise<IAction[]> {
public getSecondaryActions(tree: ITree, element: any): IAction[] {
const actions: IAction[] = [];
if (element instanceof Expression) {
const expression = <Expression>element;
......@@ -173,7 +173,7 @@ class WatchExpressionsActionProvider implements IActionProvider {
actions.push(new RemoveAllWatchExpressionsAction(RemoveAllWatchExpressionsAction.ID, RemoveAllWatchExpressionsAction.LABEL, this.debugService, this.keybindingService));
}
return Promise.resolve(actions);
return actions;
}
public getActionItem(tree: ITree, element: any, action: IAction): IActionItem {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册