@theia/plugin-ext-vscode 1.53.0-next.4 → 1.53.0-next.55
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/README.md +32 -32
- package/lib/browser/plugin-vscode-commands-contribution.d.ts +2 -0
- package/lib/browser/plugin-vscode-commands-contribution.d.ts.map +1 -1
- package/lib/browser/plugin-vscode-commands-contribution.js +24 -1
- package/lib/browser/plugin-vscode-commands-contribution.js.map +1 -1
- package/lib/common/plugin-vscode-types.d.ts +1 -1
- package/package.json +16 -16
- package/src/browser/plugin-vscode-commands-contribution.ts +987 -951
- package/src/browser/plugin-vscode-contribution.ts +47 -47
- package/src/browser/plugin-vscode-frontend-module.ts +30 -30
- package/src/common/plugin-vscode-environment.ts +59 -59
- package/src/common/plugin-vscode-types.ts +20 -20
- package/src/common/plugin-vscode-uri.ts +45 -45
- package/src/node/context/plugin-vscode-init-fe.ts +43 -43
- package/src/node/local-vsix-file-plugin-deployer-resolver.ts +51 -51
- package/src/node/package.spec.ts +28 -28
- package/src/node/plugin-vscode-backend-module.ts +46 -46
- package/src/node/plugin-vscode-cli-contribution.ts +64 -64
- package/src/node/plugin-vscode-deployer-participant.ts +48 -48
- package/src/node/plugin-vscode-directory-handler.ts +123 -123
- package/src/node/plugin-vscode-file-handler.ts +62 -62
- package/src/node/plugin-vscode-init.ts +80 -80
- package/src/node/plugin-vscode-utils.ts +101 -101
- package/src/node/scanner-vscode.ts +113 -113
|
@@ -1,951 +1,987 @@
|
|
|
1
|
-
// *****************************************************************************
|
|
2
|
-
// Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
-
//
|
|
4
|
-
// This program and the accompanying materials are made available under the
|
|
5
|
-
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
-
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
-
//
|
|
8
|
-
// This Source Code may also be made available under the following Secondary
|
|
9
|
-
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
-
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
-
// with the GNU Classpath Exception which is available at
|
|
12
|
-
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
-
//
|
|
14
|
-
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
-
// *****************************************************************************
|
|
16
|
-
|
|
17
|
-
import { Command, CommandContribution, CommandRegistry, environment, isOSX, CancellationTokenSource, MessageService } from '@theia/core';
|
|
18
|
-
import {
|
|
19
|
-
ApplicationShell,
|
|
20
|
-
CommonCommands,
|
|
21
|
-
NavigatableWidget,
|
|
22
|
-
OpenerService, OpenHandler,
|
|
23
|
-
QuickInputService,
|
|
24
|
-
Saveable,
|
|
25
|
-
TabBar,
|
|
26
|
-
Title,
|
|
27
|
-
Widget
|
|
28
|
-
} from '@theia/core/lib/browser';
|
|
29
|
-
import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
|
|
30
|
-
import { ApplicationShellMouseTracker } from '@theia/core/lib/browser/shell/application-shell-mouse-tracker';
|
|
31
|
-
import { CommandService } from '@theia/core/lib/common/command';
|
|
32
|
-
import TheiaURI from '@theia/core/lib/common/uri';
|
|
33
|
-
import { EditorManager, EditorCommands } from '@theia/editor/lib/browser';
|
|
34
|
-
import {
|
|
35
|
-
TextDocumentShowOptions,
|
|
36
|
-
Location,
|
|
37
|
-
CallHierarchyItem,
|
|
38
|
-
CallHierarchyIncomingCall,
|
|
39
|
-
CallHierarchyOutgoingCall,
|
|
40
|
-
TypeHierarchyItem,
|
|
41
|
-
Hover,
|
|
42
|
-
TextEdit,
|
|
43
|
-
FormattingOptions,
|
|
44
|
-
DocumentHighlight
|
|
45
|
-
} from '@theia/plugin-ext/lib/common/plugin-api-rpc-model';
|
|
46
|
-
import { DocumentsMainImpl } from '@theia/plugin-ext/lib/main/browser/documents-main';
|
|
47
|
-
import { isUriComponents,
|
|
48
|
-
import { ViewColumn } from '@theia/plugin-ext/lib/plugin/types-impl';
|
|
49
|
-
import { WorkspaceCommands } from '@theia/workspace/lib/browser';
|
|
50
|
-
import { WorkspaceService, WorkspaceInput } from '@theia/workspace/lib/browser/workspace-service';
|
|
51
|
-
import { DiffService } from '@theia/workspace/lib/browser/diff-service';
|
|
52
|
-
import { inject, injectable, optional } from '@theia/core/shared/inversify';
|
|
53
|
-
import { Position } from '@theia/plugin-ext/lib/common/plugin-api-rpc';
|
|
54
|
-
import { URI } from '@theia/core/shared/vscode-uri';
|
|
55
|
-
import { PluginServer } from '@theia/plugin-ext/lib/common/plugin-protocol';
|
|
56
|
-
import { TerminalFrontendContribution } from '@theia/terminal/lib/browser/terminal-frontend-contribution';
|
|
57
|
-
import { QuickOpenWorkspace } from '@theia/workspace/lib/browser/quick-open-workspace';
|
|
58
|
-
import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-service';
|
|
59
|
-
import {
|
|
60
|
-
FileNavigatorCommands,
|
|
61
|
-
FILE_NAVIGATOR_TOGGLE_COMMAND_ID
|
|
62
|
-
} from '@theia/navigator/lib/browser/navigator-contribution';
|
|
63
|
-
import { FILE_NAVIGATOR_ID, FileNavigatorWidget } from '@theia/navigator/lib/browser';
|
|
64
|
-
import { SelectableTreeNode } from '@theia/core/lib/browser/tree/tree-selection';
|
|
65
|
-
import { UriComponents } from '@theia/plugin-ext/lib/common/uri-components';
|
|
66
|
-
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
67
|
-
import { CallHierarchyServiceProvider, CallHierarchyService } from '@theia/callhierarchy/lib/browser';
|
|
68
|
-
import { TypeHierarchyServiceProvider, TypeHierarchyService } from '@theia/typehierarchy/lib/browser';
|
|
69
|
-
import { MonacoTextModelService } from '@theia/monaco/lib/browser/monaco-text-model-service';
|
|
70
|
-
import {
|
|
71
|
-
fromCallHierarchyCalleeToModelCallHierarchyOutgoingCall,
|
|
72
|
-
fromCallHierarchyCallerToModelCallHierarchyIncomingCall,
|
|
73
|
-
fromItemHierarchyDefinition,
|
|
74
|
-
toItemHierarchyDefinition
|
|
75
|
-
} from '@theia/plugin-ext/lib/main/browser/hierarchy/hierarchy-types-converters';
|
|
76
|
-
import { CustomEditorOpener } from '@theia/plugin-ext/lib/main/browser/custom-editors/custom-editor-opener';
|
|
77
|
-
import { nls } from '@theia/core/lib/common/nls';
|
|
78
|
-
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
|
79
|
-
import * as monaco from '@theia/monaco-editor-core';
|
|
80
|
-
import { VSCodeExtensionUri } from '../common/plugin-vscode-uri';
|
|
81
|
-
import { CodeEditorWidgetUtil } from '@theia/plugin-ext/lib/main/browser/menus/vscode-theia-menu-mappings';
|
|
82
|
-
import { OutlineViewContribution } from '@theia/outline-view/lib/browser/outline-view-contribution';
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
readonly
|
|
118
|
-
readonly
|
|
119
|
-
readonly
|
|
120
|
-
readonly
|
|
121
|
-
readonly
|
|
122
|
-
readonly
|
|
123
|
-
readonly
|
|
124
|
-
readonly
|
|
125
|
-
readonly
|
|
126
|
-
readonly
|
|
127
|
-
readonly
|
|
128
|
-
readonly
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
readonly
|
|
144
|
-
readonly
|
|
145
|
-
readonly
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
@inject(
|
|
153
|
-
protected readonly
|
|
154
|
-
@inject(
|
|
155
|
-
protected readonly
|
|
156
|
-
@inject(
|
|
157
|
-
protected readonly
|
|
158
|
-
@inject(
|
|
159
|
-
protected readonly
|
|
160
|
-
@inject(
|
|
161
|
-
protected readonly
|
|
162
|
-
@inject(
|
|
163
|
-
protected readonly
|
|
164
|
-
@inject(
|
|
165
|
-
protected readonly
|
|
166
|
-
@inject(
|
|
167
|
-
protected readonly
|
|
168
|
-
@inject(
|
|
169
|
-
protected readonly
|
|
170
|
-
@inject(
|
|
171
|
-
protected readonly
|
|
172
|
-
@inject(
|
|
173
|
-
protected readonly
|
|
174
|
-
@inject(
|
|
175
|
-
protected readonly
|
|
176
|
-
@inject(
|
|
177
|
-
protected readonly
|
|
178
|
-
@inject(
|
|
179
|
-
protected readonly
|
|
180
|
-
@inject(
|
|
181
|
-
protected readonly
|
|
182
|
-
@inject(
|
|
183
|
-
protected readonly
|
|
184
|
-
@inject(
|
|
185
|
-
protected readonly
|
|
186
|
-
@inject(
|
|
187
|
-
protected readonly
|
|
188
|
-
@inject(
|
|
189
|
-
protected readonly
|
|
190
|
-
@inject(
|
|
191
|
-
protected
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
options = {
|
|
208
|
-
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
await
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
commands.registerCommand(VscodeCommands.
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
this.
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
if (viewType
|
|
268
|
-
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
if (!result) {
|
|
277
|
-
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
if (
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
*
|
|
334
|
-
*
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
Saveable.
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
commands.registerCommand({ id: '
|
|
529
|
-
execute: (
|
|
530
|
-
});
|
|
531
|
-
|
|
532
|
-
commands.registerCommand({ id: '
|
|
533
|
-
execute: () =>
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
*
|
|
544
|
-
*
|
|
545
|
-
*
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
//
|
|
553
|
-
// see https://
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
}
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
}
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
}
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
}
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
}
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
}
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
}
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
{
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
const
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
const
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
return
|
|
748
|
-
}
|
|
749
|
-
}
|
|
750
|
-
);
|
|
751
|
-
commands.registerCommand(
|
|
752
|
-
{
|
|
753
|
-
id: 'vscode.
|
|
754
|
-
},
|
|
755
|
-
{
|
|
756
|
-
execute: async (
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
}
|
|
847
|
-
});
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
}
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
}
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
1
|
+
// *****************************************************************************
|
|
2
|
+
// Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
+
//
|
|
4
|
+
// This program and the accompanying materials are made available under the
|
|
5
|
+
// terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
// http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
//
|
|
8
|
+
// This Source Code may also be made available under the following Secondary
|
|
9
|
+
// Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
// with the GNU Classpath Exception which is available at
|
|
12
|
+
// https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
//
|
|
14
|
+
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
|
|
15
|
+
// *****************************************************************************
|
|
16
|
+
|
|
17
|
+
import { Command, CommandContribution, CommandRegistry, environment, isOSX, CancellationTokenSource, MessageService } from '@theia/core';
|
|
18
|
+
import {
|
|
19
|
+
ApplicationShell,
|
|
20
|
+
CommonCommands,
|
|
21
|
+
NavigatableWidget,
|
|
22
|
+
OpenerService, OpenHandler,
|
|
23
|
+
QuickInputService,
|
|
24
|
+
Saveable,
|
|
25
|
+
TabBar,
|
|
26
|
+
Title,
|
|
27
|
+
Widget
|
|
28
|
+
} from '@theia/core/lib/browser';
|
|
29
|
+
import { ContextKeyService } from '@theia/core/lib/browser/context-key-service';
|
|
30
|
+
import { ApplicationShellMouseTracker } from '@theia/core/lib/browser/shell/application-shell-mouse-tracker';
|
|
31
|
+
import { CommandService } from '@theia/core/lib/common/command';
|
|
32
|
+
import TheiaURI from '@theia/core/lib/common/uri';
|
|
33
|
+
import { EditorManager, EditorCommands } from '@theia/editor/lib/browser';
|
|
34
|
+
import {
|
|
35
|
+
TextDocumentShowOptions,
|
|
36
|
+
Location,
|
|
37
|
+
CallHierarchyItem,
|
|
38
|
+
CallHierarchyIncomingCall,
|
|
39
|
+
CallHierarchyOutgoingCall,
|
|
40
|
+
TypeHierarchyItem,
|
|
41
|
+
Hover,
|
|
42
|
+
TextEdit,
|
|
43
|
+
FormattingOptions,
|
|
44
|
+
DocumentHighlight
|
|
45
|
+
} from '@theia/plugin-ext/lib/common/plugin-api-rpc-model';
|
|
46
|
+
import { DocumentsMainImpl } from '@theia/plugin-ext/lib/main/browser/documents-main';
|
|
47
|
+
import { isUriComponents, toMergedSymbol, toPosition } from '@theia/plugin-ext/lib/plugin/type-converters';
|
|
48
|
+
import { ViewColumn } from '@theia/plugin-ext/lib/plugin/types-impl';
|
|
49
|
+
import { WorkspaceCommands } from '@theia/workspace/lib/browser';
|
|
50
|
+
import { WorkspaceService, WorkspaceInput } from '@theia/workspace/lib/browser/workspace-service';
|
|
51
|
+
import { DiffService } from '@theia/workspace/lib/browser/diff-service';
|
|
52
|
+
import { inject, injectable, optional } from '@theia/core/shared/inversify';
|
|
53
|
+
import { Position } from '@theia/plugin-ext/lib/common/plugin-api-rpc';
|
|
54
|
+
import { URI } from '@theia/core/shared/vscode-uri';
|
|
55
|
+
import { PluginServer } from '@theia/plugin-ext/lib/common/plugin-protocol';
|
|
56
|
+
import { TerminalFrontendContribution } from '@theia/terminal/lib/browser/terminal-frontend-contribution';
|
|
57
|
+
import { QuickOpenWorkspace } from '@theia/workspace/lib/browser/quick-open-workspace';
|
|
58
|
+
import { TerminalService } from '@theia/terminal/lib/browser/base/terminal-service';
|
|
59
|
+
import {
|
|
60
|
+
FileNavigatorCommands,
|
|
61
|
+
FILE_NAVIGATOR_TOGGLE_COMMAND_ID
|
|
62
|
+
} from '@theia/navigator/lib/browser/navigator-contribution';
|
|
63
|
+
import { FILE_NAVIGATOR_ID, FileNavigatorWidget } from '@theia/navigator/lib/browser';
|
|
64
|
+
import { SelectableTreeNode } from '@theia/core/lib/browser/tree/tree-selection';
|
|
65
|
+
import { UriComponents } from '@theia/plugin-ext/lib/common/uri-components';
|
|
66
|
+
import { FileService } from '@theia/filesystem/lib/browser/file-service';
|
|
67
|
+
import { CallHierarchyServiceProvider, CallHierarchyService } from '@theia/callhierarchy/lib/browser';
|
|
68
|
+
import { TypeHierarchyServiceProvider, TypeHierarchyService } from '@theia/typehierarchy/lib/browser';
|
|
69
|
+
import { MonacoTextModelService } from '@theia/monaco/lib/browser/monaco-text-model-service';
|
|
70
|
+
import {
|
|
71
|
+
fromCallHierarchyCalleeToModelCallHierarchyOutgoingCall,
|
|
72
|
+
fromCallHierarchyCallerToModelCallHierarchyIncomingCall,
|
|
73
|
+
fromItemHierarchyDefinition,
|
|
74
|
+
toItemHierarchyDefinition
|
|
75
|
+
} from '@theia/plugin-ext/lib/main/browser/hierarchy/hierarchy-types-converters';
|
|
76
|
+
import { CustomEditorOpener } from '@theia/plugin-ext/lib/main/browser/custom-editors/custom-editor-opener';
|
|
77
|
+
import { nls } from '@theia/core/lib/common/nls';
|
|
78
|
+
import { WindowService } from '@theia/core/lib/browser/window/window-service';
|
|
79
|
+
import * as monaco from '@theia/monaco-editor-core';
|
|
80
|
+
import { VSCodeExtensionUri } from '../common/plugin-vscode-uri';
|
|
81
|
+
import { CodeEditorWidgetUtil } from '@theia/plugin-ext/lib/main/browser/menus/vscode-theia-menu-mappings';
|
|
82
|
+
import { OutlineViewContribution } from '@theia/outline-view/lib/browser/outline-view-contribution';
|
|
83
|
+
import { Range } from '@theia/plugin';
|
|
84
|
+
import { MonacoLanguages } from '@theia/monaco/lib/browser/monaco-languages';
|
|
85
|
+
|
|
86
|
+
export namespace VscodeCommands {
|
|
87
|
+
|
|
88
|
+
export const GET_CODE_EXCHANGE_ENDPOINTS: Command = {
|
|
89
|
+
id: 'workbench.getCodeExchangeProxyEndpoints' // this command is used in the github auth built-in
|
|
90
|
+
// see: https://github.com/microsoft/vscode/blob/191be39e5ac872e03f9d79cc859d9917f40ad935/extensions/github-authentication/src/githubServer.ts#L60
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
export const OPEN: Command = {
|
|
94
|
+
id: 'vscode.open'
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export const OPEN_WITH: Command = {
|
|
98
|
+
id: 'vscode.openWith'
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
export const OPEN_FOLDER: Command = {
|
|
102
|
+
id: 'vscode.openFolder'
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
export const DIFF: Command = {
|
|
106
|
+
id: 'vscode.diff'
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
export const INSTALL_FROM_VSIX: Command = {
|
|
110
|
+
id: 'workbench.extensions.installExtension'
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
// https://wicg.github.io/webusb/
|
|
115
|
+
|
|
116
|
+
export interface UsbDeviceData {
|
|
117
|
+
readonly deviceClass: number;
|
|
118
|
+
readonly deviceProtocol: number;
|
|
119
|
+
readonly deviceSubclass: number;
|
|
120
|
+
readonly deviceVersionMajor: number;
|
|
121
|
+
readonly deviceVersionMinor: number;
|
|
122
|
+
readonly deviceVersionSubminor: number;
|
|
123
|
+
readonly manufacturerName?: string;
|
|
124
|
+
readonly productId: number;
|
|
125
|
+
readonly productName?: string;
|
|
126
|
+
readonly serialNumber?: string;
|
|
127
|
+
readonly usbVersionMajor: number;
|
|
128
|
+
readonly usbVersionMinor: number;
|
|
129
|
+
readonly usbVersionSubminor: number;
|
|
130
|
+
readonly vendorId: number;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// https://wicg.github.io/serial/
|
|
134
|
+
|
|
135
|
+
export interface SerialPortData {
|
|
136
|
+
readonly usbVendorId?: number | undefined;
|
|
137
|
+
readonly usbProductId?: number | undefined;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// https://wicg.github.io/webhid/
|
|
141
|
+
|
|
142
|
+
export interface HidDeviceData {
|
|
143
|
+
readonly opened: boolean;
|
|
144
|
+
readonly vendorId: number;
|
|
145
|
+
readonly productId: number;
|
|
146
|
+
readonly productName: string;
|
|
147
|
+
readonly collections: [];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
@injectable()
|
|
151
|
+
export class PluginVscodeCommandsContribution implements CommandContribution {
|
|
152
|
+
@inject(CommandService)
|
|
153
|
+
protected readonly commandService: CommandService;
|
|
154
|
+
@inject(ContextKeyService)
|
|
155
|
+
protected readonly contextKeyService: ContextKeyService;
|
|
156
|
+
@inject(EditorManager)
|
|
157
|
+
protected readonly editorManager: EditorManager;
|
|
158
|
+
@inject(ApplicationShell)
|
|
159
|
+
protected readonly shell: ApplicationShell;
|
|
160
|
+
@inject(DiffService)
|
|
161
|
+
protected readonly diffService: DiffService;
|
|
162
|
+
@inject(OpenerService)
|
|
163
|
+
protected readonly openerService: OpenerService;
|
|
164
|
+
@inject(ApplicationShellMouseTracker)
|
|
165
|
+
protected readonly mouseTracker: ApplicationShellMouseTracker;
|
|
166
|
+
@inject(QuickInputService) @optional()
|
|
167
|
+
protected readonly quickInput: QuickInputService;
|
|
168
|
+
@inject(WorkspaceService)
|
|
169
|
+
protected readonly workspaceService: WorkspaceService;
|
|
170
|
+
@inject(TerminalFrontendContribution)
|
|
171
|
+
protected readonly terminalContribution: TerminalFrontendContribution;
|
|
172
|
+
@inject(QuickOpenWorkspace)
|
|
173
|
+
protected readonly quickOpenWorkspace: QuickOpenWorkspace;
|
|
174
|
+
@inject(TerminalService)
|
|
175
|
+
protected readonly terminalService: TerminalService;
|
|
176
|
+
@inject(CodeEditorWidgetUtil)
|
|
177
|
+
protected readonly codeEditorWidgetUtil: CodeEditorWidgetUtil;
|
|
178
|
+
@inject(PluginServer)
|
|
179
|
+
protected readonly pluginServer: PluginServer;
|
|
180
|
+
@inject(FileService)
|
|
181
|
+
protected readonly fileService: FileService;
|
|
182
|
+
@inject(CallHierarchyServiceProvider)
|
|
183
|
+
protected readonly callHierarchyProvider: CallHierarchyServiceProvider;
|
|
184
|
+
@inject(TypeHierarchyServiceProvider)
|
|
185
|
+
protected readonly typeHierarchyProvider: TypeHierarchyServiceProvider;
|
|
186
|
+
@inject(MonacoTextModelService)
|
|
187
|
+
protected readonly textModelService: MonacoTextModelService;
|
|
188
|
+
@inject(WindowService)
|
|
189
|
+
protected readonly windowService: WindowService;
|
|
190
|
+
@inject(MessageService)
|
|
191
|
+
protected readonly messageService: MessageService;
|
|
192
|
+
@inject(OutlineViewContribution)
|
|
193
|
+
protected outlineViewContribution: OutlineViewContribution;
|
|
194
|
+
@inject(MonacoLanguages)
|
|
195
|
+
protected monacoLanguages: MonacoLanguages;
|
|
196
|
+
|
|
197
|
+
private async openWith(commandId: string, resource: URI, columnOrOptions?: ViewColumn | TextDocumentShowOptions, openerId?: string): Promise<boolean> {
|
|
198
|
+
if (!resource) {
|
|
199
|
+
throw new Error(`${commandId} command requires at least URI argument.`);
|
|
200
|
+
}
|
|
201
|
+
if (!URI.isUri(resource)) {
|
|
202
|
+
throw new Error(`Invalid argument for ${commandId} command with URI argument. Found ${resource}`);
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
let options: TextDocumentShowOptions | undefined;
|
|
206
|
+
if (typeof columnOrOptions === 'number') {
|
|
207
|
+
options = {
|
|
208
|
+
viewColumn: columnOrOptions
|
|
209
|
+
};
|
|
210
|
+
} else if (columnOrOptions) {
|
|
211
|
+
options = {
|
|
212
|
+
...columnOrOptions
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const uri = new TheiaURI(resource);
|
|
217
|
+
const editorOptions = DocumentsMainImpl.toEditorOpenerOptions(this.shell, options);
|
|
218
|
+
|
|
219
|
+
let openHandler: OpenHandler | undefined;
|
|
220
|
+
if (typeof openerId === 'string') {
|
|
221
|
+
const lowerViewType = openerId.toLowerCase();
|
|
222
|
+
const openers = await this.openerService.getOpeners();
|
|
223
|
+
for (const opener of openers) {
|
|
224
|
+
const idLowerCase = opener.id.toLowerCase();
|
|
225
|
+
if (lowerViewType === idLowerCase) {
|
|
226
|
+
openHandler = opener;
|
|
227
|
+
break;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
} else {
|
|
231
|
+
openHandler = await this.openerService.getOpener(uri, editorOptions);
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
if (openHandler) {
|
|
235
|
+
await openHandler.open(uri, editorOptions);
|
|
236
|
+
return true;
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
return false;
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
registerCommands(commands: CommandRegistry): void {
|
|
243
|
+
commands.registerCommand(VscodeCommands.GET_CODE_EXCHANGE_ENDPOINTS, {
|
|
244
|
+
execute: () => undefined // this is a dummy implementation: only used in the case of web apps, which is not supported yet.
|
|
245
|
+
});
|
|
246
|
+
|
|
247
|
+
commands.registerCommand(VscodeCommands.OPEN, {
|
|
248
|
+
isVisible: () => false,
|
|
249
|
+
execute: async (resource: URI | string, columnOrOptions?: ViewColumn | TextDocumentShowOptions) => {
|
|
250
|
+
if (typeof resource === 'string') {
|
|
251
|
+
resource = URI.parse(resource);
|
|
252
|
+
}
|
|
253
|
+
try {
|
|
254
|
+
await this.openWith(VscodeCommands.OPEN.id, resource, columnOrOptions);
|
|
255
|
+
} catch (error) {
|
|
256
|
+
const message = nls.localizeByDefault("Unable to open '{0}'", resource.path);
|
|
257
|
+
const reason = nls.localizeByDefault('Error: {0}', error.message);
|
|
258
|
+
this.messageService.error(`${message}\n${reason}`);
|
|
259
|
+
console.warn(error);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
commands.registerCommand(VscodeCommands.OPEN_WITH, {
|
|
265
|
+
isVisible: () => false,
|
|
266
|
+
execute: async (resource: URI, viewType: string, columnOrOptions?: ViewColumn | TextDocumentShowOptions) => {
|
|
267
|
+
if (!viewType) {
|
|
268
|
+
throw new Error(`Running the contributed command: ${VscodeCommands.OPEN_WITH} failed.`);
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
if (viewType.toLowerCase() === 'default') {
|
|
272
|
+
return commands.executeCommand(VscodeCommands.OPEN.id, resource, columnOrOptions);
|
|
273
|
+
}
|
|
274
|
+
|
|
275
|
+
let result = await this.openWith(VscodeCommands.OPEN_WITH.id, resource, columnOrOptions, viewType);
|
|
276
|
+
if (!result) {
|
|
277
|
+
result = await this.openWith(VscodeCommands.OPEN_WITH.id, resource, columnOrOptions, CustomEditorOpener.toCustomEditorId(viewType));
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (!result) {
|
|
281
|
+
throw new Error(`Could not find an editor for '${viewType}'`);
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
});
|
|
285
|
+
|
|
286
|
+
interface IOpenFolderAPICommandOptions {
|
|
287
|
+
forceNewWindow?: boolean;
|
|
288
|
+
forceReuseWindow?: boolean;
|
|
289
|
+
noRecentEntry?: boolean;
|
|
290
|
+
}
|
|
291
|
+
|
|
292
|
+
commands.registerCommand(VscodeCommands.OPEN_FOLDER, {
|
|
293
|
+
isVisible: () => false,
|
|
294
|
+
execute: async (resource?: URI, arg: boolean | IOpenFolderAPICommandOptions = {}) => {
|
|
295
|
+
if (!resource) {
|
|
296
|
+
return commands.executeCommand(WorkspaceCommands.OPEN_WORKSPACE.id);
|
|
297
|
+
}
|
|
298
|
+
if (!URI.isUri(resource)) {
|
|
299
|
+
throw new Error(`Invalid argument for ${VscodeCommands.OPEN_FOLDER.id} command with URI argument. Found ${resource}`);
|
|
300
|
+
}
|
|
301
|
+
let options: WorkspaceInput | undefined;
|
|
302
|
+
if (typeof arg === 'boolean') {
|
|
303
|
+
options = { preserveWindow: !arg };
|
|
304
|
+
} else {
|
|
305
|
+
options = { preserveWindow: !arg.forceNewWindow };
|
|
306
|
+
}
|
|
307
|
+
this.workspaceService.open(new TheiaURI(resource), options);
|
|
308
|
+
}
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
commands.registerCommand(VscodeCommands.DIFF, {
|
|
312
|
+
isVisible: () => false,
|
|
313
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
314
|
+
execute: async (left: URI, right: URI, label?: string, options?: TextDocumentShowOptions) => {
|
|
315
|
+
if (!left || !right) {
|
|
316
|
+
throw new Error(`${VscodeCommands.DIFF} command requires at least two URI arguments. Found left=${left}, right=${right} as arguments`);
|
|
317
|
+
}
|
|
318
|
+
if (!URI.isUri(left)) {
|
|
319
|
+
throw new Error(`Invalid argument for ${VscodeCommands.DIFF.id} command with left argument. Expecting URI left type but found ${left}`);
|
|
320
|
+
}
|
|
321
|
+
if (!URI.isUri(right)) {
|
|
322
|
+
throw new Error(`Invalid argument for ${VscodeCommands.DIFF.id} command with right argument. Expecting URI right type but found ${right}`);
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
const leftURI = new TheiaURI(left);
|
|
326
|
+
const editorOptions = DocumentsMainImpl.toEditorOpenerOptions(this.shell, options);
|
|
327
|
+
await this.diffService.openDiffEditor(leftURI, new TheiaURI(right), label, editorOptions);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
// https://code.visualstudio.com/docs/getstarted/keybindings#_navigation
|
|
332
|
+
/*
|
|
333
|
+
* internally, in VS Code, any widget opened in the main area is represented as an editor
|
|
334
|
+
* operations below apply to them, but not to side-bar widgets, like the explorer
|
|
335
|
+
*
|
|
336
|
+
* in Theia, there are not such difference and any widget can be put in any area
|
|
337
|
+
* because of it we filter out editors from views based on `NavigatableWidget.is`
|
|
338
|
+
* and apply actions only to them
|
|
339
|
+
*/
|
|
340
|
+
if (!environment.electron.is() || isOSX) {
|
|
341
|
+
commands.registerCommand({ id: 'workbench.action.files.openFileFolder' }, {
|
|
342
|
+
execute: () => commands.executeCommand(WorkspaceCommands.OPEN.id)
|
|
343
|
+
});
|
|
344
|
+
}
|
|
345
|
+
|
|
346
|
+
commands.registerCommand({ id: 'workbench.action.files.openFile' }, {
|
|
347
|
+
execute: () => commands.executeCommand(WorkspaceCommands.OPEN_FILE.id)
|
|
348
|
+
});
|
|
349
|
+
commands.registerCommand({ id: 'workbench.action.files.openFolder' }, {
|
|
350
|
+
execute: () => commands.executeCommand(WorkspaceCommands.OPEN_FOLDER.id)
|
|
351
|
+
});
|
|
352
|
+
commands.registerCommand({ id: 'workbench.action.addRootFolder' }, {
|
|
353
|
+
execute: () => commands.executeCommand(WorkspaceCommands.ADD_FOLDER.id)
|
|
354
|
+
});
|
|
355
|
+
commands.registerCommand({ id: 'workbench.action.saveWorkspaceAs' }, {
|
|
356
|
+
execute: () => commands.executeCommand(WorkspaceCommands.SAVE_WORKSPACE_AS.id)
|
|
357
|
+
});
|
|
358
|
+
commands.registerCommand({ id: 'workbench.action.gotoLine' }, {
|
|
359
|
+
execute: () => commands.executeCommand(EditorCommands.GOTO_LINE_COLUMN.id)
|
|
360
|
+
});
|
|
361
|
+
commands.registerCommand({ id: 'workbench.action.quickOpen' }, {
|
|
362
|
+
execute: (prefix?: unknown) => this.quickInput.open(typeof prefix === 'string' ? prefix : '')
|
|
363
|
+
});
|
|
364
|
+
commands.registerCommand({ id: 'workbench.action.openSettings' }, {
|
|
365
|
+
execute: (query?: string) => commands.executeCommand(CommonCommands.OPEN_PREFERENCES.id, query)
|
|
366
|
+
});
|
|
367
|
+
commands.registerCommand({ id: 'workbench.action.openWorkspaceConfigFile' }, {
|
|
368
|
+
execute: () => commands.executeCommand(WorkspaceCommands.OPEN_WORKSPACE_FILE.id)
|
|
369
|
+
});
|
|
370
|
+
commands.registerCommand({ id: 'workbench.files.action.refreshFilesExplorer' }, {
|
|
371
|
+
execute: () => commands.executeCommand(FileNavigatorCommands.REFRESH_NAVIGATOR.id)
|
|
372
|
+
});
|
|
373
|
+
commands.registerCommand({ id: VscodeCommands.INSTALL_FROM_VSIX.id }, {
|
|
374
|
+
execute: async (vsixUriOrExtensionId: TheiaURI | UriComponents | string) => {
|
|
375
|
+
if (typeof vsixUriOrExtensionId === 'string') {
|
|
376
|
+
await this.pluginServer.deploy(VSCodeExtensionUri.fromId(vsixUriOrExtensionId).toString());
|
|
377
|
+
} else {
|
|
378
|
+
const uriPath = isUriComponents(vsixUriOrExtensionId) ? URI.revive(vsixUriOrExtensionId).fsPath : await this.fileService.fsPath(vsixUriOrExtensionId);
|
|
379
|
+
await this.pluginServer.deploy(`local-file:${uriPath}`);
|
|
380
|
+
}
|
|
381
|
+
}
|
|
382
|
+
});
|
|
383
|
+
commands.registerCommand({ id: 'workbench.action.files.save', }, {
|
|
384
|
+
execute: (uri?: monaco.Uri) => {
|
|
385
|
+
if (uri) {
|
|
386
|
+
const uriString = uri.toString();
|
|
387
|
+
const widget = this.shell.widgets.find(w => {
|
|
388
|
+
const resourceUri = Saveable.is(w) && NavigatableWidget.is(w) && w.getResourceUri();
|
|
389
|
+
return (resourceUri && resourceUri.toString()) === uriString;
|
|
390
|
+
});
|
|
391
|
+
if (Saveable.is(widget)) {
|
|
392
|
+
Saveable.save(widget);
|
|
393
|
+
}
|
|
394
|
+
} else {
|
|
395
|
+
this.shell.save();
|
|
396
|
+
}
|
|
397
|
+
}
|
|
398
|
+
});
|
|
399
|
+
commands.registerCommand({ id: 'workbench.action.files.saveAll', }, {
|
|
400
|
+
execute: () => this.shell.saveAll()
|
|
401
|
+
});
|
|
402
|
+
commands.registerCommand({ id: 'workbench.action.closeActiveEditor' }, {
|
|
403
|
+
execute: () => commands.executeCommand(CommonCommands.CLOSE_MAIN_TAB.id)
|
|
404
|
+
});
|
|
405
|
+
commands.registerCommand({ id: 'workbench.action.closeOtherEditors' }, {
|
|
406
|
+
execute: async (uri?: monaco.Uri) => {
|
|
407
|
+
let editor = this.editorManager.currentEditor || this.shell.currentWidget;
|
|
408
|
+
if (uri) {
|
|
409
|
+
const uriString = uri.toString();
|
|
410
|
+
editor = this.editorManager.all.find(e => {
|
|
411
|
+
const resourceUri = e.getResourceUri();
|
|
412
|
+
return (resourceUri && resourceUri.toString()) === uriString;
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
const toClose = this.shell.widgets.filter(widget => widget !== editor && this.codeEditorWidgetUtil.is(widget));
|
|
416
|
+
await this.shell.closeMany(toClose);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
|
|
420
|
+
const performActionOnGroup = (
|
|
421
|
+
cb: (
|
|
422
|
+
tabBarOrArea: TabBar<Widget> | ApplicationShell.Area,
|
|
423
|
+
filter?: ((title: Title<Widget>, index: number) => boolean) | undefined
|
|
424
|
+
) => void,
|
|
425
|
+
uri?: monaco.Uri
|
|
426
|
+
): void => {
|
|
427
|
+
let editor = this.editorManager.currentEditor || this.shell.currentWidget;
|
|
428
|
+
if (uri) {
|
|
429
|
+
const uriString = uri.toString();
|
|
430
|
+
editor = this.editorManager.all.find(e => {
|
|
431
|
+
const resourceUri = e.getResourceUri();
|
|
432
|
+
return (resourceUri && resourceUri.toString()) === uriString;
|
|
433
|
+
});
|
|
434
|
+
}
|
|
435
|
+
if (editor) {
|
|
436
|
+
const tabBar = this.shell.getTabBarFor(editor);
|
|
437
|
+
if (tabBar) {
|
|
438
|
+
cb(tabBar, ({ owner }) => this.codeEditorWidgetUtil.is(owner));
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
};
|
|
442
|
+
|
|
443
|
+
commands.registerCommand({
|
|
444
|
+
id: 'workbench.action.closeEditorsInGroup',
|
|
445
|
+
label: nls.localizeByDefault('Close All Editors in Group')
|
|
446
|
+
}, {
|
|
447
|
+
execute: (uri?: monaco.Uri) => performActionOnGroup(this.shell.closeTabs, uri)
|
|
448
|
+
});
|
|
449
|
+
commands.registerCommand({
|
|
450
|
+
id: 'workbench.files.saveAllInGroup',
|
|
451
|
+
label: nls.localizeByDefault('Save All in Group')
|
|
452
|
+
}, {
|
|
453
|
+
execute: (uri?: monaco.Uri) => performActionOnGroup(this.shell.saveTabs, uri)
|
|
454
|
+
});
|
|
455
|
+
commands.registerCommand({ id: 'workbench.action.closeEditorsInOtherGroups' }, {
|
|
456
|
+
execute: () => {
|
|
457
|
+
const editor = this.editorManager.currentEditor || this.shell.currentWidget;
|
|
458
|
+
if (editor) {
|
|
459
|
+
const editorTabBar = this.shell.getTabBarFor(editor);
|
|
460
|
+
for (const tabBar of this.shell.allTabBars) {
|
|
461
|
+
if (tabBar !== editorTabBar) {
|
|
462
|
+
this.shell.closeTabs(tabBar,
|
|
463
|
+
({ owner }) => this.codeEditorWidgetUtil.is(owner)
|
|
464
|
+
);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
});
|
|
470
|
+
commands.registerCommand({ id: 'workbench.action.closeEditorsToTheLeft' }, {
|
|
471
|
+
execute: () => {
|
|
472
|
+
const editor = this.editorManager.currentEditor || this.shell.currentWidget;
|
|
473
|
+
if (editor) {
|
|
474
|
+
const tabBar = this.shell.getTabBarFor(editor);
|
|
475
|
+
if (tabBar) {
|
|
476
|
+
let left = true;
|
|
477
|
+
this.shell.closeTabs(tabBar,
|
|
478
|
+
({ owner }) => {
|
|
479
|
+
if (owner === editor) {
|
|
480
|
+
left = false;
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
return left && this.codeEditorWidgetUtil.is(owner);
|
|
484
|
+
}
|
|
485
|
+
);
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
});
|
|
490
|
+
commands.registerCommand({ id: 'workbench.action.closeEditorsToTheRight' }, {
|
|
491
|
+
execute: () => {
|
|
492
|
+
const editor = this.editorManager.currentEditor || this.shell.currentWidget;
|
|
493
|
+
if (editor) {
|
|
494
|
+
const tabBar = this.shell.getTabBarFor(editor);
|
|
495
|
+
if (tabBar) {
|
|
496
|
+
let left = true;
|
|
497
|
+
this.shell.closeTabs(tabBar,
|
|
498
|
+
({ owner }) => {
|
|
499
|
+
if (owner === editor) {
|
|
500
|
+
left = false;
|
|
501
|
+
return false;
|
|
502
|
+
}
|
|
503
|
+
return !left && this.codeEditorWidgetUtil.is(owner);
|
|
504
|
+
}
|
|
505
|
+
);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
commands.registerCommand({ id: 'workbench.action.closeAllEditors' }, {
|
|
511
|
+
execute: async () => {
|
|
512
|
+
const toClose = this.shell.widgets.filter(widget => this.codeEditorWidgetUtil.is(widget));
|
|
513
|
+
await this.shell.closeMany(toClose);
|
|
514
|
+
}
|
|
515
|
+
});
|
|
516
|
+
commands.registerCommand({ id: 'workbench.action.nextEditor' }, {
|
|
517
|
+
execute: () => this.shell.activateNextTab()
|
|
518
|
+
});
|
|
519
|
+
commands.registerCommand({ id: 'workbench.action.previousEditor' }, {
|
|
520
|
+
execute: () => this.shell.activatePreviousTab()
|
|
521
|
+
});
|
|
522
|
+
commands.registerCommand({ id: 'workbench.action.navigateBack' }, {
|
|
523
|
+
execute: () => commands.executeCommand(EditorCommands.GO_BACK.id)
|
|
524
|
+
});
|
|
525
|
+
commands.registerCommand({ id: 'workbench.action.navigateForward' }, {
|
|
526
|
+
execute: () => commands.executeCommand(EditorCommands.GO_FORWARD.id)
|
|
527
|
+
});
|
|
528
|
+
commands.registerCommand({ id: 'workbench.action.navigateToLastEditLocation' }, {
|
|
529
|
+
execute: () => commands.executeCommand(EditorCommands.GO_LAST_EDIT.id)
|
|
530
|
+
});
|
|
531
|
+
|
|
532
|
+
commands.registerCommand({ id: 'openInTerminal' }, {
|
|
533
|
+
execute: (resource: URI) => this.terminalContribution.openInTerminal(new TheiaURI(resource.toString()))
|
|
534
|
+
});
|
|
535
|
+
|
|
536
|
+
commands.registerCommand({ id: 'workbench.action.reloadWindow' }, {
|
|
537
|
+
execute: () => {
|
|
538
|
+
this.windowService.reload();
|
|
539
|
+
}
|
|
540
|
+
});
|
|
541
|
+
|
|
542
|
+
/**
|
|
543
|
+
* TODO:
|
|
544
|
+
* Open Next: workbench.action.openNextRecentlyUsedEditorInGroup
|
|
545
|
+
* Open Previous: workbench.action.openPreviousRecentlyUsedEditorInGroup
|
|
546
|
+
* Copy Path of Active File: workbench.action.files.copyPathOfActiveFile
|
|
547
|
+
* Reveal Active File in Windows: workbench.action.files.revealActiveFileInWindows
|
|
548
|
+
* Show Opened File in New Window: workbench.action.files.showOpenedFileInNewWindow
|
|
549
|
+
* Compare Opened File With: workbench.files.action.compareFileWith
|
|
550
|
+
*/
|
|
551
|
+
|
|
552
|
+
// Register built-in language service commands
|
|
553
|
+
// see https://code.visualstudio.com/api/references/commands
|
|
554
|
+
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
555
|
+
|
|
556
|
+
// TODO register other `vscode.execute...` commands.
|
|
557
|
+
// see https://github.com/microsoft/vscode/blob/master/src/vs/workbench/api/common/extHostApiCommands.ts
|
|
558
|
+
commands.registerCommand(
|
|
559
|
+
{
|
|
560
|
+
id: 'vscode.executeDefinitionProvider'
|
|
561
|
+
},
|
|
562
|
+
{
|
|
563
|
+
execute: ((resource: URI, position: Position) =>
|
|
564
|
+
commands.executeCommand<Location[]>('_executeDefinitionProvider', monaco.Uri.from(resource), position))
|
|
565
|
+
}
|
|
566
|
+
);
|
|
567
|
+
commands.registerCommand(
|
|
568
|
+
{
|
|
569
|
+
id: 'vscode.executeDeclarationProvider'
|
|
570
|
+
},
|
|
571
|
+
{
|
|
572
|
+
execute: ((resource: URI, position: Position) =>
|
|
573
|
+
commands.executeCommand<Location[]>('_executeDeclarationProvider', monaco.Uri.from(resource), position))
|
|
574
|
+
}
|
|
575
|
+
);
|
|
576
|
+
commands.registerCommand(
|
|
577
|
+
{
|
|
578
|
+
id: 'vscode.executeTypeDefinitionProvider'
|
|
579
|
+
},
|
|
580
|
+
{
|
|
581
|
+
execute: ((resource: URI, position: Position) =>
|
|
582
|
+
commands.executeCommand<Location[]>('_executeTypeDefinitionProvider', monaco.Uri.from(resource), position))
|
|
583
|
+
}
|
|
584
|
+
);
|
|
585
|
+
commands.registerCommand(
|
|
586
|
+
{
|
|
587
|
+
id: 'vscode.executeImplementationProvider'
|
|
588
|
+
},
|
|
589
|
+
{
|
|
590
|
+
execute: ((resource: URI, position: Position) =>
|
|
591
|
+
commands.executeCommand<Location[]>('_executeImplementationProvider', monaco.Uri.from(resource), position))
|
|
592
|
+
}
|
|
593
|
+
);
|
|
594
|
+
commands.registerCommand(
|
|
595
|
+
{
|
|
596
|
+
id: 'vscode.executeHoverProvider'
|
|
597
|
+
},
|
|
598
|
+
{
|
|
599
|
+
execute: ((resource: URI, position: Position) =>
|
|
600
|
+
commands.executeCommand<Hover[]>('_executeHoverProvider', monaco.Uri.from(resource), position))
|
|
601
|
+
}
|
|
602
|
+
);
|
|
603
|
+
commands.registerCommand(
|
|
604
|
+
{
|
|
605
|
+
id: 'vscode.executeDocumentHighlights'
|
|
606
|
+
},
|
|
607
|
+
{
|
|
608
|
+
execute: ((resource: URI, position: Position) =>
|
|
609
|
+
commands.executeCommand<DocumentHighlight[]>('_executeDocumentHighlights', monaco.Uri.from(resource), position))
|
|
610
|
+
}
|
|
611
|
+
);
|
|
612
|
+
commands.registerCommand(
|
|
613
|
+
{
|
|
614
|
+
id: 'vscode.executeReferenceProvider'
|
|
615
|
+
},
|
|
616
|
+
{
|
|
617
|
+
execute: ((resource: URI, position: Position) => commands.executeCommand<Location[]>('_executeReferenceProvider', monaco.Uri.from(resource), position))
|
|
618
|
+
}
|
|
619
|
+
);
|
|
620
|
+
commands.registerCommand(
|
|
621
|
+
{
|
|
622
|
+
id: 'vscode.executeDocumentSymbolProvider'
|
|
623
|
+
},
|
|
624
|
+
{
|
|
625
|
+
execute: (resource: URI) => commands.executeCommand('_executeDocumentSymbolProvider',
|
|
626
|
+
monaco.Uri.parse(resource.toString())
|
|
627
|
+
).then((value: any) => { // eslint-disable-line @typescript-eslint/no-explicit-any
|
|
628
|
+
if (!Array.isArray(value) || value === undefined) {
|
|
629
|
+
return undefined;
|
|
630
|
+
}
|
|
631
|
+
return value.map(loc => toMergedSymbol(resource, loc));
|
|
632
|
+
})
|
|
633
|
+
}
|
|
634
|
+
);
|
|
635
|
+
commands.registerCommand(
|
|
636
|
+
{
|
|
637
|
+
id: 'vscode.executeFormatDocumentProvider'
|
|
638
|
+
},
|
|
639
|
+
{
|
|
640
|
+
execute: ((resource: URI, options: FormattingOptions) =>
|
|
641
|
+
commands.executeCommand<TextEdit[]>('_executeFormatDocumentProvider', monaco.Uri.from(resource), options))
|
|
642
|
+
}
|
|
643
|
+
);
|
|
644
|
+
commands.registerCommand(
|
|
645
|
+
{
|
|
646
|
+
id: 'vscode.executeFormatRangeProvider'
|
|
647
|
+
},
|
|
648
|
+
{
|
|
649
|
+
execute: ((resource: URI, range: Range, options: FormattingOptions) =>
|
|
650
|
+
commands.executeCommand<TextEdit[]>('_executeFormatRangeProvider', monaco.Uri.from(resource), range, options))
|
|
651
|
+
}
|
|
652
|
+
);
|
|
653
|
+
commands.registerCommand(
|
|
654
|
+
{
|
|
655
|
+
id: 'vscode.executeFormatOnTypeProvider'
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
execute: ((resource: URI, position: Position, ch: string, options: FormattingOptions) =>
|
|
659
|
+
commands.executeCommand<TextEdit[]>('_executeFormatOnTypeProvider', monaco.Uri.from(resource), position, ch, options))
|
|
660
|
+
}
|
|
661
|
+
);
|
|
662
|
+
commands.registerCommand(
|
|
663
|
+
{
|
|
664
|
+
id: 'vscode.executeFoldingRangeProvider'
|
|
665
|
+
},
|
|
666
|
+
{
|
|
667
|
+
execute: ((resource: URI, position: Position) =>
|
|
668
|
+
commands.executeCommand<TextEdit[]>('_executeFoldingRangeProvider', monaco.Uri.from(resource), position))
|
|
669
|
+
}
|
|
670
|
+
);
|
|
671
|
+
commands.registerCommand(
|
|
672
|
+
{
|
|
673
|
+
id: 'vscode.executeCodeActionProvider'
|
|
674
|
+
},
|
|
675
|
+
{
|
|
676
|
+
execute: ((resource: URI, range: Range, kind?: string, itemResolveCount?: number) =>
|
|
677
|
+
commands.executeCommand<TextEdit[]>('_executeCodeActionProvider', monaco.Uri.from(resource), range, kind, itemResolveCount))
|
|
678
|
+
}
|
|
679
|
+
);
|
|
680
|
+
commands.registerCommand(
|
|
681
|
+
{
|
|
682
|
+
id: 'vscode.executeWorkspaceSymbolProvider'
|
|
683
|
+
},
|
|
684
|
+
{
|
|
685
|
+
execute: async (queryString: string) =>
|
|
686
|
+
(await Promise.all(
|
|
687
|
+
this.monacoLanguages.workspaceSymbolProviders
|
|
688
|
+
.map(async provider => provider.provideWorkspaceSymbols({ query: queryString }, new CancellationTokenSource().token))))
|
|
689
|
+
.flatMap(symbols => symbols)
|
|
690
|
+
.filter(symbols => !!symbols)
|
|
691
|
+
}
|
|
692
|
+
);
|
|
693
|
+
|
|
694
|
+
commands.registerCommand(
|
|
695
|
+
{
|
|
696
|
+
id: 'vscode.prepareCallHierarchy'
|
|
697
|
+
},
|
|
698
|
+
{
|
|
699
|
+
execute: async (resource: URI, position: Position): Promise<CallHierarchyItem[]> => {
|
|
700
|
+
const provider = await this.getCallHierarchyServiceForUri(resource);
|
|
701
|
+
const definition = await provider?.getRootDefinition(
|
|
702
|
+
resource.path,
|
|
703
|
+
toPosition(position),
|
|
704
|
+
new CancellationTokenSource().token
|
|
705
|
+
);
|
|
706
|
+
if (definition) {
|
|
707
|
+
return definition.items.map(item => fromItemHierarchyDefinition(item));
|
|
708
|
+
};
|
|
709
|
+
return [];
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
);
|
|
713
|
+
commands.registerCommand(
|
|
714
|
+
{
|
|
715
|
+
id: 'vscode.provideIncomingCalls'
|
|
716
|
+
},
|
|
717
|
+
{
|
|
718
|
+
execute: async (item: CallHierarchyItem): Promise<CallHierarchyIncomingCall[]> => {
|
|
719
|
+
const resource = URI.from(item.uri);
|
|
720
|
+
const provider = await this.getCallHierarchyServiceForUri(resource);
|
|
721
|
+
const incomingCalls = await provider?.getCallers(
|
|
722
|
+
toItemHierarchyDefinition(item),
|
|
723
|
+
new CancellationTokenSource().token,
|
|
724
|
+
);
|
|
725
|
+
if (incomingCalls) {
|
|
726
|
+
return incomingCalls.map(fromCallHierarchyCallerToModelCallHierarchyIncomingCall);
|
|
727
|
+
}
|
|
728
|
+
return [];
|
|
729
|
+
},
|
|
730
|
+
},
|
|
731
|
+
);
|
|
732
|
+
commands.registerCommand(
|
|
733
|
+
{
|
|
734
|
+
id: 'vscode.provideOutgoingCalls'
|
|
735
|
+
},
|
|
736
|
+
{
|
|
737
|
+
execute: async (item: CallHierarchyItem): Promise<CallHierarchyOutgoingCall[]> => {
|
|
738
|
+
const resource = URI.from(item.uri);
|
|
739
|
+
const provider = await this.getCallHierarchyServiceForUri(resource);
|
|
740
|
+
const outgoingCalls = await provider?.getCallees?.(
|
|
741
|
+
toItemHierarchyDefinition(item),
|
|
742
|
+
new CancellationTokenSource().token,
|
|
743
|
+
);
|
|
744
|
+
if (outgoingCalls) {
|
|
745
|
+
return outgoingCalls.map(fromCallHierarchyCalleeToModelCallHierarchyOutgoingCall);
|
|
746
|
+
}
|
|
747
|
+
return [];
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
);
|
|
751
|
+
commands.registerCommand(
|
|
752
|
+
{
|
|
753
|
+
id: 'vscode.prepareTypeHierarchy'
|
|
754
|
+
},
|
|
755
|
+
{
|
|
756
|
+
execute: async (resource: URI, position: Position): Promise<TypeHierarchyItem[]> => {
|
|
757
|
+
const provider = await this.getTypeHierarchyServiceForUri(resource);
|
|
758
|
+
const session = await provider?.prepareSession(
|
|
759
|
+
resource.path,
|
|
760
|
+
toPosition(position),
|
|
761
|
+
new CancellationTokenSource().token
|
|
762
|
+
);
|
|
763
|
+
return session ? session.items.map(item => fromItemHierarchyDefinition(item)) : [];
|
|
764
|
+
}
|
|
765
|
+
}
|
|
766
|
+
);
|
|
767
|
+
commands.registerCommand(
|
|
768
|
+
{
|
|
769
|
+
id: 'vscode.provideSupertypes'
|
|
770
|
+
},
|
|
771
|
+
{
|
|
772
|
+
execute: async (item: TypeHierarchyItem): Promise<TypeHierarchyItem[]> => {
|
|
773
|
+
if (!item._sessionId || !item._itemId) {
|
|
774
|
+
return [];
|
|
775
|
+
}
|
|
776
|
+
const resource = URI.from(item.uri);
|
|
777
|
+
const provider = await this.getTypeHierarchyServiceForUri(resource);
|
|
778
|
+
const items = await provider?.provideSuperTypes(
|
|
779
|
+
item._sessionId,
|
|
780
|
+
item._itemId,
|
|
781
|
+
new CancellationTokenSource().token
|
|
782
|
+
);
|
|
783
|
+
return (items ? items : []).map(typeItem => fromItemHierarchyDefinition(typeItem));
|
|
784
|
+
}
|
|
785
|
+
}
|
|
786
|
+
);
|
|
787
|
+
commands.registerCommand(
|
|
788
|
+
{
|
|
789
|
+
id: 'vscode.provideSubtypes'
|
|
790
|
+
},
|
|
791
|
+
{
|
|
792
|
+
execute: async (item: TypeHierarchyItem): Promise<TypeHierarchyItem[]> => {
|
|
793
|
+
if (!item._sessionId || !item._itemId) {
|
|
794
|
+
return [];
|
|
795
|
+
}
|
|
796
|
+
const resource = URI.from(item.uri);
|
|
797
|
+
const provider = await this.getTypeHierarchyServiceForUri(resource);
|
|
798
|
+
const items = await provider?.provideSubTypes(
|
|
799
|
+
item._sessionId, item._itemId,
|
|
800
|
+
new CancellationTokenSource().token
|
|
801
|
+
);
|
|
802
|
+
return (items ? items : []).map(typeItem => fromItemHierarchyDefinition(typeItem));
|
|
803
|
+
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
);
|
|
807
|
+
|
|
808
|
+
commands.registerCommand({
|
|
809
|
+
id: 'workbench.action.openRecent'
|
|
810
|
+
}, {
|
|
811
|
+
execute: () => this.quickOpenWorkspace.select()
|
|
812
|
+
});
|
|
813
|
+
commands.registerCommand({
|
|
814
|
+
id: 'explorer.newFolder'
|
|
815
|
+
}, {
|
|
816
|
+
execute: () => commands.executeCommand(WorkspaceCommands.NEW_FOLDER.id)
|
|
817
|
+
});
|
|
818
|
+
commands.registerCommand({
|
|
819
|
+
id: 'workbench.action.terminal.sendSequence'
|
|
820
|
+
}, {
|
|
821
|
+
execute: (args?: { text?: string }) => {
|
|
822
|
+
if (args === undefined || args.text === undefined) {
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
|
|
826
|
+
const currentTerminal = this.terminalService.currentTerminal;
|
|
827
|
+
|
|
828
|
+
if (currentTerminal === undefined) {
|
|
829
|
+
return;
|
|
830
|
+
}
|
|
831
|
+
|
|
832
|
+
currentTerminal.sendText(args.text);
|
|
833
|
+
}
|
|
834
|
+
});
|
|
835
|
+
commands.registerCommand({
|
|
836
|
+
id: 'workbench.action.terminal.kill'
|
|
837
|
+
}, {
|
|
838
|
+
execute: () => {
|
|
839
|
+
const currentTerminal = this.terminalService.currentTerminal;
|
|
840
|
+
|
|
841
|
+
if (currentTerminal === undefined) {
|
|
842
|
+
return;
|
|
843
|
+
}
|
|
844
|
+
|
|
845
|
+
currentTerminal.dispose();
|
|
846
|
+
}
|
|
847
|
+
});
|
|
848
|
+
commands.registerCommand({
|
|
849
|
+
id: 'workbench.view.explorer'
|
|
850
|
+
}, {
|
|
851
|
+
execute: () => commands.executeCommand(FileNavigatorCommands.FOCUS.id)
|
|
852
|
+
});
|
|
853
|
+
commands.registerCommand({
|
|
854
|
+
id: 'copyFilePath'
|
|
855
|
+
}, {
|
|
856
|
+
execute: () => commands.executeCommand(CommonCommands.COPY_PATH.id)
|
|
857
|
+
});
|
|
858
|
+
commands.registerCommand({
|
|
859
|
+
id: 'copyRelativeFilePath'
|
|
860
|
+
}, {
|
|
861
|
+
execute: () => commands.executeCommand(WorkspaceCommands.COPY_RELATIVE_FILE_PATH.id)
|
|
862
|
+
});
|
|
863
|
+
commands.registerCommand({
|
|
864
|
+
id: 'revealInExplorer'
|
|
865
|
+
}, {
|
|
866
|
+
execute: async (resource: URI | object) => {
|
|
867
|
+
if (!URI.isUri(resource)) {
|
|
868
|
+
return;
|
|
869
|
+
}
|
|
870
|
+
let navigator = await this.shell.revealWidget(FILE_NAVIGATOR_ID);
|
|
871
|
+
if (!navigator) {
|
|
872
|
+
await this.commandService.executeCommand(FILE_NAVIGATOR_TOGGLE_COMMAND_ID);
|
|
873
|
+
navigator = await this.shell.revealWidget(FILE_NAVIGATOR_ID);
|
|
874
|
+
}
|
|
875
|
+
if (navigator instanceof FileNavigatorWidget) {
|
|
876
|
+
const model = navigator.model;
|
|
877
|
+
const node = await model.revealFile(new TheiaURI(resource));
|
|
878
|
+
if (SelectableTreeNode.is(node)) {
|
|
879
|
+
model.selectNode(node);
|
|
880
|
+
}
|
|
881
|
+
}
|
|
882
|
+
}
|
|
883
|
+
});
|
|
884
|
+
|
|
885
|
+
commands.registerCommand({
|
|
886
|
+
id: 'workbench.experimental.requestUsbDevice'
|
|
887
|
+
}, {
|
|
888
|
+
execute: async (options?: { filters?: unknown[] }): Promise<UsbDeviceData | undefined> => {
|
|
889
|
+
const usb = (navigator as any).usb;
|
|
890
|
+
if (!usb) {
|
|
891
|
+
return undefined;
|
|
892
|
+
}
|
|
893
|
+
|
|
894
|
+
const device = await usb.requestDevice({ filters: options?.filters ?? [] });
|
|
895
|
+
if (!device) {
|
|
896
|
+
return undefined;
|
|
897
|
+
}
|
|
898
|
+
|
|
899
|
+
return {
|
|
900
|
+
deviceClass: device.deviceClass,
|
|
901
|
+
deviceProtocol: device.deviceProtocol,
|
|
902
|
+
deviceSubclass: device.deviceSubclass,
|
|
903
|
+
deviceVersionMajor: device.deviceVersionMajor,
|
|
904
|
+
deviceVersionMinor: device.deviceVersionMinor,
|
|
905
|
+
deviceVersionSubminor: device.deviceVersionSubminor,
|
|
906
|
+
manufacturerName: device.manufacturerName,
|
|
907
|
+
productId: device.productId,
|
|
908
|
+
productName: device.productName,
|
|
909
|
+
serialNumber: device.serialNumber,
|
|
910
|
+
usbVersionMajor: device.usbVersionMajor,
|
|
911
|
+
usbVersionMinor: device.usbVersionMinor,
|
|
912
|
+
usbVersionSubminor: device.usbVersionSubminor,
|
|
913
|
+
vendorId: device.vendorId,
|
|
914
|
+
};
|
|
915
|
+
}
|
|
916
|
+
});
|
|
917
|
+
|
|
918
|
+
commands.registerCommand({
|
|
919
|
+
id: 'workbench.experimental.requestSerialPort'
|
|
920
|
+
}, {
|
|
921
|
+
execute: async (options?: { filters?: unknown[] }): Promise<SerialPortData | undefined> => {
|
|
922
|
+
const serial = (navigator as any).serial;
|
|
923
|
+
if (!serial) {
|
|
924
|
+
return undefined;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
const port = await serial.requestPort({ filters: options?.filters ?? [] });
|
|
928
|
+
if (!port) {
|
|
929
|
+
return undefined;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
const info = port.getInfo();
|
|
933
|
+
return {
|
|
934
|
+
usbVendorId: info.usbVendorId,
|
|
935
|
+
usbProductId: info.usbProductId
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
});
|
|
939
|
+
|
|
940
|
+
commands.registerCommand({
|
|
941
|
+
id: 'workbench.experimental.requestHidDevice'
|
|
942
|
+
}, {
|
|
943
|
+
execute: async (options?: { filters?: unknown[] }): Promise<HidDeviceData | undefined> => {
|
|
944
|
+
const hid = (navigator as any).hid;
|
|
945
|
+
if (!hid) {
|
|
946
|
+
return undefined;
|
|
947
|
+
}
|
|
948
|
+
|
|
949
|
+
const devices = await hid.requestDevice({ filters: options?.filters ?? [] });
|
|
950
|
+
if (!devices.length) {
|
|
951
|
+
return undefined;
|
|
952
|
+
}
|
|
953
|
+
|
|
954
|
+
const device = devices[0];
|
|
955
|
+
return {
|
|
956
|
+
opened: device.opened,
|
|
957
|
+
vendorId: device.vendorId,
|
|
958
|
+
productId: device.productId,
|
|
959
|
+
productName: device.productName,
|
|
960
|
+
collections: device.collections
|
|
961
|
+
};
|
|
962
|
+
}
|
|
963
|
+
});
|
|
964
|
+
|
|
965
|
+
// required by Jupyter for the show table of contents action
|
|
966
|
+
commands.registerCommand({ id: 'outline.focus' }, {
|
|
967
|
+
execute: () => this.outlineViewContribution.openView({ activate: true })
|
|
968
|
+
});
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
private async resolveLanguageId(resource: URI): Promise<string> {
|
|
972
|
+
const reference = await this.textModelService.createModelReference(resource);
|
|
973
|
+
const languageId = reference.object.languageId;
|
|
974
|
+
reference.dispose();
|
|
975
|
+
return languageId;
|
|
976
|
+
}
|
|
977
|
+
|
|
978
|
+
protected async getCallHierarchyServiceForUri(resource: URI): Promise<CallHierarchyService | undefined> {
|
|
979
|
+
const languageId = await this.resolveLanguageId(resource);
|
|
980
|
+
return this.callHierarchyProvider.get(languageId, new TheiaURI(resource));
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
protected async getTypeHierarchyServiceForUri(resource: URI): Promise<TypeHierarchyService | undefined> {
|
|
984
|
+
const languageId = await this.resolveLanguageId(resource);
|
|
985
|
+
return this.typeHierarchyProvider.get(languageId, new TheiaURI(resource));
|
|
986
|
+
}
|
|
987
|
+
}
|