@theia/plugin-ext 1.28.0-next.9 → 1.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/common/plugin-api-rpc-model.d.ts +1 -0
- package/lib/common/plugin-api-rpc-model.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc-model.js.map +1 -1
- package/lib/common/plugin-api-rpc.d.ts +3 -0
- package/lib/common/plugin-api-rpc.d.ts.map +1 -1
- package/lib/common/plugin-api-rpc.js.map +1 -1
- package/lib/common/plugin-protocol.d.ts +4 -0
- package/lib/common/plugin-protocol.d.ts.map +1 -1
- package/lib/common/plugin-protocol.js.map +1 -1
- package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
- package/lib/hosted/browser/hosted-plugin.js +4 -2
- package/lib/hosted/browser/hosted-plugin.js.map +1 -1
- package/lib/hosted/browser/worker/worker-env-ext.d.ts +1 -0
- package/lib/hosted/browser/worker/worker-env-ext.d.ts.map +1 -1
- package/lib/hosted/browser/worker/worker-env-ext.js +3 -0
- package/lib/hosted/browser/worker/worker-env-ext.js.map +1 -1
- package/lib/hosted/node/scanners/scanner-theia.d.ts +5 -1
- package/lib/hosted/node/scanners/scanner-theia.d.ts.map +1 -1
- package/lib/hosted/node/scanners/scanner-theia.js +22 -15
- package/lib/hosted/node/scanners/scanner-theia.js.map +1 -1
- package/lib/main/browser/comments/comment-thread-widget.js +5 -5
- package/lib/main/browser/comments/comment-thread-widget.js.map +1 -1
- package/lib/main/browser/debug/debug-main.d.ts +1 -0
- package/lib/main/browser/debug/debug-main.d.ts.map +1 -1
- package/lib/main/browser/debug/debug-main.js +10 -0
- package/lib/main/browser/debug/debug-main.js.map +1 -1
- package/lib/main/browser/languages-main.d.ts.map +1 -1
- package/lib/main/browser/languages-main.js.map +1 -1
- package/lib/main/browser/menus/menus-contribution-handler.d.ts +24 -88
- package/lib/main/browser/menus/menus-contribution-handler.d.ts.map +1 -1
- package/lib/main/browser/menus/menus-contribution-handler.js +108 -518
- package/lib/main/browser/menus/menus-contribution-handler.js.map +1 -1
- package/lib/main/browser/menus/plugin-menu-command-adapter.d.ts +44 -0
- package/lib/main/browser/menus/plugin-menu-command-adapter.d.ts.map +1 -0
- package/lib/main/browser/menus/plugin-menu-command-adapter.js +274 -0
- package/lib/main/browser/menus/plugin-menu-command-adapter.js.map +1 -0
- package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts +18 -0
- package/lib/main/browser/menus/vscode-theia-menu-mappings.d.ts.map +1 -0
- package/lib/main/browser/menus/vscode-theia-menu-mappings.js +88 -0
- package/lib/main/browser/menus/vscode-theia-menu-mappings.js.map +1 -0
- package/lib/main/browser/plugin-contribution-handler.d.ts.map +1 -1
- package/lib/main/browser/plugin-contribution-handler.js +9 -4
- package/lib/main/browser/plugin-contribution-handler.js.map +1 -1
- package/lib/main/browser/plugin-ext-frontend-module.d.ts.map +1 -1
- package/lib/main/browser/plugin-ext-frontend-module.js +4 -3
- package/lib/main/browser/plugin-ext-frontend-module.js.map +1 -1
- package/lib/main/browser/plugin-frontend-contribution.d.ts +0 -2
- package/lib/main/browser/plugin-frontend-contribution.d.ts.map +1 -1
- package/lib/main/browser/plugin-frontend-contribution.js +0 -8
- package/lib/main/browser/plugin-frontend-contribution.js.map +1 -1
- package/lib/main/browser/plugin-shared-style.d.ts.map +1 -1
- package/lib/main/browser/plugin-shared-style.js +0 -1
- package/lib/main/browser/plugin-shared-style.js.map +1 -1
- package/lib/main/browser/scm-main.d.ts +1 -0
- package/lib/main/browser/scm-main.d.ts.map +1 -1
- package/lib/main/browser/scm-main.js +7 -0
- package/lib/main/browser/scm-main.js.map +1 -1
- package/lib/main/browser/view/tree-view-widget.js +2 -2
- package/lib/main/browser/view/tree-view-widget.js.map +1 -1
- package/lib/main/node/handlers/plugin-theia-file-handler.d.ts +0 -4
- package/lib/main/node/handlers/plugin-theia-file-handler.d.ts.map +1 -1
- package/lib/main/node/handlers/plugin-theia-file-handler.js +0 -26
- package/lib/main/node/handlers/plugin-theia-file-handler.js.map +1 -1
- package/lib/main/node/plugin-ext-backend-module.d.ts.map +1 -1
- package/lib/main/node/plugin-ext-backend-module.js +0 -2
- package/lib/main/node/plugin-ext-backend-module.js.map +1 -1
- package/lib/main/node/resolvers/local-plugin-deployer-resolver.d.ts.map +1 -1
- package/lib/main/node/resolvers/local-plugin-deployer-resolver.js.map +1 -1
- package/lib/plugin/debug/debug-ext.d.ts +3 -1
- package/lib/plugin/debug/debug-ext.d.ts.map +1 -1
- package/lib/plugin/debug/debug-ext.js +26 -4
- package/lib/plugin/debug/debug-ext.js.map +1 -1
- package/lib/plugin/debug/plugin-debug-adapter-session.d.ts +1 -0
- package/lib/plugin/debug/plugin-debug-adapter-session.d.ts.map +1 -1
- package/lib/plugin/debug/plugin-debug-adapter-session.js +3 -0
- package/lib/plugin/debug/plugin-debug-adapter-session.js.map +1 -1
- package/lib/plugin/env.d.ts +11 -0
- package/lib/plugin/env.d.ts.map +1 -1
- package/lib/plugin/env.js +20 -0
- package/lib/plugin/env.js.map +1 -1
- package/lib/plugin/languages/signature.d.ts.map +1 -1
- package/lib/plugin/languages/signature.js +5 -1
- package/lib/plugin/languages/signature.js.map +1 -1
- package/lib/plugin/node/debug/debug.spec.d.ts +2 -0
- package/lib/plugin/node/debug/debug.spec.d.ts.map +1 -0
- package/lib/plugin/node/debug/debug.spec.js +68 -0
- package/lib/plugin/node/debug/debug.spec.js.map +1 -0
- package/lib/plugin/node/env-node-ext.d.ts +3 -0
- package/lib/plugin/node/env-node-ext.d.ts.map +1 -1
- package/lib/plugin/node/env-node-ext.js +11 -0
- package/lib/plugin/node/env-node-ext.js.map +1 -1
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +10 -0
- package/lib/plugin/plugin-context.js.map +1 -1
- package/lib/plugin/plugin-manager.d.ts.map +1 -1
- package/lib/plugin/plugin-manager.js +1 -0
- package/lib/plugin/plugin-manager.js.map +1 -1
- package/lib/plugin/quick-open.d.ts.map +1 -1
- package/lib/plugin/quick-open.js +1 -0
- package/lib/plugin/quick-open.js.map +1 -1
- package/lib/plugin/scm.d.ts +3 -0
- package/lib/plugin/scm.d.ts.map +1 -1
- package/lib/plugin/scm.js +8 -0
- package/lib/plugin/scm.js.map +1 -1
- package/lib/plugin/type-converters.d.ts.map +1 -1
- package/lib/plugin/type-converters.js +4 -2
- package/lib/plugin/type-converters.js.map +1 -1
- package/lib/plugin/types-impl.d.ts +4 -3
- package/lib/plugin/types-impl.d.ts.map +1 -1
- package/lib/plugin/types-impl.js +9 -8
- package/lib/plugin/types-impl.js.map +1 -1
- package/package.json +27 -27
- package/src/common/plugin-api-rpc-model.ts +1 -0
- package/src/common/plugin-api-rpc.ts +3 -0
- package/src/common/plugin-protocol.ts +4 -0
- package/src/hosted/browser/hosted-plugin.ts +4 -2
- package/src/hosted/browser/worker/worker-env-ext.ts +4 -0
- package/src/hosted/node/scanners/scanner-theia.ts +21 -15
- package/src/main/browser/comments/comment-thread-widget.tsx +5 -5
- package/src/main/browser/debug/debug-main.ts +9 -0
- package/src/main/browser/languages-main.ts +5 -0
- package/src/main/browser/menus/menus-contribution-handler.ts +104 -578
- package/src/main/browser/menus/plugin-menu-command-adapter.ts +259 -0
- package/src/main/browser/menus/vscode-theia-menu-mappings.ts +85 -0
- package/src/main/browser/plugin-contribution-handler.ts +3 -1
- package/src/main/browser/plugin-ext-frontend-module.ts +4 -3
- package/src/main/browser/plugin-frontend-contribution.ts +0 -9
- package/src/main/browser/plugin-shared-style.ts +0 -1
- package/src/main/browser/scm-main.ts +10 -0
- package/src/main/browser/view/tree-view-widget.tsx +2 -2
- package/src/main/node/handlers/plugin-theia-file-handler.ts +0 -26
- package/src/main/node/plugin-ext-backend-module.ts +0 -2
- package/src/main/node/resolvers/local-plugin-deployer-resolver.ts +4 -8
- package/src/plugin/debug/debug-ext.ts +30 -5
- package/src/plugin/debug/plugin-debug-adapter-session.ts +4 -0
- package/src/plugin/env.ts +30 -0
- package/src/plugin/languages/signature.ts +3 -1
- package/src/plugin/node/debug/debug.spec.ts +94 -0
- package/src/plugin/node/env-node-ext.ts +13 -1
- package/src/plugin/plugin-context.ts +10 -0
- package/src/plugin/plugin-manager.ts +1 -0
- package/src/plugin/quick-open.ts +1 -0
- package/src/plugin/scm.ts +11 -0
- package/src/plugin/type-converters.ts +4 -2
- package/src/plugin/types-impl.ts +7 -5
- package/lib/main/browser/plugin-ext-deploy-command.d.ts +0 -10
- package/lib/main/browser/plugin-ext-deploy-command.d.ts.map +0 -1
- package/lib/main/browser/plugin-ext-deploy-command.js +0 -64
- package/lib/main/browser/plugin-ext-deploy-command.js.map +0 -1
- package/lib/main/node/resolvers/local-file-plugin-deployer-resolver.d.ts +0 -8
- package/lib/main/node/resolvers/local-file-plugin-deployer-resolver.d.ts.map +0 -1
- package/lib/main/node/resolvers/local-file-plugin-deployer-resolver.js +0 -43
- package/lib/main/node/resolvers/local-file-plugin-deployer-resolver.js.map +0 -1
- package/src/main/browser/plugin-ext-deploy-command.ts +0 -50
- package/src/main/node/resolvers/local-file-plugin-deployer-resolver.ts +0 -34
|
@@ -23,170 +23,105 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
23
23
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
24
24
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
25
25
|
};
|
|
26
|
-
var MenusContributionPointHandler_1;
|
|
27
26
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
28
|
-
exports.
|
|
27
|
+
exports.MenusContributionPointHandler = void 0;
|
|
29
28
|
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
30
|
-
const vscode_uri_1 = require("@theia/core/shared/vscode-uri");
|
|
31
29
|
const inversify_1 = require("@theia/core/shared/inversify");
|
|
32
30
|
const core_1 = require("@theia/core");
|
|
33
|
-
const browser_1 = require("@theia/editor/lib/browser");
|
|
34
31
|
const common_1 = require("@theia/core/lib/common");
|
|
35
|
-
const event_1 = require("@theia/core/lib/common/event");
|
|
36
32
|
const tab_bar_toolbar_1 = require("@theia/core/lib/browser/shell/tab-bar-toolbar");
|
|
37
|
-
const navigator_contribution_1 = require("@theia/navigator/lib/browser/navigator-contribution");
|
|
38
|
-
const tree_view_widget_1 = require("../view/tree-view-widget");
|
|
39
|
-
const common_2 = require("../../../common");
|
|
40
|
-
const debug_stack_frames_widget_1 = require("@theia/debug/lib/browser/view/debug-stack-frames-widget");
|
|
41
|
-
const debug_threads_widget_1 = require("@theia/debug/lib/browser/view/debug-threads-widget");
|
|
42
|
-
const tree_widget_selection_1 = require("@theia/core/lib/browser/tree/tree-widget-selection");
|
|
43
33
|
const scm_widget_1 = require("@theia/scm/lib/browser/scm-widget");
|
|
44
|
-
const scm_tree_widget_1 = require("@theia/scm/lib/browser/scm-tree-widget");
|
|
45
|
-
const scm_service_1 = require("@theia/scm/lib/browser/scm-service");
|
|
46
|
-
const scm_repository_1 = require("@theia/scm/lib/browser/scm-repository");
|
|
47
|
-
const scm_main_1 = require("../scm-main");
|
|
48
|
-
const resource_context_key_1 = require("@theia/core/lib/browser/resource-context-key");
|
|
49
34
|
const plugin_view_widget_1 = require("../view/plugin-view-widget");
|
|
50
|
-
const
|
|
51
|
-
const
|
|
52
|
-
const
|
|
35
|
+
const browser_1 = require("@theia/core/lib/browser");
|
|
36
|
+
const vscode_theia_menu_mappings_1 = require("./vscode-theia-menu-mappings");
|
|
37
|
+
const plugin_menu_command_adapter_1 = require("./plugin-menu-command-adapter");
|
|
38
|
+
const contextkey_1 = require("@theia/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey");
|
|
53
39
|
const context_key_service_1 = require("@theia/core/lib/browser/context-key-service");
|
|
54
|
-
const
|
|
55
|
-
const
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
40
|
+
const plugin_shared_style_1 = require("../plugin-shared-style");
|
|
41
|
+
const themeService_1 = require("@theia/monaco-editor-core/esm/vs/platform/theme/common/themeService");
|
|
42
|
+
let MenusContributionPointHandler = class MenusContributionPointHandler {
|
|
43
|
+
constructor() {
|
|
44
|
+
this.titleContributionContextKeys = new plugin_menu_command_adapter_1.ReferenceCountingSet();
|
|
45
|
+
this.onDidChangeTitleContributionEmitter = new core_1.Emitter();
|
|
46
|
+
this.initialized = false;
|
|
47
|
+
}
|
|
48
|
+
initialize() {
|
|
49
|
+
this.initialized = true;
|
|
50
|
+
this.commandAdapterRegistry.registerAdapter(this.commandAdapter);
|
|
51
|
+
for (const contributionPoint of vscode_theia_menu_mappings_1.implementedVSCodeContributionPoints) {
|
|
52
|
+
this.menuRegistry.registerIndependentSubmenu(contributionPoint, '');
|
|
53
|
+
this.getMatchingMenu(contributionPoint).forEach(([menu, when]) => this.menuRegistry.linkSubmenu(menu, contributionPoint, { role: 2 /* Flat */, when }));
|
|
54
|
+
}
|
|
55
|
+
this.tabBarToolbar.registerMenuDelegate(vscode_theia_menu_mappings_1.PLUGIN_EDITOR_TITLE_MENU, widget => this.codeEditorWidgetUtil.is(widget));
|
|
56
|
+
this.tabBarToolbar.registerMenuDelegate(vscode_theia_menu_mappings_1.PLUGIN_SCM_TITLE_MENU, widget => widget instanceof scm_widget_1.ScmWidget);
|
|
57
|
+
this.tabBarToolbar.registerMenuDelegate(vscode_theia_menu_mappings_1.PLUGIN_VIEW_TITLE_MENU, widget => widget instanceof plugin_view_widget_1.PluginViewWidget);
|
|
58
|
+
this.tabBarToolbar.registerItem({ id: 'plugin-menu-contribution-title-contribution', command: '_never_', onDidChange: this.onDidChangeTitleContributionEmitter.event });
|
|
59
|
+
this.contextKeyService.onDidChange(event => {
|
|
60
|
+
if (event.affects(this.titleContributionContextKeys)) {
|
|
61
|
+
this.onDidChangeTitleContributionEmitter.fire();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
60
64
|
}
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return resourceUri ? resourceUri['codeUri'] : undefined;
|
|
65
|
+
getMatchingMenu(contributionPoint) {
|
|
66
|
+
return vscode_theia_menu_mappings_1.codeToTheiaMappings.get(contributionPoint);
|
|
64
67
|
}
|
|
65
|
-
};
|
|
66
|
-
CodeEditorWidgetUtil = __decorate([
|
|
67
|
-
(0, inversify_1.injectable)()
|
|
68
|
-
], CodeEditorWidgetUtil);
|
|
69
|
-
exports.CodeEditorWidgetUtil = CodeEditorWidgetUtil;
|
|
70
|
-
let MenusContributionPointHandler = MenusContributionPointHandler_1 = class MenusContributionPointHandler {
|
|
71
68
|
handle(plugin) {
|
|
72
|
-
|
|
69
|
+
var _a, _b, _c, _d;
|
|
70
|
+
const allMenus = (_a = plugin.contributes) === null || _a === void 0 ? void 0 : _a.menus;
|
|
73
71
|
if (!allMenus) {
|
|
74
72
|
return core_1.Disposable.NULL;
|
|
75
73
|
}
|
|
74
|
+
if (!this.initialized) {
|
|
75
|
+
this.initialize();
|
|
76
|
+
}
|
|
76
77
|
const toDispose = new core_1.DisposableCollection();
|
|
77
|
-
const
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
// Generating group in format: `<submenu group>/<submenu name>`
|
|
88
|
-
submenuGroup = `${submenuGroup}/${menu.label}`;
|
|
89
|
-
if (submenusOrder) {
|
|
90
|
-
// Adding previous submenus order to the start of current submenu order
|
|
91
|
-
// in format: `<submenu order>/<submenu order>.../<menu order>`.
|
|
92
|
-
submenuOrder = `${submenusOrder}/${submenuOrder}`;
|
|
93
|
-
}
|
|
94
|
-
registerMenuActions(menu.children, submenuGroup, submenuOrder);
|
|
78
|
+
const submenus = (_c = (_b = plugin.contributes) === null || _b === void 0 ? void 0 : _b.submenus) !== null && _c !== void 0 ? _c : [];
|
|
79
|
+
for (const submenu of submenus) {
|
|
80
|
+
const iconClass = submenu.icon && this.toIconClass(submenu.icon, toDispose);
|
|
81
|
+
this.menuRegistry.registerIndependentSubmenu(submenu.id, submenu.label, iconClass ? { iconClass } : undefined);
|
|
82
|
+
}
|
|
83
|
+
for (const [contributionPoint, items] of Object.entries(allMenus)) {
|
|
84
|
+
for (const item of items) {
|
|
85
|
+
try {
|
|
86
|
+
if (contributionPoint === 'commandPalette') {
|
|
87
|
+
toDispose.push(this.registerCommandPaletteAction(item));
|
|
95
88
|
}
|
|
96
89
|
else {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
registerMenuActions(rootMenu.children, undefined, undefined);
|
|
103
|
-
});
|
|
104
|
-
return toDispose;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Transforms the structure of Menus & Submenus
|
|
108
|
-
* into something more tree-like.
|
|
109
|
-
*/
|
|
110
|
-
getMenusTree(plugin) {
|
|
111
|
-
const allMenus = plugin.contributes && plugin.contributes.menus;
|
|
112
|
-
if (!allMenus) {
|
|
113
|
-
return [];
|
|
114
|
-
}
|
|
115
|
-
const allSubmenus = plugin.contributes && plugin.contributes.submenus;
|
|
116
|
-
const tree = [];
|
|
117
|
-
Object.keys(allMenus).forEach(location => {
|
|
118
|
-
// Don't build menus tree for a submenu declaration at root.
|
|
119
|
-
if (allSubmenus && allSubmenus.findIndex(submenu => submenu.id === location) > -1) {
|
|
120
|
-
return;
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* @param menus the menus to create a tree from.
|
|
124
|
-
* @param submenusIds contains all the previous submenus ids in the current tree.
|
|
125
|
-
* @returns {MenuTree[]} the trees for the given menus.
|
|
126
|
-
*/
|
|
127
|
-
const getChildren = (menus, submenusIds) => {
|
|
128
|
-
// Contains all the submenus ids of the current parent.
|
|
129
|
-
const parentSubmenusIds = new Set();
|
|
130
|
-
return menus.reduce((children, menuItem) => {
|
|
131
|
-
if (menuItem.submenu) {
|
|
132
|
-
if (parentSubmenusIds.has(menuItem.submenu)) {
|
|
133
|
-
console.warn(`Submenu ${menuItem.submenu} already registered`);
|
|
90
|
+
this.checkTitleContribution(contributionPoint, item, toDispose);
|
|
91
|
+
if (item.submenu) {
|
|
92
|
+
const targets = (_d = this.getMatchingMenu(contributionPoint)) !== null && _d !== void 0 ? _d : [contributionPoint];
|
|
93
|
+
const { group, order } = this.parseGroup(item.group);
|
|
94
|
+
targets.forEach(([target]) => toDispose.push(this.menuRegistry.linkSubmenu(target, item.submenu, { order, when: item.when }, group)));
|
|
134
95
|
}
|
|
135
|
-
else if (
|
|
136
|
-
|
|
96
|
+
else if (item.command) {
|
|
97
|
+
toDispose.push(this.commandAdapter.addCommand(item.command));
|
|
98
|
+
const { group, order } = this.parseGroup(item.group);
|
|
99
|
+
const node = new core_1.ActionMenuNode({
|
|
100
|
+
commandId: item.command,
|
|
101
|
+
when: item.when,
|
|
102
|
+
order,
|
|
103
|
+
}, this.commands);
|
|
104
|
+
const parent = this.menuRegistry.getMenuNode(contributionPoint, group);
|
|
105
|
+
toDispose.push(parent.addNode(node));
|
|
137
106
|
}
|
|
138
|
-
else {
|
|
139
|
-
parentSubmenusIds.add(menuItem.submenu);
|
|
140
|
-
const submenu = allSubmenus.find(s => s.id === menuItem.submenu);
|
|
141
|
-
const menuTree = new MenuTree(Object.assign({}, menuItem), menuItem.submenu, submenu.label);
|
|
142
|
-
menuTree.children = getChildren(allMenus[submenu.id], new Set([...submenusIds, menuItem.submenu]));
|
|
143
|
-
children.push(menuTree);
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
else {
|
|
147
|
-
children.push(new MenuTree(Object.assign({}, menuItem)));
|
|
148
107
|
}
|
|
149
|
-
return children;
|
|
150
|
-
}, []);
|
|
151
|
-
};
|
|
152
|
-
const rootMenu = new MenuTree(undefined, location);
|
|
153
|
-
rootMenu.children = getChildren(allMenus[location], new Set());
|
|
154
|
-
tree.push(rootMenu);
|
|
155
|
-
});
|
|
156
|
-
return tree;
|
|
157
|
-
}
|
|
158
|
-
registerAction(plugin, location, action) {
|
|
159
|
-
const allMenus = plugin.contributes && plugin.contributes.menus;
|
|
160
|
-
if (!allMenus) {
|
|
161
|
-
return core_1.Disposable.NULL;
|
|
162
|
-
}
|
|
163
|
-
switch (location) {
|
|
164
|
-
case 'commandPalette': return this.registerCommandPaletteAction(action);
|
|
165
|
-
case 'editor/title': return this.registerEditorTitleAction(location, action);
|
|
166
|
-
case 'view/title': return this.registerViewTitleAction(location, action);
|
|
167
|
-
case 'view/item/context': return this.registerViewItemContextAction(action);
|
|
168
|
-
case 'scm/title': return this.registerScmTitleAction(location, action);
|
|
169
|
-
case 'scm/resourceGroup/context': return this.registerScmResourceGroupAction(action);
|
|
170
|
-
case 'scm/resourceFolder/context': return this.registerScmResourceFolderAction(action);
|
|
171
|
-
case 'scm/resourceState/context': return this.registerScmResourceStateAction(action);
|
|
172
|
-
case 'timeline/item/context': return this.registerTimelineItemAction(action);
|
|
173
|
-
case 'comments/commentThread/context': return this.registerCommentThreadAction(action, plugin);
|
|
174
|
-
case 'comments/comment/title': return this.registerCommentTitleAction(action);
|
|
175
|
-
case 'comments/comment/context': return this.registerCommentContextAction(action);
|
|
176
|
-
case 'debug/callstack/context': return this.registerDebugCallstackAction(action);
|
|
177
|
-
default:
|
|
178
|
-
if (allMenus.hasOwnProperty(location)) {
|
|
179
|
-
return this.registerGlobalMenuAction(action, location, plugin);
|
|
180
108
|
}
|
|
181
|
-
|
|
109
|
+
catch (error) {
|
|
110
|
+
console.warn(`Failed to register a menu item for plugin ${plugin.metadata.model.id} contributed to ${contributionPoint}`, item, error);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
182
113
|
}
|
|
114
|
+
return toDispose;
|
|
183
115
|
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
116
|
+
parseGroup(rawGroup) {
|
|
117
|
+
if (!rawGroup) {
|
|
118
|
+
return {};
|
|
119
|
+
}
|
|
120
|
+
const separatorIndex = rawGroup.lastIndexOf('@');
|
|
121
|
+
if (separatorIndex > -1) {
|
|
122
|
+
return { group: rawGroup.substring(0, separatorIndex), order: rawGroup.substring(separatorIndex + 1) || undefined };
|
|
188
123
|
}
|
|
189
|
-
return
|
|
124
|
+
return { group: rawGroup };
|
|
190
125
|
}
|
|
191
126
|
registerCommandPaletteAction(menu) {
|
|
192
127
|
if (menu.command && menu.when) {
|
|
@@ -194,332 +129,28 @@ let MenusContributionPointHandler = MenusContributionPointHandler_1 = class Menu
|
|
|
194
129
|
}
|
|
195
130
|
return core_1.Disposable.NULL;
|
|
196
131
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
}
|
|
205
|
-
registerViewTitleAction(location, action) {
|
|
206
|
-
return this.registerTitleAction(location, action, {
|
|
207
|
-
execute: widget => widget instanceof plugin_view_widget_1.PluginViewWidget && this.commands.executeCommand(action.command),
|
|
208
|
-
isEnabled: widget => widget instanceof plugin_view_widget_1.PluginViewWidget && this.commands.isEnabled(action.command),
|
|
209
|
-
isVisible: widget => widget instanceof plugin_view_widget_1.PluginViewWidget && this.commands.isVisible(action.command),
|
|
210
|
-
});
|
|
211
|
-
}
|
|
212
|
-
registerViewItemContextAction(menu) {
|
|
213
|
-
const inline = menu.group && /^inline/.test(menu.group) || false;
|
|
214
|
-
const menuPath = inline ? tree_view_widget_1.VIEW_ITEM_INLINE_MENU : tree_view_widget_1.VIEW_ITEM_CONTEXT_MENU;
|
|
215
|
-
return this.registerTreeMenuAction(menuPath, menu);
|
|
216
|
-
}
|
|
217
|
-
registerScmResourceGroupAction(menu) {
|
|
218
|
-
const inline = menu.group && /^inline/.test(menu.group) || false;
|
|
219
|
-
const menuPath = inline ? scm_tree_widget_1.ScmTreeWidget.RESOURCE_GROUP_INLINE_MENU : scm_tree_widget_1.ScmTreeWidget.RESOURCE_GROUP_CONTEXT_MENU;
|
|
220
|
-
return this.registerScmMenuAction(menuPath, menu);
|
|
221
|
-
}
|
|
222
|
-
registerScmResourceFolderAction(menu) {
|
|
223
|
-
const inline = menu.group && /^inline/.test(menu.group) || false;
|
|
224
|
-
const menuPath = inline ? scm_tree_widget_1.ScmTreeWidget.RESOURCE_FOLDER_INLINE_MENU : scm_tree_widget_1.ScmTreeWidget.RESOURCE_FOLDER_CONTEXT_MENU;
|
|
225
|
-
return this.registerScmMenuAction(menuPath, menu);
|
|
226
|
-
}
|
|
227
|
-
registerScmResourceStateAction(menu) {
|
|
228
|
-
const inline = menu.group && /^inline/.test(menu.group) || false;
|
|
229
|
-
const menuPath = inline ? scm_tree_widget_1.ScmTreeWidget.RESOURCE_INLINE_MENU : scm_tree_widget_1.ScmTreeWidget.RESOURCE_CONTEXT_MENU;
|
|
230
|
-
return this.registerScmMenuAction(menuPath, menu);
|
|
231
|
-
}
|
|
232
|
-
registerTimelineItemAction(menu) {
|
|
233
|
-
return this.registerMenuAction(timeline_tree_widget_1.TIMELINE_ITEM_CONTEXT_MENU, menu, command => ({
|
|
234
|
-
execute: (...args) => this.commands.executeCommand(command, ...this.toTimelineArgs(...args)),
|
|
235
|
-
isEnabled: (...args) => this.commands.isEnabled(command, ...this.toTimelineArgs(...args)),
|
|
236
|
-
isVisible: (...args) => this.commands.isVisible(command, ...this.toTimelineArgs(...args))
|
|
237
|
-
}));
|
|
238
|
-
}
|
|
239
|
-
registerCommentThreadAction(menu, plugin) {
|
|
240
|
-
return this.registerMenuAction(comment_thread_widget_1.COMMENT_THREAD_CONTEXT, menu, command => ({
|
|
241
|
-
execute: (...args) => this.commands.executeCommand(command, ...this.toCommentArgs(...args)),
|
|
242
|
-
isEnabled: () => {
|
|
243
|
-
var _a;
|
|
244
|
-
const commandContributions = (_a = plugin.contributes) === null || _a === void 0 ? void 0 : _a.commands;
|
|
245
|
-
if (commandContributions) {
|
|
246
|
-
const commandContribution = commandContributions.find(c => c.command === command);
|
|
247
|
-
if (commandContribution && commandContribution.enablement) {
|
|
248
|
-
return this.contextKeyService.match(commandContribution.enablement);
|
|
249
|
-
}
|
|
132
|
+
checkTitleContribution(contributionPoint, contribution, toDispose) {
|
|
133
|
+
if (contribution.when && contributionPoint.endsWith('title')) {
|
|
134
|
+
const expression = contextkey_1.ContextKeyExpr.deserialize(contribution.when);
|
|
135
|
+
if (expression) {
|
|
136
|
+
for (const key of expression.keys()) {
|
|
137
|
+
this.titleContributionContextKeys.add(key);
|
|
138
|
+
toDispose.push(core_1.Disposable.create(() => this.titleContributionContextKeys.delete(key)));
|
|
250
139
|
}
|
|
251
|
-
|
|
252
|
-
},
|
|
253
|
-
isVisible: (...args) => this.commands.isVisible(command, ...this.toCommentArgs(...args))
|
|
254
|
-
}));
|
|
255
|
-
}
|
|
256
|
-
registerCommentTitleAction(menu) {
|
|
257
|
-
return this.registerMenuAction(comment_thread_widget_1.COMMENT_TITLE, menu, command => ({
|
|
258
|
-
execute: (...args) => this.commands.executeCommand(command, ...this.toCommentArgs(...args)),
|
|
259
|
-
isEnabled: (...args) => this.commands.isEnabled(command, ...this.toCommentArgs(...args)),
|
|
260
|
-
isVisible: (...args) => this.commands.isVisible(command, ...this.toCommentArgs(...args))
|
|
261
|
-
}));
|
|
262
|
-
}
|
|
263
|
-
registerCommentContextAction(menu) {
|
|
264
|
-
return this.registerMenuAction(comment_thread_widget_1.COMMENT_CONTEXT, menu, command => ({
|
|
265
|
-
execute: (...args) => this.commands.executeCommand(command, ...this.toCommentArgs(...args)),
|
|
266
|
-
isEnabled: () => true,
|
|
267
|
-
isVisible: (...args) => this.commands.isVisible(command, ...this.toCommentArgs(...args))
|
|
268
|
-
}));
|
|
269
|
-
}
|
|
270
|
-
registerDebugCallstackAction(menu) {
|
|
271
|
-
const toDispose = new core_1.DisposableCollection();
|
|
272
|
-
[debug_stack_frames_widget_1.DebugStackFramesWidget.CONTEXT_MENU, debug_threads_widget_1.DebugThreadsWidget.CONTEXT_MENU].forEach(menuPath => {
|
|
273
|
-
toDispose.push(this.registerMenuAction(menuPath, menu, command => ({
|
|
274
|
-
execute: (...args) => this.commands.executeCommand(command, args[0]),
|
|
275
|
-
isEnabled: (...args) => this.commands.isEnabled(command, args[0]),
|
|
276
|
-
isVisible: (...args) => this.commands.isVisible(command, args[0])
|
|
277
|
-
})));
|
|
278
|
-
});
|
|
279
|
-
return toDispose;
|
|
280
|
-
}
|
|
281
|
-
registerTreeMenuAction(menuPath, menu) {
|
|
282
|
-
return this.registerMenuAction(menuPath, menu, command => ({
|
|
283
|
-
execute: (...args) => this.commands.executeCommand(command, ...this.toTreeArgs(...args)),
|
|
284
|
-
isEnabled: (...args) => this.commands.isEnabled(command, ...this.toTreeArgs(...args)),
|
|
285
|
-
isVisible: (...args) => this.commands.isVisible(command, ...this.toTreeArgs(...args))
|
|
286
|
-
}));
|
|
287
|
-
}
|
|
288
|
-
toTreeArgs(...args) {
|
|
289
|
-
const treeArgs = [];
|
|
290
|
-
for (const arg of args) {
|
|
291
|
-
if (common_2.TreeViewSelection.is(arg)) {
|
|
292
|
-
treeArgs.push(arg);
|
|
293
|
-
}
|
|
294
|
-
}
|
|
295
|
-
return treeArgs;
|
|
296
|
-
}
|
|
297
|
-
registerTitleAction(location, action, handler) {
|
|
298
|
-
if (!action.command) {
|
|
299
|
-
return core_1.Disposable.NULL;
|
|
300
|
-
}
|
|
301
|
-
const toDispose = new core_1.DisposableCollection();
|
|
302
|
-
const id = this.createSyntheticCommandId(action.command, { prefix: `__plugin.${location.replace('/', '.')}.action.` });
|
|
303
|
-
const command = { id };
|
|
304
|
-
toDispose.push(this.commands.registerCommand(command, handler));
|
|
305
|
-
const { when } = action;
|
|
306
|
-
const whenKeys = when && this.contextKeyService.parseKeys(when);
|
|
307
|
-
let onDidChange;
|
|
308
|
-
if (whenKeys && whenKeys.size) {
|
|
309
|
-
const onDidChangeEmitter = new event_1.Emitter();
|
|
310
|
-
toDispose.push(onDidChangeEmitter);
|
|
311
|
-
onDidChange = onDidChangeEmitter.event;
|
|
312
|
-
event_1.Event.addMaxListeners(this.contextKeyService.onDidChange, 1);
|
|
313
|
-
toDispose.push(core_1.Disposable.create(() => {
|
|
314
|
-
event_1.Event.addMaxListeners(this.contextKeyService.onDidChange, -1);
|
|
315
|
-
}));
|
|
316
|
-
toDispose.push(this.contextKeyService.onDidChange(event => {
|
|
317
|
-
if (event.affects(whenKeys)) {
|
|
318
|
-
onDidChangeEmitter.fire(undefined);
|
|
319
|
-
}
|
|
320
|
-
}));
|
|
321
|
-
}
|
|
322
|
-
// handle group and priority
|
|
323
|
-
// if group is empty or white space is will be set to navigation
|
|
324
|
-
// ' ' => ['navigation', 0]
|
|
325
|
-
// 'navigation@1' => ['navigation', 1]
|
|
326
|
-
// '1_rest-client@2' => ['1_rest-client', 2]
|
|
327
|
-
// if priority is not a number it will be set to 0
|
|
328
|
-
// navigation@test => ['navigation', 0]
|
|
329
|
-
const [group, sort] = (action.group || 'navigation').split('@');
|
|
330
|
-
const item = { id, command: id, group: group.trim() || 'navigation', priority: ~~sort || undefined, when, onDidChange };
|
|
331
|
-
toDispose.push(this.tabBarToolbar.registerItem(item));
|
|
332
|
-
toDispose.push(this.onDidRegisterCommand(action.command, pluginCommand => {
|
|
333
|
-
command.category = pluginCommand.category;
|
|
334
|
-
item.tooltip = pluginCommand.label;
|
|
335
|
-
if (group === 'navigation') {
|
|
336
|
-
command.iconClass = pluginCommand.iconClass;
|
|
337
|
-
}
|
|
338
|
-
}));
|
|
339
|
-
return toDispose;
|
|
340
|
-
}
|
|
341
|
-
registerScmTitleAction(location, action) {
|
|
342
|
-
if (!action.command) {
|
|
343
|
-
return core_1.Disposable.NULL;
|
|
344
|
-
}
|
|
345
|
-
const selectedRepository = () => this.toScmArg(this.scmService.selectedRepository);
|
|
346
|
-
return this.registerTitleAction(location, action, {
|
|
347
|
-
execute: widget => widget instanceof scm_widget_1.ScmWidget && this.commands.executeCommand(action.command, selectedRepository()),
|
|
348
|
-
isEnabled: widget => widget instanceof scm_widget_1.ScmWidget && this.commands.isEnabled(action.command, selectedRepository()),
|
|
349
|
-
isVisible: widget => widget instanceof scm_widget_1.ScmWidget && this.commands.isVisible(action.command, selectedRepository())
|
|
350
|
-
});
|
|
351
|
-
}
|
|
352
|
-
registerScmMenuAction(menuPath, menu) {
|
|
353
|
-
return this.registerMenuAction(menuPath, menu, command => ({
|
|
354
|
-
execute: (...args) => this.commands.executeCommand(command, ...this.toScmArgs(...args)),
|
|
355
|
-
isEnabled: (...args) => this.commands.isEnabled(command, ...this.toScmArgs(...args)),
|
|
356
|
-
isVisible: (...args) => this.commands.isVisible(command, ...this.toScmArgs(...args))
|
|
357
|
-
}));
|
|
358
|
-
}
|
|
359
|
-
toScmArgs(...args) {
|
|
360
|
-
const scmArgs = [];
|
|
361
|
-
for (const arg of args) {
|
|
362
|
-
const scmArg = this.toScmArg(arg);
|
|
363
|
-
if (scmArg) {
|
|
364
|
-
scmArgs.push(scmArg);
|
|
140
|
+
toDispose.push(core_1.Disposable.create(() => this.onDidChangeTitleContributionEmitter.fire()));
|
|
365
141
|
}
|
|
366
142
|
}
|
|
367
|
-
return scmArgs;
|
|
368
|
-
}
|
|
369
|
-
toScmArg(arg) {
|
|
370
|
-
if (arg instanceof scm_repository_1.ScmRepository && arg.provider instanceof scm_main_1.PluginScmProvider) {
|
|
371
|
-
return {
|
|
372
|
-
sourceControlHandle: arg.provider.handle
|
|
373
|
-
};
|
|
374
|
-
}
|
|
375
|
-
if (arg instanceof scm_main_1.PluginScmResourceGroup) {
|
|
376
|
-
return {
|
|
377
|
-
sourceControlHandle: arg.provider.handle,
|
|
378
|
-
resourceGroupHandle: arg.handle
|
|
379
|
-
};
|
|
380
|
-
}
|
|
381
|
-
if (arg instanceof scm_main_1.PluginScmResource) {
|
|
382
|
-
return {
|
|
383
|
-
sourceControlHandle: arg.group.provider.handle,
|
|
384
|
-
resourceGroupHandle: arg.group.handle,
|
|
385
|
-
resourceStateHandle: arg.handle
|
|
386
|
-
};
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
toTimelineArgs(...args) {
|
|
390
|
-
const timelineArgs = [];
|
|
391
|
-
const arg = args[0];
|
|
392
|
-
timelineArgs.push(this.toTimelineArg(arg));
|
|
393
|
-
timelineArgs.push(vscode_uri_1.URI.parse(arg.uri));
|
|
394
|
-
timelineArgs.push('source' in arg ? arg.source : '');
|
|
395
|
-
return timelineArgs;
|
|
396
143
|
}
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
};
|
|
403
|
-
}
|
|
404
|
-
toCommentArgs(...args) {
|
|
405
|
-
const arg = args[0];
|
|
406
|
-
if ('text' in arg) {
|
|
407
|
-
if ('commentUniqueId' in arg) {
|
|
408
|
-
return [{
|
|
409
|
-
commentControlHandle: arg.thread.controllerHandle,
|
|
410
|
-
commentThreadHandle: arg.thread.commentThreadHandle,
|
|
411
|
-
text: arg.text,
|
|
412
|
-
commentUniqueId: arg.commentUniqueId
|
|
413
|
-
}];
|
|
414
|
-
}
|
|
415
|
-
return [{
|
|
416
|
-
commentControlHandle: arg.thread.controllerHandle,
|
|
417
|
-
commentThreadHandle: arg.thread.commentThreadHandle,
|
|
418
|
-
text: arg.text
|
|
419
|
-
}];
|
|
420
|
-
}
|
|
421
|
-
return [{
|
|
422
|
-
commentControlHandle: arg.thread.controllerHandle,
|
|
423
|
-
commentThreadHandle: arg.thread.commentThreadHandle,
|
|
424
|
-
commentUniqueId: arg.commentUniqueId
|
|
425
|
-
}];
|
|
426
|
-
}
|
|
427
|
-
registerGlobalMenuAction(menu, location, plugin) {
|
|
428
|
-
const menuPaths = MenusContributionPointHandler_1.parseMenuPaths(location);
|
|
429
|
-
if (!menuPaths.length) {
|
|
430
|
-
this.logger.warn(`'${plugin.metadata.model.id}' plugin contributes items to a menu with invalid identifier: ${location}`);
|
|
431
|
-
return core_1.Disposable.NULL;
|
|
432
|
-
}
|
|
433
|
-
const selectedResource = () => {
|
|
434
|
-
const selection = this.selectionService.selection;
|
|
435
|
-
if (tree_widget_selection_1.TreeWidgetSelection.is(selection) && selection.source instanceof tree_view_widget_1.TreeViewWidget && selection[0]) {
|
|
436
|
-
return selection.source.toTreeViewSelection(selection[0]);
|
|
437
|
-
}
|
|
438
|
-
const uri = this.resourceContextKey.get();
|
|
439
|
-
return uri ? uri['codeUri'] : undefined;
|
|
440
|
-
};
|
|
441
|
-
const toDispose = new core_1.DisposableCollection();
|
|
442
|
-
menuPaths.forEach(menuPath => {
|
|
443
|
-
toDispose.push(this.registerMenuAction(menuPath, menu, command => ({
|
|
444
|
-
execute: () => this.commands.executeCommand(command, selectedResource()),
|
|
445
|
-
isEnabled: () => this.commands.isEnabled(command, selectedResource()),
|
|
446
|
-
isVisible: () => this.commands.isVisible(command, selectedResource())
|
|
447
|
-
})));
|
|
448
|
-
});
|
|
449
|
-
return toDispose;
|
|
450
|
-
}
|
|
451
|
-
registerMenuAction(menuPath, menu, handler) {
|
|
452
|
-
var _a, _b;
|
|
453
|
-
if (!menu.command) {
|
|
454
|
-
return core_1.Disposable.NULL;
|
|
455
|
-
}
|
|
456
|
-
const toDispose = new core_1.DisposableCollection();
|
|
457
|
-
const commandId = this.createSyntheticCommandId(menu.command, { prefix: '__plugin.menu.action.' });
|
|
458
|
-
const altId = menu.alt && this.createSyntheticCommandId(menu.alt, { prefix: '__plugin.menu.action.' });
|
|
459
|
-
const inline = Boolean(menu.group && /^inline/.test(menu.group));
|
|
460
|
-
const [group, order = undefined] = (menu.group || '_').split('@');
|
|
461
|
-
const command = { id: commandId };
|
|
462
|
-
const action = { commandId, alt: altId, order, when: menu.when };
|
|
463
|
-
toDispose.push(this.commands.registerCommand(command, handler(menu.command)));
|
|
464
|
-
toDispose.push((_a = this.quickCommandService) === null || _a === void 0 ? void 0 : _a.pushCommandContext(commandId, 'false'));
|
|
465
|
-
toDispose.push(this.menuRegistry.registerMenuAction(inline ? menuPath : [...menuPath, ...group.split('/')], action));
|
|
466
|
-
toDispose.push(this.onDidRegisterCommand(menu.command, pluginCommand => {
|
|
467
|
-
command.category = pluginCommand.category;
|
|
468
|
-
command.label = pluginCommand.label;
|
|
469
|
-
if (inline) {
|
|
470
|
-
command.iconClass = pluginCommand.iconClass;
|
|
471
|
-
}
|
|
472
|
-
}));
|
|
473
|
-
if (menu.alt && altId) {
|
|
474
|
-
const alt = { id: altId };
|
|
475
|
-
toDispose.push(this.commands.registerCommand(alt, handler(menu.alt)));
|
|
476
|
-
toDispose.push((_b = this.quickCommandService) === null || _b === void 0 ? void 0 : _b.pushCommandContext(altId, 'false'));
|
|
477
|
-
toDispose.push(this.onDidRegisterCommand(menu.alt, pluginCommand => {
|
|
478
|
-
alt.category = pluginCommand.category;
|
|
479
|
-
alt.label = pluginCommand.label;
|
|
480
|
-
if (inline) {
|
|
481
|
-
alt.iconClass = pluginCommand.iconClass;
|
|
482
|
-
}
|
|
483
|
-
}));
|
|
484
|
-
}
|
|
485
|
-
// Register a submenu if the group is in format `<submenu group>/<submenu name>/<submenu order>.../<menu group>`
|
|
486
|
-
if (group.includes('/')) {
|
|
487
|
-
const groupSplit = group.split('/');
|
|
488
|
-
const orderSplit = (menu.submenusOrder || '').split('/');
|
|
489
|
-
const paths = [];
|
|
490
|
-
for (let i = 0, j = 0; i < groupSplit.length - 1; i += 2, j += 1) {
|
|
491
|
-
const submenuGroup = groupSplit[i];
|
|
492
|
-
const submenuLabel = groupSplit[i + 1];
|
|
493
|
-
const submenuOrder = orderSplit[j];
|
|
494
|
-
paths.push(submenuGroup, submenuLabel);
|
|
495
|
-
toDispose.push(this.menuRegistry.registerSubmenu([...menuPath, ...paths], submenuLabel, { order: submenuOrder }));
|
|
144
|
+
toIconClass(url, toDispose) {
|
|
145
|
+
if (typeof url === 'string') {
|
|
146
|
+
const asThemeIcon = themeService_1.ThemeIcon.fromString(url);
|
|
147
|
+
if (asThemeIcon) {
|
|
148
|
+
return themeService_1.ThemeIcon.asClassName(asThemeIcon);
|
|
496
149
|
}
|
|
497
150
|
}
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
let id = prefix + command;
|
|
502
|
-
let index = 0;
|
|
503
|
-
while (this.commands.getCommand(id)) {
|
|
504
|
-
id = prefix + command + ':' + index;
|
|
505
|
-
index++;
|
|
506
|
-
}
|
|
507
|
-
return id;
|
|
508
|
-
}
|
|
509
|
-
onDidRegisterCommand(id, cb) {
|
|
510
|
-
const command = this.commands.getCommand(id);
|
|
511
|
-
if (command) {
|
|
512
|
-
cb(command);
|
|
513
|
-
return core_1.Disposable.NULL;
|
|
514
|
-
}
|
|
515
|
-
const toDispose = new core_1.DisposableCollection();
|
|
516
|
-
// Registering a menu action requires the related command to be already registered.
|
|
517
|
-
// But Theia plugin registers the commands dynamically via the Commands API.
|
|
518
|
-
// Let's wait for ~2 sec. It should be enough to finish registering all the contributed commands.
|
|
519
|
-
// FIXME: remove this workaround (timer) once the https://github.com/theia-ide/theia/issues/3344 is fixed
|
|
520
|
-
const handle = setTimeout(() => toDispose.push(this.onDidRegisterCommand(id, cb)), 2000);
|
|
521
|
-
toDispose.push(core_1.Disposable.create(() => clearTimeout(handle)));
|
|
522
|
-
return toDispose;
|
|
151
|
+
const reference = this.style.toIconClass(url);
|
|
152
|
+
toDispose.push(reference);
|
|
153
|
+
return reference.object.iconClass;
|
|
523
154
|
}
|
|
524
155
|
};
|
|
525
156
|
__decorate([
|
|
@@ -530,78 +161,37 @@ __decorate([
|
|
|
530
161
|
(0, inversify_1.inject)(core_1.CommandRegistry),
|
|
531
162
|
__metadata("design:type", core_1.CommandRegistry)
|
|
532
163
|
], MenusContributionPointHandler.prototype, "commands", void 0);
|
|
533
|
-
__decorate([
|
|
534
|
-
(0, inversify_1.inject)(core_1.ILogger),
|
|
535
|
-
__metadata("design:type", Object)
|
|
536
|
-
], MenusContributionPointHandler.prototype, "logger", void 0);
|
|
537
|
-
__decorate([
|
|
538
|
-
(0, inversify_1.inject)(scm_service_1.ScmService),
|
|
539
|
-
__metadata("design:type", scm_service_1.ScmService)
|
|
540
|
-
], MenusContributionPointHandler.prototype, "scmService", void 0);
|
|
541
|
-
__decorate([
|
|
542
|
-
(0, inversify_1.inject)(browser_2.QuickCommandService),
|
|
543
|
-
(0, inversify_1.optional)(),
|
|
544
|
-
__metadata("design:type", browser_2.QuickCommandService)
|
|
545
|
-
], MenusContributionPointHandler.prototype, "quickCommandService", void 0);
|
|
546
164
|
__decorate([
|
|
547
165
|
(0, inversify_1.inject)(tab_bar_toolbar_1.TabBarToolbarRegistry),
|
|
548
166
|
__metadata("design:type", tab_bar_toolbar_1.TabBarToolbarRegistry)
|
|
549
167
|
], MenusContributionPointHandler.prototype, "tabBarToolbar", void 0);
|
|
550
168
|
__decorate([
|
|
551
|
-
(0, inversify_1.inject)(
|
|
552
|
-
__metadata("design:type",
|
|
553
|
-
], MenusContributionPointHandler.prototype, "
|
|
169
|
+
(0, inversify_1.inject)(vscode_theia_menu_mappings_1.CodeEditorWidgetUtil),
|
|
170
|
+
__metadata("design:type", vscode_theia_menu_mappings_1.CodeEditorWidgetUtil)
|
|
171
|
+
], MenusContributionPointHandler.prototype, "codeEditorWidgetUtil", void 0);
|
|
554
172
|
__decorate([
|
|
555
|
-
(0, inversify_1.inject)(
|
|
556
|
-
__metadata("design:type",
|
|
557
|
-
], MenusContributionPointHandler.prototype, "
|
|
173
|
+
(0, inversify_1.inject)(plugin_menu_command_adapter_1.PluginMenuCommandAdapter),
|
|
174
|
+
__metadata("design:type", plugin_menu_command_adapter_1.PluginMenuCommandAdapter)
|
|
175
|
+
], MenusContributionPointHandler.prototype, "commandAdapter", void 0);
|
|
558
176
|
__decorate([
|
|
559
|
-
(0, inversify_1.inject)(
|
|
560
|
-
__metadata("design:type",
|
|
561
|
-
], MenusContributionPointHandler.prototype, "
|
|
177
|
+
(0, inversify_1.inject)(core_1.MenuCommandAdapterRegistry),
|
|
178
|
+
__metadata("design:type", Object)
|
|
179
|
+
], MenusContributionPointHandler.prototype, "commandAdapterRegistry", void 0);
|
|
562
180
|
__decorate([
|
|
563
181
|
(0, inversify_1.inject)(context_key_service_1.ContextKeyService),
|
|
564
182
|
__metadata("design:type", Object)
|
|
565
183
|
], MenusContributionPointHandler.prototype, "contextKeyService", void 0);
|
|
566
184
|
__decorate([
|
|
567
|
-
(0, inversify_1.inject)(
|
|
568
|
-
__metadata("design:type",
|
|
569
|
-
], MenusContributionPointHandler.prototype, "
|
|
570
|
-
|
|
185
|
+
(0, inversify_1.inject)(plugin_shared_style_1.PluginSharedStyle),
|
|
186
|
+
__metadata("design:type", plugin_shared_style_1.PluginSharedStyle)
|
|
187
|
+
], MenusContributionPointHandler.prototype, "style", void 0);
|
|
188
|
+
__decorate([
|
|
189
|
+
(0, inversify_1.inject)(browser_1.QuickCommandService),
|
|
190
|
+
(0, inversify_1.optional)(),
|
|
191
|
+
__metadata("design:type", browser_1.QuickCommandService)
|
|
192
|
+
], MenusContributionPointHandler.prototype, "quickCommandService", void 0);
|
|
193
|
+
MenusContributionPointHandler = __decorate([
|
|
571
194
|
(0, inversify_1.injectable)()
|
|
572
195
|
], MenusContributionPointHandler);
|
|
573
196
|
exports.MenusContributionPointHandler = MenusContributionPointHandler;
|
|
574
|
-
/**
|
|
575
|
-
* MenuTree representing a (sub)menu in the menu tree structure.
|
|
576
|
-
*/
|
|
577
|
-
class MenuTree {
|
|
578
|
-
constructor(menu,
|
|
579
|
-
/** The location where the menu item will be open from. */
|
|
580
|
-
id,
|
|
581
|
-
/** The label of the menu item which leads to the submenu. */
|
|
582
|
-
label) {
|
|
583
|
-
this.id = id;
|
|
584
|
-
this.label = label;
|
|
585
|
-
this._children = [];
|
|
586
|
-
if (menu) {
|
|
587
|
-
this.command = menu.command;
|
|
588
|
-
this.alt = menu.alt;
|
|
589
|
-
this.group = menu.group;
|
|
590
|
-
this.when = menu.when;
|
|
591
|
-
}
|
|
592
|
-
}
|
|
593
|
-
get children() {
|
|
594
|
-
return this._children;
|
|
595
|
-
}
|
|
596
|
-
set children(items) {
|
|
597
|
-
this._children.push(...items);
|
|
598
|
-
}
|
|
599
|
-
addChild(node) {
|
|
600
|
-
this._children.push(node);
|
|
601
|
-
}
|
|
602
|
-
get isSubmenu() {
|
|
603
|
-
return this.label !== undefined;
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
exports.MenuTree = MenuTree;
|
|
607
197
|
//# sourceMappingURL=menus-contribution-handler.js.map
|