Path: blob/main/src/vs/workbench/contrib/comments/browser/commentMenus.ts
3296 views
/*---------------------------------------------------------------------------------------------1* Copyright (c) Microsoft Corporation. All rights reserved.2* Licensed under the MIT License. See License.txt in the project root for license information.3*--------------------------------------------------------------------------------------------*/45import { IDisposable } from '../../../../base/common/lifecycle.js';6import { Comment } from '../../../../editor/common/languages.js';7import { IMenu, IMenuActionOptions, IMenuCreateOptions, IMenuService, MenuId, MenuItemAction, SubmenuItemAction } from '../../../../platform/actions/common/actions.js';8import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';910export class CommentMenus implements IDisposable {11constructor(12@IMenuService private readonly menuService: IMenuService13) { }1415getCommentThreadTitleActions(contextKeyService: IContextKeyService): IMenu {16return this.getMenu(MenuId.CommentThreadTitle, contextKeyService);17}1819getCommentThreadActions(contextKeyService: IContextKeyService): IMenu {20return this.getMenu(MenuId.CommentThreadActions, contextKeyService);21}2223getCommentEditorActions(contextKeyService: IContextKeyService): IMenu {24return this.getMenu(MenuId.CommentEditorActions, contextKeyService);25}2627getCommentThreadAdditionalActions(contextKeyService: IContextKeyService): IMenu {28return this.getMenu(MenuId.CommentThreadAdditionalActions, contextKeyService, { emitEventsForSubmenuChanges: true });29}3031getCommentTitleActions(comment: Comment, contextKeyService: IContextKeyService): IMenu {32return this.getMenu(MenuId.CommentTitle, contextKeyService);33}3435getCommentActions(comment: Comment, contextKeyService: IContextKeyService): IMenu {36return this.getMenu(MenuId.CommentActions, contextKeyService);37}3839getCommentThreadTitleContextActions(contextKeyService: IContextKeyService) {40return this.getActions(MenuId.CommentThreadTitleContext, contextKeyService, { shouldForwardArgs: true });41}4243private getMenu(menuId: MenuId, contextKeyService: IContextKeyService, options?: IMenuCreateOptions): IMenu {44return this.menuService.createMenu(menuId, contextKeyService, options);45}4647private getActions(menuId: MenuId, contextKeyService: IContextKeyService, options?: IMenuActionOptions): Array<MenuItemAction | SubmenuItemAction> {48return this.menuService.getMenuActions(menuId, contextKeyService, options).map((value) => value[1]).flat();49}5051dispose(): void {5253}54}555657