@theia/plugin-ext-vscode 1.34.3 → 1.34.4

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.
Files changed (53) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +32 -32
  3. package/lib/browser/plugin-vscode-commands-contribution.d.ts +79 -79
  4. package/lib/browser/plugin-vscode-commands-contribution.js +768 -768
  5. package/lib/browser/plugin-vscode-contribution.d.ts +5 -5
  6. package/lib/browser/plugin-vscode-contribution.js +53 -53
  7. package/lib/browser/plugin-vscode-frontend-module.d.ts +3 -3
  8. package/lib/browser/plugin-vscode-frontend-module.js +30 -30
  9. package/lib/common/plugin-vscode-environment.d.ts +7 -7
  10. package/lib/common/plugin-vscode-environment.js +47 -47
  11. package/lib/common/plugin-vscode-types.d.ts +2 -2
  12. package/lib/common/plugin-vscode-types.js +21 -21
  13. package/lib/common/plugin-vscode-uri.d.ts +16 -16
  14. package/lib/common/plugin-vscode-uri.js +51 -51
  15. package/lib/node/context/plugin-vscode-init-fe.d.ts +2 -2
  16. package/lib/node/context/plugin-vscode-init-fe.js +37 -37
  17. package/lib/node/local-vsix-file-plugin-deployer-resolver.d.ts +14 -14
  18. package/lib/node/local-vsix-file-plugin-deployer-resolver.js +77 -77
  19. package/lib/node/package.spec.js +25 -25
  20. package/lib/node/plugin-reader.d.ts +6 -6
  21. package/lib/node/plugin-reader.js +36 -36
  22. package/lib/node/plugin-vscode-backend-module.d.ts +3 -3
  23. package/lib/node/plugin-vscode-backend-module.js +43 -43
  24. package/lib/node/plugin-vscode-cli-contribution.d.ts +21 -21
  25. package/lib/node/plugin-vscode-cli-contribution.js +67 -67
  26. package/lib/node/plugin-vscode-deployer-participant.d.ts +6 -6
  27. package/lib/node/plugin-vscode-deployer-participant.js +43 -43
  28. package/lib/node/plugin-vscode-directory-handler.d.ts +21 -21
  29. package/lib/node/plugin-vscode-directory-handler.js +144 -144
  30. package/lib/node/plugin-vscode-file-handler.d.ts +11 -11
  31. package/lib/node/plugin-vscode-file-handler.js +82 -82
  32. package/lib/node/plugin-vscode-init.d.ts +2 -2
  33. package/lib/node/plugin-vscode-init.js +68 -68
  34. package/lib/node/scanner-vscode.d.ts +12 -12
  35. package/lib/node/scanner-vscode.js +111 -111
  36. package/package.json +15 -15
  37. package/src/browser/plugin-vscode-commands-contribution.ts +924 -924
  38. package/src/browser/plugin-vscode-contribution.ts +47 -47
  39. package/src/browser/plugin-vscode-frontend-module.ts +30 -30
  40. package/src/common/plugin-vscode-environment.ts +36 -36
  41. package/src/common/plugin-vscode-types.ts +20 -20
  42. package/src/common/plugin-vscode-uri.ts +47 -47
  43. package/src/node/context/plugin-vscode-init-fe.ts +43 -43
  44. package/src/node/local-vsix-file-plugin-deployer-resolver.ts +65 -65
  45. package/src/node/package.spec.ts +28 -28
  46. package/src/node/plugin-reader.ts +28 -28
  47. package/src/node/plugin-vscode-backend-module.ts +50 -50
  48. package/src/node/plugin-vscode-cli-contribution.ts +64 -64
  49. package/src/node/plugin-vscode-deployer-participant.ts +32 -32
  50. package/src/node/plugin-vscode-directory-handler.ts +141 -141
  51. package/src/node/plugin-vscode-file-handler.ts +72 -72
  52. package/src/node/plugin-vscode-init.ts +80 -80
  53. package/src/node/scanner-vscode.ts +108 -108
