diff --git a/src/vs/base/browser/contextmenu.ts b/src/vs/base/browser/contextmenu.ts index 2a35a1d7c1e..4fa0bf17ce0 100644 --- a/src/vs/base/browser/contextmenu.ts +++ b/src/vs/base/browser/contextmenu.ts @@ -25,7 +25,7 @@ export class ContextSubMenu extends SubmenuAction { export interface IContextMenuDelegate { getAnchor(): HTMLElement | { x: number; y: number; width?: number; height?: number; }; getActions(): Array; - getActionItem?(action: IAction): IActionItem | null; + getActionItem?(action: IAction): IActionItem | undefined; getActionsContext?(event?: IContextMenuEvent): any; getKeyBinding?(action: IAction): ResolvedKeybinding | undefined; getMenuClassName?(): string; diff --git a/src/vs/base/browser/ui/actionbar/actionbar.ts b/src/vs/base/browser/ui/actionbar/actionbar.ts index d21243405e7..0c986e86c13 100644 --- a/src/vs/base/browser/ui/actionbar/actionbar.ts +++ b/src/vs/base/browser/ui/actionbar/actionbar.ts @@ -364,7 +364,7 @@ export interface ActionTrigger { } export interface IActionItemProvider { - (action: IAction): IActionItem | null; + (action: IAction): IActionItem | undefined; } export interface IActionBarOptions { @@ -609,7 +609,7 @@ export class ActionBar extends Disposable implements IActionRunner { e.stopPropagation(); })); - let item: IActionItem | null = null; + let item: IActionItem | undefined; if (this.options.actionItemProvider) { item = this.options.actionItemProvider(action); diff --git a/src/vs/base/browser/ui/dropdown/dropdown.ts b/src/vs/base/browser/ui/dropdown/dropdown.ts index ea595a9af9d..d8661533782 100644 --- a/src/vs/base/browser/ui/dropdown/dropdown.ts +++ b/src/vs/base/browser/ui/dropdown/dropdown.ts @@ -247,7 +247,7 @@ export class DropdownMenu extends BaseDropdown { getAnchor: () => this.element, getActions: () => this.actions, getActionsContext: () => this.menuOptions ? this.menuOptions.context : null, - getActionItem: action => this.menuOptions && this.menuOptions.actionItemProvider ? this.menuOptions.actionItemProvider(action) : null, + getActionItem: action => this.menuOptions && this.menuOptions.actionItemProvider ? this.menuOptions.actionItemProvider(action) : undefined, getKeyBinding: action => this.menuOptions && this.menuOptions.getKeyBinding ? this.menuOptions.getKeyBinding(action) : undefined, getMenuClassName: () => this.menuClassName, onHide: () => this.onHide(), diff --git a/src/vs/base/browser/ui/toolbar/toolbar.ts b/src/vs/base/browser/ui/toolbar/toolbar.ts index 00a8b5872c7..1c144b24096 100644 --- a/src/vs/base/browser/ui/toolbar/toolbar.ts +++ b/src/vs/base/browser/ui/toolbar/toolbar.ts @@ -75,10 +75,10 @@ export class ToolBar extends Disposable { ); this.toggleMenuActionItem!.setActionContext(this.actionBar.context); - return this.toggleMenuActionItem || null; + return this.toggleMenuActionItem; } - return options.actionItemProvider ? options.actionItemProvider(action) : null; + return options.actionItemProvider ? options.actionItemProvider(action) : undefined; } })); } diff --git a/src/vs/base/parts/quickopen/browser/quickOpenModel.ts b/src/vs/base/parts/quickopen/browser/quickOpenModel.ts index 853d28ee8d4..2a1daf72771 100644 --- a/src/vs/base/parts/quickopen/browser/quickOpenModel.ts +++ b/src/vs/base/parts/quickopen/browser/quickOpenModel.ts @@ -300,8 +300,8 @@ class NoActionProvider implements IActionProvider { return null; } - getActionItem(tree: ITree, element: any, action: Action): IActionItem | null { - return null; + getActionItem(tree: ITree, element: any, action: Action): IActionItem | undefined { + return undefined; } } diff --git a/src/vs/base/parts/tree/browser/tree.ts b/src/vs/base/parts/tree/browser/tree.ts index 9966687e74b..60a318b61a0 100644 --- a/src/vs/base/parts/tree/browser/tree.ts +++ b/src/vs/base/parts/tree/browser/tree.ts @@ -736,5 +736,5 @@ export interface IActionProvider { /** * Returns an action item to render an action. */ - getActionItem(tree: ITree, element: any, action: IAction): IActionItem | null; + getActionItem(tree: ITree, element: any, action: IAction): IActionItem | undefined; } diff --git a/src/vs/workbench/browser/actions.ts b/src/vs/workbench/browser/actions.ts index 05af729b5dd..eeea8b100f6 100644 --- a/src/vs/workbench/browser/actions.ts +++ b/src/vs/workbench/browser/actions.ts @@ -130,7 +130,7 @@ export class ContributableActionProvider implements IActionProvider { return prepareActions(actions); } - getActionItem(tree: ITree, element: any, action: Action): BaseActionItem | null { + getActionItem(tree: ITree, element: any, action: Action): BaseActionItem | undefined { const contributors = this.registry.getActionBarContributors(Scope.VIEWER); const context = this.toContext(tree, element); @@ -143,7 +143,7 @@ export class ContributableActionProvider implements IActionProvider { } } - return null; + return undefined; } } diff --git a/src/vs/workbench/browser/composite.ts b/src/vs/workbench/browser/composite.ts index 482d47ce222..a750a3d77a2 100644 --- a/src/vs/workbench/browser/composite.ts +++ b/src/vs/workbench/browser/composite.ts @@ -166,11 +166,11 @@ export abstract class Composite extends Component implements IComposite { /** * For any of the actions returned by this composite, provide an IActionItem in * cases where the implementor of the composite wants to override the presentation - * of an action. Returns null to indicate that the action is not rendered through + * of an action. Returns undefined to indicate that the action is not rendered through * an action item. */ - getActionItem(action: IAction): IActionItem | null { - return null; + getActionItem(action: IAction): IActionItem | undefined { + return undefined; } /** diff --git a/src/vs/workbench/browser/parts/compositeBar.ts b/src/vs/workbench/browser/parts/compositeBar.ts index 13ff1de0f1d..cabce5e4455 100644 --- a/src/vs/workbench/browser/parts/compositeBar.ts +++ b/src/vs/workbench/browser/parts/compositeBar.ts @@ -50,7 +50,7 @@ export class CompositeBar extends Widget implements ICompositeBar { private compositeSwitcherBar: ActionBar; private compositeOverflowAction: CompositeOverflowActivityAction | null; - private compositeOverflowActionItem: CompositeOverflowActivityActionItem | null; + private compositeOverflowActionItem: CompositeOverflowActivityActionItem | undefined; private model: CompositeBarModel; private visibleComposites: string[]; @@ -345,7 +345,7 @@ export class CompositeBar extends Widget implements ICompositeBar { if (this.compositeOverflowActionItem) { this.compositeOverflowActionItem.dispose(); } - this.compositeOverflowActionItem = null; + this.compositeOverflowActionItem = undefined; } // Pull out composites that overflow or got hidden diff --git a/src/vs/workbench/browser/parts/compositePart.ts b/src/vs/workbench/browser/parts/compositePart.ts index 446fff73709..585b9f9247e 100644 --- a/src/vs/workbench/browser/parts/compositePart.ts +++ b/src/vs/workbench/browser/parts/compositePart.ts @@ -432,14 +432,14 @@ export abstract class CompositePart extends Part { this.titleLabel.updateStyles(); } - protected actionItemProvider(action: Action): IActionItem | null { + protected actionItemProvider(action: Action): IActionItem | undefined { // Check Active Composite if (this.activeComposite) { return this.activeComposite.getActionItem(action); } - return null; + return undefined; } protected actionsContextProvider(): any { diff --git a/src/vs/workbench/browser/parts/editor/titleControl.ts b/src/vs/workbench/browser/parts/editor/titleControl.ts index 7698416dc78..5ded487fdd9 100644 --- a/src/vs/workbench/browser/parts/editor/titleControl.ts +++ b/src/vs/workbench/browser/parts/editor/titleControl.ts @@ -39,7 +39,6 @@ import { Themable } from 'vs/workbench/common/theme'; import { IExtensionService } from 'vs/workbench/services/extensions/common/extensions'; import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview'; import { IFileService } from 'vs/platform/files/common/files'; -import { withUndefinedAsNull } from 'vs/base/common/types'; export interface IToolbarActions { primary: IAction[]; @@ -155,18 +154,18 @@ export abstract class TitleControl extends Themable { })); } - private actionItemProvider(action: Action): IActionItem | null { + private actionItemProvider(action: Action): IActionItem | undefined { const activeControl = this.group.activeControl; // Check Active Editor - let actionItem: IActionItem | null = null; + let actionItem: IActionItem | undefined = undefined; if (activeControl instanceof BaseEditor) { actionItem = activeControl.getActionItem(action); } // Check extensions if (!actionItem) { - actionItem = withUndefinedAsNull(createActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService)); + actionItem = createActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService); } return actionItem; diff --git a/src/vs/workbench/browser/parts/notifications/notificationsViewer.ts b/src/vs/workbench/browser/parts/notifications/notificationsViewer.ts index fcdf3b638cb..500fe4d881d 100644 --- a/src/vs/workbench/browser/parts/notifications/notificationsViewer.ts +++ b/src/vs/workbench/browser/parts/notifications/notificationsViewer.ts @@ -227,7 +227,7 @@ export class NotificationRenderer implements IListRenderer action instanceof MenuItemAction ? this.instantiationService.createInstance(ContextAwareMenuItemActionItem, action) : null; + const actionItemProvider = (action: IAction) => action instanceof MenuItemAction ? this.instantiationService.createInstance(ContextAwareMenuItemActionItem, action) : undefined; const menus = this._register(this.instantiationService.createInstance(TreeMenus, this.id)); this.treeLabels = this._register(this.instantiationService.createInstance(ResourceLabels, this)); const dataSource = this.instantiationService.createInstance(TreeDataSource, this, (task: Promise) => this.progressService.withProgress({ location: this.viewContainer.id }, () => task)); @@ -814,7 +814,7 @@ class TreeController extends WorkbenchTreeController { if (keybinding) { return new ActionItem(action, action, { label: true, keybinding: keybinding.getLabel() }); } - return null; + return undefined; }, onHide: (wasCancelled?: boolean) => { diff --git a/src/vs/workbench/browser/parts/views/panelViewlet.ts b/src/vs/workbench/browser/parts/views/panelViewlet.ts index deac45f20b0..b7476eb3c61 100644 --- a/src/vs/workbench/browser/parts/views/panelViewlet.ts +++ b/src/vs/workbench/browser/parts/views/panelViewlet.ts @@ -174,8 +174,8 @@ export abstract class ViewletPanel extends Panel implements IView { return []; } - getActionItem(action: IAction): IActionItem | null { - return null; + getActionItem(action: IAction): IActionItem | undefined { + return undefined; } getActionsContext(): any { @@ -282,7 +282,7 @@ export class PanelViewlet extends Viewlet { return []; } - getActionItem(action: IAction): IActionItem | null { + getActionItem(action: IAction): IActionItem | undefined { if (this.isSingleView()) { return this.panelItems[0].panel.getActionItem(action); } diff --git a/src/vs/workbench/common/composite.ts b/src/vs/workbench/common/composite.ts index 0cb35c09d36..e7211e49525 100644 --- a/src/vs/workbench/common/composite.ts +++ b/src/vs/workbench/common/composite.ts @@ -35,7 +35,7 @@ export interface IComposite { /** * Returns the action item for a specific action. */ - getActionItem(action: IAction): IActionItem | null; + getActionItem(action: IAction): IActionItem | undefined; /** * Returns the underlying control of this composite. diff --git a/src/vs/workbench/contrib/debug/browser/debugToolbar.ts b/src/vs/workbench/contrib/debug/browser/debugToolbar.ts index 7dae7e4ea69..c16c901963f 100644 --- a/src/vs/workbench/contrib/debug/browser/debugToolbar.ts +++ b/src/vs/workbench/contrib/debug/browser/debugToolbar.ts @@ -95,7 +95,7 @@ export class DebugToolbar extends Themable implements IWorkbenchContribution { return new MenuItemActionItem(action, this.keybindingService, this.notificationService, contextMenuService); } - return null; + return undefined; } })); diff --git a/src/vs/workbench/contrib/debug/browser/debugViewlet.ts b/src/vs/workbench/contrib/debug/browser/debugViewlet.ts index 9284c15c89b..df860949fcc 100644 --- a/src/vs/workbench/contrib/debug/browser/debugViewlet.ts +++ b/src/vs/workbench/contrib/debug/browser/debugViewlet.ts @@ -129,7 +129,7 @@ export class DebugViewlet extends ViewContainerViewlet { return [this.selectAndStartAction, this.configureAction, this.toggleReplAction]; } - getActionItem(action: IAction): IActionItem | null { + getActionItem(action: IAction): IActionItem | undefined { if (action.id === StartAction.ID) { this.startDebugActionItem = this.instantiationService.createInstance(StartDebugActionItem, null, action); return this.startDebugActionItem; @@ -141,7 +141,7 @@ export class DebugViewlet extends ViewContainerViewlet { return new MenuItemActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService); } - return null; + return undefined; } focusView(id: string): void { diff --git a/src/vs/workbench/contrib/debug/browser/repl.ts b/src/vs/workbench/contrib/debug/browser/repl.ts index b0c8f908bca..b5d58c910a7 100644 --- a/src/vs/workbench/contrib/debug/browser/repl.ts +++ b/src/vs/workbench/contrib/debug/browser/repl.ts @@ -309,12 +309,12 @@ export class Repl extends Panel implements IPrivateReplService, IHistoryNavigati this.replInput.focus(); } - getActionItem(action: IAction): IActionItem | null { + getActionItem(action: IAction): IActionItem | undefined { if (action.id === SelectReplAction.ID) { return this.instantiationService.createInstance(SelectReplActionItem, this.selectReplAction); } - return null; + return undefined; } getActions(): IAction[] { diff --git a/src/vs/workbench/contrib/extensions/electron-browser/extensionEditor.ts b/src/vs/workbench/contrib/extensions/electron-browser/extensionEditor.ts index 003079ca880..c1c89619d65 100644 --- a/src/vs/workbench/contrib/extensions/electron-browser/extensionEditor.ts +++ b/src/vs/workbench/contrib/extensions/electron-browser/extensionEditor.ts @@ -254,7 +254,7 @@ export class ExtensionEditor extends BaseEditor { if (action instanceof ExtensionEditorDropDownAction) { return action.createActionItem(); } - return null; + return undefined; } }); diff --git a/src/vs/workbench/contrib/markers/browser/markersPanel.ts b/src/vs/workbench/contrib/markers/browser/markersPanel.ts index 3c7a8de1582..a1a4c04b447 100644 --- a/src/vs/workbench/contrib/markers/browser/markersPanel.ts +++ b/src/vs/workbench/contrib/markers/browser/markersPanel.ts @@ -628,7 +628,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { if (keybinding) { return new ActionItem(action, action, { label: true, keybinding: keybinding.getLabel() }); } - return null; + return undefined; }, onHide: (wasCancelled?: boolean) => { if (wasCancelled) { @@ -670,7 +670,7 @@ export class MarkersPanel extends Panel implements IMarkerFilterController { return this.tree.getFocus()[0]; } - public getActionItem(action: IAction): IActionItem | null { + public getActionItem(action: IAction): IActionItem | undefined { if (action.id === MarkersFilterAction.ID) { this.filterInputActionItem = this.instantiationService.createInstance(MarkersFilterActionItem, this.filterAction, this); return this.filterInputActionItem; diff --git a/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts b/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts index 271b617a7b0..8e37ccf4aa6 100644 --- a/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts +++ b/src/vs/workbench/contrib/markers/browser/markersTreeViewer.ts @@ -253,7 +253,7 @@ class MarkerWidget extends Disposable { ) { super(); this.actionBar = this._register(new ActionBar(dom.append(parent, dom.$('.actions')), { - actionItemProvider: (action) => action.id === QuickFixAction.ID ? instantiationService.createInstance(QuickFixActionItem, action) : null + actionItemProvider: (action) => action.id === QuickFixAction.ID ? instantiationService.createInstance(QuickFixActionItem, action) : undefined })); this.icon = dom.append(parent, dom.$('.icon')); this.multilineActionbar = this._register(new ActionBar(dom.append(parent, dom.$('.multiline-actions')))); diff --git a/src/vs/workbench/contrib/output/browser/outputPanel.ts b/src/vs/workbench/contrib/output/browser/outputPanel.ts index 793df5e5c8b..c626a799910 100644 --- a/src/vs/workbench/contrib/output/browser/outputPanel.ts +++ b/src/vs/workbench/contrib/output/browser/outputPanel.ts @@ -75,7 +75,7 @@ export class OutputPanel extends AbstractTextResourceEditor { return this.actions; } - public getActionItem(action: Action): IActionItem | null { + public getActionItem(action: Action): IActionItem | undefined { if (action.id === SwitchOutputAction.ID) { return this.instantiationService.createInstance(SwitchOutputActionItem, action); } diff --git a/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts b/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts index df1da6b1103..3e823a061a8 100644 --- a/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts +++ b/src/vs/workbench/contrib/preferences/browser/keybindingsEditor.ts @@ -376,7 +376,7 @@ export class KeybindingsEditor extends BaseEditor implements IKeybindingsEditor if (action.id === this.recordKeysAction.id) { return new CheckboxActionItem(null, action); } - return null; + return undefined; } })); diff --git a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts index 55c8f055069..b63bba31943 100644 --- a/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts +++ b/src/vs/workbench/contrib/preferences/browser/preferencesWidgets.ts @@ -424,7 +424,7 @@ export class FolderSettingsActionItem extends BaseActionItem { this.contextMenuService.showContextMenu({ getAnchor: () => this.container, getActions: () => this.getDropdownMenuActions(), - getActionItem: () => null, + getActionItem: () => undefined, onHide: () => { this.anchorElement.blur(); } @@ -495,7 +495,7 @@ export class SettingsTargetsWidget extends Widget { orientation: ActionsOrientation.HORIZONTAL, ariaLabel: localize('settingsSwitcherBarAriaLabel', "Settings Switcher"), animated: false, - actionItemProvider: (action: Action) => action.id === 'folderSettings' ? this.folderSettings : null + actionItemProvider: (action: Action) => action.id === 'folderSettings' ? this.folderSettings : undefined })); this.userSettings = new Action('userSettings', localize('userSettings', "User Settings"), '.settings-tab', true, () => this.updateTarget(ConfigurationTarget.USER)); diff --git a/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts b/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts index 96a6f591f65..adec1c2ae4b 100644 --- a/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts +++ b/src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts @@ -294,9 +294,9 @@ class DirtyDiffWidget extends PeekViewWidget { }; } - getActionItem(action: IAction): IActionItem | null { + getActionItem(action: IAction): IActionItem | undefined { if (!(action instanceof MenuItemAction)) { - return null; + return undefined; } return new DiffMenuItemActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService); diff --git a/src/vs/workbench/contrib/scm/browser/scmViewlet.ts b/src/vs/workbench/contrib/scm/browser/scmViewlet.ts index 40234b4505c..6246d730057 100644 --- a/src/vs/workbench/contrib/scm/browser/scmViewlet.ts +++ b/src/vs/workbench/contrib/scm/browser/scmViewlet.ts @@ -918,9 +918,9 @@ export class RepositoryPanel extends ViewletPanel { return this.menus.getTitleSecondaryActions(); } - getActionItem(action: IAction): IActionItem | null { + getActionItem(action: IAction): IActionItem | undefined { if (!(action instanceof MenuItemAction)) { - return null; + return undefined; } return new ContextAwareMenuItemActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService); @@ -1221,9 +1221,9 @@ export class SCMViewlet extends ViewContainerViewlet implements IViewModel { } } - getActionItem(action: IAction): IActionItem | null { + getActionItem(action: IAction): IActionItem | undefined { if (!(action instanceof MenuItemAction)) { - return null; + return undefined; } return new ContextAwareMenuItemActionItem(action, this.keybindingService, this.notificationService, this.contextMenuService); diff --git a/src/vs/workbench/contrib/terminal/browser/terminalPanel.ts b/src/vs/workbench/contrib/terminal/browser/terminalPanel.ts index b248acd1af3..780147cb952 100644 --- a/src/vs/workbench/contrib/terminal/browser/terminalPanel.ts +++ b/src/vs/workbench/contrib/terminal/browser/terminalPanel.ts @@ -161,7 +161,7 @@ export class TerminalPanel extends Panel { return this._contextMenuActions; } - public getActionItem(action: Action): IActionItem | null { + public getActionItem(action: Action): IActionItem | undefined { if (action.id === SwitchTerminalAction.ID) { return this._instantiationService.createInstance(SwitchTerminalActionItem, action); }