Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
microsoft
GitHub Repository: microsoft/vscode
Path: blob/main/src/vs/workbench/contrib/comments/browser/commentMenus.ts
3296 views
1
/*---------------------------------------------------------------------------------------------
2
* Copyright (c) Microsoft Corporation. All rights reserved.
3
* Licensed under the MIT License. See License.txt in the project root for license information.
4
*--------------------------------------------------------------------------------------------*/
5
6
import { IDisposable } from '../../../../base/common/lifecycle.js';
7
import { Comment } from '../../../../editor/common/languages.js';
8
import { IMenu, IMenuActionOptions, IMenuCreateOptions, IMenuService, MenuId, MenuItemAction, SubmenuItemAction } from '../../../../platform/actions/common/actions.js';
9
import { IContextKeyService } from '../../../../platform/contextkey/common/contextkey.js';
10
11
export class CommentMenus implements IDisposable {
12
constructor(
13
@IMenuService private readonly menuService: IMenuService
14
) { }
15
16
getCommentThreadTitleActions(contextKeyService: IContextKeyService): IMenu {
17
return this.getMenu(MenuId.CommentThreadTitle, contextKeyService);
18
}
19
20
getCommentThreadActions(contextKeyService: IContextKeyService): IMenu {
21
return this.getMenu(MenuId.CommentThreadActions, contextKeyService);
22
}
23
24
getCommentEditorActions(contextKeyService: IContextKeyService): IMenu {
25
return this.getMenu(MenuId.CommentEditorActions, contextKeyService);
26
}
27
28
getCommentThreadAdditionalActions(contextKeyService: IContextKeyService): IMenu {
29
return this.getMenu(MenuId.CommentThreadAdditionalActions, contextKeyService, { emitEventsForSubmenuChanges: true });
30
}
31
32
getCommentTitleActions(comment: Comment, contextKeyService: IContextKeyService): IMenu {
33
return this.getMenu(MenuId.CommentTitle, contextKeyService);
34
}
35
36
getCommentActions(comment: Comment, contextKeyService: IContextKeyService): IMenu {
37
return this.getMenu(MenuId.CommentActions, contextKeyService);
38
}
39
40
getCommentThreadTitleContextActions(contextKeyService: IContextKeyService) {
41
return this.getActions(MenuId.CommentThreadTitleContext, contextKeyService, { shouldForwardArgs: true });
42
}
43
44
private getMenu(menuId: MenuId, contextKeyService: IContextKeyService, options?: IMenuCreateOptions): IMenu {
45
return this.menuService.createMenu(menuId, contextKeyService, options);
46
}
47
48
private getActions(menuId: MenuId, contextKeyService: IContextKeyService, options?: IMenuActionOptions): Array<MenuItemAction | SubmenuItemAction> {
49
return this.menuService.getMenuActions(menuId, contextKeyService, options).map((value) => value[1]).flat();
50
}
51
52
dispose(): void {
53
54
}
55
}
56
57