提交 9f6de388 编写于 作者: M Matt Bierner

Use ReadonlyArray for a few more lists of IActions

Also changes processService to not modify its input actions, which seems like unexpected behavior
上级 e78f05a7
......@@ -28,7 +28,7 @@ export interface IInputOptions extends IInputBoxStyles {
readonly type?: string;
readonly validationOptions?: IInputValidationOptions;
readonly flexibleHeight?: boolean;
readonly actions?: IAction[];
readonly actions?: ReadonlyArray<IAction>;
}
export interface IInputBoxStyles {
......
......@@ -576,7 +576,7 @@ export interface IActionProvider {
hasActions(tree: ITree | null, element: any): boolean;
/**
* 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.
* Returns an array with the actions of the element that should show up in place right to the element in the tree.
*/
getActions(tree: ITree | null, element: any): IAction[] | null;
getActions(tree: ITree | null, element: any): ReadonlyArray<IAction> | null;
}
......@@ -125,7 +125,7 @@ export class ContextMenuController implements IEditorContribution {
}
}
private _getMenuActions(model: ITextModel): IAction[] {
private _getMenuActions(model: ITextModel): ReadonlyArray<IAction> {
const result: IAction[] = [];
let contextMenu = this._menuService.createMenu(MenuId.EditorContext, this._contextKeyService);
......@@ -141,7 +141,7 @@ export class ContextMenuController implements IEditorContribution {
return result;
}
private _doShowContextMenu(actions: IAction[], anchor: IAnchor | null = null): void {
private _doShowContextMenu(actions: ReadonlyArray<IAction>, anchor: IAnchor | null = null): void {
if (!this._editor.hasModel()) {
return;
}
......
......@@ -180,7 +180,7 @@ export class MarkerNavigationWidget extends PeekViewWidget {
constructor(
editor: ICodeEditor,
private readonly actions: IAction[],
private readonly actions: ReadonlyArray<IAction>,
private readonly _themeService: IThemeService
) {
super(editor, { showArrow: true, showFrame: true, isAccessible: true });
......
......@@ -61,9 +61,9 @@ export interface IProgressOptions {
}
export interface IProgressNotificationOptions extends IProgressOptions {
location: ProgressLocation.Notification;
primaryActions?: IAction[];
secondaryActions?: IAction[];
readonly location: ProgressLocation.Notification;
readonly primaryActions?: ReadonlyArray<IAction>;
readonly secondaryActions?: ReadonlyArray<IAction>;
}
export interface IProgressCompositeOptions extends IProgressOptions {
......
......@@ -24,7 +24,7 @@ export class ActionBarContributor {
/**
* Returns an array of primary actions in the given context.
*/
getActions(context: unknown): IAction[] {
getActions(context: unknown): ReadonlyArray<IAction> {
return [];
}
}
......@@ -66,7 +66,7 @@ export class ContributableActionProvider implements IActionProvider {
return false;
}
getActions(tree: ITree, element: unknown): IAction[] {
getActions(tree: ITree, element: unknown): ReadonlyArray<IAction> {
const actions: IAction[] = [];
const context = this.toContext(tree, element);
......
......@@ -253,7 +253,7 @@ export class QuickOpenActionContributor extends ActionBarContributor {
return !!entry;
}
getActions(context: any): IAction[] {
getActions(context: any): ReadonlyArray<IAction> {
const actions: Action[] = [];
const entry = this.getEntry(context);
......
......@@ -121,12 +121,12 @@ export class ConfigureNotificationAction extends Action {
constructor(
id: string,
label: string,
private _configurationActions: IAction[]
private readonly _configurationActions: ReadonlyArray<IAction>
) {
super(id, label, 'configure-notification-action');
}
get configurationActions(): IAction[] {
get configurationActions(): ReadonlyArray<IAction> {
return this._configurationActions;
}
}
......
......@@ -214,7 +214,7 @@ export class QuickOpenActionContributor extends ActionBarContributor {
return !!task;
}
public getActions(context: any): IAction[] {
public getActions(context: any): ReadonlyArray<IAction> {
let actions: Action[] = [];
let task = this.getTask(context);
if (task && ContributedTask.is(task) || CustomTask.is(task)) {
......
......@@ -1041,7 +1041,7 @@ export class QuickOpenActionTermContributor extends ActionBarContributor {
super();
}
public getActions(context: any): IAction[] {
public getActions(context: any): ReadonlyArray<IAction> {
const actions: Action[] = [];
if (context.element instanceof TerminalEntry) {
actions.push(this.instantiationService.createInstance(RenameTerminalQuickOpenAction, RenameTerminalQuickOpenAction.ID, RenameTerminalQuickOpenAction.LABEL, context.element));
......
......@@ -143,8 +143,8 @@ export class ProgressService implements IProgressService {
return undefined; // we need a message at least
}
const primaryActions = options.primaryActions || [];
const secondaryActions = options.secondaryActions || [];
const primaryActions = options.primaryActions ? Array.from(options.primaryActions) : [];
const secondaryActions = options.secondaryActions ? Array.from(options.secondaryActions) : [];
if (options.cancellable) {
const cancelAction = new class extends Action {
constructor() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册