mirror of
https://github.com/microsoft/vscode.git
synced 2025-12-25 04:36:23 +00:00
Use readonly array to track actions in a few more palces in menus
The actions being passed around are generally not expected to be modified. Use ReadonlyArray to prevent this
This commit is contained in:
@@ -275,7 +275,7 @@ export class DropdownMenuActionViewItem extends BaseActionViewItem {
|
||||
private clazz: string | undefined;
|
||||
private anchorAlignmentProvider: (() => AnchorAlignment) | undefined;
|
||||
|
||||
constructor(action: IAction, menuActions: IAction[], contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment);
|
||||
constructor(action: IAction, menuActions: ReadonlyArray<IAction>, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment);
|
||||
constructor(action: IAction, actionProvider: IActionProvider, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment);
|
||||
constructor(action: IAction, menuActionsOrProvider: any, contextMenuProvider: IContextMenuProvider, actionViewItemProvider: IActionViewItemProvider | undefined, actionRunner: IActionRunner, keybindings: ((action: IAction) => ResolvedKeybinding | undefined) | undefined, clazz: string | undefined, anchorAlignmentProvider?: () => AnchorAlignment) {
|
||||
super(null, action);
|
||||
|
||||
@@ -59,7 +59,7 @@ export interface IMenuStyles {
|
||||
}
|
||||
|
||||
export class SubmenuAction extends Action {
|
||||
constructor(label: string, public entries: Array<SubmenuAction | IAction>, cssClass?: string) {
|
||||
constructor(label: string, public entries: ReadonlyArray<SubmenuAction | IAction>, cssClass?: string) {
|
||||
super(!!cssClass ? cssClass : 'submenu', label, '', true);
|
||||
}
|
||||
}
|
||||
@@ -581,7 +581,7 @@ class SubmenuMenuActionViewItem extends BaseMenuActionViewItem {
|
||||
|
||||
constructor(
|
||||
action: IAction,
|
||||
private submenuActions: IAction[],
|
||||
private submenuActions: ReadonlyArray<IAction>,
|
||||
private parentData: ISubMenuData,
|
||||
private submenuOptions?: IMenuOptions
|
||||
) {
|
||||
|
||||
@@ -29,7 +29,7 @@ export interface IMenuBarOptions {
|
||||
}
|
||||
|
||||
export interface MenuBarMenu {
|
||||
actions: IAction[];
|
||||
actions: ReadonlyArray<IAction>;
|
||||
label: string;
|
||||
}
|
||||
|
||||
@@ -48,7 +48,7 @@ export class MenuBar extends Disposable {
|
||||
buttonElement: HTMLElement;
|
||||
titleElement: HTMLElement;
|
||||
label: string;
|
||||
actions?: IAction[];
|
||||
actions?: ReadonlyArray<IAction>;
|
||||
}[];
|
||||
|
||||
private overflowMenu: {
|
||||
|
||||
@@ -114,7 +114,7 @@ export class ToolBar extends Disposable {
|
||||
this.actionBar.setAriaLabel(label);
|
||||
}
|
||||
|
||||
setActions(primaryActions: IAction[], secondaryActions?: IAction[]): () => void {
|
||||
setActions(primaryActions: ReadonlyArray<IAction>, secondaryActions?: ReadonlyArray<IAction>): () => void {
|
||||
return () => {
|
||||
let primaryActionsToSet = primaryActions ? primaryActions.slice(0) : [];
|
||||
|
||||
@@ -169,7 +169,7 @@ class ToggleMenuAction extends Action {
|
||||
|
||||
static readonly ID = 'toolbar.toggle.more';
|
||||
|
||||
private _menuActions: IAction[];
|
||||
private _menuActions: ReadonlyArray<IAction>;
|
||||
private toggleDropdownMenu: () => void;
|
||||
|
||||
constructor(toggleDropdownMenu: () => void, title?: string) {
|
||||
@@ -185,11 +185,11 @@ class ToggleMenuAction extends Action {
|
||||
return Promise.resolve(true);
|
||||
}
|
||||
|
||||
get menuActions() {
|
||||
get menuActions(): ReadonlyArray<IAction> {
|
||||
return this._menuActions;
|
||||
}
|
||||
|
||||
set menuActions(actions: IAction[]) {
|
||||
set menuActions(actions: ReadonlyArray<IAction>) {
|
||||
this._menuActions = actions;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user