/
Vscode.hx
2004 lines (1832 loc) · 90.1 KB
/
Vscode.hx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
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
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
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
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
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
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
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
import vscode.*;
@:jsRequire("vscode")
extern class Vscode {
/**
* The version of the editor.
*/
static var version(default, null):String;
/**
* Namespace describing the environment the editor runs in.
*/
static var env(default, null):VscodeEnv;
/**
* Namespace for dealing with commands. In short, a command is a function with a
* unique identifier. The function is sometimes also called _command handler_.
*
* Commands can be added to the editor using the [registerCommand](#commands.registerCommand)
* and [registerTextEditorCommand](#commands.registerTextEditorCommand) functions. Commands
* can be executed [manually](#commands.executeCommand) or from a UI gesture. Those are:
*
* * palette - Use the `commands`-section in `package.json` to make a command show in
* the [command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette).
* * keybinding - Use the `keybindings`-section in `package.json` to enable
* [keybindings](https://code.visualstudio.com/docs/getstarted/keybindings#_customizing-shortcuts)
* for your extension.
*
* Commands from other extensions and from the editor itself are accessible to an extension. However,
* when invoking an editor command not all argument types are supported.
*
* This is a sample that registers a command handler and adds an entry for that command to the palette. First
* register a command handler with the identifier `extension.sayHello`.
* ```javascript
* commands.registerCommand('extension.sayHello', () => {
* window.showInformationMessage('Hello World!');
* });
* ```
* Second, bind the command identifier to a title under which it will show in the palette (`package.json`).
* ```json
* {
* "contributes": {
* "commands": [{
* "command": "extension.sayHello",
* "title": "Hello World"
* }]
* }
* }
* ```
*/
static var commands(default, null):VscodeCommands;
/**
* Namespace for dealing with the current window of the editor. That is visible
* and active editors, as well as, UI elements to show messages, selections, and
* asking for user input.
*/
static var window(default, null):VscodeWindow;
/**
* Namespace for dealing with the current workspace. A workspace is the representation
* of the folder that has been opened. There is no workspace when just a file but not a
* folder has been opened.
*
* The workspace offers support for [listening](#workspace.createFileSystemWatcher) to fs
* events and for [finding](#workspace.findFiles) files. Both perform well and run _outside_
* the editor-process so that they should be always used instead of nodejs-equivalents.
*/
static var workspace(default, null):VscodeWorkspace;
/**
* Namespace for participating in language-specific editor [features](https://code.visualstudio.com/docs/editor/editingevolved),
* like IntelliSense, code actions, diagnostics etc.
*
* Many programming languages exist and there is huge variety in syntaxes, semantics, and paradigms. Despite that, features
* like automatic word-completion, code navigation, or code checking have become popular across different tools for different
* programming languages.
*
* The editor provides an API that makes it simple to provide such common features by having all UI and actions already in place and
* by allowing you to participate by providing data only. For instance, to contribute a hover all you have to do is provide a function
* that can be called with a [TextDocument](#TextDocument) and a [Position](#Position) returning hover info. The rest, like tracking the
* mouse, positioning the hover, keeping the hover stable etc. is taken care of by the editor.
*
* ```javascript
* languages.registerHoverProvider('javascript', {
* provideHover(document, position, token) {
* return new Hover('I am a hover!');
* }
* });
* ```
*
* Registration is done using a [document selector](#DocumentSelector) which is either a language id, like `javascript` or
* a more complex [filter](#DocumentFilter) like `{ language: 'typescript', scheme: 'file' }`. Matching a document against such
* a selector will result in a [score](#languages.match) that is used to determine if and how a provider shall be used. When
* scores are equal the provider that came last wins. For features that allow full arity, like [hover](#languages.registerHoverProvider),
* the score is only checked to be `>0`, for other features, like [IntelliSense](#languages.registerCompletionItemProvider) the
* score is used for determining the order in which providers are asked to participate.
*/
static var languages(default, null):VscodeLanguages;
static var scm(default, null):VscodeScm;
/**
* Namespace for debug functionality.
*/
static var debug(default, null):VscodeDebug;
/**
* Namespace for dealing with installed extensions. Extensions are represented
* by an [extension](#Extension)-interface which enables reflection on them.
*
* Extension writers can provide APIs to other extensions by returning their API public
* surface from the `activate`-call.
*
* ```javascript
* export function activate(context: vscode.ExtensionContext) {
* let api = {
* sum(a, b) {
* return a + b;
* },
* mul(a, b) {
* return a * b;
* }
* };
* // 'export' public api-surface
* return api;
* }
* ```
*
* When depending on the API of another extension add an `extensionDependencies`-entry
* to `package.json`, and use the [getExtension](#extensions.getExtension)-function
* and the [exports](#Extension.exports)-property, like below:
*
* ```javascript
* let mathExt = extensions.getExtension('genius.math');
* let importedApi = mathExt.exports;
*
* console.log(importedApi.mul(42, 1));
* ```
*/
static var extensions(default, null):VscodeExtensions;
/**
* Namespace for tasks functionality.
*/
static var tasks(default, null):VscodeTasks;
static var comments(default, null):VscodeComments;
/**
* Namespace for authentication.
*/
static var authentication(default, null):VscodeAuthentication;
}
extern class VscodeEnv {
/**
* The application name of the editor, like 'VS Code'.
*/
var appName(default, null):String;
/**
* The application root folder from which the editor is running.
*
* *Note* that the value is the empty string when running in an
* environment that has no representation of an application root folder.
*/
var appRoot(default, null):String;
/**
* The custom uri scheme the editor registers to in the operating system.
*/
var uriScheme(default, null):String;
/**
* Represents the preferred user-language, like `de-CH`, `fr`, or `en-US`.
*/
var language(default, null):String;
/**
* The system clipboard.
*/
var clipboard(default, null):Clipboard;
/**
* A unique identifier for the computer.
*/
var machineId(default, null):String;
/**
* A unique identifier for the current session.
* Changes each time the editor is started.
*/
var sessionId(default, null):String;
/**
* The name of a remote. Defined by extensions, popular samples are `wsl` for the Windows
* Subsystem for Linux or `ssh-remote` for remotes using a secure shell.
*
* *Note* that the value is `undefined` when there is no remote extension host but that the
* value is defined in all extension hosts (local and remote) in case a remote extension host
* exists. Use [`Extension#extensionKind`](#Extension.extensionKind) to know if
* a specific extension runs remote or not.
*/
var remoteName(default, null):Null<String>;
/**
* The detected default shell for the extension host, this is overridden by the
* `terminal.integrated.shell` setting for the extension host's platform. Note that in
* environments that do not support a shell the value is the empty string.
*/
var shell(default, null):String;
/**
* The UI kind property indicates from which UI extensions
* are accessed from. For example, extensions could be accessed
* from a desktop application or a web browser.
*/
var uiKind(default, null):UIKind;
/**
* Opens a link externally using the default application. Depending on the
* used scheme this can be:
* * a browser (`http:`, `https:`)
* * a mail client (`mailto:`)
* * VSCode itself (`vscode:` from `vscode.env.uriScheme`)
*
* *Note* that [`showTextDocument`](#window.showTextDocument) is the right
* way to open a text document inside the editor, not this function.
*
* @param target The uri that should be opened.
* @returns A promise indicating if open was successful.
*/
function openExternal(target:Uri):Thenable<Bool>;
/**
* Resolves a uri to form that is accessible externally. Currently only supports `https:`, `http:` and
* `vscode.env.uriScheme` uris.
*
* #### `http:` or `https:` scheme
*
* Resolves an *external* uri, such as a `http:` or `https:` link, from where the extension is running to a
* uri to the same resource on the client machine.
*
* This is a no-op if the extension is running on the client machine.
*
* If the extension is running remotely, this function automatically establishes a port forwarding tunnel
* from the local machine to `target` on the remote and returns a local uri to the tunnel. The lifetime of
* the port forwarding tunnel is managed by VS Code and the tunnel can be closed by the user.
*
* *Note* that uris passed through `openExternal` are automatically resolved and you should not call `asExternalUri` on them.
*
* #### `vscode.env.uriScheme`
*
* Creates a uri that - if opened in a browser (e.g. via `openExternal`) - will result in a registered [UriHandler](#UriHandler)
* to trigger.
*
* Extensions should not make any assumptions about the resulting uri and should not alter it in anyway.
* Rather, extensions can e.g. use this uri in an authentication flow, by adding the uri as callback query
* argument to the server to authenticate to.
*
* *Note* that if the server decides to add additional query parameters to the uri (e.g. a token or secret), it
* will appear in the uri that is passed to the [UriHandler](#UriHandler).
*
* **Example** of an authentication flow:
* ```typescript
* vscode.window.registerUriHandler({
* handleUri(uri: vscode.Uri): vscode.ProviderResult<void> {
* if (uri.path === '/did-authenticate') {
* console.log(uri.toString());
* }
* }
* });
*
* const callableUri = await vscode.env.asExternalUri(vscode.Uri.parse(`${vscode.env.uriScheme}://my.extension/did-authenticate`));
* await vscode.env.openExternal(callableUri);
* ```
*
* *Note* that extensions should not cache the result of `asExternalUri` as the resolved uri may become invalid due to
* a system or user action — for example, in remote cases, a user may close a port forwarding tunnel that was opened by
* `asExternalUri`.
*
* @return A uri that can be used on the client machine.
*/
function asExternalUri(target:Uri):Thenable<Uri>;
}
extern class VscodeCommands {
/**
* Registers a command that can be invoked via a keyboard shortcut,
* a menu item, an action, or directly.
*
* Registering a command with an existing command identifier twice
* will cause an error.
*
* @param command A unique identifier for the command.
* @param callback A command handler function.
* @param thisArg The `this` context used when invoking the handler function.
* @return Disposable which unregisters this command on disposal.
*/
function registerCommand(command:String, callback:Function, ?thisArg:Any):Disposable;
/**
* Registers a text editor command that can be invoked via a keyboard shortcut,
* a menu item, an action, or directly.
*
* Text editor commands are different from ordinary [commands](#commands.registerCommand) as
* they only execute when there is an active editor when the command is called. Also, the
* command handler of an editor command has access to the active editor and to an
* [edit](#TextEditorEdit)-builder. Note that the edit-builder is only valid while the
* callback executes.
*
* @param command A unique identifier for the command.
* @param callback A command handler function with access to an [editor](#TextEditor) and an [edit](#TextEditorEdit).
* @param thisArg The `this` context used when invoking the handler function.
* @return Disposable which unregisters this command on disposal.
*/
// TODO callback should receive Rest really
function registerTextEditorCommand(command:String, callback:TextEditor->TextEditorEdit->Void, ?thisArg:Any):Disposable;
/**
* Executes the command denoted by the given command identifier.
*
* * *Note 1:* When executing an editor command not all types are allowed to
* be passed as arguments. Allowed are the primitive types `string`, `boolean`,
* `number`, `undefined`, and `null`, as well as [`Position`](#Position), [`Range`](#Range), [`Uri`](#Uri) and [`Location`](#Location).
* * *Note 2:* There are no restrictions when executing commands that have been contributed
* by extensions.
*
* @param command Identifier of the command to execute.
* @param rest Parameters passed to the command function.
* @return A thenable that resolves to the returned value of the given command. `undefined` when
* the command handler function doesn't return anything.
*/
function executeCommand<T>(command:String, rest:Rest<Any>):Thenable<Null<T>>;
/**
* Retrieve the list of all available commands. Commands starting with an underscore are
* treated as internal commands.
*
* @param filterInternal Set `true` to not see internal commands (starting with an underscore)
* @return Thenable that resolves to a list of command ids.
*/
function getCommands(?filterInternal:Bool):Thenable<Array<String>>;
}
extern class VscodeWindow {
/**
* The currently active editor or `undefined`. The active editor is the one
* that currently has focus or, when none has focus, the one that has changed
* input most recently.
*/
var activeTextEditor:Null<TextEditor>;
/**
* The currently visible editors or an empty array.
*/
var visibleTextEditors:Array<TextEditor>;
/**
* An [event](#Event) which fires when the [active editor](#window.activeTextEditor)
* has changed. *Note* that the event also fires when the active editor changes
* to `undefined`.
*/
var onDidChangeActiveTextEditor(default, null):Event<Null<TextEditor>>;
/**
* An [event](#Event) which fires when the array of [visible editors](#window.visibleTextEditors)
* has changed.
*/
var onDidChangeVisibleTextEditors(default, null):Event<Array<TextEditor>>;
/**
* An [event](#Event) which fires when the selection in an editor has changed.
*/
var onDidChangeTextEditorSelection(default, null):Event<TextEditorSelectionChangeEvent>;
/**
* An [event](#Event) which fires when the visible ranges of an editor has changed.
*/
var onDidChangeTextEditorVisibleRanges(default, null):Event<TextEditorVisibleRangesChangeEvent>;
/**
* An [event](#Event) which fires when the options of an editor have changed.
*/
var onDidChangeTextEditorOptions(default, null):Event<TextEditorOptionsChangeEvent>;
/**
* An [event](#Event) which fires when the view column of an editor has changed.
*/
var onDidChangeTextEditorViewColumn(default, null):Event<TextEditorViewColumnChangeEvent>;
/**
* The currently opened terminals or an empty array.
*/
var terminals(default, null):ReadOnlyArray<Terminal>;
/**
* The currently active terminal or `undefined`. The active terminal is the one that
* currently has focus or most recently had focus.
*/
var activeTerminal(default, null):Null<Terminal>;
/**
* An [event](#Event) which fires when the [active terminal](#window.activeTerminal)
* has changed. *Note* that the event also fires when the active terminal changes
* to `undefined`.
*/
var onDidChangeActiveTerminal(default, null):Null<Event<Terminal>>;
/**
* An [event](#Event) which fires when a terminal has been created, either through the
* [createTerminal](#window.createTerminal) API or commands.
*/
var onDidOpenTerminal(default, null):Event<Terminal>;
/**
* An [event](#Event) which fires when a terminal is disposed.
*/
var onDidCloseTerminal(default, null):Event<Terminal>;
/**
* Represents the current window's state.
*/
var state(default, null):WindowState;
/**
* An [event](#Event) which fires when the focus state of the current window
* changes. The value of the event represents whether the window is focused.
*/
var onDidChangeWindowState(default, null):Event<WindowState>;
/**
* Show the given document in a text editor. A [column](#ViewColumn) can be provided
* to control where the editor is being shown. Might change the [active editor](#window.activeTextEditor).
*
* @param document A text document to be shown.
* @param column A view column in which the [editor](#TextEditor) should be shown. The default is the [active](#ViewColumn.Active), other values
* are adjusted to be `Min(column, columnCount + 1)`, the [active](#ViewColumn.Active)-column is not adjusted. Use [`ViewColumn.Beside`](#ViewColumn.Beside)
* to open the editor to the side of the currently active one.
* @param preserveFocus When `true` the editor will not take focus.
* @return A promise that resolves to an [editor](#TextEditor).
*/
@:overload(function(uri:Uri, ?options:TextDocumentShowOptions):Thenable<TextEditor> {})
@:overload(function(document:TextDocument, ?options:TextDocumentShowOptions):Thenable<TextEditor> {})
function showTextDocument(document:TextDocument, ?column:ViewColumn, ?preserveFocus:Bool):Thenable<TextEditor>;
/**
* Create a TextEditorDecorationType that can be used to add decorations to text editors.
*
* @param options Rendering options for the decoration type.
* @return A new decoration type instance.
*/
function createTextEditorDecorationType(options:DecorationRenderOptions):TextEditorDecorationType;
/**
* Show an information message.
*
* @see [showInformationMessage](#window.showInformationMessage)
*
* @param message The message to show.
* @param items A set of items that will be rendered as actions in the message.
* @param options Configures the behaviour of the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
// TODO overload plox
// /**
// * Show an information message to users. Optionally provide an array of items which will be presented as
// * clickable buttons.
// *
// * @param message The message to show.
// * @param items A set of items that will be rendered as actions in the message.
// * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
// */
// /**
// * Show an information message to users. Optionally provide an array of items which will be presented as
// * clickable buttons.
// *
// * @param message The message to show.
// * @param options Configures the behaviour of the message.
// * @param items A set of items that will be rendered as actions in the message.
// * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
// */
@:overload(function<T:MessageItem>(message:String, items:Rest<T>):Thenable<Null<T>> {})
@:overload(function<T:MessageItem>(message:String, options:MessageOptions, items:Rest<T>):Thenable<Null<T>> {})
@:overload(function(message:String, items:Rest<String>):Thenable<Null<String>> {})
function showInformationMessage(message:String, options:MessageOptions, items:Rest<String>):Thenable<Null<String>>;
/**
* Show a warning message.
*
* @see [showInformationMessage](#window.showInformationMessage)
*
* @param message The message to show.
* @param options Configures the behaviour of the message.
* @param items A set of items that will be rendered as actions in the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
@:overload(function<T:MessageItem>(message:String, items:Rest<T>):Thenable<Null<T>> {})
@:overload(function<T:MessageItem>(message:String, options:MessageOptions, items:Rest<T>):Thenable<Null<T>> {})
@:overload(function(message:String, items:Rest<String>):Thenable<Null<String>> {})
function showWarningMessage(message:String, options:MessageOptions, items:Rest<String>):Thenable<Null<String>>;
/**
* Show an error message.
*
* @see [showInformationMessage](#window.showInformationMessage)
*
* @param message The message to show.
* @param options Configures the behaviour of the message.
* @param items A set of items that will be rendered as actions in the message.
* @return A thenable that resolves to the selected item or `undefined` when being dismissed.
*/
@:overload(function<T:MessageItem>(message:String, items:Rest<T>):Thenable<Null<T>> {})
@:overload(function<T:MessageItem>(message:String, options:MessageOptions, items:Rest<T>):Thenable<Null<T>> {})
@:overload(function(message:String, items:Rest<String>):Thenable<Null<String>> {})
function showErrorMessage(message:String, options:MessageOptions, items:Rest<String>):Thenable<Null<String>>;
/**
* Shows a selection list.
*
* @param items An array of strings, or a promise that resolves to an array of strings.
* @param options Configures the behavior of the selection list.
* @param token A token that can be used to signal cancellation.
* @return A promise that resolves to the selection or `undefined`.
*/
@:overload(function(items:EitherType<Array<String>, Thenable<Array<String>>>, ?options:QuickPickOptions,
?token:CancellationToken):Thenable<Null<String>> {})
function showQuickPick<T:QuickPickItem>(items:EitherType<Array<T>, Thenable<Array<T>>>, ?options:QuickPickOptions,
?token:CancellationToken):Thenable<Null<T>>;
/**
* Shows a selection list allowing multiple selections.
*
* @param items An array of items, or a promise that resolves to an array of items.
* @param options Configures the behavior of the selection list.
* @param token A token that can be used to signal cancellation.
* @return A promise that resolves to the selected items or `undefined`.
*/
// see #13 for details on why this is needed
extern inline function showQuickPickMany<T:QuickPickItem>(items:EitherType<Array<T>, Thenable<Array<T>>>, ?options:QuickPickOptions,
?token:CancellationToken):Thenable<Null<Array<T>>> {
if (options == null)
options = {canPickMany: true};
else
options.canPickMany = true;
return cast showQuickPick(items, options, if (token == null) js.Lib.undefined else token);
}
/**
* Shows a selection list of [workspace folders](#workspace.workspaceFolders) to pick from.
* Returns `undefined` if no folder is open.
*
* @param options Configures the behavior of the workspace folder list.
* @return A promise that resolves to the workspace folder or `undefined`.
*/
function showWorkspaceFolderPick(?options:WorkspaceFolderPickOptions):Thenable<Null<WorkspaceFolder>>;
/**
* Shows a file open dialog to the user which allows to select a file
* for opening-purposes.
*
* @param options Options that control the dialog.
* @returns A promise that resolves to the selected resources or `undefined`.
*/
function showOpenDialog(?options:OpenDialogOptions):Thenable<Null<Array<Uri>>>;
/**
* Shows a file save dialog to the user which allows to select a file
* for saving-purposes.
*
* @param options Options that control the dialog.
* @returns A promise that resolves to the selected resource or `undefined`.
*/
function showSaveDialog(?options:SaveDialogOptions):Thenable<Null<Uri>>;
/**
* Opens an input box to ask the user for input.
*
* The returned value will be undefined if the input box was canceled (e.g. pressing ESC). Otherwise the
* returned value will be the string typed by the user or an empty string if the user did not type
* anything but dismissed the input box with OK.
*
* @param options Configures the behavior of the input box.
* @param token A token that can be used to signal cancellation.
* @return A promise that resolves to a string the user provided or to `undefined` in case of dismissal.
*/
function showInputBox(?options:InputBoxOptions, ?token:CancellationToken):Thenable<Null<String>>;
/**
* Creates a [QuickPick](#QuickPick) to let the user pick an item from a list
* of items of type T.
*
* Note that in many cases the more convenient [window.showQuickPick](#window.showQuickPick)
* is easier to use. [window.createQuickPick](#window.createQuickPick) should be used
* when [window.showQuickPick](#window.showQuickPick) does not offer the required flexibility.
*
* @return A new [QuickPick](#QuickPick).
*/
function createQuickPick<T:QuickPickItem>():QuickPick<T>;
/**
* Creates a [InputBox](#InputBox) to let the user enter some text input.
*
* Note that in many cases the more convenient [window.showInputBox](#window.showInputBox)
* is easier to use. [window.createInputBox](#window.createInputBox) should be used
* when [window.showInputBox](#window.showInputBox) does not offer the required flexibility.
*
* @return A new [InputBox](#InputBox).
*/
function createInputBox():InputBox;
/**
* Creates a new [output channel](#OutputChannel) with the given name.
*
* @param name Human-readable string which will be used to represent the channel in the UI.
*/
function createOutputChannel(name:String):OutputChannel;
/**
* Create and show a new webview panel.
*
* @param viewType Identifies the type of the webview panel.
* @param title Title of the panel.
* @param showOptions Where to show the webview in the editor. If preserveFocus is set, the new webview will not take focus.
* @param options Settings for the new panel.
*
* @return New webview panel.
*/
function createWebviewPanel(viewType:String, title:String, showOptions:EitherType<ViewColumn, {viewColumn:ViewColumn, ?preserveFocus:Bool}>,
?options:WebviewPanelOptions & WebviewOptions):WebviewPanel;
/**
* Set a message to the status bar. This is a short hand for the more powerful
* status bar [items](#window.createStatusBarItem).
*
* *Note* that status bar messages without hide arguments stack and that they must be disposed when no
* longer used.
*
* @param text The message to show, supports icon substitution as in status bar [items](#StatusBarItem.text).
* @param hideAfterTimeout Timeout in milliseconds after which the message will be disposed.
* @param hideWhenDone Thenable on which completion (resolve or reject) the message will be disposed.
* @return A disposable which hides the status bar message.
*/
@:overload(function(text:String, hideAfterTimeout:Float):Disposable {})
@:overload(function(text:String, hideWhenDone:Thenable<Dynamic>):Disposable {})
function setStatusBarMessage(text:String):Disposable;
/**
* Show progress in the Source Control viewlet while running the given callback and while
* its returned promise isn't resolve or rejected.
*
* @deprecated Use `withProgress` instead.
*
* @param task A callback returning a promise. Progress increments can be reported with
* the provided [progress](#Progress)-object.
* @return The thenable the task did return.
*/
@:deprecated("Use `withProgress` instead.")
function withScmProgress<R>(task:Progress<Float>->Thenable<R>):Thenable<R>;
/**
* Show progress in the editor. Progress is shown while running the given callback
* and while the promise it returned isn't resolved nor rejected. The location at which
* progress should show (and other details) is defined via the passed [`ProgressOptions`](#ProgressOptions).
*
* @param task A callback returning a promise. Progress state can be reported with
* the provided [progress](#Progress)-object.
*
* To report discrete progress, use `increment` to indicate how much work has been completed. Each call with
* a `increment` value will be summed up and reflected as overall progress until 100% is reached (a value of
* e.g. `10` accounts for `10%` of work done).
* Note that currently only `ProgressLocation.Notification` is capable of showing discrete progress.
*
* To monitor if the operation has been cancelled by the user, use the provided [`CancellationToken`](#CancellationToken).
* Note that currently only `ProgressLocation.Notification` is supporting to show a cancel button to cancel the
* long running operation.
* @return The thenable the task-callback returned.
*/
function withProgress<R>(options:ProgressOptions, task:Progress<{?message:String, ?increment:Float}>->CancellationToken->Thenable<R>):Thenable<R>;
/**
* Creates a status bar [item](#StatusBarItem).
*
* @param alignment The alignment of the item.
* @param priority The priority of the item. Higher values mean the item should be shown more to the left.
* @return A new status bar item.
*/
function createStatusBarItem(?alignment:StatusBarAlignment, ?priority:Float):StatusBarItem;
/**
* Creates a [Terminal](#Terminal) with a backing shell process. The cwd of the terminal will be the workspace
* directory if it exists.
*
* @param name Optional human-readable string which will be used to represent the terminal in the UI.
* @param shellPath Optional path to a custom shell executable to be used in the terminal.
* @param shellArgs Optional args for the custom shell executable. A string can be used on Windows only which
* allows specifying shell args in
* [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6).
* @param options A TerminalOptions object describing the characteristics of the new terminal.
* @param options An [ExtensionTerminalOptions](#ExtensionTerminalOptions) object describing
* the characteristics of the new terminal.
* @return A new Terminal.
* @throws When running in an environment where a new process cannot be started.
*/
@:overload(function(options:TerminalOptions):Terminal {})
@:overload(function(options:ExtensionTerminalOptions):Terminal {})
function createTerminal(?name:String, ?shellPath:String, ?shellArgs:EitherType<Array<String>, String>):Terminal;
/**
* Register a [TreeDataProvider](#TreeDataProvider) for the view contributed using the extension point `views`.
* This will allow you to contribute data to the [TreeView](#TreeView) and update if the data changes.
*
* **Note:** To get access to the [TreeView](#TreeView) and perform operations on it, use [createTreeView](#window.createTreeView).
*
* @param viewId Id of the view contributed using the extension point `views`.
* @param treeDataProvider A [TreeDataProvider](#TreeDataProvider) that provides tree data for the view
*/
function registerTreeDataProvider<T>(viewId:String, treeDataProvider:TreeDataProvider<T>):Disposable;
/**
* Create a [TreeView](#TreeView) for the view contributed using the extension point `views`.
* @param viewId Id of the view contributed using the extension point `views`.
* @param options Options for creating the [TreeView](#TreeView)
* @returns a [TreeView](#TreeView).
*/
function createTreeView<T>(viewId:String, options:TreeViewOptions<T>):TreeView<T>;
/**
* Registers a [uri handler](#UriHandler) capable of handling system-wide [uris](#Uri).
* In case there are multiple windows open, the topmost window will handle the uri.
* A uri handler is scoped to the extension it is contributed from; it will only
* be able to handle uris which are directed to the extension itself. A uri must respect
* the following rules:
*
* - The uri-scheme must be `vscode.env.uriScheme`;
* - The uri-authority must be the extension id (e.g. `my.extension`);
* - The uri-path, -query and -fragment parts are arbitrary.
*
* For example, if the `my.extension` extension registers a uri handler, it will only
* be allowed to handle uris with the prefix `product-name://my.extension`.
*
* An extension can only register a single uri handler in its entire activation lifetime.
*
* * *Note:* There is an activation event `onUri` that fires when a uri directed for
* the current extension is about to be handled.
*
* @param handler The uri handler to register for this extension.
*/
function registerUriHandler(handler:UriHandler):Disposable;
/**
* Registers a webview panel serializer.
*
* Extensions that support reviving should have an `"onWebviewPanel:viewType"` activation event and
* make sure that [registerWebviewPanelSerializer](#registerWebviewPanelSerializer) is called during activation.
*
* Only a single serializer may be registered at a time for a given `viewType`.
*
* @param viewType Type of the webview panel that can be serialized.
* @param serializer Webview serializer.
*/
function registerWebviewPanelSerializer<T>(viewType:String, serializer:WebviewPanelSerializer<T>):Disposable;
/**
* Register a new provider for webview views.
*
* @param viewId Unique id of the view. This should match the `id` from the
* `views` contribution in the package.json.
* @param provider Provider for the webview views.
*
* @return Disposable that unregisters the provider.
*/
function registerWebviewViewProvider(viewId:String, provider:WebviewViewProvider, ?options:{
/**
* Content settings for the webview created for this view.
*/
var ?webviewOptions(default, null):{
/**
* Controls if the webview element itself (iframe) is kept around even when the view
* is no longer visible.
*
* Normally the webview's html context is created when the view becomes visible
* and destroyed when it is hidden. Extensions that have complex state
* or UI can set the `retainContextWhenHidden` to make VS Code keep the webview
* context around, even when the webview moves to a background tab. When a webview using
* `retainContextWhenHidden` becomes hidden, its scripts and other dynamic content are suspended.
* When the view becomes visible again, the context is automatically restored
* in the exact same state it was in originally. You cannot send messages to a
* hidden webview, even with `retainContextWhenHidden` enabled.
*
* `retainContextWhenHidden` has a high memory overhead and should only be used if
* your view's context cannot be quickly saved and restored.
*/
var ?retainContextWhenHidden(default, null):Bool;
};
}):Disposable;
/**
* Register a provider for custom editors for the `viewType` contributed by the `customEditors` extension point.
*
* When a custom editor is opened, VS Code fires an `onCustomEditor:viewType` activation event. Your extension
* must register a [`CustomTextEditorProvider`](#CustomTextEditorProvider), [`CustomReadonlyEditorProvider`](#CustomReadonlyEditorProvider),
* [`CustomEditorProvider`](#CustomEditorProvider)for `viewType` as part of activation.
*
* @param viewType Unique identifier for the custom editor provider. This should match the `viewType` from the
* `customEditors` contribution point.
* @param provider Provider that resolves custom editors.
* @param options Options for the provider.
*
* @return Disposable that unregisters the provider.
*/
function registerCustomEditorProvider<T:CustomDocument>(viewType:String,
provider:EitherType<CustomTextEditorProvider, EitherType<CustomReadonlyEditorProvider<T>, CustomEditorProvider<T>>>, ?options:{
/**
* Content settings for the webview panels created for this custom editor.
*/
final ?webviewOptions:WebviewPanelOptions;
/**
* Only applies to `CustomReadonlyEditorProvider | CustomEditorProvider`.
*
* Indicates that the provider allows multiple editor instances to be open at the same time for
* the same resource.
*
* By default, VS Code only allows one editor instance to be open at a time for each resource. If the
* user tries to open a second editor instance for the resource, the first one is instead moved to where
* the second one was to be opened.
*
* When `supportsMultipleEditorsPerDocument` is enabled, users can split and create copies of the custom
* editor. In this case, the custom editor must make sure it can properly synchronize the states of all
* editor instances for a resource so that they are consistent.
*/
final ?supportsMultipleEditorsPerDocument:Bool;
}):Disposable;
/**
* Register provider that enables the detection and handling of links within the terminal.
* @param provider The provider that provides the terminal links.
* @return Disposable that unregisters the provider.
*/
function registerTerminalLinkProvider<T:TerminalLink>(provider:TerminalLinkProvider<T>):Disposable;
/**
* The currently active color theme as configured in the settings. The active
* theme can be changed via the `workbench.colorTheme` setting.
*/
var activeColorTheme:ColorTheme;
/**
* An [event](#Event) which fires when the active color theme is changed or has changes.
*/
var onDidChangeActiveColorTheme(default, null):Event<ColorTheme>;
}
extern class VscodeExtensions {
/**
* Get an extension by its full identifier in the form of: `publisher.name`.
*
* @param extensionId An extension identifier.
* @return An extension or `undefined`.
*/
function getExtension<T>(extensionId:String):Null<Extension<T>>;
/**
* All extensions currently known to the system.
*/
var all(default, null):ReadOnlyArray<Extension<Any>>;
/**
* An event which fires when `extensions.all` changes. This can happen when extensions are
* installed, uninstalled, enabled or disabled.
*/
var onDidChange(default, null):Event<Void>;
}
extern class VscodeScm {
/**
* The [input box](#SourceControlInputBox) for the last source control
* created by the extension.
*
* @deprecated Use SourceControl.inputBox instead
*/
@:deprecated("Use SourceControl.inputBox instead")
var inputBox(default, null):SourceControlInputBox;
/**
* Creates a new [source control](#SourceControl) instance.
*
* @param id An `id` for the source control. Something short, e.g.: `git`.
* @param label A human-readable string for the source control. E.g.: `Git`.
* @param rootUri An optional Uri of the root of the source control. E.g.: `Uri.parse(workspaceRoot)`.
* @return An instance of [source control](#SourceControl).
*/
function createSourceControl(id:String, label:String, ?rootUri:Uri):SourceControl;
}
extern class VscodeLanguages {
/**
* Return the identifiers of all known languages.
* @return Promise resolving to an array of identifier strings.
*/
function getLanguages():Thenable<Array<String>>;
/**
* Set (and change) the [language](#TextDocument.languageId) that is associated
* with the given document.
*
* *Note* that calling this function will trigger the [`onDidCloseTextDocument`](#workspace.onDidCloseTextDocument) event
* followed by the [`onDidOpenTextDocument`](#workspace.onDidOpenTextDocument) event.
*
* @param document The document which language is to be changed
* @param languageId The new language identifier.
* @returns A thenable that resolves with the updated document.
*/
function setTextDocumentLanguage(document:TextDocument, languageId:String):Thenable<TextDocument>;
/**
* Compute the match between a document [selector](#DocumentSelector) and a document. Values
* greater than zero mean the selector matches the document.
*
* A match is computed according to these rules:
* 1. When [`DocumentSelector`](#DocumentSelector) is an array, compute the match for each contained `DocumentFilter` or language identifier and take the maximum value.
* 2. A string will be desugared to become the `language`-part of a [`DocumentFilter`](#DocumentFilter), so `"fooLang"` is like `{ language: "fooLang" }`.
* 3. A [`DocumentFilter`](#DocumentFilter) will be matched against the document by comparing its parts with the document. The following rules apply:
* 1. When the `DocumentFilter` is empty (`{}`) the result is `0`
* 2. When `scheme`, `language`, or `pattern` are defined but one doesn't match, the result is `0`
* 3. Matching against `*` gives a score of `5`, matching via equality or via a glob-pattern gives a score of `10`
* 4. The result is the maximum value of each match
*
* Samples:
* ```js
* // default document from disk (file-scheme)
* doc.uri; //'file:///my/file.js'
* doc.languageId; // 'javascript'
* match('javascript', doc); // 10;
* match({language: 'javascript'}, doc); // 10;
* match({language: 'javascript', scheme: 'file'}, doc); // 10;
* match('*', doc); // 5
* match('fooLang', doc); // 0
* match(['fooLang', '*'], doc); // 5
*
* // virtual document, e.g. from git-index
* doc.uri; // 'git:/my/file.js'
* doc.languageId; // 'javascript'
* match('javascript', doc); // 10;
* match({language: 'javascript', scheme: 'git'}, doc); // 10;
* match('*', doc); // 5
* ```
*
* @param selector A document selector.
* @param document A text document.
* @return A number `>0` when the selector matches and `0` when the selector does not match.
*/
function match(selector:DocumentSelector, document:TextDocument):Float;
/**
* An [event](#Event) which fires when the global set of diagnostics changes. This is
* newly added and removed diagnostics.
*/
var onDidChangeDiagnostics(default, never):Event<DiagnosticChangeEvent>;
/**
* Get all diagnostics for a given resource.
*
* @param resource A resource
* @returns An array of [diagnostics](#Diagnostic) objects or an empty array.
*
* OR
*
* Get all diagnostics.
*
* @returns An array of uri-diagnostics tuples or an empty array.
*/
@:overload(function(resource:Uri):Array<Diagnostic> {})
function getDiagnostics():Array<VscodeLanguagesGetDiagnosticsReturn>;
/**
* Create a diagnostics collection.
*
* @param name The [name](#DiagnosticCollection.name) of the collection.
* @return A new diagnostic collection.
*/
function createDiagnosticCollection(?name:String):DiagnosticCollection;
/**
* Register a completion provider.
*
* Multiple providers can be registered for a language. In that case providers are sorted
* by their [score](#languages.match) and groups of equal score are sequentially asked for
* completion items. The process stops when one or many providers of a group return a
* result. A failing provider (rejected promise or exception) will not fail the whole
* operation.
*
* A completion item provider can be associated with a set of `triggerCharacters`. When trigger
* characters are being typed, completions are requested but only from providers that registered
* the typed character. Because of that trigger characters should be different than [word characters](#LanguageConfiguration.wordPattern),
* a common trigger character is `.` to trigger member completions.
*
* @param selector A selector that defines the documents this provider is applicable to.