File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ export class ContextSubMenu extends SubmenuAction {
2424
2525export interface IContextMenuDelegate {
2626 getAnchor ( ) : HTMLElement | { x : number ; y : number ; width ?: number ; height ?: number ; } ;
27- getActions ( ) : Array < IAction | ContextSubMenu > ;
27+ getActions ( ) : ReadonlyArray < IAction | ContextSubMenu > ;
2828 getActionViewItem ?( action : IAction ) : IActionViewItem | undefined ;
2929 getActionsContext ?( event ?: IContextMenuEvent ) : any ;
3030 getKeyBinding ?( action : IAction ) : ResolvedKeybinding | undefined ;
Original file line number Diff line number Diff line change @@ -16,7 +16,6 @@ import { StandardKeyboardEvent } from 'vs/base/browser/keyboardEvent';
1616import { KeyCode , KeyMod } from 'vs/base/common/keyCodes' ;
1717import { IContextViewProvider } from 'vs/base/browser/ui/contextview/contextview' ;
1818import { Event , Emitter } from 'vs/base/common/event' ;
19- import { asArray } from 'vs/base/common/arrays' ;
2019
2120export interface IActionViewItem {
2221 actionRunner : IActionRunner ;
@@ -596,8 +595,8 @@ export class ActionBar extends Disposable implements IActionRunner {
596595 return this . domNode ;
597596 }
598597
599- push ( arg : IAction | IAction [ ] , options : IActionOptions = { } ) : void {
600- const actions : IAction [ ] = asArray ( arg ) ;
598+ push ( arg : IAction | ReadonlyArray < IAction > , options : IActionOptions = { } ) : void {
599+ const actions : ReadonlyArray < IAction > = Array . isArray ( arg ) ? arg : [ arg ] ;
601600
602601 let index = types . isNumber ( options . index ) ? options . index : null ;
603602
Original file line number Diff line number Diff line change @@ -192,20 +192,20 @@ export interface IContextMenuProvider {
192192}
193193
194194export interface IActionProvider {
195- getActions ( ) : IAction [ ] ;
195+ getActions ( ) : ReadonlyArray < IAction > ;
196196}
197197
198198export interface IDropdownMenuOptions extends IBaseDropdownOptions {
199199 contextMenuProvider : IContextMenuProvider ;
200- actions ?: IAction [ ] ;
200+ actions ?: ReadonlyArray < IAction > ;
201201 actionProvider ?: IActionProvider ;
202202 menuClassName ?: string ;
203203}
204204
205205export class DropdownMenu extends BaseDropdown {
206206 private _contextMenuProvider : IContextMenuProvider ;
207207 private _menuOptions : IMenuOptions ;
208- private _actions : IAction [ ] ;
208+ private _actions : ReadonlyArray < IAction > ;
209209 private actionProvider ?: IActionProvider ;
210210 private menuClassName : string ;
211211
@@ -226,15 +226,15 @@ export class DropdownMenu extends BaseDropdown {
226226 return this . _menuOptions ;
227227 }
228228
229- private get actions ( ) : IAction [ ] {
229+ private get actions ( ) : ReadonlyArray < IAction > {
230230 if ( this . actionProvider ) {
231231 return this . actionProvider . getActions ( ) ;
232232 }
233233
234234 return this . _actions ;
235235 }
236236
237- private set actions ( actions : IAction [ ] ) {
237+ private set actions ( actions : ReadonlyArray < IAction > ) {
238238 this . _actions = actions ;
239239 }
240240
Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ export class Menu extends ActionBar {
7878
7979 private readonly _onScroll : Emitter < void > ;
8080
81- constructor ( container : HTMLElement , actions : IAction [ ] , options : IMenuOptions = { } ) {
81+ constructor ( container : HTMLElement , actions : ReadonlyArray < IAction > , options : IMenuOptions = { } ) {
8282 addClass ( container , 'monaco-menu-container' ) ;
8383 container . setAttribute ( 'role' , 'presentation' ) ;
8484 const menuElement = document . createElement ( 'div' ) ;
Original file line number Diff line number Diff line change @@ -115,7 +115,7 @@ class NativeContextMenuService extends Disposable implements IContextMenuService
115115 }
116116 }
117117
118- private createMenu ( delegate : IContextMenuDelegate , entries : Array < IAction | ContextSubMenu > , onHide : ( ) => void ) : IContextMenuItem [ ] {
118+ private createMenu ( delegate : IContextMenuDelegate , entries : ReadonlyArray < IAction | ContextSubMenu > , onHide : ( ) => void ) : IContextMenuItem [ ] {
119119 const actionRunner = delegate . actionRunner || new ActionRunner ( ) ;
120120
121121 return entries . map ( entry => this . createMenuItem ( delegate , entry , actionRunner , onHide ) ) ;
You can’t perform that action at this time.
0 commit comments