@@ -1,769 +1,769 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2018 Red Hat, Inc. and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
- return c > 3 && r && Object.defineProperty(target, key, r), r;
22
- };
23
- var __metadata = (this && this.__metadata) || function (k, v) {
24
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
- };
26
- Object.defineProperty(exports, "__esModule", { value: true });
27
- exports.PluginVscodeCommandsContribution = exports.VscodeCommands = void 0;
28
- const core_1 = require("@theia/core");
29
- const browser_1 = require("@theia/core/lib/browser");
30
- const context_key_service_1 = require("@theia/core/lib/browser/context-key-service");
31
- const application_shell_mouse_tracker_1 = require("@theia/core/lib/browser/shell/application-shell-mouse-tracker");
32
- const command_1 = require("@theia/core/lib/common/command");
33
- const uri_1 = require("@theia/core/lib/common/uri");
34
- const browser_2 = require("@theia/editor/lib/browser");
35
- const documents_main_1 = require("@theia/plugin-ext/lib/main/browser/documents-main");
36
- const type_converters_1 = require("@theia/plugin-ext/lib/plugin/type-converters");
37
- const browser_3 = require("@theia/workspace/lib/browser");
38
- const workspace_service_1 = require("@theia/workspace/lib/browser/workspace-service");
39
- const diff_service_1 = require("@theia/workspace/lib/browser/diff-service");
40
- const inversify_1 = require("@theia/core/shared/inversify");
41
- const vscode_uri_1 = require("@theia/core/shared/vscode-uri");
42
- const plugin_protocol_1 = require("@theia/plugin-ext/lib/common/plugin-protocol");
43
- const terminal_frontend_contribution_1 = require("@theia/terminal/lib/browser/terminal-frontend-contribution");
44
- const quick_open_workspace_1 = require("@theia/workspace/lib/browser/quick-open-workspace");
45
- const terminal_service_1 = require("@theia/terminal/lib/browser/base/terminal-service");
46
- const navigator_contribution_1 = require("@theia/navigator/lib/browser/navigator-contribution");
47
- const browser_4 = require("@theia/navigator/lib/browser");
48
- const tree_selection_1 = require("@theia/core/lib/browser/tree/tree-selection");
49
- const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
50
- const browser_5 = require("@theia/callhierarchy/lib/browser");
51
- const browser_6 = require("@theia/typehierarchy/lib/browser");
52
- const monaco_text_model_service_1 = require("@theia/monaco/lib/browser/monaco-text-model-service");
53
- const hierarchy_types_converters_1 = require("@theia/plugin-ext/lib/main/browser/hierarchy/hierarchy-types-converters");
54
- const custom_editor_opener_1 = require("@theia/plugin-ext/lib/main/browser/custom-editors/custom-editor-opener");
55
- const nls_1 = require("@theia/core/lib/common/nls");
56
- const window_service_1 = require("@theia/core/lib/browser/window/window-service");
57
- const monaco = require("@theia/monaco-editor-core");
58
- const plugin_vscode_uri_1 = require("../common/plugin-vscode-uri");
59
- const vscode_theia_menu_mappings_1 = require("@theia/plugin-ext/lib/main/browser/menus/vscode-theia-menu-mappings");
60
- var VscodeCommands;
61
- (function (VscodeCommands) {
62
- VscodeCommands.OPEN = {
63
- id: 'vscode.open'
64
- };
65
- VscodeCommands.OPEN_WITH = {
66
- id: 'vscode.openWith'
67
- };
68
- VscodeCommands.OPEN_FOLDER = {
69
- id: 'vscode.openFolder'
70
- };
71
- VscodeCommands.DIFF = {
72
- id: 'vscode.diff'
73
- };
74
- VscodeCommands.INSTALL_FROM_VSIX = {
75
- id: 'workbench.extensions.installExtension'
76
- };
77
- })(VscodeCommands = exports.VscodeCommands || (exports.VscodeCommands = {}));
78
- let PluginVscodeCommandsContribution = class PluginVscodeCommandsContribution {
79
- async openWith(commandId, resource, columnOrOptions, openerId) {
80
- if (!resource) {
81
- throw new Error(`${commandId} command requires at least URI argument.`);
82
- }
83
- if (!vscode_uri_1.URI.isUri(resource)) {
84
- throw new Error(`Invalid argument for ${commandId} command with URI argument. Found ${resource}`);
85
- }
86
- let options;
87
- if (typeof columnOrOptions === 'number') {
88
- options = {
89
- viewColumn: columnOrOptions
90
- };
91
- }
92
- else if (columnOrOptions) {
93
- options = Object.assign({}, columnOrOptions);
94
- }
95
- const uri = new uri_1.default(resource);
96
- const editorOptions = documents_main_1.DocumentsMainImpl.toEditorOpenerOptions(this.shell, options);
97
- let openHandler;
98
- if (typeof openerId === 'string') {
99
- const lowerViewType = openerId.toLowerCase();
100
- const openers = await this.openerService.getOpeners();
101
- for (const opener of openers) {
102
- const idLowerCase = opener.id.toLowerCase();
103
- if (lowerViewType === idLowerCase) {
104
- openHandler = opener;
105
- break;
106
- }
107
- }
108
- }
109
- else {
110
- openHandler = await this.openerService.getOpener(uri, editorOptions);
111
- }
112
- if (openHandler) {
113
- await openHandler.open(uri, editorOptions);
114
- return true;
115
- }
116
- return false;
117
- }
118
- registerCommands(commands) {
119
- commands.registerCommand(VscodeCommands.OPEN, {
120
- isVisible: () => false,
121
- execute: async (resource, columnOrOptions) => {
122
- const result = await this.openWith(VscodeCommands.OPEN.id, resource, columnOrOptions);
123
- if (!result) {
124
- throw new Error(`Could not find an editor for ${resource}`);
125
- }
126
- }
127
- });
128
- commands.registerCommand(VscodeCommands.OPEN_WITH, {
129
- isVisible: () => false,
130
- execute: async (resource, viewType, columnOrOptions) => {
131
- if (!viewType) {
132
- throw new Error(`Running the contributed command: ${VscodeCommands.OPEN_WITH} failed.`);
133
- }
134
- if (viewType.toLowerCase() === 'default') {
135
- return commands.executeCommand(VscodeCommands.OPEN.id, resource, columnOrOptions);
136
- }
137
- let result = await this.openWith(VscodeCommands.OPEN_WITH.id, resource, columnOrOptions, viewType);
138
- if (!result) {
139
- result = await this.openWith(VscodeCommands.OPEN_WITH.id, resource, columnOrOptions, custom_editor_opener_1.CustomEditorOpener.toCustomEditorId(viewType));
140
- }
141
- if (!result) {
142
- throw new Error(`Could not find an editor for '${viewType}'`);
143
- }
144
- }
145
- });
146
- commands.registerCommand(VscodeCommands.OPEN_FOLDER, {
147
- isVisible: () => false,
148
- execute: async (resource, arg = {}) => {
149
- if (!resource) {
150
- return commands.executeCommand(browser_3.WorkspaceCommands.OPEN_WORKSPACE.id);
151
- }
152
- if (!vscode_uri_1.URI.isUri(resource)) {
153
- throw new Error(`Invalid argument for ${VscodeCommands.OPEN_FOLDER.id} command with URI argument. Found ${resource}`);
154
- }
155
- let options;
156
- if (typeof arg === 'boolean') {
157
- options = { preserveWindow: !arg };
158
- }
159
- else {
160
- options = { preserveWindow: !arg.forceNewWindow };
161
- }
162
- this.workspaceService.open(new uri_1.default(resource), options);
163
- }
164
- });
165
- commands.registerCommand(VscodeCommands.DIFF, {
166
- isVisible: () => false,
167
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
- execute: async (left, right, label, options) => {
169
- if (!left || !right) {
170
- throw new Error(`${VscodeCommands.DIFF} command requires at least two URI arguments. Found left=${left}, right=${right} as arguments`);
171
- }
172
- if (!vscode_uri_1.URI.isUri(left)) {
173
- throw new Error(`Invalid argument for ${VscodeCommands.DIFF.id} command with left argument. Expecting URI left type but found ${left}`);
174
- }
175
- if (!vscode_uri_1.URI.isUri(right)) {
176
- throw new Error(`Invalid argument for ${VscodeCommands.DIFF.id} command with right argument. Expecting URI right type but found ${right}`);
177
- }
178
- const leftURI = new uri_1.default(left);
179
- const editorOptions = documents_main_1.DocumentsMainImpl.toEditorOpenerOptions(this.shell, options);
180
- await this.diffService.openDiffEditor(leftURI, new uri_1.default(right), label, editorOptions);
181
- }
182
- });
183
- // https://code.visualstudio.com/docs/getstarted/keybindings#_navigation
184
- /*
185
- * internally, in VS Code, any widget opened in the main area is represented as an editor
186
- * operations below apply to them, but not to side-bar widgets, like the explorer
187
- *
188
- * in Theia, there are not such difference and any widget can be put in any area
189
- * because of it we filter out editors from views based on `NavigatableWidget.is`
190
- * and apply actions only to them
191
- */
192
- if (!core_1.environment.electron.is() || core_1.isOSX) {
193
- commands.registerCommand({ id: 'workbench.action.files.openFileFolder' }, {
194
- execute: () => commands.executeCommand(browser_3.WorkspaceCommands.OPEN.id)
195
- });
196
- }
197
- commands.registerCommand({ id: 'workbench.action.files.openFile' }, {
198
- execute: () => commands.executeCommand(browser_3.WorkspaceCommands.OPEN_FILE.id)
199
- });
200
- commands.registerCommand({ id: 'workbench.action.files.openFolder' }, {
201
- execute: () => commands.executeCommand(browser_3.WorkspaceCommands.OPEN_FOLDER.id)
202
- });
203
- commands.registerCommand({ id: 'workbench.action.addRootFolder' }, {
204
- execute: () => commands.executeCommand(browser_3.WorkspaceCommands.ADD_FOLDER.id)
205
- });
206
- commands.registerCommand({ id: 'workbench.action.saveWorkspaceAs' }, {
207
- execute: () => commands.executeCommand(browser_3.WorkspaceCommands.SAVE_WORKSPACE_AS.id)
208
- });
209
- commands.registerCommand({ id: 'workbench.action.gotoLine' }, {
210
- execute: () => commands.executeCommand(browser_2.EditorCommands.GOTO_LINE_COLUMN.id)
211
- });
212
- commands.registerCommand({ id: 'workbench.action.quickOpen' }, {
213
- execute: (prefix) => this.quickInput.open(typeof prefix === 'string' ? prefix : '')
214
- });
215
- commands.registerCommand({ id: 'workbench.action.openSettings' }, {
216
- execute: (query) => commands.executeCommand(browser_1.CommonCommands.OPEN_PREFERENCES.id, query)
217
- });
218
- commands.registerCommand({ id: 'workbench.action.openWorkspaceConfigFile' }, {
219
- execute: () => commands.executeCommand(browser_3.WorkspaceCommands.OPEN_WORKSPACE_FILE.id)
220
- });
221
- commands.registerCommand({ id: 'workbench.files.action.refreshFilesExplorer' }, {
222
- execute: () => commands.executeCommand(navigator_contribution_1.FileNavigatorCommands.REFRESH_NAVIGATOR.id)
223
- });
224
- commands.registerCommand({ id: VscodeCommands.INSTALL_FROM_VSIX.id }, {
225
- execute: async (vsixUriOrExtensionId) => {
226
- if (typeof vsixUriOrExtensionId === 'string') {
227
- await this.pluginServer.deploy(plugin_vscode_uri_1.VSCodeExtensionUri.toVsxExtensionUriString(vsixUriOrExtensionId));
228
- }
229
- else {
230
- const uriPath = (0, type_converters_1.isUriComponents)(vsixUriOrExtensionId) ? vscode_uri_1.URI.revive(vsixUriOrExtensionId).fsPath : await this.fileService.fsPath(vsixUriOrExtensionId);
231
- await this.pluginServer.deploy(`local-file:${uriPath}`);
232
- }
233
- }
234
- });
235
- commands.registerCommand({ id: 'workbench.action.files.save', }, {
236
- execute: (uri) => {
237
- if (uri) {
238
- const uriString = uri.toString();
239
- const widget = this.shell.widgets.find(w => {
240
- const resourceUri = browser_1.Saveable.is(w) && browser_1.NavigatableWidget.is(w) && w.getResourceUri();
241
- return (resourceUri && resourceUri.toString()) === uriString;
242
- });
243
- if (browser_1.Saveable.is(widget)) {
244
- browser_1.Saveable.save(widget);
245
- }
246
- }
247
- else {
248
- this.shell.save();
249
- }
250
- }
251
- });
252
- commands.registerCommand({ id: 'workbench.action.files.saveAll', }, {
253
- execute: () => this.shell.saveAll()
254
- });
255
- commands.registerCommand({ id: 'workbench.action.closeActiveEditor' }, {
256
- execute: () => commands.executeCommand(browser_1.CommonCommands.CLOSE_MAIN_TAB.id)
257
- });
258
- commands.registerCommand({ id: 'workbench.action.closeOtherEditors' }, {
259
- execute: async (uri) => {
260
- let editor = this.editorManager.currentEditor || this.shell.currentWidget;
261
- if (uri) {
262
- const uriString = uri.toString();
263
- editor = this.editorManager.all.find(e => {
264
- const resourceUri = e.getResourceUri();
265
- return (resourceUri && resourceUri.toString()) === uriString;
266
- });
267
- }
268
- const toClose = this.shell.widgets.filter(widget => widget !== editor && this.codeEditorWidgetUtil.is(widget));
269
- await this.shell.closeMany(toClose);
270
- }
271
- });
272
- const performActionOnGroup = (cb, uri) => {
273
- let editor = this.editorManager.currentEditor || this.shell.currentWidget;
274
- if (uri) {
275
- const uriString = uri.toString();
276
- editor = this.editorManager.all.find(e => {
277
- const resourceUri = e.getResourceUri();
278
- return (resourceUri && resourceUri.toString()) === uriString;
279
- });
280
- }
281
- if (editor) {
282
- const tabBar = this.shell.getTabBarFor(editor);
283
- if (tabBar) {
284
- cb(tabBar, ({ owner }) => this.codeEditorWidgetUtil.is(owner));
285
- }
286
- }
287
- };
288
- commands.registerCommand({
289
- id: 'workbench.action.closeEditorsInGroup',
290
- label: nls_1.nls.localizeByDefault('Close All Editors in Group')
291
- }, {
292
- execute: (uri) => performActionOnGroup(this.shell.closeTabs, uri)
293
- });
294
- commands.registerCommand({
295
- id: 'workbench.files.saveAllInGroup',
296
- label: nls_1.nls.localizeByDefault('Save All in Group')
297
- }, {
298
- execute: (uri) => performActionOnGroup(this.shell.saveTabs, uri)
299
- });
300
- commands.registerCommand({ id: 'workbench.action.closeEditorsInOtherGroups' }, {
301
- execute: () => {
302
- const editor = this.editorManager.currentEditor || this.shell.currentWidget;
303
- if (editor) {
304
- const editorTabBar = this.shell.getTabBarFor(editor);
305
- for (const tabBar of this.shell.allTabBars) {
306
- if (tabBar !== editorTabBar) {
307
- this.shell.closeTabs(tabBar, ({ owner }) => this.codeEditorWidgetUtil.is(owner));
308
- }
309
- }
310
- }
311
- }
312
- });
313
- commands.registerCommand({ id: 'workbench.action.closeEditorsToTheLeft' }, {
314
- execute: () => {
315
- const editor = this.editorManager.currentEditor || this.shell.currentWidget;
316
- if (editor) {
317
- const tabBar = this.shell.getTabBarFor(editor);
318
- if (tabBar) {
319
- let left = true;
320
- this.shell.closeTabs(tabBar, ({ owner }) => {
321
- if (owner === editor) {
322
- left = false;
323
- return false;
324
- }
325
- return left && this.codeEditorWidgetUtil.is(owner);
326
- });
327
- }
328
- }
329
- }
330
- });
331
- commands.registerCommand({ id: 'workbench.action.closeEditorsToTheRight' }, {
332
- execute: () => {
333
- const editor = this.editorManager.currentEditor || this.shell.currentWidget;
334
- if (editor) {
335
- const tabBar = this.shell.getTabBarFor(editor);
336
- if (tabBar) {
337
- let left = true;
338
- this.shell.closeTabs(tabBar, ({ owner }) => {
339
- if (owner === editor) {
340
- left = false;
341
- return false;
342
- }
343
- return !left && this.codeEditorWidgetUtil.is(owner);
344
- });
345
- }
346
- }
347
- }
348
- });
349
- commands.registerCommand({ id: 'workbench.action.closeAllEditors' }, {
350
- execute: async () => {
351
- const toClose = this.shell.widgets.filter(widget => this.codeEditorWidgetUtil.is(widget));
352
- await this.shell.closeMany(toClose);
353
- }
354
- });
355
- commands.registerCommand({ id: 'workbench.action.nextEditor' }, {
356
- execute: () => this.shell.activateNextTab()
357
- });
358
- commands.registerCommand({ id: 'workbench.action.previousEditor' }, {
359
- execute: () => this.shell.activatePreviousTab()
360
- });
361
- commands.registerCommand({ id: 'workbench.action.navigateBack' }, {
362
- execute: () => commands.executeCommand(browser_2.EditorCommands.GO_BACK.id)
363
- });
364
- commands.registerCommand({ id: 'workbench.action.navigateForward' }, {
365
- execute: () => commands.executeCommand(browser_2.EditorCommands.GO_FORWARD.id)
366
- });
367
- commands.registerCommand({ id: 'workbench.action.navigateToLastEditLocation' }, {
368
- execute: () => commands.executeCommand(browser_2.EditorCommands.GO_LAST_EDIT.id)
369
- });
370
- commands.registerCommand({ id: 'openInTerminal' }, {
371
- execute: (resource) => this.terminalContribution.openInTerminal(new uri_1.default(resource.toString()))
372
- });
373
- commands.registerCommand({ id: 'workbench.action.reloadWindow' }, {
374
- execute: () => {
375
- this.windowService.reload();
376
- }
377
- });
378
- /**
379
- * TODO:
380
- * Open Next: workbench.action.openNextRecentlyUsedEditorInGroup
381
- * Open Previous: workbench.action.openPreviousRecentlyUsedEditorInGroup
382
- * Copy Path of Active File: workbench.action.files.copyPathOfActiveFile
383
- * Reveal Active File in Windows: workbench.action.files.revealActiveFileInWindows
384
- * Show Opened File in New Window: workbench.action.files.showOpenedFileInNewWindow
385
- * Compare Opened File With: workbench.files.action.compareFileWith
386
- */
387
- // Register built-in language service commands
388
- // see https://code.visualstudio.com/api/references/commands
389
- /* eslint-disable @typescript-eslint/no-explicit-any */
390
- // TODO register other `vscode.execute...` commands.
391
- // see https://github.com/microsoft/vscode/blob/master/src/vs/workbench/api/common/extHostApiCommands.ts
392
- commands.registerCommand({
393
- id: 'vscode.executeDefinitionProvider'
394
- }, {
395
- execute: ((resource, position) => commands.executeCommand('_executeDefinitionProvider', monaco.Uri.from(resource), position))
396
- });
397
- commands.registerCommand({
398
- id: 'vscode.executeDeclarationProvider'
399
- }, {
400
- execute: ((resource, position) => commands.executeCommand('_executeDeclarationProvider', monaco.Uri.from(resource), position))
401
- });
402
- commands.registerCommand({
403
- id: 'vscode.executeTypeDefinitionProvider'
404
- }, {
405
- execute: ((resource, position) => commands.executeCommand('_executeTypeDefinitionProvider', monaco.Uri.from(resource), position))
406
- });
407
- commands.registerCommand({
408
- id: 'vscode.executeImplementationProvider'
409
- }, {
410
- execute: ((resource, position) => commands.executeCommand('_executeImplementationProvider', monaco.Uri.from(resource), position))
411
- });
412
- commands.registerCommand({
413
- id: 'vscode.executeHoverProvider'
414
- }, {
415
- execute: ((resource, position) => commands.executeCommand('_executeHoverProvider', monaco.Uri.from(resource), position))
416
- });
417
- commands.registerCommand({
418
- id: 'vscode.executeDocumentHighlights'
419
- }, {
420
- execute: ((resource, position) => commands.executeCommand('_executeDocumentHighlights', monaco.Uri.from(resource), position))
421
- });
422
- commands.registerCommand({
423
- id: 'vscode.executeReferenceProvider'
424
- }, {
425
- execute: ((resource, position) => commands.executeCommand('_executeReferenceProvider', monaco.Uri.from(resource), position))
426
- });
427
- commands.registerCommand({
428
- id: 'vscode.executeDocumentSymbolProvider'
429
- }, {
430
- execute: (resource) => commands.executeCommand('_executeDocumentSymbolProvider', monaco.Uri.parse(resource.toString())).then((value) => {
431
- if (!Array.isArray(value) || value === undefined) {
432
- return undefined;
433
- }
434
- return value.map(loc => (0, type_converters_1.toDocumentSymbol)(loc));
435
- })
436
- });
437
- commands.registerCommand({
438
- id: 'vscode.executeFormatDocumentProvider'
439
- }, {
440
- execute: ((resource, options) => commands.executeCommand('_executeFormatDocumentProvider', monaco.Uri.from(resource), options))
441
- });
442
- commands.registerCommand({
443
- id: 'vscode.executeFormatRangeProvider'
444
- }, {
445
- execute: ((resource, range, options) => commands.executeCommand('_executeFormatRangeProvider', monaco.Uri.from(resource), range, options))
446
- });
447
- commands.registerCommand({
448
- id: 'vscode.executeFormatOnTypeProvider'
449
- }, {
450
- execute: ((resource, position, ch, options) => commands.executeCommand('_executeFormatOnTypeProvider', monaco.Uri.from(resource), position, ch, options))
451
- });
452
- commands.registerCommand({
453
- id: 'vscode.prepareCallHierarchy'
454
- }, {
455
- execute: async (resource, position) => {
456
- const provider = await this.getCallHierarchyServiceForUri(resource);
457
- const definition = await (provider === null || provider === void 0 ? void 0 : provider.getRootDefinition(resource.path, (0, type_converters_1.toPosition)(position), new core_1.CancellationTokenSource().token));
458
- if (definition) {
459
- return definition.items.map(item => (0, hierarchy_types_converters_1.fromItemHierarchyDefinition)(item));
460
- }
461
- ;
462
- return [];
463
- }
464
- });
465
- commands.registerCommand({
466
- id: 'vscode.provideIncomingCalls'
467
- }, {
468
- execute: async (item) => {
469
- const resource = vscode_uri_1.URI.from(item.uri);
470
- const provider = await this.getCallHierarchyServiceForUri(resource);
471
- const incomingCalls = await (provider === null || provider === void 0 ? void 0 : provider.getCallers((0, hierarchy_types_converters_1.toItemHierarchyDefinition)(item), new core_1.CancellationTokenSource().token));
472
- if (incomingCalls) {
473
- return incomingCalls.map(hierarchy_types_converters_1.fromCallHierarchyCallerToModelCallHierarchyIncomingCall);
474
- }
475
- return [];
476
- },
477
- });
478
- commands.registerCommand({
479
- id: 'vscode.provideOutgoingCalls'
480
- }, {
481
- execute: async (item) => {
482
- var _a;
483
- const resource = vscode_uri_1.URI.from(item.uri);
484
- const provider = await this.getCallHierarchyServiceForUri(resource);
485
- const outgoingCalls = await ((_a = provider === null || provider === void 0 ? void 0 : provider.getCallees) === null || _a === void 0 ? void 0 : _a.call(provider, (0, hierarchy_types_converters_1.toItemHierarchyDefinition)(item), new core_1.CancellationTokenSource().token));
486
- if (outgoingCalls) {
487
- return outgoingCalls.map(hierarchy_types_converters_1.fromCallHierarchyCalleeToModelCallHierarchyOutgoingCall);
488
- }
489
- return [];
490
- }
491
- });
492
- commands.registerCommand({
493
- id: 'vscode.prepareTypeHierarchy'
494
- }, {
495
- execute: async (resource, position) => {
496
- const provider = await this.getTypeHierarchyServiceForUri(resource);
497
- const session = await (provider === null || provider === void 0 ? void 0 : provider.prepareSession(resource.path, (0, type_converters_1.toPosition)(position), new core_1.CancellationTokenSource().token));
498
- return session ? session.items.map(item => (0, hierarchy_types_converters_1.fromItemHierarchyDefinition)(item)) : [];
499
- }
500
- });
501
- commands.registerCommand({
502
- id: 'vscode.provideSupertypes'
503
- }, {
504
- execute: async (item) => {
505
- if (!item._sessionId || !item._itemId) {
506
- return [];
507
- }
508
- const resource = vscode_uri_1.URI.from(item.uri);
509
- const provider = await this.getTypeHierarchyServiceForUri(resource);
510
- const items = await (provider === null || provider === void 0 ? void 0 : provider.provideSuperTypes(item._sessionId, item._itemId, new core_1.CancellationTokenSource().token));
511
- return (items ? items : []).map(typeItem => (0, hierarchy_types_converters_1.fromItemHierarchyDefinition)(typeItem));
512
- }
513
- });
514
- commands.registerCommand({
515
- id: 'vscode.provideSubtypes'
516
- }, {
517
- execute: async (item) => {
518
- if (!item._sessionId || !item._itemId) {
519
- return [];
520
- }
521
- const resource = vscode_uri_1.URI.from(item.uri);
522
- const provider = await this.getTypeHierarchyServiceForUri(resource);
523
- const items = await (provider === null || provider === void 0 ? void 0 : provider.provideSubTypes(item._sessionId, item._itemId, new core_1.CancellationTokenSource().token));
524
- return (items ? items : []).map(typeItem => (0, hierarchy_types_converters_1.fromItemHierarchyDefinition)(typeItem));
525
- }
526
- });
527
- commands.registerCommand({
528
- id: 'workbench.action.openRecent'
529
- }, {
530
- execute: () => this.quickOpenWorkspace.select()
531
- });
532
- commands.registerCommand({
533
- id: 'explorer.newFolder'
534
- }, {
535
- execute: () => commands.executeCommand(browser_3.WorkspaceCommands.NEW_FOLDER.id)
536
- });
537
- commands.registerCommand({
538
- id: 'workbench.action.terminal.sendSequence'
539
- }, {
540
- execute: (args) => {
541
- if (args === undefined || args.text === undefined) {
542
- return;
543
- }
544
- const currentTerminal = this.terminalService.currentTerminal;
545
- if (currentTerminal === undefined) {
546
- return;
547
- }
548
- currentTerminal.sendText(args.text);
549
- }
550
- });
551
- commands.registerCommand({
552
- id: 'workbench.action.terminal.kill'
553
- }, {
554
- execute: () => {
555
- const currentTerminal = this.terminalService.currentTerminal;
556
- if (currentTerminal === undefined) {
557
- return;
558
- }
559
- currentTerminal.dispose();
560
- }
561
- });
562
- commands.registerCommand({
563
- id: 'workbench.view.explorer'
564
- }, {
565
- execute: () => commands.executeCommand(navigator_contribution_1.FileNavigatorCommands.FOCUS.id)
566
- });
567
- commands.registerCommand({
568
- id: 'copyFilePath'
569
- }, {
570
- execute: () => commands.executeCommand(browser_1.CommonCommands.COPY_PATH.id)
571
- });
572
- commands.registerCommand({
573
- id: 'copyRelativeFilePath'
574
- }, {
575
- execute: () => commands.executeCommand(browser_3.WorkspaceCommands.COPY_RELATIVE_FILE_PATH.id)
576
- });
577
- commands.registerCommand({
578
- id: 'revealInExplorer'
579
- }, {
580
- execute: async (resource) => {
581
- if (!vscode_uri_1.URI.isUri(resource)) {
582
- return;
583
- }
584
- let navigator = await this.shell.revealWidget(browser_4.FILE_NAVIGATOR_ID);
585
- if (!navigator) {
586
- await this.commandService.executeCommand(navigator_contribution_1.FILE_NAVIGATOR_TOGGLE_COMMAND_ID);
587
- navigator = await this.shell.revealWidget(browser_4.FILE_NAVIGATOR_ID);
588
- }
589
- if (navigator instanceof browser_4.FileNavigatorWidget) {
590
- const model = navigator.model;
591
- const node = await model.revealFile(new uri_1.default(resource));
592
- if (tree_selection_1.SelectableTreeNode.is(node)) {
593
- model.selectNode(node);
594
- }
595
- }
596
- }
597
- });
598
- commands.registerCommand({
599
- id: 'workbench.experimental.requestUsbDevice'
600
- }, {
601
- execute: async (options) => {
602
- var _a;
603
- const usb = navigator.usb;
604
- if (!usb) {
605
- return undefined;
606
- }
607
- const device = await usb.requestDevice({ filters: (_a = options === null || options === void 0 ? void 0 : options.filters) !== null && _a !== void 0 ? _a : [] });
608
- if (!device) {
609
- return undefined;
610
- }
611
- return {
612
- deviceClass: device.deviceClass,
613
- deviceProtocol: device.deviceProtocol,
614
- deviceSubclass: device.deviceSubclass,
615
- deviceVersionMajor: device.deviceVersionMajor,
616
- deviceVersionMinor: device.deviceVersionMinor,
617
- deviceVersionSubminor: device.deviceVersionSubminor,
618
- manufacturerName: device.manufacturerName,
619
- productId: device.productId,
620
- productName: device.productName,
621
- serialNumber: device.serialNumber,
622
- usbVersionMajor: device.usbVersionMajor,
623
- usbVersionMinor: device.usbVersionMinor,
624
- usbVersionSubminor: device.usbVersionSubminor,
625
- vendorId: device.vendorId,
626
- };
627
- }
628
- });
629
- commands.registerCommand({
630
- id: 'workbench.experimental.requestSerialPort'
631
- }, {
632
- execute: async (options) => {
633
- var _a;
634
- const serial = navigator.serial;
635
- if (!serial) {
636
- return undefined;
637
- }
638
- const port = await serial.requestPort({ filters: (_a = options === null || options === void 0 ? void 0 : options.filters) !== null && _a !== void 0 ? _a : [] });
639
- if (!port) {
640
- return undefined;
641
- }
642
- const info = port.getInfo();
643
- return {
644
- usbVendorId: info.usbVendorId,
645
- usbProductId: info.usbProductId
646
- };
647
- }
648
- });
649
- commands.registerCommand({
650
- id: 'workbench.experimental.requestHidDevice'
651
- }, {
652
- execute: async (options) => {
653
- var _a;
654
- const hid = navigator.hid;
655
- if (!hid) {
656
- return undefined;
657
- }
658
- const devices = await hid.requestDevice({ filters: (_a = options === null || options === void 0 ? void 0 : options.filters) !== null && _a !== void 0 ? _a : [] });
659
- if (!devices.length) {
660
- return undefined;
661
- }
662
- const device = devices[0];
663
- return {
664
- opened: device.opened,
665
- vendorId: device.vendorId,
666
- productId: device.productId,
667
- productName: device.productName,
668
- collections: device.collections
669
- };
670
- }
671
- });
672
- }
673
- async resolveLanguageId(resource) {
674
- const reference = await this.textModelService.createModelReference(resource);
675
- const languageId = reference.object.languageId;
676
- reference.dispose();
677
- return languageId;
678
- }
679
- async getCallHierarchyServiceForUri(resource) {
680
- const languageId = await this.resolveLanguageId(resource);
681
- return this.callHierarchyProvider.get(languageId, new uri_1.default(resource));
682
- }
683
- async getTypeHierarchyServiceForUri(resource) {
684
- const languageId = await this.resolveLanguageId(resource);
685
- return this.typeHierarchyProvider.get(languageId, new uri_1.default(resource));
686
- }
687
- };
688
- __decorate([
689
- (0, inversify_1.inject)(command_1.CommandService),
690
- __metadata("design:type", Object)
691
- ], PluginVscodeCommandsContribution.prototype, "commandService", void 0);
692
- __decorate([
693
- (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
694
- __metadata("design:type", Object)
695
- ], PluginVscodeCommandsContribution.prototype, "contextKeyService", void 0);
696
- __decorate([
697
- (0, inversify_1.inject)(browser_2.EditorManager),
698
- __metadata("design:type", browser_2.EditorManager)
699
- ], PluginVscodeCommandsContribution.prototype, "editorManager", void 0);
700
- __decorate([
701
- (0, inversify_1.inject)(browser_1.ApplicationShell),
702
- __metadata("design:type", browser_1.ApplicationShell)
703
- ], PluginVscodeCommandsContribution.prototype, "shell", void 0);
704
- __decorate([
705
- (0, inversify_1.inject)(diff_service_1.DiffService),
706
- __metadata("design:type", diff_service_1.DiffService)
707
- ], PluginVscodeCommandsContribution.prototype, "diffService", void 0);
708
- __decorate([
709
- (0, inversify_1.inject)(browser_1.OpenerService),
710
- __metadata("design:type", Object)
711
- ], PluginVscodeCommandsContribution.prototype, "openerService", void 0);
712
- __decorate([
713
- (0, inversify_1.inject)(application_shell_mouse_tracker_1.ApplicationShellMouseTracker),
714
- __metadata("design:type", application_shell_mouse_tracker_1.ApplicationShellMouseTracker)
715
- ], PluginVscodeCommandsContribution.prototype, "mouseTracker", void 0);
716
- __decorate([
717
- (0, inversify_1.inject)(browser_1.QuickInputService),
718
- (0, inversify_1.optional)(),
719
- __metadata("design:type", Object)
720
- ], PluginVscodeCommandsContribution.prototype, "quickInput", void 0);
721
- __decorate([
722
- (0, inversify_1.inject)(workspace_service_1.WorkspaceService),
723
- __metadata("design:type", workspace_service_1.WorkspaceService)
724
- ], PluginVscodeCommandsContribution.prototype, "workspaceService", void 0);
725
- __decorate([
726
- (0, inversify_1.inject)(terminal_frontend_contribution_1.TerminalFrontendContribution),
727
- __metadata("design:type", terminal_frontend_contribution_1.TerminalFrontendContribution)
728
- ], PluginVscodeCommandsContribution.prototype, "terminalContribution", void 0);
729
- __decorate([
730
- (0, inversify_1.inject)(quick_open_workspace_1.QuickOpenWorkspace),
731
- __metadata("design:type", quick_open_workspace_1.QuickOpenWorkspace)
732
- ], PluginVscodeCommandsContribution.prototype, "quickOpenWorkspace", void 0);
733
- __decorate([
734
- (0, inversify_1.inject)(terminal_service_1.TerminalService),
735
- __metadata("design:type", Object)
736
- ], PluginVscodeCommandsContribution.prototype, "terminalService", void 0);
737
- __decorate([
738
- (0, inversify_1.inject)(vscode_theia_menu_mappings_1.CodeEditorWidgetUtil),
739
- __metadata("design:type", vscode_theia_menu_mappings_1.CodeEditorWidgetUtil)
740
- ], PluginVscodeCommandsContribution.prototype, "codeEditorWidgetUtil", void 0);
741
- __decorate([
742
- (0, inversify_1.inject)(plugin_protocol_1.PluginServer),
743
- __metadata("design:type", Object)
744
- ], PluginVscodeCommandsContribution.prototype, "pluginServer", void 0);
745
- __decorate([
746
- (0, inversify_1.inject)(file_service_1.FileService),
747
- __metadata("design:type", file_service_1.FileService)
748
- ], PluginVscodeCommandsContribution.prototype, "fileService", void 0);
749
- __decorate([
750
- (0, inversify_1.inject)(browser_5.CallHierarchyServiceProvider),
751
- __metadata("design:type", browser_5.CallHierarchyServiceProvider)
752
- ], PluginVscodeCommandsContribution.prototype, "callHierarchyProvider", void 0);
753
- __decorate([
754
- (0, inversify_1.inject)(browser_6.TypeHierarchyServiceProvider),
755
- __metadata("design:type", browser_6.TypeHierarchyServiceProvider)
756
- ], PluginVscodeCommandsContribution.prototype, "typeHierarchyProvider", void 0);
757
- __decorate([
758
- (0, inversify_1.inject)(monaco_text_model_service_1.MonacoTextModelService),
759
- __metadata("design:type", monaco_text_model_service_1.MonacoTextModelService)
760
- ], PluginVscodeCommandsContribution.prototype, "textModelService", void 0);
761
- __decorate([
762
- (0, inversify_1.inject)(window_service_1.WindowService),
763
- __metadata("design:type", Object)
764
- ], PluginVscodeCommandsContribution.prototype, "windowService", void 0);
765
- PluginVscodeCommandsContribution = __decorate([
766
- (0, inversify_1.injectable)()
767
- ], PluginVscodeCommandsContribution);
768
- exports.PluginVscodeCommandsContribution = PluginVscodeCommandsContribution;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2018 Red Hat, Inc. and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ Object.defineProperty(exports, "__esModule", { value: true });
27
+ exports.PluginVscodeCommandsContribution = exports.VscodeCommands = void 0;
28
+ const core_1 = require("@theia/core");
29
+ const browser_1 = require("@theia/core/lib/browser");
30
+ const context_key_service_1 = require("@theia/core/lib/browser/context-key-service");
31
+ const application_shell_mouse_tracker_1 = require("@theia/core/lib/browser/shell/application-shell-mouse-tracker");
32
+ const command_1 = require("@theia/core/lib/common/command");
33
+ const uri_1 = require("@theia/core/lib/common/uri");
34
+ const browser_2 = require("@theia/editor/lib/browser");
35
+ const documents_main_1 = require("@theia/plugin-ext/lib/main/browser/documents-main");
36
+ const type_converters_1 = require("@theia/plugin-ext/lib/plugin/type-converters");
37
+ const browser_3 = require("@theia/workspace/lib/browser");
38
+ const workspace_service_1 = require("@theia/workspace/lib/browser/workspace-service");
39
+ const diff_service_1 = require("@theia/workspace/lib/browser/diff-service");
40
+ const inversify_1 = require("@theia/core/shared/inversify");
41
+ const vscode_uri_1 = require("@theia/core/shared/vscode-uri");
42
+ const plugin_protocol_1 = require("@theia/plugin-ext/lib/common/plugin-protocol");
43
+ const terminal_frontend_contribution_1 = require("@theia/terminal/lib/browser/terminal-frontend-contribution");
44
+ const quick_open_workspace_1 = require("@theia/workspace/lib/browser/quick-open-workspace");
45
+ const terminal_service_1 = require("@theia/terminal/lib/browser/base/terminal-service");
46
+ const navigator_contribution_1 = require("@theia/navigator/lib/browser/navigator-contribution");
47
+ const browser_4 = require("@theia/navigator/lib/browser");
48
+ const tree_selection_1 = require("@theia/core/lib/browser/tree/tree-selection");
49
+ const file_service_1 = require("@theia/filesystem/lib/browser/file-service");
50
+ const browser_5 = require("@theia/callhierarchy/lib/browser");
51
+ const browser_6 = require("@theia/typehierarchy/lib/browser");
52
+ const monaco_text_model_service_1 = require("@theia/monaco/lib/browser/monaco-text-model-service");
53
+ const hierarchy_types_converters_1 = require("@theia/plugin-ext/lib/main/browser/hierarchy/hierarchy-types-converters");
54
+ const custom_editor_opener_1 = require("@theia/plugin-ext/lib/main/browser/custom-editors/custom-editor-opener");
55
+ const nls_1 = require("@theia/core/lib/common/nls");
56
+ const window_service_1 = require("@theia/core/lib/browser/window/window-service");
57
+ const monaco = require("@theia/monaco-editor-core");
58
+ const plugin_vscode_uri_1 = require("../common/plugin-vscode-uri");
59
+ const vscode_theia_menu_mappings_1 = require("@theia/plugin-ext/lib/main/browser/menus/vscode-theia-menu-mappings");
60
+ var VscodeCommands;
61
+ (function (VscodeCommands) {
62
+ VscodeCommands.OPEN = {
63
+ id: 'vscode.open'
64
+ };
65
+ VscodeCommands.OPEN_WITH = {
66
+ id: 'vscode.openWith'
67
+ };
68
+ VscodeCommands.OPEN_FOLDER = {
69
+ id: 'vscode.openFolder'
70
+ };
71
+ VscodeCommands.DIFF = {
72
+ id: 'vscode.diff'
73
+ };
74
+ VscodeCommands.INSTALL_FROM_VSIX = {
75
+ id: 'workbench.extensions.installExtension'
76
+ };
77
+ })(VscodeCommands = exports.VscodeCommands || (exports.VscodeCommands = {}));
78
+ let PluginVscodeCommandsContribution = class PluginVscodeCommandsContribution {
79
+ async openWith(commandId, resource, columnOrOptions, openerId) {
80
+ if (!resource) {
81
+ throw new Error(`${commandId} command requires at least URI argument.`);
82
+ }
83
+ if (!vscode_uri_1.URI.isUri(resource)) {
84
+ throw new Error(`Invalid argument for ${commandId} command with URI argument. Found ${resource}`);
85
+ }
86
+ let options;
87
+ if (typeof columnOrOptions === 'number') {
88
+ options = {
89
+ viewColumn: columnOrOptions
90
+ };
91
+ }
92
+ else if (columnOrOptions) {
93
+ options = Object.assign({}, columnOrOptions);
94
+ }
95
+ const uri = new uri_1.default(resource);
96
+ const editorOptions = documents_main_1.DocumentsMainImpl.toEditorOpenerOptions(this.shell, options);
97
+ let openHandler;
98
+ if (typeof openerId === 'string') {
99
+ const lowerViewType = openerId.toLowerCase();
100
+ const openers = await this.openerService.getOpeners();
101
+ for (const opener of openers) {
102
+ const idLowerCase = opener.id.toLowerCase();
103
+ if (lowerViewType === idLowerCase) {
104
+ openHandler = opener;
105
+ break;
106
+ }
107
+ }
108
+ }
109
+ else {
110
+ openHandler = await this.openerService.getOpener(uri, editorOptions);
111
+ }
112
+ if (openHandler) {
113
+ await openHandler.open(uri, editorOptions);
114
+ return true;
115
+ }
116
+ return false;
117
+ }
118
+ registerCommands(commands) {
119
+ commands.registerCommand(VscodeCommands.OPEN, {
120
+ isVisible: () => false,
121
+ execute: async (resource, columnOrOptions) => {
122
+ const result = await this.openWith(VscodeCommands.OPEN.id, resource, columnOrOptions);
123
+ if (!result) {
124
+ throw new Error(`Could not find an editor for ${resource}`);
125
+ }
126
+ }
127
+ });
128
+ commands.registerCommand(VscodeCommands.OPEN_WITH, {
129
+ isVisible: () => false,
130
+ execute: async (resource, viewType, columnOrOptions) => {
131
+ if (!viewType) {
132
+ throw new Error(`Running the contributed command: ${VscodeCommands.OPEN_WITH} failed.`);
133
+ }
134
+ if (viewType.toLowerCase() === 'default') {
135
+ return commands.executeCommand(VscodeCommands.OPEN.id, resource, columnOrOptions);
136
+ }
137
+ let result = await this.openWith(VscodeCommands.OPEN_WITH.id, resource, columnOrOptions, viewType);
138
+ if (!result) {
139
+ result = await this.openWith(VscodeCommands.OPEN_WITH.id, resource, columnOrOptions, custom_editor_opener_1.CustomEditorOpener.toCustomEditorId(viewType));
140
+ }
141
+ if (!result) {
142
+ throw new Error(`Could not find an editor for '${viewType}'`);
143
+ }
144
+ }
145
+ });
146
+ commands.registerCommand(VscodeCommands.OPEN_FOLDER, {
147
+ isVisible: () => false,
148
+ execute: async (resource, arg = {}) => {
149
+ if (!resource) {
150
+ return commands.executeCommand(browser_3.WorkspaceCommands.OPEN_WORKSPACE.id);
151
+ }
152
+ if (!vscode_uri_1.URI.isUri(resource)) {
153
+ throw new Error(`Invalid argument for ${VscodeCommands.OPEN_FOLDER.id} command with URI argument. Found ${resource}`);
154
+ }
155
+ let options;
156
+ if (typeof arg === 'boolean') {
157
+ options = { preserveWindow: !arg };
158
+ }
159
+ else {
160
+ options = { preserveWindow: !arg.forceNewWindow };
161
+ }
162
+ this.workspaceService.open(new uri_1.default(resource), options);
163
+ }
164
+ });
165
+ commands.registerCommand(VscodeCommands.DIFF, {
166
+ isVisible: () => false,
167
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
168
+ execute: async (left, right, label, options) => {
169
+ if (!left || !right) {
170
+ throw new Error(`${VscodeCommands.DIFF} command requires at least two URI arguments. Found left=${left}, right=${right} as arguments`);
171
+ }
172
+ if (!vscode_uri_1.URI.isUri(left)) {
173
+ throw new Error(`Invalid argument for ${VscodeCommands.DIFF.id} command with left argument. Expecting URI left type but found ${left}`);
174
+ }
175
+ if (!vscode_uri_1.URI.isUri(right)) {
176
+ throw new Error(`Invalid argument for ${VscodeCommands.DIFF.id} command with right argument. Expecting URI right type but found ${right}`);
177
+ }
178
+ const leftURI = new uri_1.default(left);
179
+ const editorOptions = documents_main_1.DocumentsMainImpl.toEditorOpenerOptions(this.shell, options);
180
+ await this.diffService.openDiffEditor(leftURI, new uri_1.default(right), label, editorOptions);
181
+ }
182
+ });
183
+ // https://code.visualstudio.com/docs/getstarted/keybindings#_navigation
184
+ /*
185
+ * internally, in VS Code, any widget opened in the main area is represented as an editor
186
+ * operations below apply to them, but not to side-bar widgets, like the explorer
187
+ *
188
+ * in Theia, there are not such difference and any widget can be put in any area
189
+ * because of it we filter out editors from views based on `NavigatableWidget.is`
190
+ * and apply actions only to them
191
+ */
192
+ if (!core_1.environment.electron.is() || core_1.isOSX) {
193
+ commands.registerCommand({ id: 'workbench.action.files.openFileFolder' }, {
194
+ execute: () => commands.executeCommand(browser_3.WorkspaceCommands.OPEN.id)
195
+ });
196
+ }
197
+ commands.registerCommand({ id: 'workbench.action.files.openFile' }, {
198
+ execute: () => commands.executeCommand(browser_3.WorkspaceCommands.OPEN_FILE.id)
199
+ });
200
+ commands.registerCommand({ id: 'workbench.action.files.openFolder' }, {
201
+ execute: () => commands.executeCommand(browser_3.WorkspaceCommands.OPEN_FOLDER.id)
202
+ });
203
+ commands.registerCommand({ id: 'workbench.action.addRootFolder' }, {
204
+ execute: () => commands.executeCommand(browser_3.WorkspaceCommands.ADD_FOLDER.id)
205
+ });
206
+ commands.registerCommand({ id: 'workbench.action.saveWorkspaceAs' }, {
207
+ execute: () => commands.executeCommand(browser_3.WorkspaceCommands.SAVE_WORKSPACE_AS.id)
208
+ });
209
+ commands.registerCommand({ id: 'workbench.action.gotoLine' }, {
210
+ execute: () => commands.executeCommand(browser_2.EditorCommands.GOTO_LINE_COLUMN.id)
211
+ });
212
+ commands.registerCommand({ id: 'workbench.action.quickOpen' }, {
213
+ execute: (prefix) => this.quickInput.open(typeof prefix === 'string' ? prefix : '')
214
+ });
215
+ commands.registerCommand({ id: 'workbench.action.openSettings' }, {
216
+ execute: (query) => commands.executeCommand(browser_1.CommonCommands.OPEN_PREFERENCES.id, query)
217
+ });
218
+ commands.registerCommand({ id: 'workbench.action.openWorkspaceConfigFile' }, {
219
+ execute: () => commands.executeCommand(browser_3.WorkspaceCommands.OPEN_WORKSPACE_FILE.id)
220
+ });
221
+ commands.registerCommand({ id: 'workbench.files.action.refreshFilesExplorer' }, {
222
+ execute: () => commands.executeCommand(navigator_contribution_1.FileNavigatorCommands.REFRESH_NAVIGATOR.id)
223
+ });
224
+ commands.registerCommand({ id: VscodeCommands.INSTALL_FROM_VSIX.id }, {
225
+ execute: async (vsixUriOrExtensionId) => {
226
+ if (typeof vsixUriOrExtensionId === 'string') {
227
+ await this.pluginServer.deploy(plugin_vscode_uri_1.VSCodeExtensionUri.toVsxExtensionUriString(vsixUriOrExtensionId));
228
+ }
229
+ else {
230
+ const uriPath = (0, type_converters_1.isUriComponents)(vsixUriOrExtensionId) ? vscode_uri_1.URI.revive(vsixUriOrExtensionId).fsPath : await this.fileService.fsPath(vsixUriOrExtensionId);
231
+ await this.pluginServer.deploy(`local-file:${uriPath}`);
232
+ }
233
+ }
234
+ });
235
+ commands.registerCommand({ id: 'workbench.action.files.save', }, {
236
+ execute: (uri) => {
237
+ if (uri) {
238
+ const uriString = uri.toString();
239
+ const widget = this.shell.widgets.find(w => {
240
+ const resourceUri = browser_1.Saveable.is(w) && browser_1.NavigatableWidget.is(w) && w.getResourceUri();
241
+ return (resourceUri && resourceUri.toString()) === uriString;
242
+ });
243
+ if (browser_1.Saveable.is(widget)) {
244
+ browser_1.Saveable.save(widget);
245
+ }
246
+ }
247
+ else {
248
+ this.shell.save();
249
+ }
250
+ }
251
+ });
252
+ commands.registerCommand({ id: 'workbench.action.files.saveAll', }, {
253
+ execute: () => this.shell.saveAll()
254
+ });
255
+ commands.registerCommand({ id: 'workbench.action.closeActiveEditor' }, {
256
+ execute: () => commands.executeCommand(browser_1.CommonCommands.CLOSE_MAIN_TAB.id)
257
+ });
258
+ commands.registerCommand({ id: 'workbench.action.closeOtherEditors' }, {
259
+ execute: async (uri) => {
260
+ let editor = this.editorManager.currentEditor || this.shell.currentWidget;
261
+ if (uri) {
262
+ const uriString = uri.toString();
263
+ editor = this.editorManager.all.find(e => {
264
+ const resourceUri = e.getResourceUri();
265
+ return (resourceUri && resourceUri.toString()) === uriString;
266
+ });
267
+ }
268
+ const toClose = this.shell.widgets.filter(widget => widget !== editor && this.codeEditorWidgetUtil.is(widget));
269
+ await this.shell.closeMany(toClose);
270
+ }
271
+ });
272
+ const performActionOnGroup = (cb, uri) => {
273
+ let editor = this.editorManager.currentEditor || this.shell.currentWidget;
274
+ if (uri) {
275
+ const uriString = uri.toString();
276
+ editor = this.editorManager.all.find(e => {
277
+ const resourceUri = e.getResourceUri();
278
+ return (resourceUri && resourceUri.toString()) === uriString;
279
+ });
280
+ }
281
+ if (editor) {
282
+ const tabBar = this.shell.getTabBarFor(editor);
283
+ if (tabBar) {
284
+ cb(tabBar, ({ owner }) => this.codeEditorWidgetUtil.is(owner));
285
+ }
286
+ }
287
+ };
288
+ commands.registerCommand({
289
+ id: 'workbench.action.closeEditorsInGroup',
290
+ label: nls_1.nls.localizeByDefault('Close All Editors in Group')
291
+ }, {
292
+ execute: (uri) => performActionOnGroup(this.shell.closeTabs, uri)
293
+ });
294
+ commands.registerCommand({
295
+ id: 'workbench.files.saveAllInGroup',
296
+ label: nls_1.nls.localizeByDefault('Save All in Group')
297
+ }, {
298
+ execute: (uri) => performActionOnGroup(this.shell.saveTabs, uri)
299
+ });
300
+ commands.registerCommand({ id: 'workbench.action.closeEditorsInOtherGroups' }, {
301
+ execute: () => {
302
+ const editor = this.editorManager.currentEditor || this.shell.currentWidget;
303
+ if (editor) {
304
+ const editorTabBar = this.shell.getTabBarFor(editor);
305
+ for (const tabBar of this.shell.allTabBars) {
306
+ if (tabBar !== editorTabBar) {
307
+ this.shell.closeTabs(tabBar, ({ owner }) => this.codeEditorWidgetUtil.is(owner));
308
+ }
309
+ }
310
+ }
311
+ }
312
+ });
313
+ commands.registerCommand({ id: 'workbench.action.closeEditorsToTheLeft' }, {
314
+ execute: () => {
315
+ const editor = this.editorManager.currentEditor || this.shell.currentWidget;
316
+ if (editor) {
317
+ const tabBar = this.shell.getTabBarFor(editor);
318
+ if (tabBar) {
319
+ let left = true;
320
+ this.shell.closeTabs(tabBar, ({ owner }) => {
321
+ if (owner === editor) {
322
+ left = false;
323
+ return false;
324
+ }
325
+ return left && this.codeEditorWidgetUtil.is(owner);
326
+ });
327
+ }
328
+ }
329
+ }
330
+ });
331
+ commands.registerCommand({ id: 'workbench.action.closeEditorsToTheRight' }, {
332
+ execute: () => {
333
+ const editor = this.editorManager.currentEditor || this.shell.currentWidget;
334
+ if (editor) {
335
+ const tabBar = this.shell.getTabBarFor(editor);
336
+ if (tabBar) {
337
+ let left = true;
338
+ this.shell.closeTabs(tabBar, ({ owner }) => {
339
+ if (owner === editor) {
340
+ left = false;
341
+ return false;
342
+ }
343
+ return !left && this.codeEditorWidgetUtil.is(owner);
344
+ });
345
+ }
346
+ }
347
+ }
348
+ });
349
+ commands.registerCommand({ id: 'workbench.action.closeAllEditors' }, {
350
+ execute: async () => {
351
+ const toClose = this.shell.widgets.filter(widget => this.codeEditorWidgetUtil.is(widget));
352
+ await this.shell.closeMany(toClose);
353
+ }
354
+ });
355
+ commands.registerCommand({ id: 'workbench.action.nextEditor' }, {
356
+ execute: () => this.shell.activateNextTab()
357
+ });
358
+ commands.registerCommand({ id: 'workbench.action.previousEditor' }, {
359
+ execute: () => this.shell.activatePreviousTab()
360
+ });
361
+ commands.registerCommand({ id: 'workbench.action.navigateBack' }, {
362
+ execute: () => commands.executeCommand(browser_2.EditorCommands.GO_BACK.id)
363
+ });
364
+ commands.registerCommand({ id: 'workbench.action.navigateForward' }, {
365
+ execute: () => commands.executeCommand(browser_2.EditorCommands.GO_FORWARD.id)
366
+ });
367
+ commands.registerCommand({ id: 'workbench.action.navigateToLastEditLocation' }, {
368
+ execute: () => commands.executeCommand(browser_2.EditorCommands.GO_LAST_EDIT.id)
369
+ });
370
+ commands.registerCommand({ id: 'openInTerminal' }, {
371
+ execute: (resource) => this.terminalContribution.openInTerminal(new uri_1.default(resource.toString()))
372
+ });
373
+ commands.registerCommand({ id: 'workbench.action.reloadWindow' }, {
374
+ execute: () => {
375
+ this.windowService.reload();
376
+ }
377
+ });
378
+ /**
379
+ * TODO:
380
+ * Open Next: workbench.action.openNextRecentlyUsedEditorInGroup
381
+ * Open Previous: workbench.action.openPreviousRecentlyUsedEditorInGroup
382
+ * Copy Path of Active File: workbench.action.files.copyPathOfActiveFile
383
+ * Reveal Active File in Windows: workbench.action.files.revealActiveFileInWindows
384
+ * Show Opened File in New Window: workbench.action.files.showOpenedFileInNewWindow
385
+ * Compare Opened File With: workbench.files.action.compareFileWith
386
+ */
387
+ // Register built-in language service commands
388
+ // see https://code.visualstudio.com/api/references/commands
389
+ /* eslint-disable @typescript-eslint/no-explicit-any */
390
+ // TODO register other `vscode.execute...` commands.
391
+ // see https://github.com/microsoft/vscode/blob/master/src/vs/workbench/api/common/extHostApiCommands.ts
392
+ commands.registerCommand({
393
+ id: 'vscode.executeDefinitionProvider'
394
+ }, {
395
+ execute: ((resource, position) => commands.executeCommand('_executeDefinitionProvider', monaco.Uri.from(resource), position))
396
+ });
397
+ commands.registerCommand({
398
+ id: 'vscode.executeDeclarationProvider'
399
+ }, {
400
+ execute: ((resource, position) => commands.executeCommand('_executeDeclarationProvider', monaco.Uri.from(resource), position))
401
+ });
402
+ commands.registerCommand({
403
+ id: 'vscode.executeTypeDefinitionProvider'
404
+ }, {
405
+ execute: ((resource, position) => commands.executeCommand('_executeTypeDefinitionProvider', monaco.Uri.from(resource), position))
406
+ });
407
+ commands.registerCommand({
408
+ id: 'vscode.executeImplementationProvider'
409
+ }, {
410
+ execute: ((resource, position) => commands.executeCommand('_executeImplementationProvider', monaco.Uri.from(resource), position))
411
+ });
412
+ commands.registerCommand({
413
+ id: 'vscode.executeHoverProvider'
414
+ }, {
415
+ execute: ((resource, position) => commands.executeCommand('_executeHoverProvider', monaco.Uri.from(resource), position))
416
+ });
417
+ commands.registerCommand({
418
+ id: 'vscode.executeDocumentHighlights'
419
+ }, {
420
+ execute: ((resource, position) => commands.executeCommand('_executeDocumentHighlights', monaco.Uri.from(resource), position))
421
+ });
422
+ commands.registerCommand({
423
+ id: 'vscode.executeReferenceProvider'
424
+ }, {
425
+ execute: ((resource, position) => commands.executeCommand('_executeReferenceProvider', monaco.Uri.from(resource), position))
426
+ });
427
+ commands.registerCommand({
428
+ id: 'vscode.executeDocumentSymbolProvider'
429
+ }, {
430
+ execute: (resource) => commands.executeCommand('_executeDocumentSymbolProvider', monaco.Uri.parse(resource.toString())).then((value) => {
431
+ if (!Array.isArray(value) || value === undefined) {
432
+ return undefined;
433
+ }
434
+ return value.map(loc => (0, type_converters_1.toDocumentSymbol)(loc));
435
+ })
436
+ });
437
+ commands.registerCommand({
438
+ id: 'vscode.executeFormatDocumentProvider'
439
+ }, {
440
+ execute: ((resource, options) => commands.executeCommand('_executeFormatDocumentProvider', monaco.Uri.from(resource), options))
441
+ });
442
+ commands.registerCommand({
443
+ id: 'vscode.executeFormatRangeProvider'
444
+ }, {
445
+ execute: ((resource, range, options) => commands.executeCommand('_executeFormatRangeProvider', monaco.Uri.from(resource), range, options))
446
+ });
447
+ commands.registerCommand({
448
+ id: 'vscode.executeFormatOnTypeProvider'
449
+ }, {
450
+ execute: ((resource, position, ch, options) => commands.executeCommand('_executeFormatOnTypeProvider', monaco.Uri.from(resource), position, ch, options))
451
+ });
452
+ commands.registerCommand({
453
+ id: 'vscode.prepareCallHierarchy'
454
+ }, {
455
+ execute: async (resource, position) => {
456
+ const provider = await this.getCallHierarchyServiceForUri(resource);
457
+ const definition = await (provider === null || provider === void 0 ? void 0 : provider.getRootDefinition(resource.path, (0, type_converters_1.toPosition)(position), new core_1.CancellationTokenSource().token));
458
+ if (definition) {
459
+ return definition.items.map(item => (0, hierarchy_types_converters_1.fromItemHierarchyDefinition)(item));
460
+ }
461
+ ;
462
+ return [];
463
+ }
464
+ });
465
+ commands.registerCommand({
466
+ id: 'vscode.provideIncomingCalls'
467
+ }, {
468
+ execute: async (item) => {
469
+ const resource = vscode_uri_1.URI.from(item.uri);
470
+ const provider = await this.getCallHierarchyServiceForUri(resource);
471
+ const incomingCalls = await (provider === null || provider === void 0 ? void 0 : provider.getCallers((0, hierarchy_types_converters_1.toItemHierarchyDefinition)(item), new core_1.CancellationTokenSource().token));
472
+ if (incomingCalls) {
473
+ return incomingCalls.map(hierarchy_types_converters_1.fromCallHierarchyCallerToModelCallHierarchyIncomingCall);
474
+ }
475
+ return [];
476
+ },
477
+ });
478
+ commands.registerCommand({
479
+ id: 'vscode.provideOutgoingCalls'
480
+ }, {
481
+ execute: async (item) => {
482
+ var _a;
483
+ const resource = vscode_uri_1.URI.from(item.uri);
484
+ const provider = await this.getCallHierarchyServiceForUri(resource);
485
+ const outgoingCalls = await ((_a = provider === null || provider === void 0 ? void 0 : provider.getCallees) === null || _a === void 0 ? void 0 : _a.call(provider, (0, hierarchy_types_converters_1.toItemHierarchyDefinition)(item), new core_1.CancellationTokenSource().token));
486
+ if (outgoingCalls) {
487
+ return outgoingCalls.map(hierarchy_types_converters_1.fromCallHierarchyCalleeToModelCallHierarchyOutgoingCall);
488
+ }
489
+ return [];
490
+ }
491
+ });
492
+ commands.registerCommand({
493
+ id: 'vscode.prepareTypeHierarchy'
494
+ }, {
495
+ execute: async (resource, position) => {
496
+ const provider = await this.getTypeHierarchyServiceForUri(resource);
497
+ const session = await (provider === null || provider === void 0 ? void 0 : provider.prepareSession(resource.path, (0, type_converters_1.toPosition)(position), new core_1.CancellationTokenSource().token));
498
+ return session ? session.items.map(item => (0, hierarchy_types_converters_1.fromItemHierarchyDefinition)(item)) : [];
499
+ }
500
+ });
501
+ commands.registerCommand({
502
+ id: 'vscode.provideSupertypes'
503
+ }, {
504
+ execute: async (item) => {
505
+ if (!item._sessionId || !item._itemId) {
506
+ return [];
507
+ }
508
+ const resource = vscode_uri_1.URI.from(item.uri);
509
+ const provider = await this.getTypeHierarchyServiceForUri(resource);
510
+ const items = await (provider === null || provider === void 0 ? void 0 : provider.provideSuperTypes(item._sessionId, item._itemId, new core_1.CancellationTokenSource().token));
511
+ return (items ? items : []).map(typeItem => (0, hierarchy_types_converters_1.fromItemHierarchyDefinition)(typeItem));
512
+ }
513
+ });
514
+ commands.registerCommand({
515
+ id: 'vscode.provideSubtypes'
516
+ }, {
517
+ execute: async (item) => {
518
+ if (!item._sessionId || !item._itemId) {
519
+ return [];
520
+ }
521
+ const resource = vscode_uri_1.URI.from(item.uri);
522
+ const provider = await this.getTypeHierarchyServiceForUri(resource);
523
+ const items = await (provider === null || provider === void 0 ? void 0 : provider.provideSubTypes(item._sessionId, item._itemId, new core_1.CancellationTokenSource().token));
524
+ return (items ? items : []).map(typeItem => (0, hierarchy_types_converters_1.fromItemHierarchyDefinition)(typeItem));
525
+ }
526
+ });
527
+ commands.registerCommand({
528
+ id: 'workbench.action.openRecent'
529
+ }, {
530
+ execute: () => this.quickOpenWorkspace.select()
531
+ });
532
+ commands.registerCommand({
533
+ id: 'explorer.newFolder'
534
+ }, {
535
+ execute: () => commands.executeCommand(browser_3.WorkspaceCommands.NEW_FOLDER.id)
536
+ });
537
+ commands.registerCommand({
538
+ id: 'workbench.action.terminal.sendSequence'
539
+ }, {
540
+ execute: (args) => {
541
+ if (args === undefined || args.text === undefined) {
542
+ return;
543
+ }
544
+ const currentTerminal = this.terminalService.currentTerminal;
545
+ if (currentTerminal === undefined) {
546
+ return;
547
+ }
548
+ currentTerminal.sendText(args.text);
549
+ }
550
+ });
551
+ commands.registerCommand({
552
+ id: 'workbench.action.terminal.kill'
553
+ }, {
554
+ execute: () => {
555
+ const currentTerminal = this.terminalService.currentTerminal;
556
+ if (currentTerminal === undefined) {
557
+ return;
558
+ }
559
+ currentTerminal.dispose();
560
+ }
561
+ });
562
+ commands.registerCommand({
563
+ id: 'workbench.view.explorer'
564
+ }, {
565
+ execute: () => commands.executeCommand(navigator_contribution_1.FileNavigatorCommands.FOCUS.id)
566
+ });
567
+ commands.registerCommand({
568
+ id: 'copyFilePath'
569
+ }, {
570
+ execute: () => commands.executeCommand(browser_1.CommonCommands.COPY_PATH.id)
571
+ });
572
+ commands.registerCommand({
573
+ id: 'copyRelativeFilePath'
574
+ }, {
575
+ execute: () => commands.executeCommand(browser_3.WorkspaceCommands.COPY_RELATIVE_FILE_PATH.id)
576
+ });
577
+ commands.registerCommand({
578
+ id: 'revealInExplorer'
579
+ }, {
580
+ execute: async (resource) => {
581
+ if (!vscode_uri_1.URI.isUri(resource)) {
582
+ return;
583
+ }
584
+ let navigator = await this.shell.revealWidget(browser_4.FILE_NAVIGATOR_ID);
585
+ if (!navigator) {
586
+ await this.commandService.executeCommand(navigator_contribution_1.FILE_NAVIGATOR_TOGGLE_COMMAND_ID);
587
+ navigator = await this.shell.revealWidget(browser_4.FILE_NAVIGATOR_ID);
588
+ }
589
+ if (navigator instanceof browser_4.FileNavigatorWidget) {
590
+ const model = navigator.model;
591
+ const node = await model.revealFile(new uri_1.default(resource));
592
+ if (tree_selection_1.SelectableTreeNode.is(node)) {
593
+ model.selectNode(node);
594
+ }
595
+ }
596
+ }
597
+ });
598
+ commands.registerCommand({
599
+ id: 'workbench.experimental.requestUsbDevice'
600
+ }, {
601
+ execute: async (options) => {
602
+ var _a;
603
+ const usb = navigator.usb;
604
+ if (!usb) {
605
+ return undefined;
606
+ }
607
+ const device = await usb.requestDevice({ filters: (_a = options === null || options === void 0 ? void 0 : options.filters) !== null && _a !== void 0 ? _a : [] });
608
+ if (!device) {
609
+ return undefined;
610
+ }
611
+ return {
612
+ deviceClass: device.deviceClass,
613
+ deviceProtocol: device.deviceProtocol,
614
+ deviceSubclass: device.deviceSubclass,
615
+ deviceVersionMajor: device.deviceVersionMajor,
616
+ deviceVersionMinor: device.deviceVersionMinor,
617
+ deviceVersionSubminor: device.deviceVersionSubminor,
618
+ manufacturerName: device.manufacturerName,
619
+ productId: device.productId,
620
+ productName: device.productName,
621
+ serialNumber: device.serialNumber,
622
+ usbVersionMajor: device.usbVersionMajor,
623
+ usbVersionMinor: device.usbVersionMinor,
624
+ usbVersionSubminor: device.usbVersionSubminor,
625
+ vendorId: device.vendorId,
626
+ };
627
+ }
628
+ });
629
+ commands.registerCommand({
630
+ id: 'workbench.experimental.requestSerialPort'
631
+ }, {
632
+ execute: async (options) => {
633
+ var _a;
634
+ const serial = navigator.serial;
635
+ if (!serial) {
636
+ return undefined;
637
+ }
638
+ const port = await serial.requestPort({ filters: (_a = options === null || options === void 0 ? void 0 : options.filters) !== null && _a !== void 0 ? _a : [] });
639
+ if (!port) {
640
+ return undefined;
641
+ }
642
+ const info = port.getInfo();
643
+ return {
644
+ usbVendorId: info.usbVendorId,
645
+ usbProductId: info.usbProductId
646
+ };
647
+ }
648
+ });
649
+ commands.registerCommand({
650
+ id: 'workbench.experimental.requestHidDevice'
651
+ }, {
652
+ execute: async (options) => {
653
+ var _a;
654
+ const hid = navigator.hid;
655
+ if (!hid) {
656
+ return undefined;
657
+ }
658
+ const devices = await hid.requestDevice({ filters: (_a = options === null || options === void 0 ? void 0 : options.filters) !== null && _a !== void 0 ? _a : [] });
659
+ if (!devices.length) {
660
+ return undefined;
661
+ }
662
+ const device = devices[0];
663
+ return {
664
+ opened: device.opened,
665
+ vendorId: device.vendorId,
666
+ productId: device.productId,
667
+ productName: device.productName,
668
+ collections: device.collections
669
+ };
670
+ }
671
+ });
672
+ }
673
+ async resolveLanguageId(resource) {
674
+ const reference = await this.textModelService.createModelReference(resource);
675
+ const languageId = reference.object.languageId;
676
+ reference.dispose();
677
+ return languageId;
678
+ }
679
+ async getCallHierarchyServiceForUri(resource) {
680
+ const languageId = await this.resolveLanguageId(resource);
681
+ return this.callHierarchyProvider.get(languageId, new uri_1.default(resource));
682
+ }
683
+ async getTypeHierarchyServiceForUri(resource) {
684
+ const languageId = await this.resolveLanguageId(resource);
685
+ return this.typeHierarchyProvider.get(languageId, new uri_1.default(resource));
686
+ }
687
+ };
688
+ __decorate([
689
+ (0, inversify_1.inject)(command_1.CommandService),
690
+ __metadata("design:type", Object)
691
+ ], PluginVscodeCommandsContribution.prototype, "commandService", void 0);
692
+ __decorate([
693
+ (0, inversify_1.inject)(context_key_service_1.ContextKeyService),
694
+ __metadata("design:type", Object)
695
+ ], PluginVscodeCommandsContribution.prototype, "contextKeyService", void 0);
696
+ __decorate([
697
+ (0, inversify_1.inject)(browser_2.EditorManager),
698
+ __metadata("design:type", browser_2.EditorManager)
699
+ ], PluginVscodeCommandsContribution.prototype, "editorManager", void 0);
700
+ __decorate([
701
+ (0, inversify_1.inject)(browser_1.ApplicationShell),
702
+ __metadata("design:type", browser_1.ApplicationShell)
703
+ ], PluginVscodeCommandsContribution.prototype, "shell", void 0);
704
+ __decorate([
705
+ (0, inversify_1.inject)(diff_service_1.DiffService),
706
+ __metadata("design:type", diff_service_1.DiffService)
707
+ ], PluginVscodeCommandsContribution.prototype, "diffService", void 0);
708
+ __decorate([
709
+ (0, inversify_1.inject)(browser_1.OpenerService),
710
+ __metadata("design:type", Object)
711
+ ], PluginVscodeCommandsContribution.prototype, "openerService", void 0);
712
+ __decorate([
713
+ (0, inversify_1.inject)(application_shell_mouse_tracker_1.ApplicationShellMouseTracker),
714
+ __metadata("design:type", application_shell_mouse_tracker_1.ApplicationShellMouseTracker)
715
+ ], PluginVscodeCommandsContribution.prototype, "mouseTracker", void 0);
716
+ __decorate([
717
+ (0, inversify_1.inject)(browser_1.QuickInputService),
718
+ (0, inversify_1.optional)(),
719
+ __metadata("design:type", Object)
720
+ ], PluginVscodeCommandsContribution.prototype, "quickInput", void 0);
721
+ __decorate([
722
+ (0, inversify_1.inject)(workspace_service_1.WorkspaceService),
723
+ __metadata("design:type", workspace_service_1.WorkspaceService)
724
+ ], PluginVscodeCommandsContribution.prototype, "workspaceService", void 0);
725
+ __decorate([
726
+ (0, inversify_1.inject)(terminal_frontend_contribution_1.TerminalFrontendContribution),
727
+ __metadata("design:type", terminal_frontend_contribution_1.TerminalFrontendContribution)
728
+ ], PluginVscodeCommandsContribution.prototype, "terminalContribution", void 0);
729
+ __decorate([
730
+ (0, inversify_1.inject)(quick_open_workspace_1.QuickOpenWorkspace),
731
+ __metadata("design:type", quick_open_workspace_1.QuickOpenWorkspace)
732
+ ], PluginVscodeCommandsContribution.prototype, "quickOpenWorkspace", void 0);
733
+ __decorate([
734
+ (0, inversify_1.inject)(terminal_service_1.TerminalService),
735
+ __metadata("design:type", Object)
736
+ ], PluginVscodeCommandsContribution.prototype, "terminalService", void 0);
737
+ __decorate([
738
+ (0, inversify_1.inject)(vscode_theia_menu_mappings_1.CodeEditorWidgetUtil),
739
+ __metadata("design:type", vscode_theia_menu_mappings_1.CodeEditorWidgetUtil)
740
+ ], PluginVscodeCommandsContribution.prototype, "codeEditorWidgetUtil", void 0);
741
+ __decorate([
742
+ (0, inversify_1.inject)(plugin_protocol_1.PluginServer),
743
+ __metadata("design:type", Object)
744
+ ], PluginVscodeCommandsContribution.prototype, "pluginServer", void 0);
745
+ __decorate([
746
+ (0, inversify_1.inject)(file_service_1.FileService),
747
+ __metadata("design:type", file_service_1.FileService)
748
+ ], PluginVscodeCommandsContribution.prototype, "fileService", void 0);
749
+ __decorate([
750
+ (0, inversify_1.inject)(browser_5.CallHierarchyServiceProvider),
751
+ __metadata("design:type", browser_5.CallHierarchyServiceProvider)
752
+ ], PluginVscodeCommandsContribution.prototype, "callHierarchyProvider", void 0);
753
+ __decorate([
754
+ (0, inversify_1.inject)(browser_6.TypeHierarchyServiceProvider),
755
+ __metadata("design:type", browser_6.TypeHierarchyServiceProvider)
756
+ ], PluginVscodeCommandsContribution.prototype, "typeHierarchyProvider", void 0);
757
+ __decorate([
758
+ (0, inversify_1.inject)(monaco_text_model_service_1.MonacoTextModelService),
759
+ __metadata("design:type", monaco_text_model_service_1.MonacoTextModelService)
760
+ ], PluginVscodeCommandsContribution.prototype, "textModelService", void 0);
761
+ __decorate([
762
+ (0, inversify_1.inject)(window_service_1.WindowService),
763
+ __metadata("design:type", Object)
764
+ ], PluginVscodeCommandsContribution.prototype, "windowService", void 0);
765
+ PluginVscodeCommandsContribution = __decorate([
766
+ (0, inversify_1.injectable)()
767
+ ], PluginVscodeCommandsContribution);
768
+ exports.PluginVscodeCommandsContribution = PluginVscodeCommandsContribution;
769
769
  //# sourceMappingURL=plugin-vscode-commands-contribution.js.map