UNPKG

659 kBTypeScriptView Raw
1/*---------------------------------------------------------------------------------------------
2 * Copyright (c) Microsoft Corporation. All rights reserved.
3 * Licensed under the MIT License.
4 * See https://github.com/microsoft/vscode/blob/main/LICENSE.txt for license information.
5 *--------------------------------------------------------------------------------------------*/
6
7/**
8 * Type Definition for Visual Studio Code 1.92 Extension API
9 * See https://code.visualstudio.com/api for more information
10 */
11
12declare module 'vscode' {
13
14 /**
15 * The version of the editor.
16 */
17 export const version: string;
18
19 /**
20 * Represents a reference to a command. Provides a title which
21 * will be used to represent a command in the UI and, optionally,
22 * an array of arguments which will be passed to the command handler
23 * function when invoked.
24 */
25 export interface Command {
26 /**
27 * Title of the command, like `save`.
28 */
29 title: string;
30
31 /**
32 * The identifier of the actual command handler.
33 * @see {@link commands.registerCommand}
34 */
35 command: string;
36
37 /**
38 * A tooltip for the command, when represented in the UI.
39 */
40 tooltip?: string;
41
42 /**
43 * Arguments that the command handler should be
44 * invoked with.
45 */
46 arguments?: any[];
47 }
48
49 /**
50 * Represents a line of text, such as a line of source code.
51 *
52 * TextLine objects are __immutable__. When a {@link TextDocument document} changes,
53 * previously retrieved lines will not represent the latest state.
54 */
55 export interface TextLine {
56
57 /**
58 * The zero-based line number.
59 */
60 readonly lineNumber: number;
61
62 /**
63 * The text of this line without the line separator characters.
64 */
65 readonly text: string;
66
67 /**
68 * The range this line covers without the line separator characters.
69 */
70 readonly range: Range;
71
72 /**
73 * The range this line covers with the line separator characters.
74 */
75 readonly rangeIncludingLineBreak: Range;
76
77 /**
78 * The offset of the first character which is not a whitespace character as defined
79 * by `/\s/`. **Note** that if a line is all whitespace the length of the line is returned.
80 */
81 readonly firstNonWhitespaceCharacterIndex: number;
82
83 /**
84 * Whether this line is whitespace only, shorthand
85 * for {@link TextLine.firstNonWhitespaceCharacterIndex} === {@link TextLine.text TextLine.text.length}.
86 */
87 readonly isEmptyOrWhitespace: boolean;
88 }
89
90 /**
91 * Represents a text document, such as a source file. Text documents have
92 * {@link TextLine lines} and knowledge about an underlying resource like a file.
93 */
94 export interface TextDocument {
95
96 /**
97 * The associated uri for this document.
98 *
99 * *Note* that most documents use the `file`-scheme, which means they are files on disk. However, **not** all documents are
100 * saved on disk and therefore the `scheme` must be checked before trying to access the underlying file or siblings on disk.
101 *
102 * @see {@link FileSystemProvider}
103 * @see {@link TextDocumentContentProvider}
104 */
105 readonly uri: Uri;
106
107 /**
108 * The file system path of the associated resource. Shorthand
109 * notation for {@link TextDocument.uri TextDocument.uri.fsPath}. Independent of the uri scheme.
110 */
111 readonly fileName: string;
112
113 /**
114 * Is this document representing an untitled file which has never been saved yet. *Note* that
115 * this does not mean the document will be saved to disk, use {@linkcode Uri.scheme}
116 * to figure out where a document will be {@link FileSystemProvider saved}, e.g. `file`, `ftp` etc.
117 */
118 readonly isUntitled: boolean;
119
120 /**
121 * The identifier of the language associated with this document.
122 */
123 readonly languageId: string;
124
125 /**
126 * The version number of this document (it will strictly increase after each
127 * change, including undo/redo).
128 */
129 readonly version: number;
130
131 /**
132 * `true` if there are unpersisted changes.
133 */
134 readonly isDirty: boolean;
135
136 /**
137 * `true` if the document has been closed. A closed document isn't synchronized anymore
138 * and won't be re-used when the same resource is opened again.
139 */
140 readonly isClosed: boolean;
141
142 /**
143 * Save the underlying file.
144 *
145 * @returns A promise that will resolve to `true` when the file
146 * has been saved. If the save failed, will return `false`.
147 */
148 save(): Thenable<boolean>;
149
150 /**
151 * The {@link EndOfLine end of line} sequence that is predominately
152 * used in this document.
153 */
154 readonly eol: EndOfLine;
155
156 /**
157 * The number of lines in this document.
158 */
159 readonly lineCount: number;
160
161 /**
162 * Returns a text line denoted by the line number. Note
163 * that the returned object is *not* live and changes to the
164 * document are not reflected.
165 *
166 * @param line A line number in [0, lineCount).
167 * @returns A {@link TextLine line}.
168 */
169 lineAt(line: number): TextLine;
170
171 /**
172 * Returns a text line denoted by the position. Note
173 * that the returned object is *not* live and changes to the
174 * document are not reflected.
175 *
176 * The position will be {@link TextDocument.validatePosition adjusted}.
177 *
178 * @see {@link TextDocument.lineAt}
179 *
180 * @param position A position.
181 * @returns A {@link TextLine line}.
182 */
183 lineAt(position: Position): TextLine;
184
185 /**
186 * Converts the position to a zero-based offset.
187 *
188 * The position will be {@link TextDocument.validatePosition adjusted}.
189 *
190 * @param position A position.
191 * @returns A valid zero-based offset.
192 */
193 offsetAt(position: Position): number;
194
195 /**
196 * Converts a zero-based offset to a position.
197 *
198 * @param offset A zero-based offset.
199 * @returns A valid {@link Position}.
200 */
201 positionAt(offset: number): Position;
202
203 /**
204 * Get the text of this document. A substring can be retrieved by providing
205 * a range. The range will be {@link TextDocument.validateRange adjusted}.
206 *
207 * @param range Include only the text included by the range.
208 * @returns The text inside the provided range or the entire text.
209 */
210 getText(range?: Range): string;
211
212 /**
213 * Get a word-range at the given position. By default words are defined by
214 * common separators, like space, -, _, etc. In addition, per language custom
215 * [word definitions] can be defined. It
216 * is also possible to provide a custom regular expression.
217 *
218 * * *Note 1:* A custom regular expression must not match the empty string and
219 * if it does, it will be ignored.
220 * * *Note 2:* A custom regular expression will fail to match multiline strings
221 * and in the name of speed regular expressions should not match words with
222 * spaces. Use {@linkcode TextLine.text} for more complex, non-wordy, scenarios.
223 *
224 * The position will be {@link TextDocument.validatePosition adjusted}.
225 *
226 * @param position A position.
227 * @param regex Optional regular expression that describes what a word is.
228 * @returns A range spanning a word, or `undefined`.
229 */
230 getWordRangeAtPosition(position: Position, regex?: RegExp): Range | undefined;
231
232 /**
233 * Ensure a range is completely contained in this document.
234 *
235 * @param range A range.
236 * @returns The given range or a new, adjusted range.
237 */
238 validateRange(range: Range): Range;
239
240 /**
241 * Ensure a position is contained in the range of this document.
242 *
243 * @param position A position.
244 * @returns The given position or a new, adjusted position.
245 */
246 validatePosition(position: Position): Position;
247 }
248
249 /**
250 * Represents a line and character position, such as
251 * the position of the cursor.
252 *
253 * Position objects are __immutable__. Use the {@link Position.with with} or
254 * {@link Position.translate translate} methods to derive new positions
255 * from an existing position.
256 */
257 export class Position {
258
259 /**
260 * The zero-based line value.
261 */
262 readonly line: number;
263
264 /**
265 * The zero-based character value.
266 */
267 readonly character: number;
268
269 /**
270 * @param line A zero-based line value.
271 * @param character A zero-based character value.
272 */
273 constructor(line: number, character: number);
274
275 /**
276 * Check if this position is before `other`.
277 *
278 * @param other A position.
279 * @returns `true` if position is on a smaller line
280 * or on the same line on a smaller character.
281 */
282 isBefore(other: Position): boolean;
283
284 /**
285 * Check if this position is before or equal to `other`.
286 *
287 * @param other A position.
288 * @returns `true` if position is on a smaller line
289 * or on the same line on a smaller or equal character.
290 */
291 isBeforeOrEqual(other: Position): boolean;
292
293 /**
294 * Check if this position is after `other`.
295 *
296 * @param other A position.
297 * @returns `true` if position is on a greater line
298 * or on the same line on a greater character.
299 */
300 isAfter(other: Position): boolean;
301
302 /**
303 * Check if this position is after or equal to `other`.
304 *
305 * @param other A position.
306 * @returns `true` if position is on a greater line
307 * or on the same line on a greater or equal character.
308 */
309 isAfterOrEqual(other: Position): boolean;
310
311 /**
312 * Check if this position is equal to `other`.
313 *
314 * @param other A position.
315 * @returns `true` if the line and character of the given position are equal to
316 * the line and character of this position.
317 */
318 isEqual(other: Position): boolean;
319
320 /**
321 * Compare this to `other`.
322 *
323 * @param other A position.
324 * @returns A number smaller than zero if this position is before the given position,
325 * a number greater than zero if this position is after the given position, or zero when
326 * this and the given position are equal.
327 */
328 compareTo(other: Position): number;
329
330 /**
331 * Create a new position relative to this position.
332 *
333 * @param lineDelta Delta value for the line value, default is `0`.
334 * @param characterDelta Delta value for the character value, default is `0`.
335 * @returns A position which line and character is the sum of the current line and
336 * character and the corresponding deltas.
337 */
338 translate(lineDelta?: number, characterDelta?: number): Position;
339
340 /**
341 * Derived a new position relative to this position.
342 *
343 * @param change An object that describes a delta to this position.
344 * @returns A position that reflects the given delta. Will return `this` position if the change
345 * is not changing anything.
346 */
347 translate(change: {
348 /**
349 * Delta value for the line value, default is `0`.
350 */
351 lineDelta?: number;
352 /**
353 * Delta value for the character value, default is `0`.
354 */
355 characterDelta?: number;
356 }): Position;
357
358 /**
359 * Create a new position derived from this position.
360 *
361 * @param line Value that should be used as line value, default is the {@link Position.line existing value}
362 * @param character Value that should be used as character value, default is the {@link Position.character existing value}
363 * @returns A position where line and character are replaced by the given values.
364 */
365 with(line?: number, character?: number): Position;
366
367 /**
368 * Derived a new position from this position.
369 *
370 * @param change An object that describes a change to this position.
371 * @returns A position that reflects the given change. Will return `this` position if the change
372 * is not changing anything.
373 */
374 with(change: {
375 /**
376 * New line value, defaults the line value of `this`.
377 */
378 line?: number;
379 /**
380 * New character value, defaults the character value of `this`.
381 */
382 character?: number;
383 }): Position;
384 }
385
386 /**
387 * A range represents an ordered pair of two positions.
388 * It is guaranteed that {@link Range.start start}.isBeforeOrEqual({@link Range.end end})
389 *
390 * Range objects are __immutable__. Use the {@link Range.with with},
391 * {@link Range.intersection intersection}, or {@link Range.union union} methods
392 * to derive new ranges from an existing range.
393 */
394 export class Range {
395
396 /**
397 * The start position. It is before or equal to {@link Range.end end}.
398 */
399 readonly start: Position;
400
401 /**
402 * The end position. It is after or equal to {@link Range.start start}.
403 */
404 readonly end: Position;
405
406 /**
407 * Create a new range from two positions. If `start` is not
408 * before or equal to `end`, the values will be swapped.
409 *
410 * @param start A position.
411 * @param end A position.
412 */
413 constructor(start: Position, end: Position);
414
415 /**
416 * Create a new range from number coordinates. It is a shorter equivalent of
417 * using `new Range(new Position(startLine, startCharacter), new Position(endLine, endCharacter))`
418 *
419 * @param startLine A zero-based line value.
420 * @param startCharacter A zero-based character value.
421 * @param endLine A zero-based line value.
422 * @param endCharacter A zero-based character value.
423 */
424 constructor(startLine: number, startCharacter: number, endLine: number, endCharacter: number);
425
426 /**
427 * `true` if `start` and `end` are equal.
428 */
429 isEmpty: boolean;
430
431 /**
432 * `true` if `start.line` and `end.line` are equal.
433 */
434 isSingleLine: boolean;
435
436 /**
437 * Check if a position or a range is contained in this range.
438 *
439 * @param positionOrRange A position or a range.
440 * @returns `true` if the position or range is inside or equal
441 * to this range.
442 */
443 contains(positionOrRange: Position | Range): boolean;
444
445 /**
446 * Check if `other` equals this range.
447 *
448 * @param other A range.
449 * @returns `true` when start and end are {@link Position.isEqual equal} to
450 * start and end of this range.
451 */
452 isEqual(other: Range): boolean;
453
454 /**
455 * Intersect `range` with this range and returns a new range or `undefined`
456 * if the ranges have no overlap.
457 *
458 * @param range A range.
459 * @returns A range of the greater start and smaller end positions. Will
460 * return undefined when there is no overlap.
461 */
462 intersection(range: Range): Range | undefined;
463
464 /**
465 * Compute the union of `other` with this range.
466 *
467 * @param other A range.
468 * @returns A range of smaller start position and the greater end position.
469 */
470 union(other: Range): Range;
471
472 /**
473 * Derived a new range from this range.
474 *
475 * @param start A position that should be used as start. The default value is the {@link Range.start current start}.
476 * @param end A position that should be used as end. The default value is the {@link Range.end current end}.
477 * @returns A range derived from this range with the given start and end position.
478 * If start and end are not different `this` range will be returned.
479 */
480 with(start?: Position, end?: Position): Range;
481
482 /**
483 * Derived a new range from this range.
484 *
485 * @param change An object that describes a change to this range.
486 * @returns A range that reflects the given change. Will return `this` range if the change
487 * is not changing anything.
488 */
489 with(change: {
490 /**
491 * New start position, defaults to {@link Range.start current start}
492 */
493 start?: Position;
494 /**
495 * New end position, defaults to {@link Range.end current end}
496 */
497 end?: Position;
498 }): Range;
499 }
500
501 /**
502 * Represents a text selection in an editor.
503 */
504 export class Selection extends Range {
505
506 /**
507 * The position at which the selection starts.
508 * This position might be before or after {@link Selection.active active}.
509 */
510 anchor: Position;
511
512 /**
513 * The position of the cursor.
514 * This position might be before or after {@link Selection.anchor anchor}.
515 */
516 active: Position;
517
518 /**
519 * Create a selection from two positions.
520 *
521 * @param anchor A position.
522 * @param active A position.
523 */
524 constructor(anchor: Position, active: Position);
525
526 /**
527 * Create a selection from four coordinates.
528 *
529 * @param anchorLine A zero-based line value.
530 * @param anchorCharacter A zero-based character value.
531 * @param activeLine A zero-based line value.
532 * @param activeCharacter A zero-based character value.
533 */
534 constructor(anchorLine: number, anchorCharacter: number, activeLine: number, activeCharacter: number);
535
536 /**
537 * A selection is reversed if its {@link Selection.anchor anchor} is the {@link Selection.end end} position.
538 */
539 isReversed: boolean;
540 }
541
542 /**
543 * Represents sources that can cause {@link window.onDidChangeTextEditorSelection selection change events}.
544 */
545 export enum TextEditorSelectionChangeKind {
546 /**
547 * Selection changed due to typing in the editor.
548 */
549 Keyboard = 1,
550 /**
551 * Selection change due to clicking in the editor.
552 */
553 Mouse = 2,
554 /**
555 * Selection changed because a command ran.
556 */
557 Command = 3
558 }
559
560 /**
561 * Represents an event describing the change in a {@link TextEditor.selections text editor's selections}.
562 */
563 export interface TextEditorSelectionChangeEvent {
564 /**
565 * The {@link TextEditor text editor} for which the selections have changed.
566 */
567 readonly textEditor: TextEditor;
568 /**
569 * The new value for the {@link TextEditor.selections text editor's selections}.
570 */
571 readonly selections: readonly Selection[];
572 /**
573 * The {@link TextEditorSelectionChangeKind change kind} which has triggered this
574 * event. Can be `undefined`.
575 */
576 readonly kind: TextEditorSelectionChangeKind | undefined;
577 }
578
579 /**
580 * Represents an event describing the change in a {@link TextEditor.visibleRanges text editor's visible ranges}.
581 */
582 export interface TextEditorVisibleRangesChangeEvent {
583 /**
584 * The {@link TextEditor text editor} for which the visible ranges have changed.
585 */
586 readonly textEditor: TextEditor;
587 /**
588 * The new value for the {@link TextEditor.visibleRanges text editor's visible ranges}.
589 */
590 readonly visibleRanges: readonly Range[];
591 }
592
593 /**
594 * Represents an event describing the change in a {@link TextEditor.options text editor's options}.
595 */
596 export interface TextEditorOptionsChangeEvent {
597 /**
598 * The {@link TextEditor text editor} for which the options have changed.
599 */
600 readonly textEditor: TextEditor;
601 /**
602 * The new value for the {@link TextEditor.options text editor's options}.
603 */
604 readonly options: TextEditorOptions;
605 }
606
607 /**
608 * Represents an event describing the change of a {@link TextEditor.viewColumn text editor's view column}.
609 */
610 export interface TextEditorViewColumnChangeEvent {
611 /**
612 * The {@link TextEditor text editor} for which the view column has changed.
613 */
614 readonly textEditor: TextEditor;
615 /**
616 * The new value for the {@link TextEditor.viewColumn text editor's view column}.
617 */
618 readonly viewColumn: ViewColumn;
619 }
620
621 /**
622 * Rendering style of the cursor.
623 */
624 export enum TextEditorCursorStyle {
625 /**
626 * Render the cursor as a vertical thick line.
627 */
628 Line = 1,
629 /**
630 * Render the cursor as a block filled.
631 */
632 Block = 2,
633 /**
634 * Render the cursor as a thick horizontal line.
635 */
636 Underline = 3,
637 /**
638 * Render the cursor as a vertical thin line.
639 */
640 LineThin = 4,
641 /**
642 * Render the cursor as a block outlined.
643 */
644 BlockOutline = 5,
645 /**
646 * Render the cursor as a thin horizontal line.
647 */
648 UnderlineThin = 6
649 }
650
651 /**
652 * Rendering style of the line numbers.
653 */
654 export enum TextEditorLineNumbersStyle {
655 /**
656 * Do not render the line numbers.
657 */
658 Off = 0,
659 /**
660 * Render the line numbers.
661 */
662 On = 1,
663 /**
664 * Render the line numbers with values relative to the primary cursor location.
665 */
666 Relative = 2,
667 /**
668 * Render the line numbers on every 10th line number.
669 */
670 Interval = 3,
671 }
672
673 /**
674 * Represents a {@link TextEditor text editor}'s {@link TextEditor.options options}.
675 */
676 export interface TextEditorOptions {
677
678 /**
679 * The size in spaces a tab takes. This is used for two purposes:
680 * - the rendering width of a tab character;
681 * - the number of spaces to insert when {@link TextEditorOptions.insertSpaces insertSpaces} is true
682 * and `indentSize` is set to `"tabSize"`.
683 *
684 * When getting a text editor's options, this property will always be a number (resolved).
685 * When setting a text editor's options, this property is optional and it can be a number or `"auto"`.
686 */
687 tabSize?: number | string;
688
689 /**
690 * The number of spaces to insert when {@link TextEditorOptions.insertSpaces insertSpaces} is true.
691 *
692 * When getting a text editor's options, this property will always be a number (resolved).
693 * When setting a text editor's options, this property is optional and it can be a number or `"tabSize"`.
694 */
695 indentSize?: number | string;
696
697 /**
698 * When pressing Tab insert {@link TextEditorOptions.tabSize n} spaces.
699 * When getting a text editor's options, this property will always be a boolean (resolved).
700 * When setting a text editor's options, this property is optional and it can be a boolean or `"auto"`.
701 */
702 insertSpaces?: boolean | string;
703
704 /**
705 * The rendering style of the cursor in this editor.
706 * When getting a text editor's options, this property will always be present.
707 * When setting a text editor's options, this property is optional.
708 */
709 cursorStyle?: TextEditorCursorStyle;
710
711 /**
712 * Render relative line numbers w.r.t. the current line number.
713 * When getting a text editor's options, this property will always be present.
714 * When setting a text editor's options, this property is optional.
715 */
716 lineNumbers?: TextEditorLineNumbersStyle;
717 }
718
719 /**
720 * Represents a handle to a set of decorations
721 * sharing the same {@link DecorationRenderOptions styling options} in a {@link TextEditor text editor}.
722 *
723 * To get an instance of a `TextEditorDecorationType` use
724 * {@link window.createTextEditorDecorationType createTextEditorDecorationType}.
725 */
726 export interface TextEditorDecorationType {
727
728 /**
729 * Internal representation of the handle.
730 */
731 readonly key: string;
732
733 /**
734 * Remove this decoration type and all decorations on all text editors using it.
735 */
736 dispose(): void;
737 }
738
739 /**
740 * Represents different {@link TextEditor.revealRange reveal} strategies in a text editor.
741 */
742 export enum TextEditorRevealType {
743 /**
744 * The range will be revealed with as little scrolling as possible.
745 */
746 Default = 0,
747 /**
748 * The range will always be revealed in the center of the viewport.
749 */
750 InCenter = 1,
751 /**
752 * If the range is outside the viewport, it will be revealed in the center of the viewport.
753 * Otherwise, it will be revealed with as little scrolling as possible.
754 */
755 InCenterIfOutsideViewport = 2,
756 /**
757 * The range will always be revealed at the top of the viewport.
758 */
759 AtTop = 3
760 }
761
762 /**
763 * Represents different positions for rendering a decoration in an {@link DecorationRenderOptions.overviewRulerLane overview ruler}.
764 * The overview ruler supports three lanes.
765 */
766 export enum OverviewRulerLane {
767 /**
768 * The left lane of the overview ruler.
769 */
770 Left = 1,
771 /**
772 * The center lane of the overview ruler.
773 */
774 Center = 2,
775 /**
776 * The right lane of the overview ruler.
777 */
778 Right = 4,
779 /**
780 * All lanes of the overview ruler.
781 */
782 Full = 7
783 }
784
785 /**
786 * Describes the behavior of decorations when typing/editing at their edges.
787 */
788 export enum DecorationRangeBehavior {
789 /**
790 * The decoration's range will widen when edits occur at the start or end.
791 */
792 OpenOpen = 0,
793 /**
794 * The decoration's range will not widen when edits occur at the start or end.
795 */
796 ClosedClosed = 1,
797 /**
798 * The decoration's range will widen when edits occur at the start, but not at the end.
799 */
800 OpenClosed = 2,
801 /**
802 * The decoration's range will widen when edits occur at the end, but not at the start.
803 */
804 ClosedOpen = 3
805 }
806
807 /**
808 * Represents options to configure the behavior of showing a {@link TextDocument document} in an {@link TextEditor editor}.
809 */
810 export interface TextDocumentShowOptions {
811 /**
812 * An optional view column in which the {@link TextEditor editor} should be shown.
813 * The default is the {@link ViewColumn.Active active}. Columns that do not exist
814 * will be created as needed up to the maximum of {@linkcode ViewColumn.Nine}.
815 * Use {@linkcode ViewColumn.Beside} to open the editor to the side of the currently
816 * active one.
817 */
818 viewColumn?: ViewColumn;
819
820 /**
821 * An optional flag that when `true` will stop the {@link TextEditor editor} from taking focus.
822 */
823 preserveFocus?: boolean;
824
825 /**
826 * An optional flag that controls if an {@link TextEditor editor}-tab shows as preview. Preview tabs will
827 * be replaced and reused until set to stay - either explicitly or through editing.
828 *
829 * *Note* that the flag is ignored if a user has disabled preview editors in settings.
830 */
831 preview?: boolean;
832
833 /**
834 * An optional selection to apply for the document in the {@link TextEditor editor}.
835 */
836 selection?: Range;
837 }
838
839 /**
840 * Represents an event describing the change in a {@link NotebookEditor.selections notebook editor's selections}.
841 */
842 export interface NotebookEditorSelectionChangeEvent {
843 /**
844 * The {@link NotebookEditor notebook editor} for which the selections have changed.
845 */
846 readonly notebookEditor: NotebookEditor;
847
848 /**
849 * The new value for the {@link NotebookEditor.selections notebook editor's selections}.
850 */
851 readonly selections: readonly NotebookRange[];
852 }
853
854 /**
855 * Represents an event describing the change in a {@link NotebookEditor.visibleRanges notebook editor's visibleRanges}.
856 */
857 export interface NotebookEditorVisibleRangesChangeEvent {
858 /**
859 * The {@link NotebookEditor notebook editor} for which the visible ranges have changed.
860 */
861 readonly notebookEditor: NotebookEditor;
862
863 /**
864 * The new value for the {@link NotebookEditor.visibleRanges notebook editor's visibleRanges}.
865 */
866 readonly visibleRanges: readonly NotebookRange[];
867 }
868
869 /**
870 * Represents options to configure the behavior of showing a {@link NotebookDocument notebook document} in an {@link NotebookEditor notebook editor}.
871 */
872 export interface NotebookDocumentShowOptions {
873 /**
874 * An optional view column in which the {@link NotebookEditor notebook editor} should be shown.
875 * The default is the {@link ViewColumn.Active active}. Columns that do not exist
876 * will be created as needed up to the maximum of {@linkcode ViewColumn.Nine}.
877 * Use {@linkcode ViewColumn.Beside} to open the editor to the side of the currently
878 * active one.
879 */
880 readonly viewColumn?: ViewColumn;
881
882 /**
883 * An optional flag that when `true` will stop the {@link NotebookEditor notebook editor} from taking focus.
884 */
885 readonly preserveFocus?: boolean;
886
887 /**
888 * An optional flag that controls if an {@link NotebookEditor notebook editor}-tab shows as preview. Preview tabs will
889 * be replaced and reused until set to stay - either explicitly or through editing. The default behaviour depends
890 * on the `workbench.editor.enablePreview`-setting.
891 */
892 readonly preview?: boolean;
893
894 /**
895 * An optional selection to apply for the document in the {@link NotebookEditor notebook editor}.
896 */
897 readonly selections?: readonly NotebookRange[];
898 }
899
900 /**
901 * A reference to one of the workbench colors as defined in https://code.visualstudio.com/api/references/theme-color.
902 * Using a theme color is preferred over a custom color as it gives theme authors and users the possibility to change the color.
903 */
904 export class ThemeColor {
905
906 /**
907 * Creates a reference to a theme color.
908 * @param id of the color. The available colors are listed in https://code.visualstudio.com/api/references/theme-color.
909 */
910 constructor(id: string);
911 }
912
913 /**
914 * A reference to a named icon. Currently, {@link ThemeIcon.File File}, {@link ThemeIcon.Folder Folder},
915 * and [ThemeIcon ids](https://code.visualstudio.com/api/references/icons-in-labels#icon-listing) are supported.
916 * Using a theme icon is preferred over a custom icon as it gives product theme authors the possibility to change the icons.
917 *
918 * *Note* that theme icons can also be rendered inside labels and descriptions. Places that support theme icons spell this out
919 * and they use the `$(<name>)`-syntax, for instance `quickPick.label = "Hello World $(globe)"`.
920 */
921 export class ThemeIcon {
922 /**
923 * Reference to an icon representing a file. The icon is taken from the current file icon theme or a placeholder icon is used.
924 */
925 static readonly File: ThemeIcon;
926
927 /**
928 * Reference to an icon representing a folder. The icon is taken from the current file icon theme or a placeholder icon is used.
929 */
930 static readonly Folder: ThemeIcon;
931
932 /**
933 * The id of the icon. The available icons are listed in https://code.visualstudio.com/api/references/icons-in-labels#icon-listing.
934 */
935 readonly id: string;
936
937 /**
938 * The optional ThemeColor of the icon. The color is currently only used in {@link TreeItem}.
939 */
940 readonly color?: ThemeColor | undefined;
941
942 /**
943 * Creates a reference to a theme icon.
944 * @param id id of the icon. The available icons are listed in https://code.visualstudio.com/api/references/icons-in-labels#icon-listing.
945 * @param color optional `ThemeColor` for the icon. The color is currently only used in {@link TreeItem}.
946 */
947 constructor(id: string, color?: ThemeColor);
948 }
949
950 /**
951 * Represents theme specific rendering styles for a {@link TextEditorDecorationType text editor decoration}.
952 */
953 export interface ThemableDecorationRenderOptions {
954 /**
955 * Background color of the decoration. Use rgba() and define transparent background colors to play well with other decorations.
956 * Alternatively a color from the color registry can be {@link ThemeColor referenced}.
957 */
958 backgroundColor?: string | ThemeColor;
959
960 /**
961 * CSS styling property that will be applied to text enclosed by a decoration.
962 */
963 outline?: string;
964
965 /**
966 * CSS styling property that will be applied to text enclosed by a decoration.
967 * Better use 'outline' for setting one or more of the individual outline properties.
968 */
969 outlineColor?: string | ThemeColor;
970
971 /**
972 * CSS styling property that will be applied to text enclosed by a decoration.
973 * Better use 'outline' for setting one or more of the individual outline properties.
974 */
975 outlineStyle?: string;
976
977 /**
978 * CSS styling property that will be applied to text enclosed by a decoration.
979 * Better use 'outline' for setting one or more of the individual outline properties.
980 */
981 outlineWidth?: string;
982
983 /**
984 * CSS styling property that will be applied to text enclosed by a decoration.
985 */
986 border?: string;
987
988 /**
989 * CSS styling property that will be applied to text enclosed by a decoration.
990 * Better use 'border' for setting one or more of the individual border properties.
991 */
992 borderColor?: string | ThemeColor;
993
994 /**
995 * CSS styling property that will be applied to text enclosed by a decoration.
996 * Better use 'border' for setting one or more of the individual border properties.
997 */
998 borderRadius?: string;
999
1000 /**
1001 * CSS styling property that will be applied to text enclosed by a decoration.
1002 * Better use 'border' for setting one or more of the individual border properties.
1003 */
1004 borderSpacing?: string;
1005
1006 /**
1007 * CSS styling property that will be applied to text enclosed by a decoration.
1008 * Better use 'border' for setting one or more of the individual border properties.
1009 */
1010 borderStyle?: string;
1011
1012 /**
1013 * CSS styling property that will be applied to text enclosed by a decoration.
1014 * Better use 'border' for setting one or more of the individual border properties.
1015 */
1016 borderWidth?: string;
1017
1018 /**
1019 * CSS styling property that will be applied to text enclosed by a decoration.
1020 */
1021 fontStyle?: string;
1022
1023 /**
1024 * CSS styling property that will be applied to text enclosed by a decoration.
1025 */
1026 fontWeight?: string;
1027
1028 /**
1029 * CSS styling property that will be applied to text enclosed by a decoration.
1030 */
1031 textDecoration?: string;
1032
1033 /**
1034 * CSS styling property that will be applied to text enclosed by a decoration.
1035 */
1036 cursor?: string;
1037
1038 /**
1039 * CSS styling property that will be applied to text enclosed by a decoration.
1040 */
1041 color?: string | ThemeColor;
1042
1043 /**
1044 * CSS styling property that will be applied to text enclosed by a decoration.
1045 */
1046 opacity?: string;
1047
1048 /**
1049 * CSS styling property that will be applied to text enclosed by a decoration.
1050 */
1051 letterSpacing?: string;
1052
1053 /**
1054 * An **absolute path** or an URI to an image to be rendered in the gutter.
1055 */
1056 gutterIconPath?: string | Uri;
1057
1058 /**
1059 * Specifies the size of the gutter icon.
1060 * Available values are 'auto', 'contain', 'cover' and any percentage value.
1061 * For further information: https://msdn.microsoft.com/en-us/library/jj127316(v=vs.85).aspx
1062 */
1063 gutterIconSize?: string;
1064
1065 /**
1066 * The color of the decoration in the overview ruler. Use rgba() and define transparent colors to play well with other decorations.
1067 */
1068 overviewRulerColor?: string | ThemeColor;
1069
1070 /**
1071 * Defines the rendering options of the attachment that is inserted before the decorated text.
1072 */
1073 before?: ThemableDecorationAttachmentRenderOptions;
1074
1075 /**
1076 * Defines the rendering options of the attachment that is inserted after the decorated text.
1077 */
1078 after?: ThemableDecorationAttachmentRenderOptions;
1079 }
1080
1081 /**
1082 * Represents theme specific rendeirng styles for {@link ThemableDecorationRenderOptions.before before} and
1083 * {@link ThemableDecorationRenderOptions.after after} the content of text decorations.
1084 */
1085 export interface ThemableDecorationAttachmentRenderOptions {
1086 /**
1087 * Defines a text content that is shown in the attachment. Either an icon or a text can be shown, but not both.
1088 */
1089 contentText?: string;
1090 /**
1091 * An **absolute path** or an URI to an image to be rendered in the attachment. Either an icon
1092 * or a text can be shown, but not both.
1093 */
1094 contentIconPath?: string | Uri;
1095 /**
1096 * CSS styling property that will be applied to the decoration attachment.
1097 */
1098 border?: string;
1099 /**
1100 * CSS styling property that will be applied to text enclosed by a decoration.
1101 */
1102 borderColor?: string | ThemeColor;
1103 /**
1104 * CSS styling property that will be applied to the decoration attachment.
1105 */
1106 fontStyle?: string;
1107 /**
1108 * CSS styling property that will be applied to the decoration attachment.
1109 */
1110 fontWeight?: string;
1111 /**
1112 * CSS styling property that will be applied to the decoration attachment.
1113 */
1114 textDecoration?: string;
1115 /**
1116 * CSS styling property that will be applied to the decoration attachment.
1117 */
1118 color?: string | ThemeColor;
1119 /**
1120 * CSS styling property that will be applied to the decoration attachment.
1121 */
1122 backgroundColor?: string | ThemeColor;
1123 /**
1124 * CSS styling property that will be applied to the decoration attachment.
1125 */
1126 margin?: string;
1127 /**
1128 * CSS styling property that will be applied to the decoration attachment.
1129 */
1130 width?: string;
1131 /**
1132 * CSS styling property that will be applied to the decoration attachment.
1133 */
1134 height?: string;
1135 }
1136
1137 /**
1138 * Represents rendering styles for a {@link TextEditorDecorationType text editor decoration}.
1139 */
1140 export interface DecorationRenderOptions extends ThemableDecorationRenderOptions {
1141 /**
1142 * Should the decoration be rendered also on the whitespace after the line text.
1143 * Defaults to `false`.
1144 */
1145 isWholeLine?: boolean;
1146
1147 /**
1148 * Customize the growing behavior of the decoration when edits occur at the edges of the decoration's range.
1149 * Defaults to `DecorationRangeBehavior.OpenOpen`.
1150 */
1151 rangeBehavior?: DecorationRangeBehavior;
1152
1153 /**
1154 * The position in the overview ruler where the decoration should be rendered.
1155 */
1156 overviewRulerLane?: OverviewRulerLane;
1157
1158 /**
1159 * Overwrite options for light themes.
1160 */
1161 light?: ThemableDecorationRenderOptions;
1162
1163 /**
1164 * Overwrite options for dark themes.
1165 */
1166 dark?: ThemableDecorationRenderOptions;
1167 }
1168
1169 /**
1170 * Represents options for a specific decoration in a {@link TextEditorDecorationType decoration set}.
1171 */
1172 export interface DecorationOptions {
1173
1174 /**
1175 * Range to which this decoration is applied. The range must not be empty.
1176 */
1177 range: Range;
1178
1179 /**
1180 * A message that should be rendered when hovering over the decoration.
1181 */
1182 hoverMessage?: MarkdownString | MarkedString | Array<MarkdownString | MarkedString>;
1183
1184 /**
1185 * Render options applied to the current decoration. For performance reasons, keep the
1186 * number of decoration specific options small, and use decoration types wherever possible.
1187 */
1188 renderOptions?: DecorationInstanceRenderOptions;
1189 }
1190
1191 /**
1192 * Represents themable render options for decoration instances.
1193 */
1194 export interface ThemableDecorationInstanceRenderOptions {
1195 /**
1196 * Defines the rendering options of the attachment that is inserted before the decorated text.
1197 */
1198 before?: ThemableDecorationAttachmentRenderOptions;
1199
1200 /**
1201 * Defines the rendering options of the attachment that is inserted after the decorated text.
1202 */
1203 after?: ThemableDecorationAttachmentRenderOptions;
1204 }
1205
1206 /**
1207 * Represents render options for decoration instances. See {@link DecorationOptions.renderOptions}.
1208 */
1209 export interface DecorationInstanceRenderOptions extends ThemableDecorationInstanceRenderOptions {
1210 /**
1211 * Overwrite options for light themes.
1212 */
1213 light?: ThemableDecorationInstanceRenderOptions;
1214
1215 /**
1216 * Overwrite options for dark themes.
1217 */
1218 dark?: ThemableDecorationInstanceRenderOptions;
1219 }
1220
1221 /**
1222 * Represents an editor that is attached to a {@link TextDocument document}.
1223 */
1224 export interface TextEditor {
1225
1226 /**
1227 * The document associated with this text editor. The document will be the same for the entire lifetime of this text editor.
1228 */
1229 readonly document: TextDocument;
1230
1231 /**
1232 * The primary selection on this text editor. Shorthand for `TextEditor.selections[0]`.
1233 */
1234 selection: Selection;
1235
1236 /**
1237 * The selections in this text editor. The primary selection is always at index 0.
1238 */
1239 selections: readonly Selection[];
1240
1241 /**
1242 * The current visible ranges in the editor (vertically).
1243 * This accounts only for vertical scrolling, and not for horizontal scrolling.
1244 */
1245 readonly visibleRanges: readonly Range[];
1246
1247 /**
1248 * Text editor options.
1249 */
1250 options: TextEditorOptions;
1251
1252 /**
1253 * The column in which this editor shows. Will be `undefined` in case this
1254 * isn't one of the main editors, e.g. an embedded editor, or when the editor
1255 * column is larger than three.
1256 */
1257 readonly viewColumn: ViewColumn | undefined;
1258
1259 /**
1260 * Perform an edit on the document associated with this text editor.
1261 *
1262 * The given callback-function is invoked with an {@link TextEditorEdit edit-builder} which must
1263 * be used to make edits. Note that the edit-builder is only valid while the
1264 * callback executes.
1265 *
1266 * @param callback A function which can create edits using an {@link TextEditorEdit edit-builder}.
1267 * @param options The undo/redo behavior around this edit. By default, undo stops will be created before and after this edit.
1268 * @returns A promise that resolves with a value indicating if the edits could be applied.
1269 */
1270 edit(callback: (editBuilder: TextEditorEdit) => void, options?: {
1271 /**
1272 * Add undo stop before making the edits.
1273 */
1274 readonly undoStopBefore: boolean;
1275 /**
1276 * Add undo stop after making the edits.
1277 */
1278 readonly undoStopAfter: boolean;
1279 }): Thenable<boolean>;
1280
1281 /**
1282 * Insert a {@link SnippetString snippet} and put the editor into snippet mode. "Snippet mode"
1283 * means the editor adds placeholders and additional cursors so that the user can complete
1284 * or accept the snippet.
1285 *
1286 * @param snippet The snippet to insert in this edit.
1287 * @param location Position or range at which to insert the snippet, defaults to the current editor selection or selections.
1288 * @param options The undo/redo behavior around this edit. By default, undo stops will be created before and after this edit.
1289 * @returns A promise that resolves with a value indicating if the snippet could be inserted. Note that the promise does not signal
1290 * that the snippet is completely filled-in or accepted.
1291 */
1292 insertSnippet(snippet: SnippetString, location?: Position | Range | readonly Position[] | readonly Range[], options?: {
1293 /**
1294 * Add undo stop before making the edits.
1295 */
1296 readonly undoStopBefore: boolean;
1297 /**
1298 * Add undo stop after making the edits.
1299 */
1300 readonly undoStopAfter: boolean;
1301 }): Thenable<boolean>;
1302
1303 /**
1304 * Adds a set of decorations to the text editor. If a set of decorations already exists with
1305 * the given {@link TextEditorDecorationType decoration type}, they will be replaced. If
1306 * `rangesOrOptions` is empty, the existing decorations with the given {@link TextEditorDecorationType decoration type}
1307 * will be removed.
1308 *
1309 * @see {@link window.createTextEditorDecorationType createTextEditorDecorationType}.
1310 *
1311 * @param decorationType A decoration type.
1312 * @param rangesOrOptions Either {@link Range ranges} or more detailed {@link DecorationOptions options}.
1313 */
1314 setDecorations(decorationType: TextEditorDecorationType, rangesOrOptions: readonly Range[] | readonly DecorationOptions[]): void;
1315
1316 /**
1317 * Scroll as indicated by `revealType` in order to reveal the given range.
1318 *
1319 * @param range A range.
1320 * @param revealType The scrolling strategy for revealing `range`.
1321 */
1322 revealRange(range: Range, revealType?: TextEditorRevealType): void;
1323
1324 /**
1325 * Show the text editor.
1326 *
1327 * @deprecated Use {@link window.showTextDocument} instead.
1328 *
1329 * @param column The {@link ViewColumn column} in which to show this editor.
1330 * This method shows unexpected behavior and will be removed in the next major update.
1331 */
1332 show(column?: ViewColumn): void;
1333
1334 /**
1335 * Hide the text editor.
1336 *
1337 * @deprecated Use the command `workbench.action.closeActiveEditor` instead.
1338 * This method shows unexpected behavior and will be removed in the next major update.
1339 */
1340 hide(): void;
1341 }
1342
1343 /**
1344 * Represents an end of line character sequence in a {@link TextDocument document}.
1345 */
1346 export enum EndOfLine {
1347 /**
1348 * The line feed `\n` character.
1349 */
1350 LF = 1,
1351 /**
1352 * The carriage return line feed `\r\n` sequence.
1353 */
1354 CRLF = 2
1355 }
1356
1357 /**
1358 * A complex edit that will be applied in one transaction on a TextEditor.
1359 * This holds a description of the edits and if the edits are valid (i.e. no overlapping regions, document was not changed in the meantime, etc.)
1360 * they can be applied on a {@link TextDocument document} associated with a {@link TextEditor text editor}.
1361 */
1362 export interface TextEditorEdit {
1363 /**
1364 * Replace a certain text region with a new value.
1365 * You can use `\r\n` or `\n` in `value` and they will be normalized to the current {@link TextDocument document}.
1366 *
1367 * @param location The range this operation should remove.
1368 * @param value The new text this operation should insert after removing `location`.
1369 */
1370 replace(location: Position | Range | Selection, value: string): void;
1371
1372 /**
1373 * Insert text at a location.
1374 * You can use `\r\n` or `\n` in `value` and they will be normalized to the current {@link TextDocument document}.
1375 * Although the equivalent text edit can be made with {@link TextEditorEdit.replace replace}, `insert` will produce a different resulting selection (it will get moved).
1376 *
1377 * @param location The position where the new text should be inserted.
1378 * @param value The new text this operation should insert.
1379 */
1380 insert(location: Position, value: string): void;
1381
1382 /**
1383 * Delete a certain text region.
1384 *
1385 * @param location The range this operation should remove.
1386 */
1387 delete(location: Range | Selection): void;
1388
1389 /**
1390 * Set the end of line sequence.
1391 *
1392 * @param endOfLine The new end of line for the {@link TextDocument document}.
1393 */
1394 setEndOfLine(endOfLine: EndOfLine): void;
1395 }
1396
1397 /**
1398 * A universal resource identifier representing either a file on disk
1399 * or another resource, like untitled resources.
1400 */
1401 export class Uri {
1402
1403 /**
1404 * Create an URI from a string, e.g. `http://www.example.com/some/path`,
1405 * `file:///usr/home`, or `scheme:with/path`.
1406 *
1407 * *Note* that for a while uris without a `scheme` were accepted. That is not correct
1408 * as all uris should have a scheme. To avoid breakage of existing code the optional
1409 * `strict`-argument has been added. We *strongly* advise to use it, e.g. `Uri.parse('my:uri', true)`
1410 *
1411 * @see {@link Uri.toString}
1412 * @param value The string value of an Uri.
1413 * @param strict Throw an error when `value` is empty or when no `scheme` can be parsed.
1414 * @returns A new Uri instance.
1415 */
1416 static parse(value: string, strict?: boolean): Uri;
1417
1418 /**
1419 * Create an URI from a file system path. The {@link Uri.scheme scheme}
1420 * will be `file`.
1421 *
1422 * The *difference* between {@link Uri.parse} and {@link Uri.file} is that the latter treats the argument
1423 * as path, not as stringified-uri. E.g. `Uri.file(path)` is *not* the same as
1424 * `Uri.parse('file://' + path)` because the path might contain characters that are
1425 * interpreted (# and ?). See the following sample:
1426 * ```ts
1427 * const good = URI.file('/coding/c#/project1');
1428 * good.scheme === 'file';
1429 * good.path === '/coding/c#/project1';
1430 * good.fragment === '';
1431 *
1432 * const bad = URI.parse('file://' + '/coding/c#/project1');
1433 * bad.scheme === 'file';
1434 * bad.path === '/coding/c'; // path is now broken
1435 * bad.fragment === '/project1';
1436 * ```
1437 *
1438 * @param path A file system or UNC path.
1439 * @returns A new Uri instance.
1440 */
1441 static file(path: string): Uri;
1442
1443 /**
1444 * Create a new uri which path is the result of joining
1445 * the path of the base uri with the provided path segments.
1446 *
1447 * - Note 1: `joinPath` only affects the path component
1448 * and all other components (scheme, authority, query, and fragment) are
1449 * left as they are.
1450 * - Note 2: The base uri must have a path; an error is thrown otherwise.
1451 *
1452 * The path segments are normalized in the following ways:
1453 * - sequences of path separators (`/` or `\`) are replaced with a single separator
1454 * - for `file`-uris on windows, the backslash-character (`\`) is considered a path-separator
1455 * - the `..`-segment denotes the parent segment, the `.` denotes the current segment
1456 * - paths have a root which always remains, for instance on windows drive-letters are roots
1457 * so that is true: `joinPath(Uri.file('file:///c:/root'), '../../other').fsPath === 'c:/other'`
1458 *
1459 * @param base An uri. Must have a path.
1460 * @param pathSegments One more more path fragments
1461 * @returns A new uri which path is joined with the given fragments
1462 */
1463 static joinPath(base: Uri, ...pathSegments: string[]): Uri;
1464
1465 /**
1466 * Create an URI from its component parts
1467 *
1468 * @see {@link Uri.toString}
1469 * @param components The component parts of an Uri.
1470 * @returns A new Uri instance.
1471 */
1472 static from(components: {
1473 /**
1474 * The scheme of the uri
1475 */
1476 readonly scheme: string;
1477 /**
1478 * The authority of the uri
1479 */
1480 readonly authority?: string;
1481 /**
1482 * The path of the uri
1483 */
1484 readonly path?: string;
1485 /**
1486 * The query string of the uri
1487 */
1488 readonly query?: string;
1489 /**
1490 * The fragment identifier of the uri
1491 */
1492 readonly fragment?: string;
1493 }): Uri;
1494
1495 /**
1496 * Use the `file` and `parse` factory functions to create new `Uri` objects.
1497 */
1498 private constructor(scheme: string, authority: string, path: string, query: string, fragment: string);
1499
1500 /**
1501 * Scheme is the `http` part of `http://www.example.com/some/path?query#fragment`.
1502 * The part before the first colon.
1503 */
1504 readonly scheme: string;
1505
1506 /**
1507 * Authority is the `www.example.com` part of `http://www.example.com/some/path?query#fragment`.
1508 * The part between the first double slashes and the next slash.
1509 */
1510 readonly authority: string;
1511
1512 /**
1513 * Path is the `/some/path` part of `http://www.example.com/some/path?query#fragment`.
1514 */
1515 readonly path: string;
1516
1517 /**
1518 * Query is the `query` part of `http://www.example.com/some/path?query#fragment`.
1519 */
1520 readonly query: string;
1521
1522 /**
1523 * Fragment is the `fragment` part of `http://www.example.com/some/path?query#fragment`.
1524 */
1525 readonly fragment: string;
1526
1527 /**
1528 * The string representing the corresponding file system path of this Uri.
1529 *
1530 * Will handle UNC paths and normalize windows drive letters to lower-case. Also
1531 * uses the platform specific path separator.
1532 *
1533 * * Will *not* validate the path for invalid characters and semantics.
1534 * * Will *not* look at the scheme of this Uri.
1535 * * The resulting string shall *not* be used for display purposes but
1536 * for disk operations, like `readFile` et al.
1537 *
1538 * The *difference* to the {@linkcode Uri.path path}-property is the use of the platform specific
1539 * path separator and the handling of UNC paths. The sample below outlines the difference:
1540 * ```ts
1541 * const u = URI.parse('file://server/c$/folder/file.txt')
1542 * u.authority === 'server'
1543 * u.path === '/c$/folder/file.txt'
1544 * u.fsPath === '\\server\c$\folder\file.txt'
1545 * ```
1546 */
1547 readonly fsPath: string;
1548
1549 /**
1550 * Derive a new Uri from this Uri.
1551 *
1552 * ```ts
1553 * let file = Uri.parse('before:some/file/path');
1554 * let other = file.with({ scheme: 'after' });
1555 * assert.ok(other.toString() === 'after:some/file/path');
1556 * ```
1557 *
1558 * @param change An object that describes a change to this Uri. To unset components use `null` or
1559 * the empty string.
1560 * @returns A new Uri that reflects the given change. Will return `this` Uri if the change
1561 * is not changing anything.
1562 */
1563 with(change: {
1564 /**
1565 * The new scheme, defaults to this Uri's scheme.
1566 */
1567 scheme?: string;
1568 /**
1569 * The new authority, defaults to this Uri's authority.
1570 */
1571 authority?: string;
1572 /**
1573 * The new path, defaults to this Uri's path.
1574 */
1575 path?: string;
1576 /**
1577 * The new query, defaults to this Uri's query.
1578 */
1579 query?: string;
1580 /**
1581 * The new fragment, defaults to this Uri's fragment.
1582 */
1583 fragment?: string;
1584 }): Uri;
1585
1586 /**
1587 * Returns a string representation of this Uri. The representation and normalization
1588 * of a URI depends on the scheme.
1589 *
1590 * * The resulting string can be safely used with {@link Uri.parse}.
1591 * * The resulting string shall *not* be used for display purposes.
1592 *
1593 * *Note* that the implementation will encode _aggressive_ which often leads to unexpected,
1594 * but not incorrect, results. For instance, colons are encoded to `%3A` which might be unexpected
1595 * in file-uri. Also `&` and `=` will be encoded which might be unexpected for http-uris. For stability
1596 * reasons this cannot be changed anymore. If you suffer from too aggressive encoding you should use
1597 * the `skipEncoding`-argument: `uri.toString(true)`.
1598 *
1599 * @param skipEncoding Do not percentage-encode the result, defaults to `false`. Note that
1600 * the `#` and `?` characters occurring in the path will always be encoded.
1601 * @returns A string representation of this Uri.
1602 */
1603 toString(skipEncoding?: boolean): string;
1604
1605 /**
1606 * Returns a JSON representation of this Uri.
1607 *
1608 * @returns An object.
1609 */
1610 toJSON(): any;
1611 }
1612
1613 /**
1614 * A cancellation token is passed to an asynchronous or long running
1615 * operation to request cancellation, like cancelling a request
1616 * for completion items because the user continued to type.
1617 *
1618 * To get an instance of a `CancellationToken` use a
1619 * {@link CancellationTokenSource}.
1620 */
1621 export interface CancellationToken {
1622
1623 /**
1624 * Is `true` when the token has been cancelled, `false` otherwise.
1625 */
1626 isCancellationRequested: boolean;
1627
1628 /**
1629 * An {@link Event} which fires upon cancellation.
1630 */
1631 onCancellationRequested: Event<any>;
1632 }
1633
1634 /**
1635 * A cancellation source creates and controls a {@link CancellationToken cancellation token}.
1636 */
1637 export class CancellationTokenSource {
1638
1639 /**
1640 * The cancellation token of this source.
1641 */
1642 token: CancellationToken;
1643
1644 /**
1645 * Signal cancellation on the token.
1646 */
1647 cancel(): void;
1648
1649 /**
1650 * Dispose object and free resources.
1651 */
1652 dispose(): void;
1653 }
1654
1655 /**
1656 * An error type that should be used to signal cancellation of an operation.
1657 *
1658 * This type can be used in response to a {@link CancellationToken cancellation token}
1659 * being cancelled or when an operation is being cancelled by the
1660 * executor of that operation.
1661 */
1662 export class CancellationError extends Error {
1663
1664 /**
1665 * Creates a new cancellation error.
1666 */
1667 constructor();
1668 }
1669
1670 /**
1671 * Represents a type which can release resources, such
1672 * as event listening or a timer.
1673 */
1674 export class Disposable {
1675
1676 /**
1677 * Combine many disposable-likes into one. You can use this method when having objects with
1678 * a dispose function which aren't instances of `Disposable`.
1679 *
1680 * @param disposableLikes Objects that have at least a `dispose`-function member. Note that asynchronous
1681 * dispose-functions aren't awaited.
1682 * @returns Returns a new disposable which, upon dispose, will
1683 * dispose all provided disposables.
1684 */
1685 static from(...disposableLikes: {
1686 /**
1687 * Function to clean up resources.
1688 */
1689 dispose: () => any;
1690 }[]): Disposable;
1691
1692 /**
1693 * Creates a new disposable that calls the provided function
1694 * on dispose.
1695 *
1696 * *Note* that an asynchronous function is not awaited.
1697 *
1698 * @param callOnDispose Function that disposes something.
1699 */
1700 constructor(callOnDispose: () => any);
1701
1702 /**
1703 * Dispose this object.
1704 */
1705 dispose(): any;
1706 }
1707
1708 /**
1709 * Represents a typed event.
1710 *
1711 * A function that represents an event to which you subscribe by calling it with
1712 * a listener function as argument.
1713 *
1714 * @example
1715 * item.onDidChange(function(event) { console.log("Event happened: " + event); });
1716 */
1717 export interface Event<T> {
1718
1719 /**
1720 * A function that represents an event to which you subscribe by calling it with
1721 * a listener function as argument.
1722 *
1723 * @param listener The listener function will be called when the event happens.
1724 * @param thisArgs The `this`-argument which will be used when calling the event listener.
1725 * @param disposables An array to which a {@link Disposable} will be added.
1726 * @returns A disposable which unsubscribes the event listener.
1727 */
1728 (listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]): Disposable;
1729 }
1730
1731 /**
1732 * An event emitter can be used to create and manage an {@link Event} for others
1733 * to subscribe to. One emitter always owns one event.
1734 *
1735 * Use this class if you want to provide event from within your extension, for instance
1736 * inside a {@link TextDocumentContentProvider} or when providing
1737 * API to other extensions.
1738 */
1739 export class EventEmitter<T> {
1740
1741 /**
1742 * The event listeners can subscribe to.
1743 */
1744 event: Event<T>;
1745
1746 /**
1747 * Notify all subscribers of the {@link EventEmitter.event event}. Failure
1748 * of one or more listener will not fail this function call.
1749 *
1750 * @param data The event object.
1751 */
1752 fire(data: T): void;
1753
1754 /**
1755 * Dispose this object and free resources.
1756 */
1757 dispose(): void;
1758 }
1759
1760 /**
1761 * A file system watcher notifies about changes to files and folders
1762 * on disk or from other {@link FileSystemProvider FileSystemProviders}.
1763 *
1764 * To get an instance of a `FileSystemWatcher` use
1765 * {@link workspace.createFileSystemWatcher createFileSystemWatcher}.
1766 */
1767 export interface FileSystemWatcher extends Disposable {
1768
1769 /**
1770 * true if this file system watcher has been created such that
1771 * it ignores creation file system events.
1772 */
1773 readonly ignoreCreateEvents: boolean;
1774
1775 /**
1776 * true if this file system watcher has been created such that
1777 * it ignores change file system events.
1778 */
1779 readonly ignoreChangeEvents: boolean;
1780
1781 /**
1782 * true if this file system watcher has been created such that
1783 * it ignores delete file system events.
1784 */
1785 readonly ignoreDeleteEvents: boolean;
1786
1787 /**
1788 * An event which fires on file/folder creation.
1789 */
1790 readonly onDidCreate: Event<Uri>;
1791
1792 /**
1793 * An event which fires on file/folder change.
1794 */
1795 readonly onDidChange: Event<Uri>;
1796
1797 /**
1798 * An event which fires on file/folder deletion.
1799 */
1800 readonly onDidDelete: Event<Uri>;
1801 }
1802
1803 /**
1804 * A text document content provider allows to add readonly documents
1805 * to the editor, such as source from a dll or generated html from md.
1806 *
1807 * Content providers are {@link workspace.registerTextDocumentContentProvider registered}
1808 * for a {@link Uri.scheme uri-scheme}. When a uri with that scheme is to
1809 * be {@link workspace.openTextDocument loaded} the content provider is
1810 * asked.
1811 */
1812 export interface TextDocumentContentProvider {
1813
1814 /**
1815 * An event to signal a resource has changed.
1816 */
1817 onDidChange?: Event<Uri>;
1818
1819 /**
1820 * Provide textual content for a given uri.
1821 *
1822 * The editor will use the returned string-content to create a readonly
1823 * {@link TextDocument document}. Resources allocated should be released when
1824 * the corresponding document has been {@link workspace.onDidCloseTextDocument closed}.
1825 *
1826 * **Note**: The contents of the created {@link TextDocument document} might not be
1827 * identical to the provided text due to end-of-line-sequence normalization.
1828 *
1829 * @param uri An uri which scheme matches the scheme this provider was {@link workspace.registerTextDocumentContentProvider registered} for.
1830 * @param token A cancellation token.
1831 * @returns A string or a thenable that resolves to such.
1832 */
1833 provideTextDocumentContent(uri: Uri, token: CancellationToken): ProviderResult<string>;
1834 }
1835
1836 /**
1837 * The kind of {@link QuickPickItem quick pick item}.
1838 */
1839 export enum QuickPickItemKind {
1840 /**
1841 * When a {@link QuickPickItem} has a kind of {@link Separator}, the item is just a visual separator and does not represent a real item.
1842 * The only property that applies is {@link QuickPickItem.label label }. All other properties on {@link QuickPickItem} will be ignored and have no effect.
1843 */
1844 Separator = -1,
1845 /**
1846 * The default {@link QuickPickItem.kind} is an item that can be selected in the quick pick.
1847 */
1848 Default = 0,
1849 }
1850
1851 /**
1852 * Represents an item that can be selected from
1853 * a list of items.
1854 */
1855 export interface QuickPickItem {
1856
1857 /**
1858 * A human-readable string which is rendered prominent. Supports rendering of {@link ThemeIcon theme icons} via
1859 * the `$(<name>)`-syntax.
1860 */
1861 label: string;
1862
1863 /**
1864 * The kind of QuickPickItem that will determine how this item is rendered in the quick pick. When not specified,
1865 * the default is {@link QuickPickItemKind.Default}.
1866 */
1867 kind?: QuickPickItemKind;
1868
1869 /**
1870 * The icon path or {@link ThemeIcon} for the QuickPickItem.
1871 */
1872 iconPath?: Uri | {
1873 /**
1874 * The icon path for the light theme.
1875 */
1876 light: Uri;
1877 /**
1878 * The icon path for the dark theme.
1879 */
1880 dark: Uri;
1881 } | ThemeIcon;
1882
1883 /**
1884 * A human-readable string which is rendered less prominent in the same line. Supports rendering of
1885 * {@link ThemeIcon theme icons} via the `$(<name>)`-syntax.
1886 *
1887 * Note: this property is ignored when {@link QuickPickItem.kind kind} is set to {@link QuickPickItemKind.Separator}
1888 */
1889 description?: string;
1890
1891 /**
1892 * A human-readable string which is rendered less prominent in a separate line. Supports rendering of
1893 * {@link ThemeIcon theme icons} via the `$(<name>)`-syntax.
1894 *
1895 * Note: this property is ignored when {@link QuickPickItem.kind kind} is set to {@link QuickPickItemKind.Separator}
1896 */
1897 detail?: string;
1898
1899 /**
1900 * Optional flag indicating if this item is picked initially. This is only honored when using
1901 * the {@link window.showQuickPick showQuickPick()} API. To do the same thing with
1902 * the {@link window.createQuickPick createQuickPick()} API, simply set the {@link QuickPick.selectedItems}
1903 * to the items you want picked initially.
1904 * (*Note:* This is only honored when the picker allows multiple selections.)
1905 *
1906 * @see {@link QuickPickOptions.canPickMany}
1907 *
1908 * Note: this property is ignored when {@link QuickPickItem.kind kind} is set to {@link QuickPickItemKind.Separator}
1909 */
1910 picked?: boolean;
1911
1912 /**
1913 * Always show this item.
1914 *
1915 * Note: this property is ignored when {@link QuickPickItem.kind kind} is set to {@link QuickPickItemKind.Separator}
1916 */
1917 alwaysShow?: boolean;
1918
1919 /**
1920 * Optional buttons that will be rendered on this particular item. These buttons will trigger
1921 * an {@link QuickPickItemButtonEvent} when clicked. Buttons are only rendered when using a quickpick
1922 * created by the {@link window.createQuickPick createQuickPick()} API. Buttons are not rendered when using
1923 * the {@link window.showQuickPick showQuickPick()} API.
1924 *
1925 * Note: this property is ignored when {@link QuickPickItem.kind kind} is set to {@link QuickPickItemKind.Separator}
1926 */
1927 buttons?: readonly QuickInputButton[];
1928 }
1929
1930 /**
1931 * Options to configure the behavior of the quick pick UI.
1932 */
1933 export interface QuickPickOptions {
1934
1935 /**
1936 * An optional string that represents the title of the quick pick.
1937 */
1938 title?: string;
1939
1940 /**
1941 * An optional flag to include the description when filtering the picks.
1942 */
1943 matchOnDescription?: boolean;
1944
1945 /**
1946 * An optional flag to include the detail when filtering the picks.
1947 */
1948 matchOnDetail?: boolean;
1949
1950 /**
1951 * An optional string to show as placeholder in the input box to guide the user what to pick on.
1952 */
1953 placeHolder?: string;
1954
1955 /**
1956 * Set to `true` to keep the picker open when focus moves to another part of the editor or to another window.
1957 * This setting is ignored on iPad and is always false.
1958 */
1959 ignoreFocusOut?: boolean;
1960
1961 /**
1962 * An optional flag to make the picker accept multiple selections, if true the result is an array of picks.
1963 */
1964 canPickMany?: boolean;
1965
1966 /**
1967 * An optional function that is invoked whenever an item is selected.
1968 */
1969 onDidSelectItem?(item: QuickPickItem | string): any;
1970 }
1971
1972 /**
1973 * Options to configure the behaviour of the {@link WorkspaceFolder workspace folder} pick UI.
1974 */
1975 export interface WorkspaceFolderPickOptions {
1976
1977 /**
1978 * An optional string to show as placeholder in the input box to guide the user what to pick on.
1979 */
1980 placeHolder?: string;
1981
1982 /**
1983 * Set to `true` to keep the picker open when focus moves to another part of the editor or to another window.
1984 * This setting is ignored on iPad and is always false.
1985 */
1986 ignoreFocusOut?: boolean;
1987 }
1988
1989 /**
1990 * Options to configure the behaviour of a file open dialog.
1991 *
1992 * * Note 1: On Windows and Linux, a file dialog cannot be both a file selector and a folder selector, so if you
1993 * set both `canSelectFiles` and `canSelectFolders` to `true` on these platforms, a folder selector will be shown.
1994 * * Note 2: Explicitly setting `canSelectFiles` and `canSelectFolders` to `false` is futile
1995 * and the editor then silently adjusts the options to select files.
1996 */
1997 export interface OpenDialogOptions {
1998 /**
1999 * The resource the dialog shows when opened.
2000 */
2001 defaultUri?: Uri;
2002
2003 /**
2004 * A human-readable string for the open button.
2005 */
2006 openLabel?: string;
2007
2008 /**
2009 * Allow to select files, defaults to `true`.
2010 */
2011 canSelectFiles?: boolean;
2012
2013 /**
2014 * Allow to select folders, defaults to `false`.
2015 */
2016 canSelectFolders?: boolean;
2017
2018 /**
2019 * Allow to select many files or folders.
2020 */
2021 canSelectMany?: boolean;
2022
2023 /**
2024 * A set of file filters that are used by the dialog. Each entry is a human-readable label,
2025 * like "TypeScript", and an array of extensions, for example:
2026 * ```ts
2027 * {
2028 * 'Images': ['png', 'jpg'],
2029 * 'TypeScript': ['ts', 'tsx']
2030 * }
2031 * ```
2032 */
2033 filters?: { [name: string]: string[] };
2034
2035 /**
2036 * Dialog title.
2037 *
2038 * This parameter might be ignored, as not all operating systems display a title on open dialogs
2039 * (for example, macOS).
2040 */
2041 title?: string;
2042 }
2043
2044 /**
2045 * Options to configure the behaviour of a file save dialog.
2046 */
2047 export interface SaveDialogOptions {
2048 /**
2049 * The resource the dialog shows when opened.
2050 */
2051 defaultUri?: Uri;
2052
2053 /**
2054 * A human-readable string for the save button.
2055 */
2056 saveLabel?: string;
2057
2058 /**
2059 * A set of file filters that are used by the dialog. Each entry is a human-readable label,
2060 * like "TypeScript", and an array of extensions, for example:
2061 * ```ts
2062 * {
2063 * 'Images': ['png', 'jpg'],
2064 * 'TypeScript': ['ts', 'tsx']
2065 * }
2066 * ```
2067 */
2068 filters?: { [name: string]: string[] };
2069
2070 /**
2071 * Dialog title.
2072 *
2073 * This parameter might be ignored, as not all operating systems display a title on save dialogs
2074 * (for example, macOS).
2075 */
2076 title?: string;
2077 }
2078
2079 /**
2080 * Represents an action that is shown with an information, warning, or
2081 * error message.
2082 *
2083 * @see {@link window.showInformationMessage showInformationMessage}
2084 * @see {@link window.showWarningMessage showWarningMessage}
2085 * @see {@link window.showErrorMessage showErrorMessage}
2086 */
2087 export interface MessageItem {
2088
2089 /**
2090 * A short title like 'Retry', 'Open Log' etc.
2091 */
2092 title: string;
2093
2094 /**
2095 * A hint for modal dialogs that the item should be triggered
2096 * when the user cancels the dialog (e.g. by pressing the ESC
2097 * key).
2098 *
2099 * Note: this option is ignored for non-modal messages.
2100 */
2101 isCloseAffordance?: boolean;
2102 }
2103
2104 /**
2105 * Options to configure the behavior of the message.
2106 *
2107 * @see {@link window.showInformationMessage showInformationMessage}
2108 * @see {@link window.showWarningMessage showWarningMessage}
2109 * @see {@link window.showErrorMessage showErrorMessage}
2110 */
2111 export interface MessageOptions {
2112
2113 /**
2114 * Indicates that this message should be modal.
2115 */
2116 modal?: boolean;
2117
2118 /**
2119 * Human-readable detail message that is rendered less prominent. _Note_ that detail
2120 * is only shown for {@link MessageOptions.modal modal} messages.
2121 */
2122 detail?: string;
2123 }
2124
2125 /**
2126 * Impacts the behavior and appearance of the validation message.
2127 */
2128 /**
2129 * The severity level for input box validation.
2130 */
2131 export enum InputBoxValidationSeverity {
2132 /**
2133 * Informational severity level.
2134 */
2135 Info = 1,
2136 /**
2137 * Warning severity level.
2138 */
2139 Warning = 2,
2140 /**
2141 * Error severity level.
2142 */
2143 Error = 3
2144 }
2145
2146 /**
2147 * Object to configure the behavior of the validation message.
2148 */
2149 export interface InputBoxValidationMessage {
2150 /**
2151 * The validation message to display.
2152 */
2153 readonly message: string;
2154
2155 /**
2156 * The severity of the validation message.
2157 * NOTE: When using `InputBoxValidationSeverity.Error`, the user will not be allowed to accept (hit ENTER) the input.
2158 * `Info` and `Warning` will still allow the InputBox to accept the input.
2159 */
2160 readonly severity: InputBoxValidationSeverity;
2161 }
2162
2163 /**
2164 * Options to configure the behavior of the input box UI.
2165 */
2166 export interface InputBoxOptions {
2167
2168 /**
2169 * An optional string that represents the title of the input box.
2170 */
2171 title?: string;
2172
2173 /**
2174 * The value to pre-fill in the input box.
2175 */
2176 value?: string;
2177
2178 /**
2179 * Selection of the pre-filled {@linkcode InputBoxOptions.value value}. Defined as tuple of two number where the
2180 * first is the inclusive start index and the second the exclusive end index. When `undefined` the whole
2181 * pre-filled value will be selected, when empty (start equals end) only the cursor will be set,
2182 * otherwise the defined range will be selected.
2183 */
2184 valueSelection?: [number, number];
2185
2186 /**
2187 * The text to display underneath the input box.
2188 */
2189 prompt?: string;
2190
2191 /**
2192 * An optional string to show as placeholder in the input box to guide the user what to type.
2193 */
2194 placeHolder?: string;
2195
2196 /**
2197 * Controls if a password input is shown. Password input hides the typed text.
2198 */
2199 password?: boolean;
2200
2201 /**
2202 * Set to `true` to keep the input box open when focus moves to another part of the editor or to another window.
2203 * This setting is ignored on iPad and is always false.
2204 */
2205 ignoreFocusOut?: boolean;
2206
2207 /**
2208 * An optional function that will be called to validate input and to give a hint
2209 * to the user.
2210 *
2211 * @param value The current value of the input box.
2212 * @returns Either a human-readable string which is presented as an error message or an {@link InputBoxValidationMessage}
2213 * which can provide a specific message severity. Return `undefined`, `null`, or the empty string when 'value' is valid.
2214 */
2215 validateInput?(value: string): string | InputBoxValidationMessage | undefined | null |
2216 Thenable<string | InputBoxValidationMessage | undefined | null>;
2217 }
2218
2219 /**
2220 * A relative pattern is a helper to construct glob patterns that are matched
2221 * relatively to a base file path. The base path can either be an absolute file
2222 * path as string or uri or a {@link WorkspaceFolder workspace folder}, which is the
2223 * preferred way of creating the relative pattern.
2224 */
2225 export class RelativePattern {
2226
2227 /**
2228 * A base file path to which this pattern will be matched against relatively. The
2229 * file path must be absolute, should not have any trailing path separators and
2230 * not include any relative segments (`.` or `..`).
2231 */
2232 baseUri: Uri;
2233
2234 /**
2235 * A base file path to which this pattern will be matched against relatively.
2236 *
2237 * This matches the `fsPath` value of {@link RelativePattern.baseUri}.
2238 *
2239 * *Note:* updating this value will update {@link RelativePattern.baseUri} to
2240 * be a uri with `file` scheme.
2241 *
2242 * @deprecated This property is deprecated, please use {@link RelativePattern.baseUri} instead.
2243 */
2244 base: string;
2245
2246 /**
2247 * A file glob pattern like `*.{ts,js}` that will be matched on file paths
2248 * relative to the base path.
2249 *
2250 * Example: Given a base of `/home/work/folder` and a file path of `/home/work/folder/index.js`,
2251 * the file glob pattern will match on `index.js`.
2252 */
2253 pattern: string;
2254
2255 /**
2256 * Creates a new relative pattern object with a base file path and pattern to match. This pattern
2257 * will be matched on file paths relative to the base.
2258 *
2259 * Example:
2260 * ```ts
2261 * const folder = vscode.workspace.workspaceFolders?.[0];
2262 * if (folder) {
2263 *
2264 * // Match any TypeScript file in the root of this workspace folder
2265 * const pattern1 = new vscode.RelativePattern(folder, '*.ts');
2266 *
2267 * // Match any TypeScript file in `someFolder` inside this workspace folder
2268 * const pattern2 = new vscode.RelativePattern(folder, 'someFolder/*.ts');
2269 * }
2270 * ```
2271 *
2272 * @param base A base to which this pattern will be matched against relatively. It is recommended
2273 * to pass in a {@link WorkspaceFolder workspace folder} if the pattern should match inside the workspace.
2274 * Otherwise, a uri or string should only be used if the pattern is for a file path outside the workspace.
2275 * @param pattern A file glob pattern like `*.{ts,js}` that will be matched on paths relative to the base.
2276 */
2277 constructor(base: WorkspaceFolder | Uri | string, pattern: string);
2278 }
2279
2280 /**
2281 * A file glob pattern to match file paths against. This can either be a glob pattern string
2282 * (like `**​/*.{ts,js}` or `*.{ts,js}`) or a {@link RelativePattern relative pattern}.
2283 *
2284 * Glob patterns can have the following syntax:
2285 * * `*` to match zero or more characters in a path segment
2286 * * `?` to match on one character in a path segment
2287 * * `**` to match any number of path segments, including none
2288 * * `{}` to group conditions (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files)
2289 * * `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
2290 * * `[!...]` to negate a range of characters to match in a path segment (e.g., `example.[!0-9]` to match on `example.a`, `example.b`, but not `example.0`)
2291 *
2292 * Note: a backslash (`\`) is not valid within a glob pattern. If you have an existing file
2293 * path to match against, consider to use the {@link RelativePattern relative pattern} support
2294 * that takes care of converting any backslash into slash. Otherwise, make sure to convert
2295 * any backslash to slash when creating the glob pattern.
2296 */
2297 export type GlobPattern = string | RelativePattern;
2298
2299 /**
2300 * A document filter denotes a document by different properties like
2301 * the {@link TextDocument.languageId language}, the {@link Uri.scheme scheme} of
2302 * its resource, or a glob-pattern that is applied to the {@link TextDocument.fileName path}.
2303 *
2304 * @example <caption>A language filter that applies to typescript files on disk</caption>
2305 * { language: 'typescript', scheme: 'file' }
2306 *
2307 * @example <caption>A language filter that applies to all package.json paths</caption>
2308 * { language: 'json', pattern: '**​/package.json' }
2309 */
2310 export interface DocumentFilter {
2311
2312 /**
2313 * A language id, like `typescript`.
2314 */
2315 readonly language?: string;
2316
2317 /**
2318 * The {@link NotebookDocument.notebookType type} of a notebook, like `jupyter-notebook`. This allows
2319 * to narrow down on the type of a notebook that a {@link NotebookCell.document cell document} belongs to.
2320 *
2321 * *Note* that setting the `notebookType`-property changes how `scheme` and `pattern` are interpreted. When set
2322 * they are evaluated against the {@link NotebookDocument.uri notebook uri}, not the document uri.
2323 *
2324 * @example <caption>Match python document inside jupyter notebook that aren't stored yet (`untitled`)</caption>
2325 * { language: 'python', notebookType: 'jupyter-notebook', scheme: 'untitled' }
2326 */
2327 readonly notebookType?: string;
2328
2329 /**
2330 * A Uri {@link Uri.scheme scheme}, like `file` or `untitled`.
2331 */
2332 readonly scheme?: string;
2333
2334 /**
2335 * A {@link GlobPattern glob pattern} that is matched on the absolute path of the document. Use a {@link RelativePattern relative pattern}
2336 * to filter documents to a {@link WorkspaceFolder workspace folder}.
2337 */
2338 readonly pattern?: GlobPattern;
2339 }
2340
2341 /**
2342 * A language selector is the combination of one or many language identifiers
2343 * and {@link DocumentFilter language filters}.
2344 *
2345 * *Note* that a document selector that is just a language identifier selects *all*
2346 * documents, even those that are not saved on disk. Only use such selectors when
2347 * a feature works without further context, e.g. without the need to resolve related
2348 * 'files'.
2349 *
2350 * @example
2351 * let sel:DocumentSelector = { scheme: 'file', language: 'typescript' };
2352 */
2353 export type DocumentSelector = DocumentFilter | string | ReadonlyArray<DocumentFilter | string>;
2354
2355 /**
2356 * A provider result represents the values a provider, like the {@linkcode HoverProvider},
2357 * may return. For once this is the actual result type `T`, like `Hover`, or a thenable that resolves
2358 * to that type `T`. In addition, `null` and `undefined` can be returned - either directly or from a
2359 * thenable.
2360 *
2361 * The snippets below are all valid implementations of the {@linkcode HoverProvider}:
2362 *
2363 * ```ts
2364 * let a: HoverProvider = {
2365 * provideHover(doc, pos, token): ProviderResult<Hover> {
2366 * return new Hover('Hello World');
2367 * }
2368 * }
2369 *
2370 * let b: HoverProvider = {
2371 * provideHover(doc, pos, token): ProviderResult<Hover> {
2372 * return new Promise(resolve => {
2373 * resolve(new Hover('Hello World'));
2374 * });
2375 * }
2376 * }
2377 *
2378 * let c: HoverProvider = {
2379 * provideHover(doc, pos, token): ProviderResult<Hover> {
2380 * return; // undefined
2381 * }
2382 * }
2383 * ```
2384 */
2385 export type ProviderResult<T> = T | undefined | null | Thenable<T | undefined | null>;
2386
2387 /**
2388 * Kind of a code action.
2389 *
2390 * Kinds are a hierarchical list of identifiers separated by `.`, e.g. `"refactor.extract.function"`.
2391 *
2392 * Code action kinds are used by the editor for UI elements such as the refactoring context menu. Users
2393 * can also trigger code actions with a specific kind with the `editor.action.codeAction` command.
2394 */
2395 export class CodeActionKind {
2396 /**
2397 * Empty kind.
2398 */
2399 static readonly Empty: CodeActionKind;
2400
2401 /**
2402 * Base kind for quickfix actions: `quickfix`.
2403 *
2404 * Quick fix actions address a problem in the code and are shown in the normal code action context menu.
2405 */
2406 static readonly QuickFix: CodeActionKind;
2407
2408 /**
2409 * Base kind for refactoring actions: `refactor`
2410 *
2411 * Refactoring actions are shown in the refactoring context menu.
2412 */
2413 static readonly Refactor: CodeActionKind;
2414
2415 /**
2416 * Base kind for refactoring extraction actions: `refactor.extract`
2417 *
2418 * Example extract actions:
2419 *
2420 * - Extract method
2421 * - Extract function
2422 * - Extract variable
2423 * - Extract interface from class
2424 * - ...
2425 */
2426 static readonly RefactorExtract: CodeActionKind;
2427
2428 /**
2429 * Base kind for refactoring inline actions: `refactor.inline`
2430 *
2431 * Example inline actions:
2432 *
2433 * - Inline function
2434 * - Inline variable
2435 * - Inline constant
2436 * - ...
2437 */
2438 static readonly RefactorInline: CodeActionKind;
2439
2440 /**
2441 * Base kind for refactoring move actions: `refactor.move`
2442 *
2443 * Example move actions:
2444 *
2445 * - Move a function to a new file
2446 * - Move a property between classes
2447 * - Move method to base class
2448 * - ...
2449 */
2450 static readonly RefactorMove: CodeActionKind;
2451
2452 /**
2453 * Base kind for refactoring rewrite actions: `refactor.rewrite`
2454 *
2455 * Example rewrite actions:
2456 *
2457 * - Convert JavaScript function to class
2458 * - Add or remove parameter
2459 * - Encapsulate field
2460 * - Make method static
2461 * - ...
2462 */
2463 static readonly RefactorRewrite: CodeActionKind;
2464
2465 /**
2466 * Base kind for source actions: `source`
2467 *
2468 * Source code actions apply to the entire file. They must be explicitly requested and will not show in the
2469 * normal [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) menu. Source actions
2470 * can be run on save using `editor.codeActionsOnSave` and are also shown in the `source` context menu.
2471 */
2472 static readonly Source: CodeActionKind;
2473
2474 /**
2475 * Base kind for an organize imports source action: `source.organizeImports`.
2476 */
2477 static readonly SourceOrganizeImports: CodeActionKind;
2478
2479 /**
2480 * Base kind for auto-fix source actions: `source.fixAll`.
2481 *
2482 * Fix all actions automatically fix errors that have a clear fix that do not require user input.
2483 * They should not suppress errors or perform unsafe fixes such as generating new types or classes.
2484 */
2485 static readonly SourceFixAll: CodeActionKind;
2486
2487 /**
2488 * Base kind for all code actions applying to the enitre notebook's scope. CodeActionKinds using
2489 * this should always begin with `notebook.`
2490 *
2491 * This requires that new CodeActions be created for it and contributed via extensions.
2492 * Pre-existing kinds can not just have the new `notebook.` prefix added to them, as the functionality
2493 * is unique to the full-notebook scope.
2494 *
2495 * Notebook CodeActionKinds can be initialized as either of the following (both resulting in `notebook.source.xyz`):
2496 * - `const newKind = CodeActionKind.Notebook.append(CodeActionKind.Source.append('xyz').value)`
2497 * - `const newKind = CodeActionKind.Notebook.append('source.xyz')`
2498 *
2499 * Example Kinds/Actions:
2500 * - `notebook.source.organizeImports` (might move all imports to a new top cell)
2501 * - `notebook.source.normalizeVariableNames` (might rename all variables to a standardized casing format)
2502 */
2503 static readonly Notebook: CodeActionKind;
2504
2505 /**
2506 * Private constructor, use statix `CodeActionKind.XYZ` to derive from an existing code action kind.
2507 *
2508 * @param value The value of the kind, such as `refactor.extract.function`.
2509 */
2510 private constructor(value: string);
2511
2512 /**
2513 * String value of the kind, e.g. `"refactor.extract.function"`.
2514 */
2515 readonly value: string;
2516
2517 /**
2518 * Create a new kind by appending a more specific selector to the current kind.
2519 *
2520 * Does not modify the current kind.
2521 */
2522 append(parts: string): CodeActionKind;
2523
2524 /**
2525 * Checks if this code action kind intersects `other`.
2526 *
2527 * The kind `"refactor.extract"` for example intersects `refactor`, `"refactor.extract"` and `"refactor.extract.function"`,
2528 * but not `"unicorn.refactor.extract"`, or `"refactor.extractAll"`.
2529 *
2530 * @param other Kind to check.
2531 */
2532 intersects(other: CodeActionKind): boolean;
2533
2534 /**
2535 * Checks if `other` is a sub-kind of this `CodeActionKind`.
2536 *
2537 * The kind `"refactor.extract"` for example contains `"refactor.extract"` and ``"refactor.extract.function"`,
2538 * but not `"unicorn.refactor.extract"`, or `"refactor.extractAll"` or `refactor`.
2539 *
2540 * @param other Kind to check.
2541 */
2542 contains(other: CodeActionKind): boolean;
2543 }
2544
2545 /**
2546 * The reason why code actions were requested.
2547 */
2548 export enum CodeActionTriggerKind {
2549 /**
2550 * Code actions were explicitly requested by the user or by an extension.
2551 */
2552 Invoke = 1,
2553
2554 /**
2555 * Code actions were requested automatically.
2556 *
2557 * This typically happens when current selection in a file changes, but can
2558 * also be triggered when file content changes.
2559 */
2560 Automatic = 2,
2561 }
2562
2563 /**
2564 * Contains additional diagnostic information about the context in which
2565 * a {@link CodeActionProvider.provideCodeActions code action} is run.
2566 */
2567 export interface CodeActionContext {
2568 /**
2569 * The reason why code actions were requested.
2570 */
2571 readonly triggerKind: CodeActionTriggerKind;
2572
2573 /**
2574 * An array of diagnostics.
2575 */
2576 readonly diagnostics: readonly Diagnostic[];
2577
2578 /**
2579 * Requested kind of actions to return.
2580 *
2581 * Actions not of this kind are filtered out before being shown by the [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action).
2582 */
2583 readonly only: CodeActionKind | undefined;
2584 }
2585
2586 /**
2587 * A code action represents a change that can be performed in code, e.g. to fix a problem or
2588 * to refactor code.
2589 *
2590 * A CodeAction must set either {@linkcode CodeAction.edit edit} and/or a {@linkcode CodeAction.command command}. If both are supplied, the `edit` is applied first, then the command is executed.
2591 */
2592 export class CodeAction {
2593
2594 /**
2595 * A short, human-readable, title for this code action.
2596 */
2597 title: string;
2598
2599 /**
2600 * A {@link WorkspaceEdit workspace edit} this code action performs.
2601 */
2602 edit?: WorkspaceEdit;
2603
2604 /**
2605 * {@link Diagnostic Diagnostics} that this code action resolves.
2606 */
2607 diagnostics?: Diagnostic[];
2608
2609 /**
2610 * A {@link Command} this code action executes.
2611 *
2612 * If this command throws an exception, the editor displays the exception message to users in the editor at the
2613 * current cursor position.
2614 */
2615 command?: Command;
2616
2617 /**
2618 * {@link CodeActionKind Kind} of the code action.
2619 *
2620 * Used to filter code actions.
2621 */
2622 kind?: CodeActionKind;
2623
2624 /**
2625 * Marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted
2626 * by keybindings.
2627 *
2628 * A quick fix should be marked preferred if it properly addresses the underlying error.
2629 * A refactoring should be marked preferred if it is the most reasonable choice of actions to take.
2630 */
2631 isPreferred?: boolean;
2632
2633 /**
2634 * Marks that the code action cannot currently be applied.
2635 *
2636 * - Disabled code actions are not shown in automatic [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action)
2637 * code action menu.
2638 *
2639 * - Disabled actions are shown as faded out in the code action menu when the user request a more specific type
2640 * of code action, such as refactorings.
2641 *
2642 * - If the user has a [keybinding](https://code.visualstudio.com/docs/editor/refactoring#_keybindings-for-code-actions)
2643 * that auto applies a code action and only a disabled code actions are returned, the editor will show the user an
2644 * error message with `reason` in the editor.
2645 */
2646 disabled?: {
2647 /**
2648 * Human readable description of why the code action is currently disabled.
2649 *
2650 * This is displayed in the code actions UI.
2651 */
2652 readonly reason: string;
2653 };
2654
2655 /**
2656 * Creates a new code action.
2657 *
2658 * A code action must have at least a {@link CodeAction.title title} and {@link CodeAction.edit edits}
2659 * and/or a {@link CodeAction.command command}.
2660 *
2661 * @param title The title of the code action.
2662 * @param kind The kind of the code action.
2663 */
2664 constructor(title: string, kind?: CodeActionKind);
2665 }
2666
2667 /**
2668 * Provides contextual actions for code. Code actions typically either fix problems or beautify/refactor code.
2669 *
2670 * Code actions are surfaced to users in a few different ways:
2671 *
2672 * - The [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature, which shows
2673 * a list of code actions at the current cursor position. The lightbulb's list of actions includes both quick fixes
2674 * and refactorings.
2675 * - As commands that users can run, such as `Refactor`. Users can run these from the command palette or with keybindings.
2676 * - As source actions, such `Organize Imports`.
2677 * - {@link CodeActionKind.QuickFix Quick fixes} are shown in the problems view.
2678 * - Change applied on save by the `editor.codeActionsOnSave` setting.
2679 */
2680 export interface CodeActionProvider<T extends CodeAction = CodeAction> {
2681 /**
2682 * Get code actions for a given range in a document.
2683 *
2684 * Only return code actions that are relevant to user for the requested range. Also keep in mind how the
2685 * returned code actions will appear in the UI. The lightbulb widget and `Refactor` commands for instance show
2686 * returned code actions as a list, so do not return a large number of code actions that will overwhelm the user.
2687 *
2688 * @param document The document in which the command was invoked.
2689 * @param range The selector or range for which the command was invoked. This will always be a
2690 * {@link Selection selection} if the actions are being requested in the currently active editor.
2691 * @param context Provides additional information about what code actions are being requested. You can use this
2692 * to see what specific type of code actions are being requested by the editor in order to return more relevant
2693 * actions and avoid returning irrelevant code actions that the editor will discard.
2694 * @param token A cancellation token.
2695 *
2696 * @returns An array of code actions, such as quick fixes or refactorings. The lack of a result can be signaled
2697 * by returning `undefined`, `null`, or an empty array.
2698 *
2699 * We also support returning `Command` for legacy reasons, however all new extensions should return
2700 * `CodeAction` object instead.
2701 */
2702 provideCodeActions(document: TextDocument, range: Range | Selection, context: CodeActionContext, token: CancellationToken): ProviderResult<(Command | T)[]>;
2703
2704 /**
2705 * Given a code action fill in its {@linkcode CodeAction.edit edit}-property. Changes to
2706 * all other properties, like title, are ignored. A code action that has an edit
2707 * will not be resolved.
2708 *
2709 * *Note* that a code action provider that returns commands, not code actions, cannot successfully
2710 * implement this function. Returning commands is deprecated and instead code actions should be
2711 * returned.
2712 *
2713 * @param codeAction A code action.
2714 * @param token A cancellation token.
2715 * @returns The resolved code action or a thenable that resolves to such. It is OK to return the given
2716 * `item`. When no result is returned, the given `item` will be used.
2717 */
2718 resolveCodeAction?(codeAction: T, token: CancellationToken): ProviderResult<T>;
2719 }
2720
2721 /**
2722 * Metadata about the type of code actions that a {@link CodeActionProvider} provides.
2723 */
2724 export interface CodeActionProviderMetadata {
2725 /**
2726 * List of {@link CodeActionKind CodeActionKinds} that a {@link CodeActionProvider} may return.
2727 *
2728 * This list is used to determine if a given `CodeActionProvider` should be invoked or not.
2729 * To avoid unnecessary computation, every `CodeActionProvider` should list use `providedCodeActionKinds`. The
2730 * list of kinds may either be generic, such as `[CodeActionKind.Refactor]`, or list out every kind provided,
2731 * such as `[CodeActionKind.Refactor.Extract.append('function'), CodeActionKind.Refactor.Extract.append('constant'), ...]`.
2732 */
2733 readonly providedCodeActionKinds?: readonly CodeActionKind[];
2734
2735 /**
2736 * Static documentation for a class of code actions.
2737 *
2738 * Documentation from the provider is shown in the code actions menu if either:
2739 *
2740 * - Code actions of `kind` are requested by the editor. In this case, the editor will show the documentation that
2741 * most closely matches the requested code action kind. For example, if a provider has documentation for
2742 * both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`,
2743 * the editor will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`.
2744 *
2745 * - Any code actions of `kind` are returned by the provider.
2746 *
2747 * At most one documentation entry will be shown per provider.
2748 */
2749 readonly documentation?: ReadonlyArray<{
2750 /**
2751 * The kind of the code action being documented.
2752 *
2753 * If the kind is generic, such as `CodeActionKind.Refactor`, the documentation will be shown whenever any
2754 * refactorings are returned. If the kind if more specific, such as `CodeActionKind.RefactorExtract`, the
2755 * documentation will only be shown when extract refactoring code actions are returned.
2756 */
2757 readonly kind: CodeActionKind;
2758
2759 /**
2760 * Command that displays the documentation to the user.
2761 *
2762 * This can display the documentation directly in the editor or open a website using {@linkcode env.openExternal};
2763 *
2764 * The title of this documentation code action is taken from {@linkcode Command.title}
2765 */
2766 readonly command: Command;
2767 }>;
2768 }
2769
2770 /**
2771 * A code lens represents a {@link Command} that should be shown along with
2772 * source text, like the number of references, a way to run tests, etc.
2773 *
2774 * A code lens is _unresolved_ when no command is associated to it. For performance
2775 * reasons the creation of a code lens and resolving should be done to two stages.
2776 *
2777 * @see {@link CodeLensProvider.provideCodeLenses}
2778 * @see {@link CodeLensProvider.resolveCodeLens}
2779 */
2780 export class CodeLens {
2781
2782 /**
2783 * The range in which this code lens is valid. Should only span a single line.
2784 */
2785 range: Range;
2786
2787 /**
2788 * The command this code lens represents.
2789 */
2790 command?: Command;
2791
2792 /**
2793 * `true` when there is a command associated.
2794 */
2795 readonly isResolved: boolean;
2796
2797 /**
2798 * Creates a new code lens object.
2799 *
2800 * @param range The range to which this code lens applies.
2801 * @param command The command associated to this code lens.
2802 */
2803 constructor(range: Range, command?: Command);
2804 }
2805
2806 /**
2807 * A code lens provider adds {@link Command commands} to source text. The commands will be shown
2808 * as dedicated horizontal lines in between the source text.
2809 */
2810 export interface CodeLensProvider<T extends CodeLens = CodeLens> {
2811
2812 /**
2813 * An optional event to signal that the code lenses from this provider have changed.
2814 */
2815 onDidChangeCodeLenses?: Event<void>;
2816
2817 /**
2818 * Compute a list of {@link CodeLens lenses}. This call should return as fast as possible and if
2819 * computing the commands is expensive implementors should only return code lens objects with the
2820 * range set and implement {@link CodeLensProvider.resolveCodeLens resolve}.
2821 *
2822 * @param document The document in which the command was invoked.
2823 * @param token A cancellation token.
2824 * @returns An array of code lenses or a thenable that resolves to such. The lack of a result can be
2825 * signaled by returning `undefined`, `null`, or an empty array.
2826 */
2827 provideCodeLenses(document: TextDocument, token: CancellationToken): ProviderResult<T[]>;
2828
2829 /**
2830 * This function will be called for each visible code lens, usually when scrolling and after
2831 * calls to {@link CodeLensProvider.provideCodeLenses compute}-lenses.
2832 *
2833 * @param codeLens Code lens that must be resolved.
2834 * @param token A cancellation token.
2835 * @returns The given, resolved code lens or thenable that resolves to such.
2836 */
2837 resolveCodeLens?(codeLens: T, token: CancellationToken): ProviderResult<T>;
2838 }
2839
2840 /**
2841 * Information about where a symbol is defined.
2842 *
2843 * Provides additional metadata over normal {@link Location} definitions, including the range of
2844 * the defining symbol
2845 */
2846 export type DefinitionLink = LocationLink;
2847
2848 /**
2849 * The definition of a symbol represented as one or many {@link Location locations}.
2850 * For most programming languages there is only one location at which a symbol is
2851 * defined.
2852 */
2853 export type Definition = Location | Location[];
2854
2855 /**
2856 * The definition provider interface defines the contract between extensions and
2857 * the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
2858 * and peek definition features.
2859 */
2860 export interface DefinitionProvider {
2861
2862 /**
2863 * Provide the definition of the symbol at the given position and document.
2864 *
2865 * @param document The document in which the command was invoked.
2866 * @param position The position at which the command was invoked.
2867 * @param token A cancellation token.
2868 * @returns A definition or a thenable that resolves to such. The lack of a result can be
2869 * signaled by returning `undefined` or `null`.
2870 */
2871 provideDefinition(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
2872 }
2873
2874 /**
2875 * The implementation provider interface defines the contract between extensions and
2876 * the go to implementation feature.
2877 */
2878 export interface ImplementationProvider {
2879
2880 /**
2881 * Provide the implementations of the symbol at the given position and document.
2882 *
2883 * @param document The document in which the command was invoked.
2884 * @param position The position at which the command was invoked.
2885 * @param token A cancellation token.
2886 * @returns A definition or a thenable that resolves to such. The lack of a result can be
2887 * signaled by returning `undefined` or `null`.
2888 */
2889 provideImplementation(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
2890 }
2891
2892 /**
2893 * The type definition provider defines the contract between extensions and
2894 * the go to type definition feature.
2895 */
2896 export interface TypeDefinitionProvider {
2897
2898 /**
2899 * Provide the type definition of the symbol at the given position and document.
2900 *
2901 * @param document The document in which the command was invoked.
2902 * @param position The position at which the command was invoked.
2903 * @param token A cancellation token.
2904 * @returns A definition or a thenable that resolves to such. The lack of a result can be
2905 * signaled by returning `undefined` or `null`.
2906 */
2907 provideTypeDefinition(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
2908 }
2909
2910 /**
2911 * The declaration of a symbol representation as one or many {@link Location locations}
2912 * or {@link LocationLink location links}.
2913 */
2914 export type Declaration = Location | Location[] | LocationLink[];
2915
2916 /**
2917 * The declaration provider interface defines the contract between extensions and
2918 * the go to declaration feature.
2919 */
2920 export interface DeclarationProvider {
2921
2922 /**
2923 * Provide the declaration of the symbol at the given position and document.
2924 *
2925 * @param document The document in which the command was invoked.
2926 * @param position The position at which the command was invoked.
2927 * @param token A cancellation token.
2928 * @returns A declaration or a thenable that resolves to such. The lack of a result can be
2929 * signaled by returning `undefined` or `null`.
2930 */
2931 provideDeclaration(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Declaration>;
2932 }
2933
2934 /**
2935 * Human-readable text that supports formatting via the [markdown syntax](https://commonmark.org).
2936 *
2937 * Rendering of {@link ThemeIcon theme icons} via the `$(<name>)`-syntax is supported
2938 * when the {@linkcode supportThemeIcons} is set to `true`.
2939 *
2940 * Rendering of embedded html is supported when {@linkcode supportHtml} is set to `true`.
2941 */
2942 export class MarkdownString {
2943
2944 /**
2945 * The markdown string.
2946 */
2947 value: string;
2948
2949 /**
2950 * Indicates that this markdown string is from a trusted source. Only *trusted*
2951 * markdown supports links that execute commands, e.g. `[Run it](command:myCommandId)`.
2952 *
2953 * Defaults to `false` (commands are disabled).
2954 */
2955 isTrusted?: boolean | {
2956 /**
2957 * A set of commend ids that are allowed to be executed by this markdown string.
2958 */
2959 readonly enabledCommands: readonly string[];
2960 };
2961
2962 /**
2963 * Indicates that this markdown string can contain {@link ThemeIcon ThemeIcons}, e.g. `$(zap)`.
2964 */
2965 supportThemeIcons?: boolean;
2966
2967 /**
2968 * Indicates that this markdown string can contain raw html tags. Defaults to `false`.
2969 *
2970 * When `supportHtml` is false, the markdown renderer will strip out any raw html tags
2971 * that appear in the markdown text. This means you can only use markdown syntax for rendering.
2972 *
2973 * When `supportHtml` is true, the markdown render will also allow a safe subset of html tags
2974 * and attributes to be rendered. See https://github.com/microsoft/vscode/blob/6d2920473c6f13759c978dd89104c4270a83422d/src/vs/base/browser/markdownRenderer.ts#L296
2975 * for a list of all supported tags and attributes.
2976 */
2977 supportHtml?: boolean;
2978
2979 /**
2980 * Uri that relative paths are resolved relative to.
2981 *
2982 * If the `baseUri` ends with `/`, it is considered a directory and relative paths in the markdown are resolved relative to that directory:
2983 *
2984 * ```ts
2985 * const md = new vscode.MarkdownString(`[link](./file.js)`);
2986 * md.baseUri = vscode.Uri.file('/path/to/dir/');
2987 * // Here 'link' in the rendered markdown resolves to '/path/to/dir/file.js'
2988 * ```
2989 *
2990 * If the `baseUri` is a file, relative paths in the markdown are resolved relative to the parent dir of that file:
2991 *
2992 * ```ts
2993 * const md = new vscode.MarkdownString(`[link](./file.js)`);
2994 * md.baseUri = vscode.Uri.file('/path/to/otherFile.js');
2995 * // Here 'link' in the rendered markdown resolves to '/path/to/file.js'
2996 * ```
2997 */
2998 baseUri?: Uri;
2999
3000 /**
3001 * Creates a new markdown string with the given value.
3002 *
3003 * @param value Optional, initial value.
3004 * @param supportThemeIcons Optional, Specifies whether {@link ThemeIcon ThemeIcons} are supported within the {@linkcode MarkdownString}.
3005 */
3006 constructor(value?: string, supportThemeIcons?: boolean);
3007
3008 /**
3009 * Appends and escapes the given string to this markdown string.
3010 * @param value Plain text.
3011 */
3012 appendText(value: string): MarkdownString;
3013
3014 /**
3015 * Appends the given string 'as is' to this markdown string. When {@linkcode MarkdownString.supportThemeIcons supportThemeIcons} is `true`, {@link ThemeIcon ThemeIcons} in the `value` will be iconified.
3016 * @param value Markdown string.
3017 */
3018 appendMarkdown(value: string): MarkdownString;
3019
3020 /**
3021 * Appends the given string as codeblock using the provided language.
3022 * @param value A code snippet.
3023 * @param language An optional {@link languages.getLanguages language identifier}.
3024 */
3025 appendCodeblock(value: string, language?: string): MarkdownString;
3026 }
3027
3028 /**
3029 * MarkedString can be used to render human-readable text. It is either a markdown string
3030 * or a code-block that provides a language and a code snippet. Note that
3031 * markdown strings will be sanitized - that means html will be escaped.
3032 *
3033 * @deprecated This type is deprecated, please use {@linkcode MarkdownString} instead.
3034 */
3035 export type MarkedString = string | {
3036 /**
3037 * The language of a markdown code block
3038 * @deprecated please use {@linkcode MarkdownString} instead
3039 */
3040 language: string;
3041 /**
3042 * The code snippet of a markdown code block.
3043 * @deprecated please use {@linkcode MarkdownString} instead
3044 */
3045 value: string;
3046 };
3047
3048 /**
3049 * A hover represents additional information for a symbol or word. Hovers are
3050 * rendered in a tooltip-like widget.
3051 */
3052 export class Hover {
3053
3054 /**
3055 * The contents of this hover.
3056 */
3057 contents: Array<MarkdownString | MarkedString>;
3058
3059 /**
3060 * The range to which this hover applies. When missing, the
3061 * editor will use the range at the current position or the
3062 * current position itself.
3063 */
3064 range?: Range;
3065
3066 /**
3067 * Creates a new hover object.
3068 *
3069 * @param contents The contents of the hover.
3070 * @param range The range to which the hover applies.
3071 */
3072 constructor(contents: MarkdownString | MarkedString | Array<MarkdownString | MarkedString>, range?: Range);
3073 }
3074
3075 /**
3076 * The hover provider interface defines the contract between extensions and
3077 * the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature.
3078 */
3079 export interface HoverProvider {
3080
3081 /**
3082 * Provide a hover for the given position and document. Multiple hovers at the same
3083 * position will be merged by the editor. A hover can have a range which defaults
3084 * to the word range at the position when omitted.
3085 *
3086 * @param document The document in which the command was invoked.
3087 * @param position The position at which the command was invoked.
3088 * @param token A cancellation token.
3089 * @returns A hover or a thenable that resolves to such. The lack of a result can be
3090 * signaled by returning `undefined` or `null`.
3091 */
3092 provideHover(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Hover>;
3093 }
3094
3095 /**
3096 * An EvaluatableExpression represents an expression in a document that can be evaluated by an active debugger or runtime.
3097 * The result of this evaluation is shown in a tooltip-like widget.
3098 * If only a range is specified, the expression will be extracted from the underlying document.
3099 * An optional expression can be used to override the extracted expression.
3100 * In this case the range is still used to highlight the range in the document.
3101 */
3102 export class EvaluatableExpression {
3103
3104 /*
3105 * The range is used to extract the evaluatable expression from the underlying document and to highlight it.
3106 */
3107 readonly range: Range;
3108
3109 /*
3110 * If specified the expression overrides the extracted expression.
3111 */
3112 readonly expression?: string | undefined;
3113
3114 /**
3115 * Creates a new evaluatable expression object.
3116 *
3117 * @param range The range in the underlying document from which the evaluatable expression is extracted.
3118 * @param expression If specified overrides the extracted expression.
3119 */
3120 constructor(range: Range, expression?: string);
3121 }
3122
3123 /**
3124 * The evaluatable expression provider interface defines the contract between extensions and
3125 * the debug hover. In this contract the provider returns an evaluatable expression for a given position
3126 * in a document and the editor evaluates this expression in the active debug session and shows the result in a debug hover.
3127 */
3128 export interface EvaluatableExpressionProvider {
3129
3130 /**
3131 * Provide an evaluatable expression for the given document and position.
3132 * The editor will evaluate this expression in the active debug session and will show the result in the debug hover.
3133 * The expression can be implicitly specified by the range in the underlying document or by explicitly returning an expression.
3134 *
3135 * @param document The document for which the debug hover is about to appear.
3136 * @param position The line and character position in the document where the debug hover is about to appear.
3137 * @param token A cancellation token.
3138 * @returns An EvaluatableExpression or a thenable that resolves to such. The lack of a result can be
3139 * signaled by returning `undefined` or `null`.
3140 */
3141 provideEvaluatableExpression(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<EvaluatableExpression>;
3142 }
3143
3144 /**
3145 * Provide inline value as text.
3146 */
3147 export class InlineValueText {
3148 /**
3149 * The document range for which the inline value applies.
3150 */
3151 readonly range: Range;
3152 /**
3153 * The text of the inline value.
3154 */
3155 readonly text: string;
3156 /**
3157 * Creates a new InlineValueText object.
3158 *
3159 * @param range The document line where to show the inline value.
3160 * @param text The value to be shown for the line.
3161 */
3162 constructor(range: Range, text: string);
3163 }
3164
3165 /**
3166 * Provide inline value through a variable lookup.
3167 * If only a range is specified, the variable name will be extracted from the underlying document.
3168 * An optional variable name can be used to override the extracted name.
3169 */
3170 export class InlineValueVariableLookup {
3171 /**
3172 * The document range for which the inline value applies.
3173 * The range is used to extract the variable name from the underlying document.
3174 */
3175 readonly range: Range;
3176 /**
3177 * If specified the name of the variable to look up.
3178 */
3179 readonly variableName?: string | undefined;
3180 /**
3181 * How to perform the lookup.
3182 */
3183 readonly caseSensitiveLookup: boolean;
3184 /**
3185 * Creates a new InlineValueVariableLookup object.
3186 *
3187 * @param range The document line where to show the inline value.
3188 * @param variableName The name of the variable to look up.
3189 * @param caseSensitiveLookup How to perform the lookup. If missing lookup is case sensitive.
3190 */
3191 constructor(range: Range, variableName?: string, caseSensitiveLookup?: boolean);
3192 }
3193
3194 /**
3195 * Provide an inline value through an expression evaluation.
3196 * If only a range is specified, the expression will be extracted from the underlying document.
3197 * An optional expression can be used to override the extracted expression.
3198 */
3199 export class InlineValueEvaluatableExpression {
3200 /**
3201 * The document range for which the inline value applies.
3202 * The range is used to extract the evaluatable expression from the underlying document.
3203 */
3204 readonly range: Range;
3205 /**
3206 * If specified the expression overrides the extracted expression.
3207 */
3208 readonly expression?: string | undefined;
3209 /**
3210 * Creates a new InlineValueEvaluatableExpression object.
3211 *
3212 * @param range The range in the underlying document from which the evaluatable expression is extracted.
3213 * @param expression If specified overrides the extracted expression.
3214 */
3215 constructor(range: Range, expression?: string);
3216 }
3217
3218 /**
3219 * Inline value information can be provided by different means:
3220 * - directly as a text value (class InlineValueText).
3221 * - as a name to use for a variable lookup (class InlineValueVariableLookup)
3222 * - as an evaluatable expression (class InlineValueEvaluatableExpression)
3223 * The InlineValue types combines all inline value types into one type.
3224 */
3225 export type InlineValue = InlineValueText | InlineValueVariableLookup | InlineValueEvaluatableExpression;
3226
3227 /**
3228 * A value-object that contains contextual information when requesting inline values from a InlineValuesProvider.
3229 */
3230 export interface InlineValueContext {
3231
3232 /**
3233 * The stack frame (as a DAP Id) where the execution has stopped.
3234 */
3235 readonly frameId: number;
3236
3237 /**
3238 * The document range where execution has stopped.
3239 * Typically the end position of the range denotes the line where the inline values are shown.
3240 */
3241 readonly stoppedLocation: Range;
3242 }
3243
3244 /**
3245 * The inline values provider interface defines the contract between extensions and the editor's debugger inline values feature.
3246 * In this contract the provider returns inline value information for a given document range
3247 * and the editor shows this information in the editor at the end of lines.
3248 */
3249 export interface InlineValuesProvider {
3250
3251 /**
3252 * An optional event to signal that inline values have changed.
3253 * @see {@link EventEmitter}
3254 */
3255 onDidChangeInlineValues?: Event<void> | undefined;
3256
3257 /**
3258 * Provide "inline value" information for a given document and range.
3259 * The editor calls this method whenever debugging stops in the given document.
3260 * The returned inline values information is rendered in the editor at the end of lines.
3261 *
3262 * @param document The document for which the inline values information is needed.
3263 * @param viewPort The visible document range for which inline values should be computed.
3264 * @param context A bag containing contextual information like the current location.
3265 * @param token A cancellation token.
3266 * @returns An array of InlineValueDescriptors or a thenable that resolves to such. The lack of a result can be
3267 * signaled by returning `undefined` or `null`.
3268 */
3269 provideInlineValues(document: TextDocument, viewPort: Range, context: InlineValueContext, token: CancellationToken): ProviderResult<InlineValue[]>;
3270 }
3271
3272 /**
3273 * A document highlight kind.
3274 */
3275 export enum DocumentHighlightKind {
3276
3277 /**
3278 * A textual occurrence.
3279 */
3280 Text = 0,
3281
3282 /**
3283 * Read-access of a symbol, like reading a variable.
3284 */
3285 Read = 1,
3286
3287 /**
3288 * Write-access of a symbol, like writing to a variable.
3289 */
3290 Write = 2
3291 }
3292
3293 /**
3294 * A document highlight is a range inside a text document which deserves
3295 * special attention. Usually a document highlight is visualized by changing
3296 * the background color of its range.
3297 */
3298 export class DocumentHighlight {
3299
3300 /**
3301 * The range this highlight applies to.
3302 */
3303 range: Range;
3304
3305 /**
3306 * The highlight kind, default is {@link DocumentHighlightKind.Text text}.
3307 */
3308 kind?: DocumentHighlightKind;
3309
3310 /**
3311 * Creates a new document highlight object.
3312 *
3313 * @param range The range the highlight applies to.
3314 * @param kind The highlight kind, default is {@link DocumentHighlightKind.Text text}.
3315 */
3316 constructor(range: Range, kind?: DocumentHighlightKind);
3317 }
3318
3319 /**
3320 * The document highlight provider interface defines the contract between extensions and
3321 * the word-highlight-feature.
3322 */
3323 export interface DocumentHighlightProvider {
3324
3325 /**
3326 * Provide a set of document highlights, like all occurrences of a variable or
3327 * all exit-points of a function.
3328 *
3329 * @param document The document in which the command was invoked.
3330 * @param position The position at which the command was invoked.
3331 * @param token A cancellation token.
3332 * @returns An array of document highlights or a thenable that resolves to such. The lack of a result can be
3333 * signaled by returning `undefined`, `null`, or an empty array.
3334 */
3335 provideDocumentHighlights(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<DocumentHighlight[]>;
3336 }
3337
3338 /**
3339 * A symbol kind.
3340 */
3341 export enum SymbolKind {
3342 /**
3343 * The `File` symbol kind.
3344 */
3345 File = 0,
3346 /**
3347 * The `Module` symbol kind.
3348 */
3349 Module = 1,
3350 /**
3351 * The `Namespace` symbol kind.
3352 */
3353 Namespace = 2,
3354 /**
3355 * The `Package` symbol kind.
3356 */
3357 Package = 3,
3358 /**
3359 * The `Class` symbol kind.
3360 */
3361 Class = 4,
3362 /**
3363 * The `Method` symbol kind.
3364 */
3365 Method = 5,
3366 /**
3367 * The `Property` symbol kind.
3368 */
3369 Property = 6,
3370 /**
3371 * The `Field` symbol kind.
3372 */
3373 Field = 7,
3374 /**
3375 * The `Constructor` symbol kind.
3376 */
3377 Constructor = 8,
3378 /**
3379 * The `Enum` symbol kind.
3380 */
3381 Enum = 9,
3382 /**
3383 * The `Interface` symbol kind.
3384 */
3385 Interface = 10,
3386 /**
3387 * The `Function` symbol kind.
3388 */
3389 Function = 11,
3390 /**
3391 * The `Variable` symbol kind.
3392 */
3393 Variable = 12,
3394 /**
3395 * The `Constant` symbol kind.
3396 */
3397 Constant = 13,
3398 /**
3399 * The `String` symbol kind.
3400 */
3401 String = 14,
3402 /**
3403 * The `Number` symbol kind.
3404 */
3405 Number = 15,
3406 /**
3407 * The `Boolean` symbol kind.
3408 */
3409 Boolean = 16,
3410 /**
3411 * The `Array` symbol kind.
3412 */
3413 Array = 17,
3414 /**
3415 * The `Object` symbol kind.
3416 */
3417 Object = 18,
3418 /**
3419 * The `Key` symbol kind.
3420 */
3421 Key = 19,
3422 /**
3423 * The `Null` symbol kind.
3424 */
3425 Null = 20,
3426 /**
3427 * The `EnumMember` symbol kind.
3428 */
3429 EnumMember = 21,
3430 /**
3431 * The `Struct` symbol kind.
3432 */
3433 Struct = 22,
3434 /**
3435 * The `Event` symbol kind.
3436 */
3437 Event = 23,
3438 /**
3439 * The `Operator` symbol kind.
3440 */
3441 Operator = 24,
3442 /**
3443 * The `TypeParameter` symbol kind.
3444 */
3445 TypeParameter = 25
3446 }
3447
3448 /**
3449 * Symbol tags are extra annotations that tweak the rendering of a symbol.
3450 */
3451 export enum SymbolTag {
3452
3453 /**
3454 * Render a symbol as obsolete, usually using a strike-out.
3455 */
3456 Deprecated = 1
3457 }
3458
3459 /**
3460 * Represents information about programming constructs like variables, classes,
3461 * interfaces etc.
3462 */
3463 export class SymbolInformation {
3464
3465 /**
3466 * The name of this symbol.
3467 */
3468 name: string;
3469
3470 /**
3471 * The name of the symbol containing this symbol.
3472 */
3473 containerName: string;
3474
3475 /**
3476 * The kind of this symbol.
3477 */
3478 kind: SymbolKind;
3479
3480 /**
3481 * Tags for this symbol.
3482 */
3483 tags?: readonly SymbolTag[];
3484
3485 /**
3486 * The location of this symbol.
3487 */
3488 location: Location;
3489
3490 /**
3491 * Creates a new symbol information object.
3492 *
3493 * @param name The name of the symbol.
3494 * @param kind The kind of the symbol.
3495 * @param containerName The name of the symbol containing the symbol.
3496 * @param location The location of the symbol.
3497 */
3498 constructor(name: string, kind: SymbolKind, containerName: string, location: Location);
3499
3500 /**
3501 * Creates a new symbol information object.
3502 *
3503 * @deprecated Please use the constructor taking a {@link Location} object.
3504 *
3505 * @param name The name of the symbol.
3506 * @param kind The kind of the symbol.
3507 * @param range The range of the location of the symbol.
3508 * @param uri The resource of the location of symbol, defaults to the current document.
3509 * @param containerName The name of the symbol containing the symbol.
3510 */
3511 constructor(name: string, kind: SymbolKind, range: Range, uri?: Uri, containerName?: string);
3512 }
3513
3514 /**
3515 * Represents programming constructs like variables, classes, interfaces etc. that appear in a document. Document
3516 * symbols can be hierarchical and they have two ranges: one that encloses its definition and one that points to
3517 * its most interesting range, e.g. the range of an identifier.
3518 */
3519 export class DocumentSymbol {
3520
3521 /**
3522 * The name of this symbol.
3523 */
3524 name: string;
3525
3526 /**
3527 * More detail for this symbol, e.g. the signature of a function.
3528 */
3529 detail: string;
3530
3531 /**
3532 * The kind of this symbol.
3533 */
3534 kind: SymbolKind;
3535
3536 /**
3537 * Tags for this symbol.
3538 */
3539 tags?: readonly SymbolTag[];
3540
3541 /**
3542 * The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code.
3543 */
3544 range: Range;
3545
3546 /**
3547 * The range that should be selected and reveal when this symbol is being picked, e.g. the name of a function.
3548 * Must be contained by the {@linkcode DocumentSymbol.range range}.
3549 */
3550 selectionRange: Range;
3551
3552 /**
3553 * Children of this symbol, e.g. properties of a class.
3554 */
3555 children: DocumentSymbol[];
3556
3557 /**
3558 * Creates a new document symbol.
3559 *
3560 * @param name The name of the symbol.
3561 * @param detail Details for the symbol.
3562 * @param kind The kind of the symbol.
3563 * @param range The full range of the symbol.
3564 * @param selectionRange The range that should be reveal.
3565 */
3566 constructor(name: string, detail: string, kind: SymbolKind, range: Range, selectionRange: Range);
3567 }
3568
3569 /**
3570 * The document symbol provider interface defines the contract between extensions and
3571 * the [go to symbol](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-symbol)-feature.
3572 */
3573 export interface DocumentSymbolProvider {
3574
3575 /**
3576 * Provide symbol information for the given document.
3577 *
3578 * @param document The document in which the command was invoked.
3579 * @param token A cancellation token.
3580 * @returns An array of document highlights or a thenable that resolves to such. The lack of a result can be
3581 * signaled by returning `undefined`, `null`, or an empty array.
3582 */
3583 provideDocumentSymbols(document: TextDocument, token: CancellationToken): ProviderResult<SymbolInformation[] | DocumentSymbol[]>;
3584 }
3585
3586 /**
3587 * Metadata about a document symbol provider.
3588 */
3589 export interface DocumentSymbolProviderMetadata {
3590 /**
3591 * A human-readable string that is shown when multiple outlines trees show for one document.
3592 */
3593 label?: string;
3594 }
3595
3596 /**
3597 * The workspace symbol provider interface defines the contract between extensions and
3598 * the [symbol search](https://code.visualstudio.com/docs/editor/editingevolved#_open-symbol-by-name)-feature.
3599 */
3600 export interface WorkspaceSymbolProvider<T extends SymbolInformation = SymbolInformation> {
3601
3602 /**
3603 * Project-wide search for a symbol matching the given query string.
3604 *
3605 * The `query`-parameter should be interpreted in a *relaxed way* as the editor will apply its own highlighting
3606 * and scoring on the results. A good rule of thumb is to match case-insensitive and to simply check that the
3607 * characters of *query* appear in their order in a candidate symbol. Don't use prefix, substring, or similar
3608 * strict matching.
3609 *
3610 * To improve performance implementors can implement `resolveWorkspaceSymbol` and then provide symbols with partial
3611 * {@link SymbolInformation.location location}-objects, without a `range` defined. The editor will then call
3612 * `resolveWorkspaceSymbol` for selected symbols only, e.g. when opening a workspace symbol.
3613 *
3614 * @param query A query string, can be the empty string in which case all symbols should be returned.
3615 * @param token A cancellation token.
3616 * @returns An array of document highlights or a thenable that resolves to such. The lack of a result can be
3617 * signaled by returning `undefined`, `null`, or an empty array.
3618 */
3619 provideWorkspaceSymbols(query: string, token: CancellationToken): ProviderResult<T[]>;
3620
3621 /**
3622 * Given a symbol fill in its {@link SymbolInformation.location location}. This method is called whenever a symbol
3623 * is selected in the UI. Providers can implement this method and return incomplete symbols from
3624 * {@linkcode WorkspaceSymbolProvider.provideWorkspaceSymbols provideWorkspaceSymbols} which often helps to improve
3625 * performance.
3626 *
3627 * @param symbol The symbol that is to be resolved. Guaranteed to be an instance of an object returned from an
3628 * earlier call to `provideWorkspaceSymbols`.
3629 * @param token A cancellation token.
3630 * @returns The resolved symbol or a thenable that resolves to that. When no result is returned,
3631 * the given `symbol` is used.
3632 */
3633 resolveWorkspaceSymbol?(symbol: T, token: CancellationToken): ProviderResult<T>;
3634 }
3635
3636 /**
3637 * Value-object that contains additional information when
3638 * requesting references.
3639 */
3640 export interface ReferenceContext {
3641
3642 /**
3643 * Include the declaration of the current symbol.
3644 */
3645 readonly includeDeclaration: boolean;
3646 }
3647
3648 /**
3649 * The reference provider interface defines the contract between extensions and
3650 * the [find references](https://code.visualstudio.com/docs/editor/editingevolved#_peek)-feature.
3651 */
3652 export interface ReferenceProvider {
3653
3654 /**
3655 * Provide a set of project-wide references for the given position and document.
3656 *
3657 * @param document The document in which the command was invoked.
3658 * @param position The position at which the command was invoked.
3659 * @param token A cancellation token.
3660 *
3661 * @returns An array of locations or a thenable that resolves to such. The lack of a result can be
3662 * signaled by returning `undefined`, `null`, or an empty array.
3663 */
3664 provideReferences(document: TextDocument, position: Position, context: ReferenceContext, token: CancellationToken): ProviderResult<Location[]>;
3665 }
3666
3667 /**
3668 * A text edit represents edits that should be applied
3669 * to a document.
3670 */
3671 export class TextEdit {
3672
3673 /**
3674 * Utility to create a replace edit.
3675 *
3676 * @param range A range.
3677 * @param newText A string.
3678 * @returns A new text edit object.
3679 */
3680 static replace(range: Range, newText: string): TextEdit;
3681
3682 /**
3683 * Utility to create an insert edit.
3684 *
3685 * @param position A position, will become an empty range.
3686 * @param newText A string.
3687 * @returns A new text edit object.
3688 */
3689 static insert(position: Position, newText: string): TextEdit;
3690
3691 /**
3692 * Utility to create a delete edit.
3693 *
3694 * @param range A range.
3695 * @returns A new text edit object.
3696 */
3697 static delete(range: Range): TextEdit;
3698
3699 /**
3700 * Utility to create an eol-edit.
3701 *
3702 * @param eol An eol-sequence
3703 * @returns A new text edit object.
3704 */
3705 static setEndOfLine(eol: EndOfLine): TextEdit;
3706
3707 /**
3708 * The range this edit applies to.
3709 */
3710 range: Range;
3711
3712 /**
3713 * The string this edit will insert.
3714 */
3715 newText: string;
3716
3717 /**
3718 * The eol-sequence used in the document.
3719 *
3720 * *Note* that the eol-sequence will be applied to the
3721 * whole document.
3722 */
3723 newEol?: EndOfLine;
3724
3725 /**
3726 * Create a new TextEdit.
3727 *
3728 * @param range A range.
3729 * @param newText A string.
3730 */
3731 constructor(range: Range, newText: string);
3732 }
3733
3734 /**
3735 * A snippet edit represents an interactive edit that is performed by
3736 * the editor.
3737 *
3738 * *Note* that a snippet edit can always be performed as a normal {@link TextEdit text edit}.
3739 * This will happen when no matching editor is open or when a {@link WorkspaceEdit workspace edit}
3740 * contains snippet edits for multiple files. In that case only those that match the active editor
3741 * will be performed as snippet edits and the others as normal text edits.
3742 */
3743 export class SnippetTextEdit {
3744
3745 /**
3746 * Utility to create a replace snippet edit.
3747 *
3748 * @param range A range.
3749 * @param snippet A snippet string.
3750 * @returns A new snippet edit object.
3751 */
3752 static replace(range: Range, snippet: SnippetString): SnippetTextEdit;
3753
3754 /**
3755 * Utility to create an insert snippet edit.
3756 *
3757 * @param position A position, will become an empty range.
3758 * @param snippet A snippet string.
3759 * @returns A new snippet edit object.
3760 */
3761 static insert(position: Position, snippet: SnippetString): SnippetTextEdit;
3762
3763 /**
3764 * The range this edit applies to.
3765 */
3766 range: Range;
3767
3768 /**
3769 * The {@link SnippetString snippet} this edit will perform.
3770 */
3771 snippet: SnippetString;
3772
3773 /**
3774 * Create a new snippet edit.
3775 *
3776 * @param range A range.
3777 * @param snippet A snippet string.
3778 */
3779 constructor(range: Range, snippet: SnippetString);
3780 }
3781
3782 /**
3783 * A notebook edit represents edits that should be applied to the contents of a notebook.
3784 */
3785 export class NotebookEdit {
3786
3787 /**
3788 * Utility to create a edit that replaces cells in a notebook.
3789 *
3790 * @param range The range of cells to replace
3791 * @param newCells The new notebook cells.
3792 */
3793 static replaceCells(range: NotebookRange, newCells: NotebookCellData[]): NotebookEdit;
3794
3795 /**
3796 * Utility to create an edit that replaces cells in a notebook.
3797 *
3798 * @param index The index to insert cells at.
3799 * @param newCells The new notebook cells.
3800 */
3801 static insertCells(index: number, newCells: NotebookCellData[]): NotebookEdit;
3802
3803 /**
3804 * Utility to create an edit that deletes cells in a notebook.
3805 *
3806 * @param range The range of cells to delete.
3807 */
3808 static deleteCells(range: NotebookRange): NotebookEdit;
3809
3810 /**
3811 * Utility to create an edit that update a cell's metadata.
3812 *
3813 * @param index The index of the cell to update.
3814 * @param newCellMetadata The new metadata for the cell.
3815 */
3816 static updateCellMetadata(index: number, newCellMetadata: { [key: string]: any }): NotebookEdit;
3817
3818 /**
3819 * Utility to create an edit that updates the notebook's metadata.
3820 *
3821 * @param newNotebookMetadata The new metadata for the notebook.
3822 */
3823 static updateNotebookMetadata(newNotebookMetadata: { [key: string]: any }): NotebookEdit;
3824
3825 /**
3826 * Range of the cells being edited. May be empty.
3827 */
3828 range: NotebookRange;
3829
3830 /**
3831 * New cells being inserted. May be empty.
3832 */
3833 newCells: NotebookCellData[];
3834
3835 /**
3836 * Optional new metadata for the cells.
3837 */
3838 newCellMetadata?: { [key: string]: any };
3839
3840 /**
3841 * Optional new metadata for the notebook.
3842 */
3843 newNotebookMetadata?: { [key: string]: any };
3844
3845 /**
3846 * Create a new notebook edit.
3847 *
3848 * @param range A notebook range.
3849 * @param newCells An array of new cell data.
3850 */
3851 constructor(range: NotebookRange, newCells: NotebookCellData[]);
3852 }
3853
3854 /**
3855 * Additional data for entries of a workspace edit. Supports to label entries and marks entries
3856 * as needing confirmation by the user. The editor groups edits with equal labels into tree nodes,
3857 * for instance all edits labelled with "Changes in Strings" would be a tree node.
3858 */
3859 export interface WorkspaceEditEntryMetadata {
3860
3861 /**
3862 * A flag which indicates that user confirmation is needed.
3863 */
3864 needsConfirmation: boolean;
3865
3866 /**
3867 * A human-readable string which is rendered prominent.
3868 */
3869 label: string;
3870
3871 /**
3872 * A human-readable string which is rendered less prominent on the same line.
3873 */
3874 description?: string;
3875
3876 /**
3877 * The icon path or {@link ThemeIcon} for the edit.
3878 */
3879 iconPath?: Uri | {
3880 /**
3881 * The icon path for the light theme.
3882 */
3883 light: Uri;
3884 /**
3885 * The icon path for the dark theme.
3886 */
3887 dark: Uri;
3888 } | ThemeIcon;
3889 }
3890
3891 /**
3892 * Additional data about a workspace edit.
3893 */
3894 export interface WorkspaceEditMetadata {
3895 /**
3896 * Signal to the editor that this edit is a refactoring.
3897 */
3898 isRefactoring?: boolean;
3899 }
3900
3901 /**
3902 * A workspace edit is a collection of textual and files changes for
3903 * multiple resources and documents.
3904 *
3905 * Use the {@link workspace.applyEdit applyEdit}-function to apply a workspace edit.
3906 */
3907 export class WorkspaceEdit {
3908
3909 /**
3910 * The number of affected resources of textual or resource changes.
3911 */
3912 readonly size: number;
3913
3914 /**
3915 * Replace the given range with given text for the given resource.
3916 *
3917 * @param uri A resource identifier.
3918 * @param range A range.
3919 * @param newText A string.
3920 * @param metadata Optional metadata for the entry.
3921 */
3922 replace(uri: Uri, range: Range, newText: string, metadata?: WorkspaceEditEntryMetadata): void;
3923
3924 /**
3925 * Insert the given text at the given position.
3926 *
3927 * @param uri A resource identifier.
3928 * @param position A position.
3929 * @param newText A string.
3930 * @param metadata Optional metadata for the entry.
3931 */
3932 insert(uri: Uri, position: Position, newText: string, metadata?: WorkspaceEditEntryMetadata): void;
3933
3934 /**
3935 * Delete the text at the given range.
3936 *
3937 * @param uri A resource identifier.
3938 * @param range A range.
3939 * @param metadata Optional metadata for the entry.
3940 */
3941 delete(uri: Uri, range: Range, metadata?: WorkspaceEditEntryMetadata): void;
3942
3943 /**
3944 * Check if a text edit for a resource exists.
3945 *
3946 * @param uri A resource identifier.
3947 * @returns `true` if the given resource will be touched by this edit.
3948 */
3949 has(uri: Uri): boolean;
3950
3951 /**
3952 * Set (and replace) text edits or snippet edits for a resource.
3953 *
3954 * @param uri A resource identifier.
3955 * @param edits An array of edits.
3956 */
3957 set(uri: Uri, edits: ReadonlyArray<TextEdit | SnippetTextEdit>): void;
3958
3959 /**
3960 * Set (and replace) text edits or snippet edits with metadata for a resource.
3961 *
3962 * @param uri A resource identifier.
3963 * @param edits An array of edits.
3964 */
3965 set(uri: Uri, edits: ReadonlyArray<[TextEdit | SnippetTextEdit, WorkspaceEditEntryMetadata | undefined]>): void;
3966
3967 /**
3968 * Set (and replace) notebook edits for a resource.
3969 *
3970 * @param uri A resource identifier.
3971 * @param edits An array of edits.
3972 */
3973 set(uri: Uri, edits: readonly NotebookEdit[]): void;
3974
3975 /**
3976 * Set (and replace) notebook edits with metadata for a resource.
3977 *
3978 * @param uri A resource identifier.
3979 * @param edits An array of edits.
3980 */
3981 set(uri: Uri, edits: ReadonlyArray<[NotebookEdit, WorkspaceEditEntryMetadata | undefined]>): void;
3982
3983 /**
3984 * Get the text edits for a resource.
3985 *
3986 * @param uri A resource identifier.
3987 * @returns An array of text edits.
3988 */
3989 get(uri: Uri): TextEdit[];
3990
3991 /**
3992 * Create a regular file.
3993 *
3994 * @param uri Uri of the new file.
3995 * @param options Defines if an existing file should be overwritten or be
3996 * ignored. When `overwrite` and `ignoreIfExists` are both set `overwrite` wins.
3997 * When both are unset and when the file already exists then the edit cannot
3998 * be applied successfully. The `content`-property allows to set the initial contents
3999 * the file is being created with.
4000 * @param metadata Optional metadata for the entry.
4001 */
4002 createFile(uri: Uri, options?: {
4003 /**
4004 * Overwrite existing file. Overwrite wins over `ignoreIfExists`
4005 */
4006 readonly overwrite?: boolean;
4007 /**
4008 * Do nothing if a file with `uri` exists already.
4009 */
4010 readonly ignoreIfExists?: boolean;
4011 /**
4012 * The initial contents of the new file.
4013 *
4014 * If creating a file from a {@link DocumentDropEditProvider drop operation}, you can
4015 * pass in a {@link DataTransferFile} to improve performance by avoiding extra data copying.
4016 */
4017 readonly contents?: Uint8Array | DataTransferFile;
4018 }, metadata?: WorkspaceEditEntryMetadata): void;
4019
4020 /**
4021 * Delete a file or folder.
4022 *
4023 * @param uri The uri of the file that is to be deleted.
4024 * @param metadata Optional metadata for the entry.
4025 */
4026 deleteFile(uri: Uri, options?: {
4027 /**
4028 * Delete the content recursively if a folder is denoted.
4029 */
4030 readonly recursive?: boolean;
4031 /**
4032 * Do nothing if a file with `uri` exists already.
4033 */
4034 readonly ignoreIfNotExists?: boolean;
4035 }, metadata?: WorkspaceEditEntryMetadata): void;
4036
4037 /**
4038 * Rename a file or folder.
4039 *
4040 * @param oldUri The existing file.
4041 * @param newUri The new location.
4042 * @param options Defines if existing files should be overwritten or be
4043 * ignored. When overwrite and ignoreIfExists are both set overwrite wins.
4044 * @param metadata Optional metadata for the entry.
4045 */
4046 renameFile(oldUri: Uri, newUri: Uri, options?: {
4047 /**
4048 * Overwrite existing file. Overwrite wins over `ignoreIfExists`
4049 */
4050 readonly overwrite?: boolean;
4051 /**
4052 * Do nothing if a file with `uri` exists already.
4053 */
4054 readonly ignoreIfExists?: boolean;
4055 }, metadata?: WorkspaceEditEntryMetadata): void;
4056
4057 /**
4058 * Get all text edits grouped by resource.
4059 *
4060 * @returns A shallow copy of `[Uri, TextEdit[]]`-tuples.
4061 */
4062 entries(): [Uri, TextEdit[]][];
4063 }
4064
4065 /**
4066 * A snippet string is a template which allows to insert text
4067 * and to control the editor cursor when insertion happens.
4068 *
4069 * A snippet can define tab stops and placeholders with `$1`, `$2`
4070 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
4071 * the end of the snippet. Variables are defined with `$name` and
4072 * `${name:default value}`. Also see
4073 * [the full snippet syntax](https://code.visualstudio.com/docs/editor/userdefinedsnippets#_create-your-own-snippets).
4074 */
4075 export class SnippetString {
4076
4077 /**
4078 * The snippet string.
4079 */
4080 value: string;
4081
4082 /**
4083 * Create a new snippet string.
4084 *
4085 * @param value A snippet string.
4086 */
4087 constructor(value?: string);
4088
4089 /**
4090 * Builder-function that appends the given string to
4091 * the {@linkcode SnippetString.value value} of this snippet string.
4092 *
4093 * @param string A value to append 'as given'. The string will be escaped.
4094 * @returns This snippet string.
4095 */
4096 appendText(string: string): SnippetString;
4097
4098 /**
4099 * Builder-function that appends a tabstop (`$1`, `$2` etc) to
4100 * the {@linkcode SnippetString.value value} of this snippet string.
4101 *
4102 * @param number The number of this tabstop, defaults to an auto-increment
4103 * value starting at 1.
4104 * @returns This snippet string.
4105 */
4106 appendTabstop(number?: number): SnippetString;
4107
4108 /**
4109 * Builder-function that appends a placeholder (`${1:value}`) to
4110 * the {@linkcode SnippetString.value value} of this snippet string.
4111 *
4112 * @param value The value of this placeholder - either a string or a function
4113 * with which a nested snippet can be created.
4114 * @param number The number of this tabstop, defaults to an auto-increment
4115 * value starting at 1.
4116 * @returns This snippet string.
4117 */
4118 appendPlaceholder(value: string | ((snippet: SnippetString) => any), number?: number): SnippetString;
4119
4120 /**
4121 * Builder-function that appends a choice (`${1|a,b,c|}`) to
4122 * the {@linkcode SnippetString.value value} of this snippet string.
4123 *
4124 * @param values The values for choices - the array of strings
4125 * @param number The number of this tabstop, defaults to an auto-increment
4126 * value starting at 1.
4127 * @returns This snippet string.
4128 */
4129 appendChoice(values: readonly string[], number?: number): SnippetString;
4130
4131 /**
4132 * Builder-function that appends a variable (`${VAR}`) to
4133 * the {@linkcode SnippetString.value value} of this snippet string.
4134 *
4135 * @param name The name of the variable - excluding the `$`.
4136 * @param defaultValue The default value which is used when the variable name cannot
4137 * be resolved - either a string or a function with which a nested snippet can be created.
4138 * @returns This snippet string.
4139 */
4140 appendVariable(name: string, defaultValue: string | ((snippet: SnippetString) => any)): SnippetString;
4141 }
4142
4143 /**
4144 * The rename provider interface defines the contract between extensions and
4145 * the [rename](https://code.visualstudio.com/docs/editor/editingevolved#_rename-symbol)-feature.
4146 */
4147 export interface RenameProvider {
4148
4149 /**
4150 * Provide an edit that describes changes that have to be made to one
4151 * or many resources to rename a symbol to a different name.
4152 *
4153 * @param document The document in which the command was invoked.
4154 * @param position The position at which the command was invoked.
4155 * @param newName The new name of the symbol. If the given name is not valid, the provider must return a rejected promise.
4156 * @param token A cancellation token.
4157 * @returns A workspace edit or a thenable that resolves to such. The lack of a result can be
4158 * signaled by returning `undefined` or `null`.
4159 */
4160 provideRenameEdits(document: TextDocument, position: Position, newName: string, token: CancellationToken): ProviderResult<WorkspaceEdit>;
4161
4162 /**
4163 * Optional function for resolving and validating a position *before* running rename. The result can
4164 * be a range or a range and a placeholder text. The placeholder text should be the identifier of the symbol
4165 * which is being renamed - when omitted the text in the returned range is used.
4166 *
4167 * *Note:* This function should throw an error or return a rejected thenable when the provided location
4168 * doesn't allow for a rename.
4169 *
4170 * @param document The document in which rename will be invoked.
4171 * @param position The position at which rename will be invoked.
4172 * @param token A cancellation token.
4173 * @returns The range or range and placeholder text of the identifier that is to be renamed. The lack of a result can signaled by returning `undefined` or `null`.
4174 */
4175 prepareRename?(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Range | {
4176 /**
4177 * The range of the identifier that can be renamed.
4178 */
4179 range: Range;
4180 /**
4181 * The placeholder of the editors rename input box.
4182 */
4183 placeholder: string;
4184 }>;
4185 }
4186
4187 /**
4188 * A semantic tokens legend contains the needed information to decipher
4189 * the integer encoded representation of semantic tokens.
4190 */
4191 export class SemanticTokensLegend {
4192 /**
4193 * The possible token types.
4194 */
4195 readonly tokenTypes: string[];
4196 /**
4197 * The possible token modifiers.
4198 */
4199 readonly tokenModifiers: string[];
4200
4201 /**
4202 * Creates a semantic tokens legend.
4203 *
4204 * @param tokenTypes An array of token types.
4205 * @param tokenModifiers An array of token modifiers.
4206 */
4207 constructor(tokenTypes: string[], tokenModifiers?: string[]);
4208 }
4209
4210 /**
4211 * A semantic tokens builder can help with creating a `SemanticTokens` instance
4212 * which contains delta encoded semantic tokens.
4213 */
4214 export class SemanticTokensBuilder {
4215
4216 /**
4217 * Creates a semantic tokens builder.
4218 *
4219 * @param legend A semantic tokens legent.
4220 */
4221 constructor(legend?: SemanticTokensLegend);
4222
4223 /**
4224 * Add another token.
4225 *
4226 * @param line The token start line number (absolute value).
4227 * @param char The token start character (absolute value).
4228 * @param length The token length in characters.
4229 * @param tokenType The encoded token type.
4230 * @param tokenModifiers The encoded token modifiers.
4231 */
4232 push(line: number, char: number, length: number, tokenType: number, tokenModifiers?: number): void;
4233
4234 /**
4235 * Add another token. Use only when providing a legend.
4236 *
4237 * @param range The range of the token. Must be single-line.
4238 * @param tokenType The token type.
4239 * @param tokenModifiers The token modifiers.
4240 */
4241 push(range: Range, tokenType: string, tokenModifiers?: readonly string[]): void;
4242
4243 /**
4244 * Finish and create a `SemanticTokens` instance.
4245 */
4246 build(resultId?: string): SemanticTokens;
4247 }
4248
4249 /**
4250 * Represents semantic tokens, either in a range or in an entire document.
4251 * @see {@link DocumentSemanticTokensProvider.provideDocumentSemanticTokens provideDocumentSemanticTokens} for an explanation of the format.
4252 * @see {@link SemanticTokensBuilder} for a helper to create an instance.
4253 */
4254 export class SemanticTokens {
4255 /**
4256 * The result id of the tokens.
4257 *
4258 * This is the id that will be passed to `DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits` (if implemented).
4259 */
4260 readonly resultId: string | undefined;
4261 /**
4262 * The actual tokens data.
4263 * @see {@link DocumentSemanticTokensProvider.provideDocumentSemanticTokens provideDocumentSemanticTokens} for an explanation of the format.
4264 */
4265 readonly data: Uint32Array;
4266
4267 /**
4268 * Create new semantic tokens.
4269 *
4270 * @param data Token data.
4271 * @param resultId Result identifier.
4272 */
4273 constructor(data: Uint32Array, resultId?: string);
4274 }
4275
4276 /**
4277 * Represents edits to semantic tokens.
4278 * @see {@link DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits provideDocumentSemanticTokensEdits} for an explanation of the format.
4279 */
4280 export class SemanticTokensEdits {
4281 /**
4282 * The result id of the tokens.
4283 *
4284 * This is the id that will be passed to `DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits` (if implemented).
4285 */
4286 readonly resultId: string | undefined;
4287 /**
4288 * The edits to the tokens data.
4289 * All edits refer to the initial data state.
4290 */
4291 readonly edits: SemanticTokensEdit[];
4292
4293 /**
4294 * Create new semantic tokens edits.
4295 *
4296 * @param edits An array of semantic token edits
4297 * @param resultId Result identifier.
4298 */
4299 constructor(edits: SemanticTokensEdit[], resultId?: string);
4300 }
4301
4302 /**
4303 * Represents an edit to semantic tokens.
4304 * @see {@link DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits provideDocumentSemanticTokensEdits} for an explanation of the format.
4305 */
4306 export class SemanticTokensEdit {
4307 /**
4308 * The start offset of the edit.
4309 */
4310 readonly start: number;
4311 /**
4312 * The count of elements to remove.
4313 */
4314 readonly deleteCount: number;
4315 /**
4316 * The elements to insert.
4317 */
4318 readonly data: Uint32Array | undefined;
4319
4320 /**
4321 * Create a semantic token edit.
4322 *
4323 * @param start Start offset
4324 * @param deleteCount Number of elements to remove.
4325 * @param data Elements to insert
4326 */
4327 constructor(start: number, deleteCount: number, data?: Uint32Array);
4328 }
4329
4330 /**
4331 * The document semantic tokens provider interface defines the contract between extensions and
4332 * semantic tokens.
4333 */
4334 export interface DocumentSemanticTokensProvider {
4335 /**
4336 * An optional event to signal that the semantic tokens from this provider have changed.
4337 */
4338 onDidChangeSemanticTokens?: Event<void>;
4339
4340 /**
4341 * Tokens in a file are represented as an array of integers. The position of each token is expressed relative to
4342 * the token before it, because most tokens remain stable relative to each other when edits are made in a file.
4343 *
4344 * ---
4345 * In short, each token takes 5 integers to represent, so a specific token `i` in the file consists of the following array indices:
4346 * - at index `5*i` - `deltaLine`: token line number, relative to the previous token
4347 * - at index `5*i+1` - `deltaStart`: token start character, relative to the previous token (relative to 0 or the previous token's start if they are on the same line)
4348 * - at index `5*i+2` - `length`: the length of the token. A token cannot be multiline.
4349 * - at index `5*i+3` - `tokenType`: will be looked up in `SemanticTokensLegend.tokenTypes`. We currently ask that `tokenType` < 65536.
4350 * - at index `5*i+4` - `tokenModifiers`: each set bit will be looked up in `SemanticTokensLegend.tokenModifiers`
4351 *
4352 * ---
4353 * ### How to encode tokens
4354 *
4355 * Here is an example for encoding a file with 3 tokens in a uint32 array:
4356 * ```
4357 * { line: 2, startChar: 5, length: 3, tokenType: "property", tokenModifiers: ["private", "static"] },
4358 * { line: 2, startChar: 10, length: 4, tokenType: "type", tokenModifiers: [] },
4359 * { line: 5, startChar: 2, length: 7, tokenType: "class", tokenModifiers: [] }
4360 * ```
4361 *
4362 * 1. First of all, a legend must be devised. This legend must be provided up-front and capture all possible token types.
4363 * For this example, we will choose the following legend which must be passed in when registering the provider:
4364 * ```
4365 * tokenTypes: ['property', 'type', 'class'],
4366 * tokenModifiers: ['private', 'static']
4367 * ```
4368 *
4369 * 2. The first transformation step is to encode `tokenType` and `tokenModifiers` as integers using the legend. Token types are looked
4370 * up by index, so a `tokenType` value of `1` means `tokenTypes[1]`. Multiple token modifiers can be set by using bit flags,
4371 * so a `tokenModifier` value of `3` is first viewed as binary `0b00000011`, which means `[tokenModifiers[0], tokenModifiers[1]]` because
4372 * bits 0 and 1 are set. Using this legend, the tokens now are:
4373 * ```
4374 * { line: 2, startChar: 5, length: 3, tokenType: 0, tokenModifiers: 3 },
4375 * { line: 2, startChar: 10, length: 4, tokenType: 1, tokenModifiers: 0 },
4376 * { line: 5, startChar: 2, length: 7, tokenType: 2, tokenModifiers: 0 }
4377 * ```
4378 *
4379 * 3. The next step is to represent each token relative to the previous token in the file. In this case, the second token
4380 * is on the same line as the first token, so the `startChar` of the second token is made relative to the `startChar`
4381 * of the first token, so it will be `10 - 5`. The third token is on a different line than the second token, so the
4382 * `startChar` of the third token will not be altered:
4383 * ```
4384 * { deltaLine: 2, deltaStartChar: 5, length: 3, tokenType: 0, tokenModifiers: 3 },
4385 * { deltaLine: 0, deltaStartChar: 5, length: 4, tokenType: 1, tokenModifiers: 0 },
4386 * { deltaLine: 3, deltaStartChar: 2, length: 7, tokenType: 2, tokenModifiers: 0 }
4387 * ```
4388 *
4389 * 4. Finally, the last step is to inline each of the 5 fields for a token in a single array, which is a memory friendly representation:
4390 * ```
4391 * // 1st token, 2nd token, 3rd token
4392 * [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
4393 * ```
4394 *
4395 * @see {@link SemanticTokensBuilder} for a helper to encode tokens as integers.
4396 * *NOTE*: When doing edits, it is possible that multiple edits occur until the editor decides to invoke the semantic tokens provider.
4397 * *NOTE*: If the provider cannot temporarily compute semantic tokens, it can indicate this by throwing an error with the message 'Busy'.
4398 */
4399 provideDocumentSemanticTokens(document: TextDocument, token: CancellationToken): ProviderResult<SemanticTokens>;
4400
4401 /**
4402 * Instead of always returning all the tokens in a file, it is possible for a `DocumentSemanticTokensProvider` to implement
4403 * this method (`provideDocumentSemanticTokensEdits`) and then return incremental updates to the previously provided semantic tokens.
4404 *
4405 * ---
4406 * ### How tokens change when the document changes
4407 *
4408 * Suppose that `provideDocumentSemanticTokens` has previously returned the following semantic tokens:
4409 * ```
4410 * // 1st token, 2nd token, 3rd token
4411 * [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
4412 * ```
4413 *
4414 * Also suppose that after some edits, the new semantic tokens in a file are:
4415 * ```
4416 * // 1st token, 2nd token, 3rd token
4417 * [ 3,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
4418 * ```
4419 * It is possible to express these new tokens in terms of an edit applied to the previous tokens:
4420 * ```
4421 * [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ] // old tokens
4422 * [ 3,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ] // new tokens
4423 *
4424 * edit: { start: 0, deleteCount: 1, data: [3] } // replace integer at offset 0 with 3
4425 * ```
4426 *
4427 * *NOTE*: If the provider cannot compute `SemanticTokensEdits`, it can "give up" and return all the tokens in the document again.
4428 * *NOTE*: All edits in `SemanticTokensEdits` contain indices in the old integers array, so they all refer to the previous result state.
4429 */
4430 provideDocumentSemanticTokensEdits?(document: TextDocument, previousResultId: string, token: CancellationToken): ProviderResult<SemanticTokens | SemanticTokensEdits>;
4431 }
4432
4433 /**
4434 * The document range semantic tokens provider interface defines the contract between extensions and
4435 * semantic tokens.
4436 */
4437 export interface DocumentRangeSemanticTokensProvider {
4438 /**
4439 * @see {@link DocumentSemanticTokensProvider.provideDocumentSemanticTokens provideDocumentSemanticTokens}.
4440 */
4441 provideDocumentRangeSemanticTokens(document: TextDocument, range: Range, token: CancellationToken): ProviderResult<SemanticTokens>;
4442 }
4443
4444 /**
4445 * Value-object describing what options formatting should use.
4446 */
4447 export interface FormattingOptions {
4448
4449 /**
4450 * Size of a tab in spaces.
4451 */
4452 tabSize: number;
4453
4454 /**
4455 * Prefer spaces over tabs.
4456 */
4457 insertSpaces: boolean;
4458
4459 /**
4460 * Signature for further properties.
4461 */
4462 [key: string]: boolean | number | string;
4463 }
4464
4465 /**
4466 * The document formatting provider interface defines the contract between extensions and
4467 * the formatting-feature.
4468 */
4469 export interface DocumentFormattingEditProvider {
4470
4471 /**
4472 * Provide formatting edits for a whole document.
4473 *
4474 * @param document The document in which the command was invoked.
4475 * @param options Options controlling formatting.
4476 * @param token A cancellation token.
4477 * @returns A set of text edits or a thenable that resolves to such. The lack of a result can be
4478 * signaled by returning `undefined`, `null`, or an empty array.
4479 */
4480 provideDocumentFormattingEdits(document: TextDocument, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
4481 }
4482
4483 /**
4484 * The document formatting provider interface defines the contract between extensions and
4485 * the formatting-feature.
4486 */
4487 export interface DocumentRangeFormattingEditProvider {
4488
4489 /**
4490 * Provide formatting edits for a range in a document.
4491 *
4492 * The given range is a hint and providers can decide to format a smaller
4493 * or larger range. Often this is done by adjusting the start and end
4494 * of the range to full syntax nodes.
4495 *
4496 * @param document The document in which the command was invoked.
4497 * @param range The range which should be formatted.
4498 * @param options Options controlling formatting.
4499 * @param token A cancellation token.
4500 * @returns A set of text edits or a thenable that resolves to such. The lack of a result can be
4501 * signaled by returning `undefined`, `null`, or an empty array.
4502 */
4503 provideDocumentRangeFormattingEdits(document: TextDocument, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
4504
4505
4506 /**
4507 * Provide formatting edits for multiple ranges in a document.
4508 *
4509 * This function is optional but allows a formatter to perform faster when formatting only modified ranges or when
4510 * formatting a large number of selections.
4511 *
4512 * The given ranges are hints and providers can decide to format a smaller
4513 * or larger range. Often this is done by adjusting the start and end
4514 * of the range to full syntax nodes.
4515 *
4516 * @param document The document in which the command was invoked.
4517 * @param ranges The ranges which should be formatted.
4518 * @param options Options controlling formatting.
4519 * @param token A cancellation token.
4520 * @returns A set of text edits or a thenable that resolves to such. The lack of a result can be
4521 * signaled by returning `undefined`, `null`, or an empty array.
4522 */
4523 provideDocumentRangesFormattingEdits?(document: TextDocument, ranges: Range[], options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
4524 }
4525
4526 /**
4527 * The document formatting provider interface defines the contract between extensions and
4528 * the formatting-feature.
4529 */
4530 export interface OnTypeFormattingEditProvider {
4531
4532 /**
4533 * Provide formatting edits after a character has been typed.
4534 *
4535 * The given position and character should hint to the provider
4536 * what range the position to expand to, like find the matching `{`
4537 * when `}` has been entered.
4538 *
4539 * @param document The document in which the command was invoked.
4540 * @param position The position at which the command was invoked.
4541 * @param ch The character that has been typed.
4542 * @param options Options controlling formatting.
4543 * @param token A cancellation token.
4544 * @returns A set of text edits or a thenable that resolves to such. The lack of a result can be
4545 * signaled by returning `undefined`, `null`, or an empty array.
4546 */
4547 provideOnTypeFormattingEdits(document: TextDocument, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
4548 }
4549
4550 /**
4551 * Represents a parameter of a callable-signature. A parameter can
4552 * have a label and a doc-comment.
4553 */
4554 export class ParameterInformation {
4555
4556 /**
4557 * The label of this signature.
4558 *
4559 * Either a string or inclusive start and exclusive end offsets within its containing
4560 * {@link SignatureInformation.label signature label}. *Note*: A label of type string must be
4561 * a substring of its containing signature information's {@link SignatureInformation.label label}.
4562 */
4563 label: string | [number, number];
4564
4565 /**
4566 * The human-readable doc-comment of this signature. Will be shown
4567 * in the UI but can be omitted.
4568 */
4569 documentation?: string | MarkdownString;
4570
4571 /**
4572 * Creates a new parameter information object.
4573 *
4574 * @param label A label string or inclusive start and exclusive end offsets within its containing signature label.
4575 * @param documentation A doc string.
4576 */
4577 constructor(label: string | [number, number], documentation?: string | MarkdownString);
4578 }
4579
4580 /**
4581 * Represents the signature of something callable. A signature
4582 * can have a label, like a function-name, a doc-comment, and
4583 * a set of parameters.
4584 */
4585 export class SignatureInformation {
4586
4587 /**
4588 * The label of this signature. Will be shown in
4589 * the UI.
4590 */
4591 label: string;
4592
4593 /**
4594 * The human-readable doc-comment of this signature. Will be shown
4595 * in the UI but can be omitted.
4596 */
4597 documentation?: string | MarkdownString;
4598
4599 /**
4600 * The parameters of this signature.
4601 */
4602 parameters: ParameterInformation[];
4603
4604 /**
4605 * The index of the active parameter.
4606 *
4607 * If provided, this is used in place of {@linkcode SignatureHelp.activeParameter}.
4608 */
4609 activeParameter?: number;
4610
4611 /**
4612 * Creates a new signature information object.
4613 *
4614 * @param label A label string.
4615 * @param documentation A doc string.
4616 */
4617 constructor(label: string, documentation?: string | MarkdownString);
4618 }
4619
4620 /**
4621 * Signature help represents the signature of something
4622 * callable. There can be multiple signatures but only one
4623 * active and only one active parameter.
4624 */
4625 export class SignatureHelp {
4626
4627 /**
4628 * One or more signatures.
4629 */
4630 signatures: SignatureInformation[];
4631
4632 /**
4633 * The active signature.
4634 */
4635 activeSignature: number;
4636
4637 /**
4638 * The active parameter of the active signature.
4639 */
4640 activeParameter: number;
4641 }
4642
4643 /**
4644 * How a {@linkcode SignatureHelpProvider} was triggered.
4645 */
4646 export enum SignatureHelpTriggerKind {
4647 /**
4648 * Signature help was invoked manually by the user or by a command.
4649 */
4650 Invoke = 1,
4651
4652 /**
4653 * Signature help was triggered by a trigger character.
4654 */
4655 TriggerCharacter = 2,
4656
4657 /**
4658 * Signature help was triggered by the cursor moving or by the document content changing.
4659 */
4660 ContentChange = 3,
4661 }
4662
4663 /**
4664 * Additional information about the context in which a
4665 * {@linkcode SignatureHelpProvider.provideSignatureHelp SignatureHelpProvider} was triggered.
4666 */
4667 export interface SignatureHelpContext {
4668 /**
4669 * Action that caused signature help to be triggered.
4670 */
4671 readonly triggerKind: SignatureHelpTriggerKind;
4672
4673 /**
4674 * Character that caused signature help to be triggered.
4675 *
4676 * This is `undefined` when signature help is not triggered by typing, such as when manually invoking
4677 * signature help or when moving the cursor.
4678 */
4679 readonly triggerCharacter: string | undefined;
4680
4681 /**
4682 * `true` if signature help was already showing when it was triggered.
4683 *
4684 * Retriggers occur when the signature help is already active and can be caused by actions such as
4685 * typing a trigger character, a cursor move, or document content changes.
4686 */
4687 readonly isRetrigger: boolean;
4688
4689 /**
4690 * The currently active {@linkcode SignatureHelp}.
4691 *
4692 * The `activeSignatureHelp` has its [`SignatureHelp.activeSignature`] field updated based on
4693 * the user arrowing through available signatures.
4694 */
4695 readonly activeSignatureHelp: SignatureHelp | undefined;
4696 }
4697
4698 /**
4699 * The signature help provider interface defines the contract between extensions and
4700 * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature.
4701 */
4702 export interface SignatureHelpProvider {
4703
4704 /**
4705 * Provide help for the signature at the given position and document.
4706 *
4707 * @param document The document in which the command was invoked.
4708 * @param position The position at which the command was invoked.
4709 * @param token A cancellation token.
4710 * @param context Information about how signature help was triggered.
4711 *
4712 * @returns Signature help or a thenable that resolves to such. The lack of a result can be
4713 * signaled by returning `undefined` or `null`.
4714 */
4715 provideSignatureHelp(document: TextDocument, position: Position, token: CancellationToken, context: SignatureHelpContext): ProviderResult<SignatureHelp>;
4716 }
4717
4718 /**
4719 * Metadata about a registered {@linkcode SignatureHelpProvider}.
4720 */
4721 export interface SignatureHelpProviderMetadata {
4722 /**
4723 * List of characters that trigger signature help.
4724 */
4725 readonly triggerCharacters: readonly string[];
4726
4727 /**
4728 * List of characters that re-trigger signature help.
4729 *
4730 * These trigger characters are only active when signature help is already showing. All trigger characters
4731 * are also counted as re-trigger characters.
4732 */
4733 readonly retriggerCharacters: readonly string[];
4734 }
4735
4736 /**
4737 * A structured label for a {@link CompletionItem completion item}.
4738 */
4739 export interface CompletionItemLabel {
4740
4741 /**
4742 * The label of this completion item.
4743 *
4744 * By default this is also the text that is inserted when this completion is selected.
4745 */
4746 label: string;
4747
4748 /**
4749 * An optional string which is rendered less prominently directly after {@link CompletionItemLabel.label label},
4750 * without any spacing. Should be used for function signatures or type annotations.
4751 */
4752 detail?: string;
4753
4754 /**
4755 * An optional string which is rendered less prominently after {@link CompletionItemLabel.detail}. Should be used
4756 * for fully qualified names or file path.
4757 */
4758 description?: string;
4759 }
4760
4761 /**
4762 * Completion item kinds.
4763 */
4764 export enum CompletionItemKind {
4765 /**
4766 * The `Text` completion item kind.
4767 */
4768 Text = 0,
4769 /**
4770 * The `Method` completion item kind.
4771 */
4772 Method = 1,
4773 /**
4774 * The `Function` completion item kind.
4775 */
4776 Function = 2,
4777 /**
4778 * The `Constructor` completion item kind.
4779 */
4780 Constructor = 3,
4781 /**
4782 * The `Field` completion item kind.
4783 */
4784 Field = 4,
4785 /**
4786 * The `Variable` completion item kind.
4787 */
4788 Variable = 5,
4789 /**
4790 * The `Class` completion item kind.
4791 */
4792 Class = 6,
4793 /**
4794 * The `Interface` completion item kind.
4795 */
4796 Interface = 7,
4797 /**
4798 * The `Module` completion item kind.
4799 */
4800 Module = 8,
4801 /**
4802 * The `Property` completion item kind.
4803 */
4804 Property = 9,
4805 /**
4806 * The `Unit` completion item kind.
4807 */
4808 Unit = 10,
4809 /**
4810 * The `Value` completion item kind.
4811 */
4812 Value = 11,
4813 /**
4814 * The `Enum` completion item kind.
4815 */
4816 Enum = 12,
4817 /**
4818 * The `Keyword` completion item kind.
4819 */
4820 Keyword = 13,
4821 /**
4822 * The `Snippet` completion item kind.
4823 */
4824 Snippet = 14,
4825 /**
4826 * The `Color` completion item kind.
4827 */
4828 Color = 15,
4829 /**
4830 * The `Reference` completion item kind.
4831 */
4832 Reference = 17,
4833 /**
4834 * The `File` completion item kind.
4835 */
4836 File = 16,
4837 /**
4838 * The `Folder` completion item kind.
4839 */
4840 Folder = 18,
4841 /**
4842 * The `EnumMember` completion item kind.
4843 */
4844 EnumMember = 19,
4845 /**
4846 * The `Constant` completion item kind.
4847 */
4848 Constant = 20,
4849 /**
4850 * The `Struct` completion item kind.
4851 */
4852 Struct = 21,
4853 /**
4854 * The `Event` completion item kind.
4855 */
4856 Event = 22,
4857 /**
4858 * The `Operator` completion item kind.
4859 */
4860 Operator = 23,
4861 /**
4862 * The `TypeParameter` completion item kind.
4863 */
4864 TypeParameter = 24,
4865 /**
4866 * The `User` completion item kind.
4867 */
4868 User = 25,
4869 /**
4870 * The `Issue` completion item kind.
4871 */
4872 Issue = 26,
4873 }
4874
4875 /**
4876 * Completion item tags are extra annotations that tweak the rendering of a completion
4877 * item.
4878 */
4879 export enum CompletionItemTag {
4880 /**
4881 * Render a completion as obsolete, usually using a strike-out.
4882 */
4883 Deprecated = 1
4884 }
4885
4886 /**
4887 * A completion item represents a text snippet that is proposed to complete text that is being typed.
4888 *
4889 * It is sufficient to create a completion item from just a {@link CompletionItem.label label}. In that
4890 * case the completion item will replace the {@link TextDocument.getWordRangeAtPosition word}
4891 * until the cursor with the given label or {@link CompletionItem.insertText insertText}. Otherwise the
4892 * given {@link CompletionItem.textEdit edit} is used.
4893 *
4894 * When selecting a completion item in the editor its defined or synthesized text edit will be applied
4895 * to *all* cursors/selections whereas {@link CompletionItem.additionalTextEdits additionalTextEdits} will be
4896 * applied as provided.
4897 *
4898 * @see {@link CompletionItemProvider.provideCompletionItems}
4899 * @see {@link CompletionItemProvider.resolveCompletionItem}
4900 */
4901 export class CompletionItem {
4902
4903 /**
4904 * The label of this completion item. By default
4905 * this is also the text that is inserted when selecting
4906 * this completion.
4907 */
4908 label: string | CompletionItemLabel;
4909
4910 /**
4911 * The kind of this completion item. Based on the kind
4912 * an icon is chosen by the editor.
4913 */
4914 kind?: CompletionItemKind;
4915
4916 /**
4917 * Tags for this completion item.
4918 */
4919 tags?: readonly CompletionItemTag[];
4920
4921 /**
4922 * A human-readable string with additional information
4923 * about this item, like type or symbol information.
4924 */
4925 detail?: string;
4926
4927 /**
4928 * A human-readable string that represents a doc-comment.
4929 */
4930 documentation?: string | MarkdownString;
4931
4932 /**
4933 * A string that should be used when comparing this item
4934 * with other items. When `falsy` the {@link CompletionItem.label label}
4935 * is used.
4936 *
4937 * Note that `sortText` is only used for the initial ordering of completion
4938 * items. When having a leading word (prefix) ordering is based on how
4939 * well completions match that prefix and the initial ordering is only used
4940 * when completions match equally well. The prefix is defined by the
4941 * {@linkcode CompletionItem.range range}-property and can therefore be different
4942 * for each completion.
4943 */
4944 sortText?: string;
4945
4946 /**
4947 * A string that should be used when filtering a set of
4948 * completion items. When `falsy` the {@link CompletionItem.label label}
4949 * is used.
4950 *
4951 * Note that the filter text is matched against the leading word (prefix) which is defined
4952 * by the {@linkcode CompletionItem.range range}-property.
4953 */
4954 filterText?: string;
4955
4956 /**
4957 * Select this item when showing. *Note* that only one completion item can be selected and
4958 * that the editor decides which item that is. The rule is that the *first* item of those
4959 * that match best is selected.
4960 */
4961 preselect?: boolean;
4962
4963 /**
4964 * A string or snippet that should be inserted in a document when selecting
4965 * this completion. When `falsy` the {@link CompletionItem.label label}
4966 * is used.
4967 */
4968 insertText?: string | SnippetString;
4969
4970 /**
4971 * A range or a insert and replace range selecting the text that should be replaced by this completion item.
4972 *
4973 * When omitted, the range of the {@link TextDocument.getWordRangeAtPosition current word} is used as replace-range
4974 * and as insert-range the start of the {@link TextDocument.getWordRangeAtPosition current word} to the
4975 * current position is used.
4976 *
4977 * *Note 1:* A range must be a {@link Range.isSingleLine single line} and it must
4978 * {@link Range.contains contain} the position at which completion has been {@link CompletionItemProvider.provideCompletionItems requested}.
4979 * *Note 2:* A insert range must be a prefix of a replace range, that means it must be contained and starting at the same position.
4980 */
4981 range?: Range | {
4982 /**
4983 * The range that should be used when insert-accepting a completion. Must be a prefix of `replaceRange`.
4984 */
4985 inserting: Range;
4986 /**
4987 * The range that should be used when replace-accepting a completion.
4988 */
4989 replacing: Range;
4990 };
4991
4992 /**
4993 * An optional set of characters that when pressed while this completion is active will accept it first and
4994 * then type that character. *Note* that all commit characters should have `length=1` and that superfluous
4995 * characters will be ignored.
4996 */
4997 commitCharacters?: string[];
4998
4999 /**
5000 * Keep whitespace of the {@link CompletionItem.insertText insertText} as is. By default, the editor adjusts leading
5001 * whitespace of new lines so that they match the indentation of the line for which the item is accepted - setting
5002 * this to `true` will prevent that.
5003 */
5004 keepWhitespace?: boolean;
5005
5006 /**
5007 * @deprecated Use `CompletionItem.insertText` and `CompletionItem.range` instead.
5008 *
5009 * An {@link TextEdit edit} which is applied to a document when selecting
5010 * this completion. When an edit is provided the value of
5011 * {@link CompletionItem.insertText insertText} is ignored.
5012 *
5013 * The {@link Range} of the edit must be single-line and on the same
5014 * line completions were {@link CompletionItemProvider.provideCompletionItems requested} at.
5015 */
5016 textEdit?: TextEdit;
5017
5018 /**
5019 * An optional array of additional {@link TextEdit text edits} that are applied when
5020 * selecting this completion. Edits must not overlap with the main {@link CompletionItem.textEdit edit}
5021 * nor with themselves.
5022 */
5023 additionalTextEdits?: TextEdit[];
5024
5025 /**
5026 * An optional {@link Command} that is executed *after* inserting this completion. *Note* that
5027 * additional modifications to the current document should be described with the
5028 * {@link CompletionItem.additionalTextEdits additionalTextEdits}-property.
5029 */
5030 command?: Command;
5031
5032 /**
5033 * Creates a new completion item.
5034 *
5035 * Completion items must have at least a {@link CompletionItem.label label} which then
5036 * will be used as insert text as well as for sorting and filtering.
5037 *
5038 * @param label The label of the completion.
5039 * @param kind The {@link CompletionItemKind kind} of the completion.
5040 */
5041 constructor(label: string | CompletionItemLabel, kind?: CompletionItemKind);
5042 }
5043
5044 /**
5045 * Represents a collection of {@link CompletionItem completion items} to be presented
5046 * in the editor.
5047 */
5048 export class CompletionList<T extends CompletionItem = CompletionItem> {
5049
5050 /**
5051 * This list is not complete. Further typing should result in recomputing
5052 * this list.
5053 */
5054 isIncomplete?: boolean;
5055
5056 /**
5057 * The completion items.
5058 */
5059 items: T[];
5060
5061 /**
5062 * Creates a new completion list.
5063 *
5064 * @param items The completion items.
5065 * @param isIncomplete The list is not complete.
5066 */
5067 constructor(items?: T[], isIncomplete?: boolean);
5068 }
5069
5070 /**
5071 * How a {@link CompletionItemProvider completion provider} was triggered
5072 */
5073 export enum CompletionTriggerKind {
5074 /**
5075 * Completion was triggered normally.
5076 */
5077 Invoke = 0,
5078 /**
5079 * Completion was triggered by a trigger character.
5080 */
5081 TriggerCharacter = 1,
5082 /**
5083 * Completion was re-triggered as current completion list is incomplete
5084 */
5085 TriggerForIncompleteCompletions = 2
5086 }
5087
5088 /**
5089 * Contains additional information about the context in which
5090 * {@link CompletionItemProvider.provideCompletionItems completion provider} is triggered.
5091 */
5092 export interface CompletionContext {
5093 /**
5094 * How the completion was triggered.
5095 */
5096 readonly triggerKind: CompletionTriggerKind;
5097
5098 /**
5099 * Character that triggered the completion item provider.
5100 *
5101 * `undefined` if the provider was not triggered by a character.
5102 *
5103 * The trigger character is already in the document when the completion provider is triggered.
5104 */
5105 readonly triggerCharacter: string | undefined;
5106 }
5107
5108 /**
5109 * The completion item provider interface defines the contract between extensions and
5110 * [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense).
5111 *
5112 * Providers can delay the computation of the {@linkcode CompletionItem.detail detail}
5113 * and {@linkcode CompletionItem.documentation documentation} properties by implementing the
5114 * {@linkcode CompletionItemProvider.resolveCompletionItem resolveCompletionItem}-function. However, properties that
5115 * are needed for the initial sorting and filtering, like `sortText`, `filterText`, `insertText`, and `range`, must
5116 * not be changed during resolve.
5117 *
5118 * Providers are asked for completions either explicitly by a user gesture or -depending on the configuration-
5119 * implicitly when typing words or trigger characters.
5120 */
5121 export interface CompletionItemProvider<T extends CompletionItem = CompletionItem> {
5122
5123 /**
5124 * Provide completion items for the given position and document.
5125 *
5126 * @param document The document in which the command was invoked.
5127 * @param position The position at which the command was invoked.
5128 * @param token A cancellation token.
5129 * @param context How the completion was triggered.
5130 *
5131 * @returns An array of completions, a {@link CompletionList completion list}, or a thenable that resolves to either.
5132 * The lack of a result can be signaled by returning `undefined`, `null`, or an empty array.
5133 */
5134 provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken, context: CompletionContext): ProviderResult<T[] | CompletionList<T>>;
5135
5136 /**
5137 * Given a completion item fill in more data, like {@link CompletionItem.documentation doc-comment}
5138 * or {@link CompletionItem.detail details}.
5139 *
5140 * The editor will only resolve a completion item once.
5141 *
5142 * *Note* that this function is called when completion items are already showing in the UI or when an item has been
5143 * selected for insertion. Because of that, no property that changes the presentation (label, sorting, filtering etc)
5144 * or the (primary) insert behaviour ({@link CompletionItem.insertText insertText}) can be changed.
5145 *
5146 * This function may fill in {@link CompletionItem.additionalTextEdits additionalTextEdits}. However, that means an item might be
5147 * inserted *before* resolving is done and in that case the editor will do a best effort to still apply those additional
5148 * text edits.
5149 *
5150 * @param item A completion item currently active in the UI.
5151 * @param token A cancellation token.
5152 * @returns The resolved completion item or a thenable that resolves to of such. It is OK to return the given
5153 * `item`. When no result is returned, the given `item` will be used.
5154 */
5155 resolveCompletionItem?(item: T, token: CancellationToken): ProviderResult<T>;
5156 }
5157
5158
5159 /**
5160 * The inline completion item provider interface defines the contract between extensions and
5161 * the inline completion feature.
5162 *
5163 * Providers are asked for completions either explicitly by a user gesture or implicitly when typing.
5164 */
5165 export interface InlineCompletionItemProvider {
5166
5167 /**
5168 * Provides inline completion items for the given position and document.
5169 * If inline completions are enabled, this method will be called whenever the user stopped typing.
5170 * It will also be called when the user explicitly triggers inline completions or explicitly asks for the next or previous inline completion.
5171 * In that case, all available inline completions should be returned.
5172 * `context.triggerKind` can be used to distinguish between these scenarios.
5173 *
5174 * @param document The document inline completions are requested for.
5175 * @param position The position inline completions are requested for.
5176 * @param context A context object with additional information.
5177 * @param token A cancellation token.
5178 * @returns An array of completion items or a thenable that resolves to an array of completion items.
5179 */
5180 provideInlineCompletionItems(document: TextDocument, position: Position, context: InlineCompletionContext, token: CancellationToken): ProviderResult<InlineCompletionItem[] | InlineCompletionList>;
5181 }
5182
5183 /**
5184 * Represents a collection of {@link InlineCompletionItem inline completion items} to be presented
5185 * in the editor.
5186 */
5187 export class InlineCompletionList {
5188 /**
5189 * The inline completion items.
5190 */
5191 items: InlineCompletionItem[];
5192
5193 /**
5194 * Creates a new list of inline completion items.
5195 */
5196 constructor(items: InlineCompletionItem[]);
5197 }
5198
5199 /**
5200 * Provides information about the context in which an inline completion was requested.
5201 */
5202 export interface InlineCompletionContext {
5203 /**
5204 * Describes how the inline completion was triggered.
5205 */
5206 readonly triggerKind: InlineCompletionTriggerKind;
5207
5208 /**
5209 * Provides information about the currently selected item in the autocomplete widget if it is visible.
5210 *
5211 * If set, provided inline completions must extend the text of the selected item
5212 * and use the same range, otherwise they are not shown as preview.
5213 * As an example, if the document text is `console.` and the selected item is `.log` replacing the `.` in the document,
5214 * the inline completion must also replace `.` and start with `.log`, for example `.log()`.
5215 *
5216 * Inline completion providers are requested again whenever the selected item changes.
5217 */
5218 readonly selectedCompletionInfo: SelectedCompletionInfo | undefined;
5219 }
5220
5221 /**
5222 * Describes the currently selected completion item.
5223 */
5224 export interface SelectedCompletionInfo {
5225 /**
5226 * The range that will be replaced if this completion item is accepted.
5227 */
5228 readonly range: Range;
5229
5230 /**
5231 * The text the range will be replaced with if this completion is accepted.
5232 */
5233 readonly text: string;
5234 }
5235
5236 /**
5237 * Describes how an {@link InlineCompletionItemProvider inline completion provider} was triggered.
5238 */
5239 export enum InlineCompletionTriggerKind {
5240 /**
5241 * Completion was triggered explicitly by a user gesture.
5242 * Return multiple completion items to enable cycling through them.
5243 */
5244 Invoke = 0,
5245
5246 /**
5247 * Completion was triggered automatically while editing.
5248 * It is sufficient to return a single completion item in this case.
5249 */
5250 Automatic = 1,
5251 }
5252
5253 /**
5254 * An inline completion item represents a text snippet that is proposed inline to complete text that is being typed.
5255 *
5256 * @see {@link InlineCompletionItemProvider.provideInlineCompletionItems}
5257 */
5258 export class InlineCompletionItem {
5259 /**
5260 * The text to replace the range with. Must be set.
5261 * Is used both for the preview and the accept operation.
5262 */
5263 insertText: string | SnippetString;
5264
5265 /**
5266 * A text that is used to decide if this inline completion should be shown. When `falsy`
5267 * the {@link InlineCompletionItem.insertText} is used.
5268 *
5269 * An inline completion is shown if the text to replace is a prefix of the filter text.
5270 */
5271 filterText?: string;
5272
5273 /**
5274 * The range to replace.
5275 * Must begin and end on the same line.
5276 *
5277 * Prefer replacements over insertions to provide a better experience when the user deletes typed text.
5278 */
5279 range?: Range;
5280
5281 /**
5282 * An optional {@link Command} that is executed *after* inserting this completion.
5283 */
5284 command?: Command;
5285
5286 /**
5287 * Creates a new inline completion item.
5288 *
5289 * @param insertText The text to replace the range with.
5290 * @param range The range to replace. If not set, the word at the requested position will be used.
5291 * @param command An optional {@link Command} that is executed *after* inserting this completion.
5292 */
5293 constructor(insertText: string | SnippetString, range?: Range, command?: Command);
5294 }
5295
5296 /**
5297 * A document link is a range in a text document that links to an internal or external resource, like another
5298 * text document or a web site.
5299 */
5300 export class DocumentLink {
5301
5302 /**
5303 * The range this link applies to.
5304 */
5305 range: Range;
5306
5307 /**
5308 * The uri this link points to.
5309 */
5310 target?: Uri;
5311
5312 /**
5313 * The tooltip text when you hover over this link.
5314 *
5315 * If a tooltip is provided, is will be displayed in a string that includes instructions on how to
5316 * trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary depending on OS,
5317 * user settings, and localization.
5318 */
5319 tooltip?: string;
5320
5321 /**
5322 * Creates a new document link.
5323 *
5324 * @param range The range the document link applies to. Must not be empty.
5325 * @param target The uri the document link points to.
5326 */
5327 constructor(range: Range, target?: Uri);
5328 }
5329
5330 /**
5331 * The document link provider defines the contract between extensions and feature of showing
5332 * links in the editor.
5333 */
5334 export interface DocumentLinkProvider<T extends DocumentLink = DocumentLink> {
5335
5336 /**
5337 * Provide links for the given document. Note that the editor ships with a default provider that detects
5338 * `http(s)` and `file` links.
5339 *
5340 * @param document The document in which the command was invoked.
5341 * @param token A cancellation token.
5342 * @returns An array of {@link DocumentLink document links} or a thenable that resolves to such. The lack of a result
5343 * can be signaled by returning `undefined`, `null`, or an empty array.
5344 */
5345 provideDocumentLinks(document: TextDocument, token: CancellationToken): ProviderResult<T[]>;
5346
5347 /**
5348 * Given a link fill in its {@link DocumentLink.target target}. This method is called when an incomplete
5349 * link is selected in the UI. Providers can implement this method and return incomplete links
5350 * (without target) from the {@linkcode DocumentLinkProvider.provideDocumentLinks provideDocumentLinks} method which
5351 * often helps to improve performance.
5352 *
5353 * @param link The link that is to be resolved.
5354 * @param token A cancellation token.
5355 */
5356 resolveDocumentLink?(link: T, token: CancellationToken): ProviderResult<T>;
5357 }
5358
5359 /**
5360 * Represents a color in RGBA space.
5361 */
5362 export class Color {
5363
5364 /**
5365 * The red component of this color in the range [0-1].
5366 */
5367 readonly red: number;
5368
5369 /**
5370 * The green component of this color in the range [0-1].
5371 */
5372 readonly green: number;
5373
5374 /**
5375 * The blue component of this color in the range [0-1].
5376 */
5377 readonly blue: number;
5378
5379 /**
5380 * The alpha component of this color in the range [0-1].
5381 */
5382 readonly alpha: number;
5383
5384 /**
5385 * Creates a new color instance.
5386 *
5387 * @param red The red component.
5388 * @param green The green component.
5389 * @param blue The blue component.
5390 * @param alpha The alpha component.
5391 */
5392 constructor(red: number, green: number, blue: number, alpha: number);
5393 }
5394
5395 /**
5396 * Represents a color range from a document.
5397 */
5398 export class ColorInformation {
5399
5400 /**
5401 * The range in the document where this color appears.
5402 */
5403 range: Range;
5404
5405 /**
5406 * The actual color value for this color range.
5407 */
5408 color: Color;
5409
5410 /**
5411 * Creates a new color range.
5412 *
5413 * @param range The range the color appears in. Must not be empty.
5414 * @param color The value of the color.
5415 */
5416 constructor(range: Range, color: Color);
5417 }
5418
5419 /**
5420 * A color presentation object describes how a {@linkcode Color} should be represented as text and what
5421 * edits are required to refer to it from source code.
5422 *
5423 * For some languages one color can have multiple presentations, e.g. css can represent the color red with
5424 * the constant `Red`, the hex-value `#ff0000`, or in rgba and hsla forms. In csharp other representations
5425 * apply, e.g. `System.Drawing.Color.Red`.
5426 */
5427 export class ColorPresentation {
5428
5429 /**
5430 * The label of this color presentation. It will be shown on the color
5431 * picker header. By default this is also the text that is inserted when selecting
5432 * this color presentation.
5433 */
5434 label: string;
5435
5436 /**
5437 * An {@link TextEdit edit} which is applied to a document when selecting
5438 * this presentation for the color. When `falsy` the {@link ColorPresentation.label label}
5439 * is used.
5440 */
5441 textEdit?: TextEdit;
5442
5443 /**
5444 * An optional array of additional {@link TextEdit text edits} that are applied when
5445 * selecting this color presentation. Edits must not overlap with the main {@link ColorPresentation.textEdit edit} nor with themselves.
5446 */
5447 additionalTextEdits?: TextEdit[];
5448
5449 /**
5450 * Creates a new color presentation.
5451 *
5452 * @param label The label of this color presentation.
5453 */
5454 constructor(label: string);
5455 }
5456
5457 /**
5458 * The document color provider defines the contract between extensions and feature of
5459 * picking and modifying colors in the editor.
5460 */
5461 export interface DocumentColorProvider {
5462
5463 /**
5464 * Provide colors for the given document.
5465 *
5466 * @param document The document in which the command was invoked.
5467 * @param token A cancellation token.
5468 * @returns An array of {@link ColorInformation color information} or a thenable that resolves to such. The lack of a result
5469 * can be signaled by returning `undefined`, `null`, or an empty array.
5470 */
5471 provideDocumentColors(document: TextDocument, token: CancellationToken): ProviderResult<ColorInformation[]>;
5472
5473 /**
5474 * Provide {@link ColorPresentation representations} for a color.
5475 *
5476 * @param color The color to show and insert.
5477 * @param context A context object with additional information
5478 * @param token A cancellation token.
5479 * @returns An array of color presentations or a thenable that resolves to such. The lack of a result
5480 * can be signaled by returning `undefined`, `null`, or an empty array.
5481 */
5482 provideColorPresentations(color: Color, context: {
5483 /**
5484 * The text document that contains the color
5485 */
5486 readonly document: TextDocument;
5487 /**
5488 * The range in the document where the color is located.
5489 */
5490 readonly range: Range;
5491 }, token: CancellationToken): ProviderResult<ColorPresentation[]>;
5492 }
5493
5494 /**
5495 * Inlay hint kinds.
5496 *
5497 * The kind of an inline hint defines its appearance, e.g the corresponding foreground and background colors are being
5498 * used.
5499 */
5500 export enum InlayHintKind {
5501 /**
5502 * An inlay hint that for a type annotation.
5503 */
5504 Type = 1,
5505 /**
5506 * An inlay hint that is for a parameter.
5507 */
5508 Parameter = 2,
5509 }
5510
5511 /**
5512 * An inlay hint label part allows for interactive and composite labels of inlay hints.
5513 */
5514 export class InlayHintLabelPart {
5515
5516 /**
5517 * The value of this label part.
5518 */
5519 value: string;
5520
5521 /**
5522 * The tooltip text when you hover over this label part.
5523 *
5524 * *Note* that this property can be set late during
5525 * {@link InlayHintsProvider.resolveInlayHint resolving} of inlay hints.
5526 */
5527 tooltip?: string | MarkdownString | undefined;
5528
5529 /**
5530 * An optional {@link Location source code location} that represents this label
5531 * part.
5532 *
5533 * The editor will use this location for the hover and for code navigation features: This
5534 * part will become a clickable link that resolves to the definition of the symbol at the
5535 * given location (not necessarily the location itself), it shows the hover that shows at
5536 * the given location, and it shows a context menu with further code navigation commands.
5537 *
5538 * *Note* that this property can be set late during
5539 * {@link InlayHintsProvider.resolveInlayHint resolving} of inlay hints.
5540 */
5541 location?: Location | undefined;
5542
5543 /**
5544 * An optional command for this label part.
5545 *
5546 * The editor renders parts with commands as clickable links. The command is added to the context menu
5547 * when a label part defines {@link InlayHintLabelPart.location location} and {@link InlayHintLabelPart.command command} .
5548 *
5549 * *Note* that this property can be set late during
5550 * {@link InlayHintsProvider.resolveInlayHint resolving} of inlay hints.
5551 */
5552 command?: Command | undefined;
5553
5554 /**
5555 * Creates a new inlay hint label part.
5556 *
5557 * @param value The value of the part.
5558 */
5559 constructor(value: string);
5560 }
5561
5562 /**
5563 * Inlay hint information.
5564 */
5565 export class InlayHint {
5566
5567 /**
5568 * The position of this hint.
5569 */
5570 position: Position;
5571
5572 /**
5573 * The label of this hint. A human readable string or an array of {@link InlayHintLabelPart label parts}.
5574 *
5575 * *Note* that neither the string nor the label part can be empty.
5576 */
5577 label: string | InlayHintLabelPart[];
5578
5579 /**
5580 * The tooltip text when you hover over this item.
5581 *
5582 * *Note* that this property can be set late during
5583 * {@link InlayHintsProvider.resolveInlayHint resolving} of inlay hints.
5584 */
5585 tooltip?: string | MarkdownString | undefined;
5586
5587 /**
5588 * The kind of this hint. The inlay hint kind defines the appearance of this inlay hint.
5589 */
5590 kind?: InlayHintKind;
5591
5592 /**
5593 * Optional {@link TextEdit text edits} that are performed when accepting this inlay hint. The default
5594 * gesture for accepting an inlay hint is the double click.
5595 *
5596 * *Note* that edits are expected to change the document so that the inlay hint (or its nearest variant) is
5597 * now part of the document and the inlay hint itself is now obsolete.
5598 *
5599 * *Note* that this property can be set late during
5600 * {@link InlayHintsProvider.resolveInlayHint resolving} of inlay hints.
5601 */
5602 textEdits?: TextEdit[];
5603
5604 /**
5605 * Render padding before the hint. Padding will use the editor's background color,
5606 * not the background color of the hint itself. That means padding can be used to visually
5607 * align/separate an inlay hint.
5608 */
5609 paddingLeft?: boolean;
5610
5611 /**
5612 * Render padding after the hint. Padding will use the editor's background color,
5613 * not the background color of the hint itself. That means padding can be used to visually
5614 * align/separate an inlay hint.
5615 */
5616 paddingRight?: boolean;
5617
5618 /**
5619 * Creates a new inlay hint.
5620 *
5621 * @param position The position of the hint.
5622 * @param label The label of the hint.
5623 * @param kind The {@link InlayHintKind kind} of the hint.
5624 */
5625 constructor(position: Position, label: string | InlayHintLabelPart[], kind?: InlayHintKind);
5626 }
5627
5628 /**
5629 * The inlay hints provider interface defines the contract between extensions and
5630 * the inlay hints feature.
5631 */
5632 export interface InlayHintsProvider<T extends InlayHint = InlayHint> {
5633
5634 /**
5635 * An optional event to signal that inlay hints from this provider have changed.
5636 */
5637 onDidChangeInlayHints?: Event<void>;
5638
5639 /**
5640 * Provide inlay hints for the given range and document.
5641 *
5642 * *Note* that inlay hints that are not {@link Range.contains contained} by the given range are ignored.
5643 *
5644 * @param document The document in which the command was invoked.
5645 * @param range The range for which inlay hints should be computed.
5646 * @param token A cancellation token.
5647 * @returns An array of inlay hints or a thenable that resolves to such.
5648 */
5649 provideInlayHints(document: TextDocument, range: Range, token: CancellationToken): ProviderResult<T[]>;
5650
5651 /**
5652 * Given an inlay hint fill in {@link InlayHint.tooltip tooltip}, {@link InlayHint.textEdits text edits},
5653 * or complete label {@link InlayHintLabelPart parts}.
5654 *
5655 * *Note* that the editor will resolve an inlay hint at most once.
5656 *
5657 * @param hint An inlay hint.
5658 * @param token A cancellation token.
5659 * @returns The resolved inlay hint or a thenable that resolves to such. It is OK to return the given `item`. When no result is returned, the given `item` will be used.
5660 */
5661 resolveInlayHint?(hint: T, token: CancellationToken): ProviderResult<T>;
5662 }
5663
5664 /**
5665 * A line based folding range. To be valid, start and end line must be bigger than zero and smaller than the number of lines in the document.
5666 * Invalid ranges will be ignored.
5667 */
5668 export class FoldingRange {
5669
5670 /**
5671 * The zero-based start line of the range to fold. The folded area starts after the line's last character.
5672 * To be valid, the end must be zero or larger and smaller than the number of lines in the document.
5673 */
5674 start: number;
5675
5676 /**
5677 * The zero-based end line of the range to fold. The folded area ends with the line's last character.
5678 * To be valid, the end must be zero or larger and smaller than the number of lines in the document.
5679 */
5680 end: number;
5681
5682 /**
5683 * Describes the {@link FoldingRangeKind Kind} of the folding range such as {@link FoldingRangeKind.Comment Comment} or
5684 * {@link FoldingRangeKind.Region Region}. The kind is used to categorize folding ranges and used by commands
5685 * like 'Fold all comments'. See
5686 * {@link FoldingRangeKind} for an enumeration of all kinds.
5687 * If not set, the range is originated from a syntax element.
5688 */
5689 kind?: FoldingRangeKind;
5690
5691 /**
5692 * Creates a new folding range.
5693 *
5694 * @param start The start line of the folded range.
5695 * @param end The end line of the folded range.
5696 * @param kind The kind of the folding range.
5697 */
5698 constructor(start: number, end: number, kind?: FoldingRangeKind);
5699 }
5700
5701 /**
5702 * An enumeration of specific folding range kinds. The kind is an optional field of a {@link FoldingRange}
5703 * and is used to distinguish specific folding ranges such as ranges originated from comments. The kind is used by commands like
5704 * `Fold all comments` or `Fold all regions`.
5705 * If the kind is not set on the range, the range originated from a syntax element other than comments, imports or region markers.
5706 */
5707 export enum FoldingRangeKind {
5708 /**
5709 * Kind for folding range representing a comment.
5710 */
5711 Comment = 1,
5712 /**
5713 * Kind for folding range representing a import.
5714 */
5715 Imports = 2,
5716 /**
5717 * Kind for folding range representing regions originating from folding markers like `#region` and `#endregion`.
5718 */
5719 Region = 3
5720 }
5721
5722 /**
5723 * Folding context (for future use)
5724 */
5725 export interface FoldingContext {
5726 }
5727
5728 /**
5729 * The folding range provider interface defines the contract between extensions and
5730 * [Folding](https://code.visualstudio.com/docs/editor/codebasics#_folding) in the editor.
5731 */
5732 export interface FoldingRangeProvider {
5733
5734 /**
5735 * An optional event to signal that the folding ranges from this provider have changed.
5736 */
5737 onDidChangeFoldingRanges?: Event<void>;
5738
5739 /**
5740 * Returns a list of folding ranges or null and undefined if the provider
5741 * does not want to participate or was cancelled.
5742 * @param document The document in which the command was invoked.
5743 * @param context Additional context information (for future use)
5744 * @param token A cancellation token.
5745 */
5746 provideFoldingRanges(document: TextDocument, context: FoldingContext, token: CancellationToken): ProviderResult<FoldingRange[]>;
5747 }
5748
5749 /**
5750 * A selection range represents a part of a selection hierarchy. A selection range
5751 * may have a parent selection range that contains it.
5752 */
5753 export class SelectionRange {
5754
5755 /**
5756 * The {@link Range} of this selection range.
5757 */
5758 range: Range;
5759
5760 /**
5761 * The parent selection range containing this range.
5762 */
5763 parent?: SelectionRange;
5764
5765 /**
5766 * Creates a new selection range.
5767 *
5768 * @param range The range of the selection range.
5769 * @param parent The parent of the selection range.
5770 */
5771 constructor(range: Range, parent?: SelectionRange);
5772 }
5773
5774 /**
5775 * The selection range provider interface defines the contract between extensions and the "Expand and Shrink Selection" feature.
5776 */
5777 export interface SelectionRangeProvider {
5778 /**
5779 * Provide selection ranges for the given positions.
5780 *
5781 * Selection ranges should be computed individually and independent for each position. The editor will merge
5782 * and deduplicate ranges but providers must return hierarchies of selection ranges so that a range
5783 * is {@link Range.contains contained} by its parent.
5784 *
5785 * @param document The document in which the command was invoked.
5786 * @param positions The positions at which the command was invoked.
5787 * @param token A cancellation token.
5788 * @returns Selection ranges or a thenable that resolves to such. The lack of a result can be
5789 * signaled by returning `undefined` or `null`.
5790 */
5791 provideSelectionRanges(document: TextDocument, positions: readonly Position[], token: CancellationToken): ProviderResult<SelectionRange[]>;
5792 }
5793
5794 /**
5795 * Represents programming constructs like functions or constructors in the context
5796 * of call hierarchy.
5797 */
5798 export class CallHierarchyItem {
5799 /**
5800 * The name of this item.
5801 */
5802 name: string;
5803
5804 /**
5805 * The kind of this item.
5806 */
5807 kind: SymbolKind;
5808
5809 /**
5810 * Tags for this item.
5811 */
5812 tags?: readonly SymbolTag[];
5813
5814 /**
5815 * More detail for this item, e.g. the signature of a function.
5816 */
5817 detail?: string;
5818
5819 /**
5820 * The resource identifier of this item.
5821 */
5822 uri: Uri;
5823
5824 /**
5825 * The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code.
5826 */
5827 range: Range;
5828
5829 /**
5830 * The range that should be selected and revealed when this symbol is being picked, e.g. the name of a function.
5831 * Must be contained by the {@linkcode CallHierarchyItem.range range}.
5832 */
5833 selectionRange: Range;
5834
5835 /**
5836 * Creates a new call hierarchy item.
5837 */
5838 constructor(kind: SymbolKind, name: string, detail: string, uri: Uri, range: Range, selectionRange: Range);
5839 }
5840
5841 /**
5842 * Represents an incoming call, e.g. a caller of a method or constructor.
5843 */
5844 export class CallHierarchyIncomingCall {
5845
5846 /**
5847 * The item that makes the call.
5848 */
5849 from: CallHierarchyItem;
5850
5851 /**
5852 * The range at which at which the calls appears. This is relative to the caller
5853 * denoted by {@linkcode CallHierarchyIncomingCall.from this.from}.
5854 */
5855 fromRanges: Range[];
5856
5857 /**
5858 * Create a new call object.
5859 *
5860 * @param item The item making the call.
5861 * @param fromRanges The ranges at which the calls appear.
5862 */
5863 constructor(item: CallHierarchyItem, fromRanges: Range[]);
5864 }
5865
5866 /**
5867 * Represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc.
5868 */
5869 export class CallHierarchyOutgoingCall {
5870
5871 /**
5872 * The item that is called.
5873 */
5874 to: CallHierarchyItem;
5875
5876 /**
5877 * The range at which this item is called. This is the range relative to the caller, e.g the item
5878 * passed to {@linkcode CallHierarchyProvider.provideCallHierarchyOutgoingCalls provideCallHierarchyOutgoingCalls}
5879 * and not {@linkcode CallHierarchyOutgoingCall.to this.to}.
5880 */
5881 fromRanges: Range[];
5882
5883 /**
5884 * Create a new call object.
5885 *
5886 * @param item The item being called
5887 * @param fromRanges The ranges at which the calls appear.
5888 */
5889 constructor(item: CallHierarchyItem, fromRanges: Range[]);
5890 }
5891
5892 /**
5893 * The call hierarchy provider interface describes the contract between extensions
5894 * and the call hierarchy feature which allows to browse calls and caller of function,
5895 * methods, constructor etc.
5896 */
5897 export interface CallHierarchyProvider {
5898
5899 /**
5900 * Bootstraps call hierarchy by returning the item that is denoted by the given document
5901 * and position. This item will be used as entry into the call graph. Providers should
5902 * return `undefined` or `null` when there is no item at the given location.
5903 *
5904 * @param document The document in which the command was invoked.
5905 * @param position The position at which the command was invoked.
5906 * @param token A cancellation token.
5907 * @returns One or multiple call hierarchy items or a thenable that resolves to such. The lack of a result can be
5908 * signaled by returning `undefined`, `null`, or an empty array.
5909 */
5910 prepareCallHierarchy(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<CallHierarchyItem | CallHierarchyItem[]>;
5911
5912 /**
5913 * Provide all incoming calls for an item, e.g all callers for a method. In graph terms this describes directed
5914 * and annotated edges inside the call graph, e.g the given item is the starting node and the result is the nodes
5915 * that can be reached.
5916 *
5917 * @param item The hierarchy item for which incoming calls should be computed.
5918 * @param token A cancellation token.
5919 * @returns A set of incoming calls or a thenable that resolves to such. The lack of a result can be
5920 * signaled by returning `undefined` or `null`.
5921 */
5922 provideCallHierarchyIncomingCalls(item: CallHierarchyItem, token: CancellationToken): ProviderResult<CallHierarchyIncomingCall[]>;
5923
5924 /**
5925 * Provide all outgoing calls for an item, e.g call calls to functions, methods, or constructors from the given item. In
5926 * graph terms this describes directed and annotated edges inside the call graph, e.g the given item is the starting
5927 * node and the result is the nodes that can be reached.
5928 *
5929 * @param item The hierarchy item for which outgoing calls should be computed.
5930 * @param token A cancellation token.
5931 * @returns A set of outgoing calls or a thenable that resolves to such. The lack of a result can be
5932 * signaled by returning `undefined` or `null`.
5933 */
5934 provideCallHierarchyOutgoingCalls(item: CallHierarchyItem, token: CancellationToken): ProviderResult<CallHierarchyOutgoingCall[]>;
5935 }
5936
5937 /**
5938 * Represents an item of a type hierarchy, like a class or an interface.
5939 */
5940 export class TypeHierarchyItem {
5941 /**
5942 * The name of this item.
5943 */
5944 name: string;
5945
5946 /**
5947 * The kind of this item.
5948 */
5949 kind: SymbolKind;
5950
5951 /**
5952 * Tags for this item.
5953 */
5954 tags?: ReadonlyArray<SymbolTag>;
5955
5956 /**
5957 * More detail for this item, e.g. the signature of a function.
5958 */
5959 detail?: string;
5960
5961 /**
5962 * The resource identifier of this item.
5963 */
5964 uri: Uri;
5965
5966 /**
5967 * The range enclosing this symbol not including leading/trailing whitespace
5968 * but everything else, e.g. comments and code.
5969 */
5970 range: Range;
5971
5972 /**
5973 * The range that should be selected and revealed when this symbol is being
5974 * picked, e.g. the name of a class. Must be contained by the {@link TypeHierarchyItem.range range}-property.
5975 */
5976 selectionRange: Range;
5977
5978 /**
5979 * Creates a new type hierarchy item.
5980 *
5981 * @param kind The kind of the item.
5982 * @param name The name of the item.
5983 * @param detail The details of the item.
5984 * @param uri The Uri of the item.
5985 * @param range The whole range of the item.
5986 * @param selectionRange The selection range of the item.
5987 */
5988 constructor(kind: SymbolKind, name: string, detail: string, uri: Uri, range: Range, selectionRange: Range);
5989 }
5990
5991 /**
5992 * The type hierarchy provider interface describes the contract between extensions
5993 * and the type hierarchy feature.
5994 */
5995 export interface TypeHierarchyProvider {
5996
5997 /**
5998 * Bootstraps type hierarchy by returning the item that is denoted by the given document
5999 * and position. This item will be used as entry into the type graph. Providers should
6000 * return `undefined` or `null` when there is no item at the given location.
6001 *
6002 * @param document The document in which the command was invoked.
6003 * @param position The position at which the command was invoked.
6004 * @param token A cancellation token.
6005 * @returns One or multiple type hierarchy items or a thenable that resolves to such. The lack of a result can be
6006 * signaled by returning `undefined`, `null`, or an empty array.
6007 */
6008 prepareTypeHierarchy(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<TypeHierarchyItem | TypeHierarchyItem[]>;
6009
6010 /**
6011 * Provide all supertypes for an item, e.g all types from which a type is derived/inherited. In graph terms this describes directed
6012 * and annotated edges inside the type graph, e.g the given item is the starting node and the result is the nodes
6013 * that can be reached.
6014 *
6015 * @param item The hierarchy item for which super types should be computed.
6016 * @param token A cancellation token.
6017 * @returns A set of direct supertypes or a thenable that resolves to such. The lack of a result can be
6018 * signaled by returning `undefined` or `null`.
6019 */
6020 provideTypeHierarchySupertypes(item: TypeHierarchyItem, token: CancellationToken): ProviderResult<TypeHierarchyItem[]>;
6021
6022 /**
6023 * Provide all subtypes for an item, e.g all types which are derived/inherited from the given item. In
6024 * graph terms this describes directed and annotated edges inside the type graph, e.g the given item is the starting
6025 * node and the result is the nodes that can be reached.
6026 *
6027 * @param item The hierarchy item for which subtypes should be computed.
6028 * @param token A cancellation token.
6029 * @returns A set of direct subtypes or a thenable that resolves to such. The lack of a result can be
6030 * signaled by returning `undefined` or `null`.
6031 */
6032 provideTypeHierarchySubtypes(item: TypeHierarchyItem, token: CancellationToken): ProviderResult<TypeHierarchyItem[]>;
6033 }
6034
6035 /**
6036 * Represents a list of ranges that can be edited together along with a word pattern to describe valid range contents.
6037 */
6038 export class LinkedEditingRanges {
6039 /**
6040 * Create a new linked editing ranges object.
6041 *
6042 * @param ranges A list of ranges that can be edited together
6043 * @param wordPattern An optional word pattern that describes valid contents for the given ranges
6044 */
6045 constructor(ranges: Range[], wordPattern?: RegExp);
6046
6047 /**
6048 * A list of ranges that can be edited together. The ranges must have
6049 * identical length and text content. The ranges cannot overlap.
6050 */
6051 readonly ranges: Range[];
6052
6053 /**
6054 * An optional word pattern that describes valid contents for the given ranges.
6055 * If no pattern is provided, the language configuration's word pattern will be used.
6056 */
6057 readonly wordPattern: RegExp | undefined;
6058 }
6059
6060 /**
6061 * The linked editing range provider interface defines the contract between extensions and
6062 * the linked editing feature.
6063 */
6064 export interface LinkedEditingRangeProvider {
6065 /**
6066 * For a given position in a document, returns the range of the symbol at the position and all ranges
6067 * that have the same content. A change to one of the ranges can be applied to all other ranges if the new content
6068 * is valid. An optional word pattern can be returned with the result to describe valid contents.
6069 * If no result-specific word pattern is provided, the word pattern from the language configuration is used.
6070 *
6071 * @param document The document in which the provider was invoked.
6072 * @param position The position at which the provider was invoked.
6073 * @param token A cancellation token.
6074 * @returns A list of ranges that can be edited together
6075 */
6076 provideLinkedEditingRanges(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<LinkedEditingRanges>;
6077 }
6078
6079 /**
6080 * An edit operation applied {@link DocumentDropEditProvider on drop}.
6081 */
6082 export class DocumentDropEdit {
6083 /**
6084 * The text or snippet to insert at the drop location.
6085 */
6086 insertText: string | SnippetString;
6087
6088 /**
6089 * An optional additional edit to apply on drop.
6090 */
6091 additionalEdit?: WorkspaceEdit;
6092
6093 /**
6094 * @param insertText The text or snippet to insert at the drop location.
6095 */
6096 constructor(insertText: string | SnippetString);
6097 }
6098
6099 /**
6100 * Provider which handles dropping of resources into a text editor.
6101 *
6102 * This allows users to drag and drop resources (including resources from external apps) into the editor. While dragging
6103 * and dropping files, users can hold down `shift` to drop the file into the editor instead of opening it.
6104 * Requires `editor.dropIntoEditor.enabled` to be on.
6105 */
6106 export interface DocumentDropEditProvider {
6107 /**
6108 * Provide edits which inserts the content being dragged and dropped into the document.
6109 *
6110 * @param document The document in which the drop occurred.
6111 * @param position The position in the document where the drop occurred.
6112 * @param dataTransfer A {@link DataTransfer} object that holds data about what is being dragged and dropped.
6113 * @param token A cancellation token.
6114 *
6115 * @returns A {@link DocumentDropEdit} or a thenable that resolves to such. The lack of a result can be
6116 * signaled by returning `undefined` or `null`.
6117 */
6118 provideDocumentDropEdits(document: TextDocument, position: Position, dataTransfer: DataTransfer, token: CancellationToken): ProviderResult<DocumentDropEdit>;
6119 }
6120
6121 /**
6122 * A tuple of two characters, like a pair of
6123 * opening and closing brackets.
6124 */
6125 export type CharacterPair = [string, string];
6126
6127 /**
6128 * Describes how comments for a language work.
6129 */
6130 export interface CommentRule {
6131
6132 /**
6133 * The line comment token, like `// this is a comment`
6134 */
6135 lineComment?: string;
6136
6137 /**
6138 * The block comment character pair, like `/* block comment *&#47;`
6139 */
6140 blockComment?: CharacterPair;
6141 }
6142
6143 /**
6144 * Describes indentation rules for a language.
6145 */
6146 export interface IndentationRule {
6147 /**
6148 * If a line matches this pattern, then all the lines after it should be unindented once (until another rule matches).
6149 */
6150 decreaseIndentPattern: RegExp;
6151 /**
6152 * If a line matches this pattern, then all the lines after it should be indented once (until another rule matches).
6153 */
6154 increaseIndentPattern: RegExp;
6155 /**
6156 * If a line matches this pattern, then **only the next line** after it should be indented once.
6157 */
6158 indentNextLinePattern?: RegExp;
6159 /**
6160 * If a line matches this pattern, then its indentation should not be changed and it should not be evaluated against the other rules.
6161 */
6162 unIndentedLinePattern?: RegExp;
6163 }
6164
6165 /**
6166 * Describes what to do with the indentation when pressing Enter.
6167 */
6168 export enum IndentAction {
6169 /**
6170 * Insert new line and copy the previous line's indentation.
6171 */
6172 None = 0,
6173 /**
6174 * Insert new line and indent once (relative to the previous line's indentation).
6175 */
6176 Indent = 1,
6177 /**
6178 * Insert two new lines:
6179 * - the first one indented which will hold the cursor
6180 * - the second one at the same indentation level
6181 */
6182 IndentOutdent = 2,
6183 /**
6184 * Insert new line and outdent once (relative to the previous line's indentation).
6185 */
6186 Outdent = 3
6187 }
6188
6189 /**
6190 * Describes what to do when pressing Enter.
6191 */
6192 export interface EnterAction {
6193 /**
6194 * Describe what to do with the indentation.
6195 */
6196 indentAction: IndentAction;
6197 /**
6198 * Describes text to be appended after the new line and after the indentation.
6199 */
6200 appendText?: string;
6201 /**
6202 * Describes the number of characters to remove from the new line's indentation.
6203 */
6204 removeText?: number;
6205 }
6206
6207 /**
6208 * Describes a rule to be evaluated when pressing Enter.
6209 */
6210 export interface OnEnterRule {
6211 /**
6212 * This rule will only execute if the text before the cursor matches this regular expression.
6213 */
6214 beforeText: RegExp;
6215 /**
6216 * This rule will only execute if the text after the cursor matches this regular expression.
6217 */
6218 afterText?: RegExp;
6219 /**
6220 * This rule will only execute if the text above the current line matches this regular expression.
6221 */
6222 previousLineText?: RegExp;
6223 /**
6224 * The action to execute.
6225 */
6226 action: EnterAction;
6227 }
6228
6229 /**
6230 * Enumeration of commonly encountered syntax token types.
6231 */
6232 export enum SyntaxTokenType {
6233 /**
6234 * Everything except tokens that are part of comments, string literals and regular expressions.
6235 */
6236 Other = 0,
6237 /**
6238 * A comment.
6239 */
6240 Comment = 1,
6241 /**
6242 * A string literal.
6243 */
6244 String = 2,
6245 /**
6246 * A regular expression.
6247 */
6248 RegEx = 3
6249 }
6250
6251 /**
6252 * Describes pairs of strings where the close string will be automatically inserted when typing the opening string.
6253 */
6254 export interface AutoClosingPair {
6255 /**
6256 * The string that will trigger the automatic insertion of the closing string.
6257 */
6258 open: string;
6259 /**
6260 * The closing string that will be automatically inserted when typing the opening string.
6261 */
6262 close: string;
6263 /**
6264 * A set of tokens where the pair should not be auto closed.
6265 */
6266 notIn?: SyntaxTokenType[];
6267 }
6268
6269 /**
6270 * The language configuration interfaces defines the contract between extensions
6271 * and various editor features, like automatic bracket insertion, automatic indentation etc.
6272 */
6273 export interface LanguageConfiguration {
6274 /**
6275 * The language's comment settings.
6276 */
6277 comments?: CommentRule;
6278 /**
6279 * The language's brackets.
6280 * This configuration implicitly affects pressing Enter around these brackets.
6281 */
6282 brackets?: CharacterPair[];
6283 /**
6284 * The language's word definition.
6285 * If the language supports Unicode identifiers (e.g. JavaScript), it is preferable
6286 * to provide a word definition that uses exclusion of known separators.
6287 * e.g.: A regex that matches anything except known separators (and dot is allowed to occur in a floating point number):
6288 * /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g
6289 */
6290 wordPattern?: RegExp;
6291 /**
6292 * The language's indentation settings.
6293 */
6294 indentationRules?: IndentationRule;
6295 /**
6296 * The language's rules to be evaluated when pressing Enter.
6297 */
6298 onEnterRules?: OnEnterRule[];
6299 /**
6300 * The language's auto closing pairs.
6301 */
6302 autoClosingPairs?: AutoClosingPair[];
6303
6304 /**
6305 * **Deprecated** Do not use.
6306 *
6307 * @deprecated Will be replaced by a better API soon.
6308 */
6309 __electricCharacterSupport?: {
6310 /**
6311 * This property is deprecated and will be **ignored** from
6312 * the editor.
6313 * @deprecated
6314 */
6315 brackets?: any;
6316 /**
6317 * This property is deprecated and not fully supported anymore by
6318 * the editor (scope and lineStart are ignored).
6319 * Use the autoClosingPairs property in the language configuration file instead.
6320 * @deprecated
6321 */
6322 docComment?: {
6323 /**
6324 * @deprecated
6325 */
6326 scope: string;
6327 /**
6328 * @deprecated
6329 */
6330 open: string;
6331 /**
6332 * @deprecated
6333 */
6334 lineStart: string;
6335 /**
6336 * @deprecated
6337 */
6338 close?: string;
6339 };
6340 };
6341
6342 /**
6343 * **Deprecated** Do not use.
6344 *
6345 * @deprecated * Use the autoClosingPairs property in the language configuration file instead.
6346 */
6347 __characterPairSupport?: {
6348 /**
6349 * @deprecated
6350 */
6351 autoClosingPairs: {
6352 /**
6353 * @deprecated
6354 */
6355 open: string;
6356 /**
6357 * @deprecated
6358 */
6359 close: string;
6360 /**
6361 * @deprecated
6362 */
6363 notIn?: string[];
6364 }[];
6365 };
6366 }
6367
6368 /**
6369 * The configuration target
6370 */
6371 export enum ConfigurationTarget {
6372 /**
6373 * Global configuration
6374 */
6375 Global = 1,
6376
6377 /**
6378 * Workspace configuration
6379 */
6380 Workspace = 2,
6381
6382 /**
6383 * Workspace folder configuration
6384 */
6385 WorkspaceFolder = 3
6386 }
6387
6388 /**
6389 * Represents the configuration. It is a merged view of
6390 *
6391 * - *Default Settings*
6392 * - *Global (User) Settings*
6393 * - *Workspace settings*
6394 * - *Workspace Folder settings* - From one of the {@link workspace.workspaceFolders Workspace Folders} under which requested resource belongs to.
6395 * - *Language settings* - Settings defined under requested language.
6396 *
6397 * The *effective* value (returned by {@linkcode WorkspaceConfiguration.get get}) is computed by overriding or merging the values in the following order:
6398 *
6399 * 1. `defaultValue` (if defined in `package.json` otherwise derived from the value's type)
6400 * 1. `globalValue` (if defined)
6401 * 1. `workspaceValue` (if defined)
6402 * 1. `workspaceFolderValue` (if defined)
6403 * 1. `defaultLanguageValue` (if defined)
6404 * 1. `globalLanguageValue` (if defined)
6405 * 1. `workspaceLanguageValue` (if defined)
6406 * 1. `workspaceFolderLanguageValue` (if defined)
6407 *
6408 * **Note:** Only `object` value types are merged and all other value types are overridden.
6409 *
6410 * Example 1: Overriding
6411 *
6412 * ```ts
6413 * defaultValue = 'on';
6414 * globalValue = 'relative'
6415 * workspaceFolderValue = 'off'
6416 * value = 'off'
6417 * ```
6418 *
6419 * Example 2: Language Values
6420 *
6421 * ```ts
6422 * defaultValue = 'on';
6423 * globalValue = 'relative'
6424 * workspaceFolderValue = 'off'
6425 * globalLanguageValue = 'on'
6426 * value = 'on'
6427 * ```
6428 *
6429 * Example 3: Object Values
6430 *
6431 * ```ts
6432 * defaultValue = { "a": 1, "b": 2 };
6433 * globalValue = { "b": 3, "c": 4 };
6434 * value = { "a": 1, "b": 3, "c": 4 };
6435 * ```
6436 *
6437 * *Note:* Workspace and Workspace Folder configurations contains `launch` and `tasks` settings. Their basename will be
6438 * part of the section identifier. The following snippets shows how to retrieve all configurations
6439 * from `launch.json`:
6440 *
6441 * ```ts
6442 * // launch.json configuration
6443 * const config = workspace.getConfiguration('launch', vscode.workspace.workspaceFolders[0].uri);
6444 *
6445 * // retrieve values
6446 * const values = config.get('configurations');
6447 * ```
6448 *
6449 * Refer to [Settings](https://code.visualstudio.com/docs/getstarted/settings) for more information.
6450 */
6451 export interface WorkspaceConfiguration {
6452
6453 /**
6454 * Return a value from this configuration.
6455 *
6456 * @param section Configuration name, supports _dotted_ names.
6457 * @returns The value `section` denotes or `undefined`.
6458 */
6459 get<T>(section: string): T | undefined;
6460
6461 /**
6462 * Return a value from this configuration.
6463 *
6464 * @param section Configuration name, supports _dotted_ names.
6465 * @param defaultValue A value should be returned when no value could be found, is `undefined`.
6466 * @returns The value `section` denotes or the default.
6467 */
6468 get<T>(section: string, defaultValue: T): T;
6469
6470 /**
6471 * Check if this configuration has a certain value.
6472 *
6473 * @param section Configuration name, supports _dotted_ names.
6474 * @returns `true` if the section doesn't resolve to `undefined`.
6475 */
6476 has(section: string): boolean;
6477
6478 /**
6479 * Retrieve all information about a configuration setting. A configuration value
6480 * often consists of a *default* value, a global or installation-wide value,
6481 * a workspace-specific value, folder-specific value
6482 * and language-specific values (if {@link WorkspaceConfiguration} is scoped to a language).
6483 *
6484 * Also provides all language ids under which the given configuration setting is defined.
6485 *
6486 * *Note:* The configuration name must denote a leaf in the configuration tree
6487 * (`editor.fontSize` vs `editor`) otherwise no result is returned.
6488 *
6489 * @param section Configuration name, supports _dotted_ names.
6490 * @returns Information about a configuration setting or `undefined`.
6491 */
6492 inspect<T>(section: string): {
6493
6494 /**
6495 * The fully qualified key of the configuration value
6496 */
6497 key: string;
6498
6499 /**
6500 * The default value which is used when no other value is defined
6501 */
6502 defaultValue?: T;
6503
6504 /**
6505 * The global or installation-wide value.
6506 */
6507 globalValue?: T;
6508
6509 /**
6510 * The workspace-specific value.
6511 */
6512 workspaceValue?: T;
6513
6514 /**
6515 * The workpace-folder-specific value.
6516 */
6517 workspaceFolderValue?: T;
6518
6519 /**
6520 * Language specific default value when this configuration value is created for a {@link ConfigurationScope language scope}.
6521 */
6522 defaultLanguageValue?: T;
6523
6524 /**
6525 * Language specific global value when this configuration value is created for a {@link ConfigurationScope language scope}.
6526 */
6527 globalLanguageValue?: T;
6528
6529 /**
6530 * Language specific workspace value when this configuration value is created for a {@link ConfigurationScope language scope}.
6531 */
6532 workspaceLanguageValue?: T;
6533
6534 /**
6535 * Language specific workspace-folder value when this configuration value is created for a {@link ConfigurationScope language scope}.
6536 */
6537 workspaceFolderLanguageValue?: T;
6538
6539 /**
6540 * All language identifiers for which this configuration is defined.
6541 */
6542 languageIds?: string[];
6543
6544 } | undefined;
6545
6546 /**
6547 * Update a configuration value. The updated configuration values are persisted.
6548 *
6549 * A value can be changed in
6550 *
6551 * - {@link ConfigurationTarget.Global Global settings}: Changes the value for all instances of the editor.
6552 * - {@link ConfigurationTarget.Workspace Workspace settings}: Changes the value for current workspace, if available.
6553 * - {@link ConfigurationTarget.WorkspaceFolder Workspace folder settings}: Changes the value for settings from one of the {@link workspace.workspaceFolders Workspace Folders} under which the requested resource belongs to.
6554 * - Language settings: Changes the value for the requested languageId.
6555 *
6556 * *Note:* To remove a configuration value use `undefined`, like so: `config.update('somekey', undefined)`
6557 *
6558 * @param section Configuration name, supports _dotted_ names.
6559 * @param value The new value.
6560 * @param configurationTarget The {@link ConfigurationTarget configuration target} or a boolean value.
6561 * - If `true` updates {@link ConfigurationTarget.Global Global settings}.
6562 * - If `false` updates {@link ConfigurationTarget.Workspace Workspace settings}.
6563 * - If `undefined` or `null` updates to {@link ConfigurationTarget.WorkspaceFolder Workspace folder settings} if configuration is resource specific,
6564 * otherwise to {@link ConfigurationTarget.Workspace Workspace settings}.
6565 * @param overrideInLanguage Whether to update the value in the scope of requested languageId or not.
6566 * - If `true` updates the value under the requested languageId.
6567 * - If `undefined` updates the value under the requested languageId only if the configuration is defined for the language.
6568 * @throws error while updating
6569 * - configuration which is not registered.
6570 * - window configuration to workspace folder
6571 * - configuration to workspace or workspace folder when no workspace is opened.
6572 * - configuration to workspace folder when there is no workspace folder settings.
6573 * - configuration to workspace folder when {@link WorkspaceConfiguration} is not scoped to a resource.
6574 */
6575 update(section: string, value: any, configurationTarget?: ConfigurationTarget | boolean | null, overrideInLanguage?: boolean): Thenable<void>;
6576
6577 /**
6578 * Readable dictionary that backs this configuration.
6579 */
6580 readonly [key: string]: any;
6581 }
6582
6583 /**
6584 * Represents a location inside a resource, such as a line
6585 * inside a text file.
6586 */
6587 export class Location {
6588
6589 /**
6590 * The resource identifier of this location.
6591 */
6592 uri: Uri;
6593
6594 /**
6595 * The document range of this location.
6596 */
6597 range: Range;
6598
6599 /**
6600 * Creates a new location object.
6601 *
6602 * @param uri The resource identifier.
6603 * @param rangeOrPosition The range or position. Positions will be converted to an empty range.
6604 */
6605 constructor(uri: Uri, rangeOrPosition: Range | Position);
6606 }
6607
6608 /**
6609 * Represents the connection of two locations. Provides additional metadata over normal {@link Location locations},
6610 * including an origin range.
6611 */
6612 export interface LocationLink {
6613 /**
6614 * Span of the origin of this link.
6615 *
6616 * Used as the underlined span for mouse definition hover. Defaults to the word range at
6617 * the definition position.
6618 */
6619 originSelectionRange?: Range;
6620
6621 /**
6622 * The target resource identifier of this link.
6623 */
6624 targetUri: Uri;
6625
6626 /**
6627 * The full target range of this link.
6628 */
6629 targetRange: Range;
6630
6631 /**
6632 * The span of this link.
6633 */
6634 targetSelectionRange?: Range;
6635 }
6636
6637 /**
6638 * The event that is fired when diagnostics change.
6639 */
6640 export interface DiagnosticChangeEvent {
6641
6642 /**
6643 * An array of resources for which diagnostics have changed.
6644 */
6645 readonly uris: readonly Uri[];
6646 }
6647
6648 /**
6649 * Represents the severity of diagnostics.
6650 */
6651 export enum DiagnosticSeverity {
6652
6653 /**
6654 * Something not allowed by the rules of a language or other means.
6655 */
6656 Error = 0,
6657
6658 /**
6659 * Something suspicious but allowed.
6660 */
6661 Warning = 1,
6662
6663 /**
6664 * Something to inform about but not a problem.
6665 */
6666 Information = 2,
6667
6668 /**
6669 * Something to hint to a better way of doing it, like proposing
6670 * a refactoring.
6671 */
6672 Hint = 3
6673 }
6674
6675 /**
6676 * Represents a related message and source code location for a diagnostic. This should be
6677 * used to point to code locations that cause or related to a diagnostics, e.g. when duplicating
6678 * a symbol in a scope.
6679 */
6680 export class DiagnosticRelatedInformation {
6681
6682 /**
6683 * The location of this related diagnostic information.
6684 */
6685 location: Location;
6686
6687 /**
6688 * The message of this related diagnostic information.
6689 */
6690 message: string;
6691
6692 /**
6693 * Creates a new related diagnostic information object.
6694 *
6695 * @param location The location.
6696 * @param message The message.
6697 */
6698 constructor(location: Location, message: string);
6699 }
6700
6701 /**
6702 * Additional metadata about the type of a diagnostic.
6703 */
6704 export enum DiagnosticTag {
6705 /**
6706 * Unused or unnecessary code.
6707 *
6708 * Diagnostics with this tag are rendered faded out. The amount of fading
6709 * is controlled by the `"editorUnnecessaryCode.opacity"` theme color. For
6710 * example, `"editorUnnecessaryCode.opacity": "#000000c0"` will render the
6711 * code with 75% opacity. For high contrast themes, use the
6712 * `"editorUnnecessaryCode.border"` theme color to underline unnecessary code
6713 * instead of fading it out.
6714 */
6715 Unnecessary = 1,
6716
6717 /**
6718 * Deprecated or obsolete code.
6719 *
6720 * Diagnostics with this tag are rendered with a strike through.
6721 */
6722 Deprecated = 2,
6723 }
6724
6725 /**
6726 * Represents a diagnostic, such as a compiler error or warning. Diagnostic objects
6727 * are only valid in the scope of a file.
6728 */
6729 export class Diagnostic {
6730
6731 /**
6732 * The range to which this diagnostic applies.
6733 */
6734 range: Range;
6735
6736 /**
6737 * The human-readable message.
6738 */
6739 message: string;
6740
6741 /**
6742 * The severity, default is {@link DiagnosticSeverity.Error error}.
6743 */
6744 severity: DiagnosticSeverity;
6745
6746 /**
6747 * A human-readable string describing the source of this
6748 * diagnostic, e.g. 'typescript' or 'super lint'.
6749 */
6750 source?: string;
6751
6752 /**
6753 * A code or identifier for this diagnostic.
6754 * Should be used for later processing, e.g. when providing {@link CodeActionContext code actions}.
6755 */
6756 code?: string | number | {
6757 /**
6758 * A code or identifier for this diagnostic.
6759 * Should be used for later processing, e.g. when providing {@link CodeActionContext code actions}.
6760 */
6761 value: string | number;
6762
6763 /**
6764 * A target URI to open with more information about the diagnostic error.
6765 */
6766 target: Uri;
6767 };
6768
6769 /**
6770 * An array of related diagnostic information, e.g. when symbol-names within
6771 * a scope collide all definitions can be marked via this property.
6772 */
6773 relatedInformation?: DiagnosticRelatedInformation[];
6774
6775 /**
6776 * Additional metadata about the diagnostic.
6777 */
6778 tags?: DiagnosticTag[];
6779
6780 /**
6781 * Creates a new diagnostic object.
6782 *
6783 * @param range The range to which this diagnostic applies.
6784 * @param message The human-readable message.
6785 * @param severity The severity, default is {@link DiagnosticSeverity.Error error}.
6786 */
6787 constructor(range: Range, message: string, severity?: DiagnosticSeverity);
6788 }
6789
6790 /**
6791 * A diagnostics collection is a container that manages a set of
6792 * {@link Diagnostic diagnostics}. Diagnostics are always scopes to a
6793 * diagnostics collection and a resource.
6794 *
6795 * To get an instance of a `DiagnosticCollection` use
6796 * {@link languages.createDiagnosticCollection createDiagnosticCollection}.
6797 */
6798 export interface DiagnosticCollection extends Iterable<[uri: Uri, diagnostics: readonly Diagnostic[]]> {
6799
6800 /**
6801 * The name of this diagnostic collection, for instance `typescript`. Every diagnostic
6802 * from this collection will be associated with this name. Also, the task framework uses this
6803 * name when defining [problem matchers](https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher).
6804 */
6805 readonly name: string;
6806
6807 /**
6808 * Assign diagnostics for given resource. Will replace
6809 * existing diagnostics for that resource.
6810 *
6811 * @param uri A resource identifier.
6812 * @param diagnostics Array of diagnostics or `undefined`
6813 */
6814 set(uri: Uri, diagnostics: readonly Diagnostic[] | undefined): void;
6815
6816 /**
6817 * Replace diagnostics for multiple resources in this collection.
6818 *
6819 * _Note_ that multiple tuples of the same uri will be merged, e.g
6820 * `[[file1, [d1]], [file1, [d2]]]` is equivalent to `[[file1, [d1, d2]]]`.
6821 * If a diagnostics item is `undefined` as in `[file1, undefined]`
6822 * all previous but not subsequent diagnostics are removed.
6823 *
6824 * @param entries An array of tuples, like `[[file1, [d1, d2]], [file2, [d3, d4, d5]]]`, or `undefined`.
6825 */
6826 set(entries: ReadonlyArray<[Uri, readonly Diagnostic[] | undefined]>): void;
6827
6828 /**
6829 * Remove all diagnostics from this collection that belong
6830 * to the provided `uri`. The same as `#set(uri, undefined)`.
6831 *
6832 * @param uri A resource identifier.
6833 */
6834 delete(uri: Uri): void;
6835
6836 /**
6837 * Remove all diagnostics from this collection. The same
6838 * as calling `#set(undefined)`;
6839 */
6840 clear(): void;
6841
6842 /**
6843 * Iterate over each entry in this collection.
6844 *
6845 * @param callback Function to execute for each entry.
6846 * @param thisArg The `this` context used when invoking the handler function.
6847 */
6848 forEach(callback: (uri: Uri, diagnostics: readonly Diagnostic[], collection: DiagnosticCollection) => any, thisArg?: any): void;
6849
6850 /**
6851 * Get the diagnostics for a given resource. *Note* that you cannot
6852 * modify the diagnostics-array returned from this call.
6853 *
6854 * @param uri A resource identifier.
6855 * @returns An immutable array of {@link Diagnostic diagnostics} or `undefined`.
6856 */
6857 get(uri: Uri): readonly Diagnostic[] | undefined;
6858
6859 /**
6860 * Check if this collection contains diagnostics for a
6861 * given resource.
6862 *
6863 * @param uri A resource identifier.
6864 * @returns `true` if this collection has diagnostic for the given resource.
6865 */
6866 has(uri: Uri): boolean;
6867
6868 /**
6869 * Dispose and free associated resources. Calls
6870 * {@link DiagnosticCollection.clear clear}.
6871 */
6872 dispose(): void;
6873 }
6874
6875 /**
6876 * Represents the severity of a language status item.
6877 */
6878 /**
6879 * Represents the severity level of a language status.
6880 */
6881 export enum LanguageStatusSeverity {
6882 /**
6883 * Informational severity level.
6884 */
6885 Information = 0,
6886 /**
6887 * Warning severity level.
6888 */
6889 Warning = 1,
6890 /**
6891 * Error severity level.
6892 */
6893 Error = 2
6894 }
6895
6896 /**
6897 * A language status item is the preferred way to present language status reports for the active text editors,
6898 * such as selected linter or notifying about a configuration problem.
6899 */
6900 export interface LanguageStatusItem {
6901
6902 /**
6903 * The identifier of this item.
6904 */
6905 readonly id: string;
6906
6907 /**
6908 * The short name of this item, like 'Java Language Status', etc.
6909 */
6910 name: string | undefined;
6911
6912 /**
6913 * A {@link DocumentSelector selector} that defines for what editors
6914 * this item shows.
6915 */
6916 selector: DocumentSelector;
6917
6918 /**
6919 * The severity of this item.
6920 *
6921 * Defaults to {@link LanguageStatusSeverity.Information information}. You can use this property to
6922 * signal to users that there is a problem that needs attention, like a missing executable or an
6923 * invalid configuration.
6924 */
6925 severity: LanguageStatusSeverity;
6926
6927 /**
6928 * The text to show for the entry. You can embed icons in the text by leveraging the syntax:
6929 *
6930 * `My text $(icon-name) contains icons like $(icon-name) this one.`
6931 *
6932 * Where the icon-name is taken from the ThemeIcon [icon set](https://code.visualstudio.com/api/references/icons-in-labels#icon-listing), e.g.
6933 * `light-bulb`, `thumbsup`, `zap` etc.
6934 */
6935 text: string;
6936
6937 /**
6938 * Optional, human-readable details for this item.
6939 */
6940 detail?: string;
6941
6942 /**
6943 * Controls whether the item is shown as "busy". Defaults to `false`.
6944 */
6945 busy: boolean;
6946
6947 /**
6948 * A {@linkcode Command command} for this item.
6949 */
6950 command: Command | undefined;
6951
6952 /**
6953 * Accessibility information used when a screen reader interacts with this item
6954 */
6955 accessibilityInformation?: AccessibilityInformation;
6956
6957 /**
6958 * Dispose and free associated resources.
6959 */
6960 dispose(): void;
6961 }
6962
6963 /**
6964 * Denotes a location of an editor in the window. Editors can be arranged in a grid
6965 * and each column represents one editor location in that grid by counting the editors
6966 * in order of their appearance.
6967 */
6968 export enum ViewColumn {
6969 /**
6970 * A *symbolic* editor column representing the currently active column. This value
6971 * can be used when opening editors, but the *resolved* {@link TextEditor.viewColumn viewColumn}-value
6972 * of editors will always be `One`, `Two`, `Three`,... or `undefined` but never `Active`.
6973 */
6974 Active = -1,
6975 /**
6976 * A *symbolic* editor column representing the column to the side of the active one. This value
6977 * can be used when opening editors, but the *resolved* {@link TextEditor.viewColumn viewColumn}-value
6978 * of editors will always be `One`, `Two`, `Three`,... or `undefined` but never `Beside`.
6979 */
6980 Beside = -2,
6981 /**
6982 * The first editor column.
6983 */
6984 One = 1,
6985 /**
6986 * The second editor column.
6987 */
6988 Two = 2,
6989 /**
6990 * The third editor column.
6991 */
6992 Three = 3,
6993 /**
6994 * The fourth editor column.
6995 */
6996 Four = 4,
6997 /**
6998 * The fifth editor column.
6999 */
7000 Five = 5,
7001 /**
7002 * The sixth editor column.
7003 */
7004 Six = 6,
7005 /**
7006 * The seventh editor column.
7007 */
7008 Seven = 7,
7009 /**
7010 * The eighth editor column.
7011 */
7012 Eight = 8,
7013 /**
7014 * The ninth editor column.
7015 */
7016 Nine = 9
7017 }
7018
7019 /**
7020 * An output channel is a container for readonly textual information.
7021 *
7022 * To get an instance of an `OutputChannel` use
7023 * {@link window.createOutputChannel createOutputChannel}.
7024 */
7025 export interface OutputChannel {
7026
7027 /**
7028 * The human-readable name of this output channel.
7029 */
7030 readonly name: string;
7031
7032 /**
7033 * Append the given value to the channel.
7034 *
7035 * @param value A string, falsy values will not be printed.
7036 */
7037 append(value: string): void;
7038
7039 /**
7040 * Append the given value and a line feed character
7041 * to the channel.
7042 *
7043 * @param value A string, falsy values will be printed.
7044 */
7045 appendLine(value: string): void;
7046
7047 /**
7048 * Replaces all output from the channel with the given value.
7049 *
7050 * @param value A string, falsy values will not be printed.
7051 */
7052 replace(value: string): void;
7053
7054 /**
7055 * Removes all output from the channel.
7056 */
7057 clear(): void;
7058
7059 /**
7060 * Reveal this channel in the UI.
7061 *
7062 * @param preserveFocus When `true` the channel will not take focus.
7063 */
7064 show(preserveFocus?: boolean): void;
7065
7066 /**
7067 * Reveal this channel in the UI.
7068 *
7069 * @deprecated Use the overload with just one parameter (`show(preserveFocus?: boolean): void`).
7070 *
7071 * @param column This argument is **deprecated** and will be ignored.
7072 * @param preserveFocus When `true` the channel will not take focus.
7073 */
7074 show(column?: ViewColumn, preserveFocus?: boolean): void;
7075
7076 /**
7077 * Hide this channel from the UI.
7078 */
7079 hide(): void;
7080
7081 /**
7082 * Dispose and free associated resources.
7083 */
7084 dispose(): void;
7085 }
7086
7087 /**
7088 * A channel for containing log output.
7089 *
7090 * To get an instance of a `LogOutputChannel` use
7091 * {@link window.createOutputChannel createOutputChannel}.
7092 */
7093 export interface LogOutputChannel extends OutputChannel {
7094
7095 /**
7096 * The current log level of the channel. Defaults to {@link env.logLevel editor log level}.
7097 */
7098 readonly logLevel: LogLevel;
7099
7100 /**
7101 * An {@link Event} which fires when the log level of the channel changes.
7102 */
7103 readonly onDidChangeLogLevel: Event<LogLevel>;
7104
7105 /**
7106 * Outputs the given trace message to the channel. Use this method to log verbose information.
7107 *
7108 * The message is only logged if the channel is configured to display {@link LogLevel.Trace trace} log level.
7109 *
7110 * @param message trace message to log
7111 */
7112 trace(message: string, ...args: any[]): void;
7113
7114 /**
7115 * Outputs the given debug message to the channel.
7116 *
7117 * The message is only logged if the channel is configured to display {@link LogLevel.Debug debug} log level or lower.
7118 *
7119 * @param message debug message to log
7120 */
7121 debug(message: string, ...args: any[]): void;
7122
7123 /**
7124 * Outputs the given information message to the channel.
7125 *
7126 * The message is only logged if the channel is configured to display {@link LogLevel.Info info} log level or lower.
7127 *
7128 * @param message info message to log
7129 */
7130 info(message: string, ...args: any[]): void;
7131
7132 /**
7133 * Outputs the given warning message to the channel.
7134 *
7135 * The message is only logged if the channel is configured to display {@link LogLevel.Warning warning} log level or lower.
7136 *
7137 * @param message warning message to log
7138 */
7139 warn(message: string, ...args: any[]): void;
7140
7141 /**
7142 * Outputs the given error or error message to the channel.
7143 *
7144 * The message is only logged if the channel is configured to display {@link LogLevel.Error error} log level or lower.
7145 *
7146 * @param error Error or error message to log
7147 */
7148 error(error: string | Error, ...args: any[]): void;
7149 }
7150
7151 /**
7152 * Accessibility information which controls screen reader behavior.
7153 */
7154 export interface AccessibilityInformation {
7155 /**
7156 * Label to be read out by a screen reader once the item has focus.
7157 */
7158 readonly label: string;
7159
7160 /**
7161 * Role of the widget which defines how a screen reader interacts with it.
7162 * The role should be set in special cases when for example a tree-like element behaves like a checkbox.
7163 * If role is not specified the editor will pick the appropriate role automatically.
7164 * More about aria roles can be found here https://w3c.github.io/aria/#widget_roles
7165 */
7166 readonly role?: string;
7167 }
7168
7169 /**
7170 * Represents the alignment of status bar items.
7171 */
7172 export enum StatusBarAlignment {
7173
7174 /**
7175 * Aligned to the left side.
7176 */
7177 Left = 1,
7178
7179 /**
7180 * Aligned to the right side.
7181 */
7182 Right = 2
7183 }
7184
7185 /**
7186 * A status bar item is a status bar contribution that can
7187 * show text and icons and run a command on click.
7188 */
7189 export interface StatusBarItem {
7190
7191 /**
7192 * The identifier of this item.
7193 *
7194 * *Note*: if no identifier was provided by the {@linkcode window.createStatusBarItem}
7195 * method, the identifier will match the {@link Extension.id extension identifier}.
7196 */
7197 readonly id: string;
7198
7199 /**
7200 * The alignment of this item.
7201 */
7202 readonly alignment: StatusBarAlignment;
7203
7204 /**
7205 * The priority of this item. Higher value means the item should
7206 * be shown more to the left.
7207 */
7208 readonly priority: number | undefined;
7209
7210 /**
7211 * The name of the entry, like 'Python Language Indicator', 'Git Status' etc.
7212 * Try to keep the length of the name short, yet descriptive enough that
7213 * users can understand what the status bar item is about.
7214 */
7215 name: string | undefined;
7216
7217 /**
7218 * The text to show for the entry. You can embed icons in the text by leveraging the syntax:
7219 *
7220 * `My text $(icon-name) contains icons like $(icon-name) this one.`
7221 *
7222 * Where the icon-name is taken from the ThemeIcon [icon set](https://code.visualstudio.com/api/references/icons-in-labels#icon-listing), e.g.
7223 * `light-bulb`, `thumbsup`, `zap` etc.
7224 */
7225 text: string;
7226
7227 /**
7228 * The tooltip text when you hover over this entry.
7229 */
7230 tooltip: string | MarkdownString | undefined;
7231
7232 /**
7233 * The foreground color for this entry.
7234 */
7235 color: string | ThemeColor | undefined;
7236
7237 /**
7238 * The background color for this entry.
7239 *
7240 * *Note*: only the following colors are supported:
7241 * * `new ThemeColor('statusBarItem.errorBackground')`
7242 * * `new ThemeColor('statusBarItem.warningBackground')`
7243 *
7244 * More background colors may be supported in the future.
7245 *
7246 * *Note*: when a background color is set, the statusbar may override
7247 * the `color` choice to ensure the entry is readable in all themes.
7248 */
7249 backgroundColor: ThemeColor | undefined;
7250
7251 /**
7252 * {@linkcode Command} or identifier of a command to run on click.
7253 *
7254 * The command must be {@link commands.getCommands known}.
7255 *
7256 * Note that if this is a {@linkcode Command} object, only the {@linkcode Command.command command} and {@linkcode Command.arguments arguments}
7257 * are used by the editor.
7258 */
7259 command: string | Command | undefined;
7260
7261 /**
7262 * Accessibility information used when a screen reader interacts with this StatusBar item
7263 */
7264 accessibilityInformation: AccessibilityInformation | undefined;
7265
7266 /**
7267 * Shows the entry in the status bar.
7268 */
7269 show(): void;
7270
7271 /**
7272 * Hide the entry in the status bar.
7273 */
7274 hide(): void;
7275
7276 /**
7277 * Dispose and free associated resources. Call
7278 * {@link StatusBarItem.hide hide}.
7279 */
7280 dispose(): void;
7281 }
7282
7283 /**
7284 * Defines a generalized way of reporting progress updates.
7285 */
7286 export interface Progress<T> {
7287
7288 /**
7289 * Report a progress update.
7290 * @param value A progress item, like a message and/or an
7291 * report on how much work finished
7292 */
7293 report(value: T): void;
7294 }
7295
7296 /**
7297 * An individual terminal instance within the integrated terminal.
7298 */
7299 export interface Terminal {
7300
7301 /**
7302 * The name of the terminal.
7303 */
7304 readonly name: string;
7305
7306 /**
7307 * The process ID of the shell process.
7308 */
7309 readonly processId: Thenable<number | undefined>;
7310
7311 /**
7312 * The object used to initialize the terminal, this is useful for example to detecting the
7313 * shell type of when the terminal was not launched by this extension or for detecting what
7314 * folder the shell was launched in.
7315 */
7316 readonly creationOptions: Readonly<TerminalOptions | ExtensionTerminalOptions>;
7317
7318 /**
7319 * The exit status of the terminal, this will be undefined while the terminal is active.
7320 *
7321 * **Example:** Show a notification with the exit code when the terminal exits with a
7322 * non-zero exit code.
7323 * ```typescript
7324 * window.onDidCloseTerminal(t => {
7325 * if (t.exitStatus && t.exitStatus.code) {
7326 * vscode.window.showInformationMessage(`Exit code: ${t.exitStatus.code}`);
7327 * }
7328 * });
7329 * ```
7330 */
7331 readonly exitStatus: TerminalExitStatus | undefined;
7332
7333 /**
7334 * The current state of the {@link Terminal}.
7335 */
7336 readonly state: TerminalState;
7337
7338 /**
7339 * Send text to the terminal. The text is written to the stdin of the underlying pty process
7340 * (shell) of the terminal.
7341 *
7342 * @param text The text to send.
7343 * @param shouldExecute Indicates that the text being sent should be executed rather than just inserted in the terminal.
7344 * The character(s) added are `\n` or `\r\n`, depending on the platform. This defaults to `true`.
7345 */
7346 sendText(text: string, shouldExecute?: boolean): void;
7347
7348 /**
7349 * Show the terminal panel and reveal this terminal in the UI.
7350 *
7351 * @param preserveFocus When `true` the terminal will not take focus.
7352 */
7353 show(preserveFocus?: boolean): void;
7354
7355 /**
7356 * Hide the terminal panel if this terminal is currently showing.
7357 */
7358 hide(): void;
7359
7360 /**
7361 * Dispose and free associated resources.
7362 */
7363 dispose(): void;
7364 }
7365
7366 /**
7367 * The location of the terminal.
7368 */
7369 export enum TerminalLocation {
7370 /**
7371 * In the terminal view
7372 */
7373 Panel = 1,
7374 /**
7375 * In the editor area
7376 */
7377 Editor = 2,
7378 }
7379
7380 /**
7381 * Assumes a {@link TerminalLocation} of editor and allows specifying a {@link ViewColumn} and
7382 * {@link TerminalEditorLocationOptions.preserveFocus preserveFocus } property
7383 */
7384 export interface TerminalEditorLocationOptions {
7385 /**
7386 * A view column in which the {@link Terminal terminal} should be shown in the editor area.
7387 * The default is the {@link ViewColumn.Active active}. Columns that do not exist
7388 * will be created as needed up to the maximum of {@linkcode ViewColumn.Nine}.
7389 * Use {@linkcode ViewColumn.Beside} to open the editor to the side of the currently
7390 * active one.
7391 */
7392 viewColumn: ViewColumn;
7393 /**
7394 * An optional flag that when `true` will stop the {@link Terminal} from taking focus.
7395 */
7396 preserveFocus?: boolean;
7397 }
7398
7399 /**
7400 * Uses the parent {@link Terminal}'s location for the terminal
7401 */
7402 export interface TerminalSplitLocationOptions {
7403 /**
7404 * The parent terminal to split this terminal beside. This works whether the parent terminal
7405 * is in the panel or the editor area.
7406 */
7407 parentTerminal: Terminal;
7408 }
7409
7410 /**
7411 * Represents the state of a {@link Terminal}.
7412 */
7413 export interface TerminalState {
7414 /**
7415 * Whether the {@link Terminal} has been interacted with. Interaction means that the
7416 * terminal has sent data to the process which depending on the terminal's _mode_. By
7417 * default input is sent when a key is pressed or when a command or extension sends text,
7418 * but based on the terminal's mode it can also happen on:
7419 *
7420 * - a pointer click event
7421 * - a pointer scroll event
7422 * - a pointer move event
7423 * - terminal focus in/out
7424 *
7425 * For more information on events that can send data see "DEC Private Mode Set (DECSET)" on
7426 * https://invisible-island.net/xterm/ctlseqs/ctlseqs.html
7427 */
7428 readonly isInteractedWith: boolean;
7429 }
7430
7431 /**
7432 * Provides information on a line in a terminal in order to provide links for it.
7433 */
7434 export interface TerminalLinkContext {
7435 /**
7436 * This is the text from the unwrapped line in the terminal.
7437 */
7438 line: string;
7439
7440 /**
7441 * The terminal the link belongs to.
7442 */
7443 terminal: Terminal;
7444 }
7445
7446 /**
7447 * A provider that enables detection and handling of links within terminals.
7448 */
7449 export interface TerminalLinkProvider<T extends TerminalLink = TerminalLink> {
7450 /**
7451 * Provide terminal links for the given context. Note that this can be called multiple times
7452 * even before previous calls resolve, make sure to not share global objects (eg. `RegExp`)
7453 * that could have problems when asynchronous usage may overlap.
7454 * @param context Information about what links are being provided for.
7455 * @param token A cancellation token.
7456 * @returns A list of terminal links for the given line.
7457 */
7458 provideTerminalLinks(context: TerminalLinkContext, token: CancellationToken): ProviderResult<T[]>;
7459
7460 /**
7461 * Handle an activated terminal link.
7462 * @param link The link to handle.
7463 */
7464 handleTerminalLink(link: T): ProviderResult<void>;
7465 }
7466
7467 /**
7468 * A link on a terminal line.
7469 */
7470 export class TerminalLink {
7471 /**
7472 * The start index of the link on {@link TerminalLinkContext.line}.
7473 */
7474 startIndex: number;
7475
7476 /**
7477 * The length of the link on {@link TerminalLinkContext.line}.
7478 */
7479 length: number;
7480
7481 /**
7482 * The tooltip text when you hover over this link.
7483 *
7484 * If a tooltip is provided, is will be displayed in a string that includes instructions on
7485 * how to trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary
7486 * depending on OS, user settings, and localization.
7487 */
7488 tooltip?: string;
7489
7490 /**
7491 * Creates a new terminal link.
7492 * @param startIndex The start index of the link on {@link TerminalLinkContext.line}.
7493 * @param length The length of the link on {@link TerminalLinkContext.line}.
7494 * @param tooltip The tooltip text when you hover over this link.
7495 *
7496 * If a tooltip is provided, is will be displayed in a string that includes instructions on
7497 * how to trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary
7498 * depending on OS, user settings, and localization.
7499 */
7500 constructor(startIndex: number, length: number, tooltip?: string);
7501 }
7502
7503 /**
7504 * Provides a terminal profile for the contributed terminal profile when launched via the UI or
7505 * command.
7506 */
7507 export interface TerminalProfileProvider {
7508 /**
7509 * Provide the terminal profile.
7510 * @param token A cancellation token that indicates the result is no longer needed.
7511 * @returns The terminal profile.
7512 */
7513 provideTerminalProfile(token: CancellationToken): ProviderResult<TerminalProfile>;
7514 }
7515
7516 /**
7517 * A terminal profile defines how a terminal will be launched.
7518 */
7519 export class TerminalProfile {
7520 /**
7521 * The options that the terminal will launch with.
7522 */
7523 options: TerminalOptions | ExtensionTerminalOptions;
7524
7525 /**
7526 * Creates a new terminal profile.
7527 * @param options The options that the terminal will launch with.
7528 */
7529 constructor(options: TerminalOptions | ExtensionTerminalOptions);
7530 }
7531
7532 /**
7533 * A file decoration represents metadata that can be rendered with a file.
7534 */
7535 export class FileDecoration {
7536
7537 /**
7538 * A very short string that represents this decoration.
7539 */
7540 badge?: string;
7541
7542 /**
7543 * A human-readable tooltip for this decoration.
7544 */
7545 tooltip?: string;
7546
7547 /**
7548 * The color of this decoration.
7549 */
7550 color?: ThemeColor;
7551
7552 /**
7553 * A flag expressing that this decoration should be
7554 * propagated to its parents.
7555 */
7556 propagate?: boolean;
7557
7558 /**
7559 * Creates a new decoration.
7560 *
7561 * @param badge A letter that represents the decoration.
7562 * @param tooltip The tooltip of the decoration.
7563 * @param color The color of the decoration.
7564 */
7565 constructor(badge?: string, tooltip?: string, color?: ThemeColor);
7566 }
7567
7568 /**
7569 * The decoration provider interfaces defines the contract between extensions and
7570 * file decorations.
7571 */
7572 export interface FileDecorationProvider {
7573
7574 /**
7575 * An optional event to signal that decorations for one or many files have changed.
7576 *
7577 * *Note* that this event should be used to propagate information about children.
7578 *
7579 * @see {@link EventEmitter}
7580 */
7581 onDidChangeFileDecorations?: Event<undefined | Uri | Uri[]>;
7582
7583 /**
7584 * Provide decorations for a given uri.
7585 *
7586 * *Note* that this function is only called when a file gets rendered in the UI.
7587 * This means a decoration from a descendent that propagates upwards must be signaled
7588 * to the editor via the {@link FileDecorationProvider.onDidChangeFileDecorations onDidChangeFileDecorations}-event.
7589 *
7590 * @param uri The uri of the file to provide a decoration for.
7591 * @param token A cancellation token.
7592 * @returns A decoration or a thenable that resolves to such.
7593 */
7594 provideFileDecoration(uri: Uri, token: CancellationToken): ProviderResult<FileDecoration>;
7595 }
7596
7597
7598 /**
7599 * In a remote window the extension kind describes if an extension
7600 * runs where the UI (window) runs or if an extension runs remotely.
7601 */
7602 export enum ExtensionKind {
7603
7604 /**
7605 * Extension runs where the UI runs.
7606 */
7607 UI = 1,
7608
7609 /**
7610 * Extension runs where the remote extension host runs.
7611 */
7612 Workspace = 2
7613 }
7614
7615 /**
7616 * Represents an extension.
7617 *
7618 * To get an instance of an `Extension` use {@link extensions.getExtension getExtension}.
7619 */
7620 export interface Extension<T> {
7621
7622 /**
7623 * The canonical extension identifier in the form of: `publisher.name`.
7624 */
7625 readonly id: string;
7626
7627 /**
7628 * The uri of the directory containing the extension.
7629 */
7630 readonly extensionUri: Uri;
7631
7632 /**
7633 * The absolute file path of the directory containing this extension. Shorthand
7634 * notation for {@link Extension.extensionUri Extension.extensionUri.fsPath} (independent of the uri scheme).
7635 */
7636 readonly extensionPath: string;
7637
7638 /**
7639 * `true` if the extension has been activated.
7640 */
7641 readonly isActive: boolean;
7642
7643 /**
7644 * The parsed contents of the extension's package.json.
7645 */
7646 readonly packageJSON: any;
7647
7648 /**
7649 * The extension kind describes if an extension runs where the UI runs
7650 * or if an extension runs where the remote extension host runs. The extension kind
7651 * is defined in the `package.json`-file of extensions but can also be refined
7652 * via the `remote.extensionKind`-setting. When no remote extension host exists,
7653 * the value is {@linkcode ExtensionKind.UI}.
7654 */
7655 extensionKind: ExtensionKind;
7656
7657 /**
7658 * The public API exported by this extension (return value of `activate`).
7659 * It is an invalid action to access this field before this extension has been activated.
7660 */
7661 readonly exports: T;
7662
7663 /**
7664 * Activates this extension and returns its public API.
7665 *
7666 * @returns A promise that will resolve when this extension has been activated.
7667 */
7668 activate(): Thenable<T>;
7669 }
7670
7671 /**
7672 * The ExtensionMode is provided on the `ExtensionContext` and indicates the
7673 * mode the specific extension is running in.
7674 */
7675 export enum ExtensionMode {
7676 /**
7677 * The extension is installed normally (for example, from the marketplace
7678 * or VSIX) in the editor.
7679 */
7680 Production = 1,
7681
7682 /**
7683 * The extension is running from an `--extensionDevelopmentPath` provided
7684 * when launching the editor.
7685 */
7686 Development = 2,
7687
7688 /**
7689 * The extension is running from an `--extensionTestsPath` and
7690 * the extension host is running unit tests.
7691 */
7692 Test = 3,
7693 }
7694
7695 /**
7696 * An extension context is a collection of utilities private to an
7697 * extension.
7698 *
7699 * An instance of an `ExtensionContext` is provided as the first
7700 * parameter to the `activate`-call of an extension.
7701 */
7702 export interface ExtensionContext {
7703
7704 /**
7705 * An array to which disposables can be added. When this
7706 * extension is deactivated the disposables will be disposed.
7707 *
7708 * *Note* that asynchronous dispose-functions aren't awaited.
7709 */
7710 readonly subscriptions: {
7711 /**
7712 * Function to clean up resources.
7713 */
7714 dispose(): any;
7715 }[];
7716
7717 /**
7718 * A memento object that stores state in the context
7719 * of the currently opened {@link workspace.workspaceFolders workspace}.
7720 */
7721 readonly workspaceState: Memento;
7722
7723 /**
7724 * A memento object that stores state independent
7725 * of the current opened {@link workspace.workspaceFolders workspace}.
7726 */
7727 readonly globalState: Memento & {
7728 /**
7729 * Set the keys whose values should be synchronized across devices when synchronizing user-data
7730 * like configuration, extensions, and mementos.
7731 *
7732 * Note that this function defines the whole set of keys whose values are synchronized:
7733 * - calling it with an empty array stops synchronization for this memento
7734 * - calling it with a non-empty array replaces all keys whose values are synchronized
7735 *
7736 * For any given set of keys this function needs to be called only once but there is no harm in
7737 * repeatedly calling it.
7738 *
7739 * @param keys The set of keys whose values are synced.
7740 */
7741 setKeysForSync(keys: readonly string[]): void;
7742 };
7743
7744 /**
7745 * A storage utility for secrets. Secrets are persisted across reloads and are independent of the
7746 * current opened {@link workspace.workspaceFolders workspace}.
7747 */
7748 readonly secrets: SecretStorage;
7749
7750 /**
7751 * The uri of the directory containing the extension.
7752 */
7753 readonly extensionUri: Uri;
7754
7755 /**
7756 * The absolute file path of the directory containing the extension. Shorthand
7757 * notation for {@link TextDocument.uri ExtensionContext.extensionUri.fsPath} (independent of the uri scheme).
7758 */
7759 readonly extensionPath: string;
7760
7761 /**
7762 * Gets the extension's global environment variable collection for this workspace, enabling changes to be
7763 * applied to terminal environment variables.
7764 */
7765 readonly environmentVariableCollection: GlobalEnvironmentVariableCollection;
7766
7767 /**
7768 * Get the absolute path of a resource contained in the extension.
7769 *
7770 * *Note* that an absolute uri can be constructed via {@linkcode Uri.joinPath} and
7771 * {@linkcode ExtensionContext.extensionUri extensionUri}, e.g. `vscode.Uri.joinPath(context.extensionUri, relativePath);`
7772 *
7773 * @param relativePath A relative path to a resource contained in the extension.
7774 * @returns The absolute path of the resource.
7775 */
7776 asAbsolutePath(relativePath: string): string;
7777
7778 /**
7779 * The uri of a workspace specific directory in which the extension
7780 * can store private state. The directory might not exist and creation is
7781 * up to the extension. However, the parent directory is guaranteed to be existent.
7782 * The value is `undefined` when no workspace nor folder has been opened.
7783 *
7784 * Use {@linkcode ExtensionContext.workspaceState workspaceState} or
7785 * {@linkcode ExtensionContext.globalState globalState} to store key value data.
7786 *
7787 * @see {@linkcode FileSystem workspace.fs} for how to read and write files and folders from
7788 * an uri.
7789 */
7790 readonly storageUri: Uri | undefined;
7791
7792 /**
7793 * An absolute file path of a workspace specific directory in which the extension
7794 * can store private state. The directory might not exist on disk and creation is
7795 * up to the extension. However, the parent directory is guaranteed to be existent.
7796 *
7797 * Use {@linkcode ExtensionContext.workspaceState workspaceState} or
7798 * {@linkcode ExtensionContext.globalState globalState} to store key value data.
7799 *
7800 * @deprecated Use {@link ExtensionContext.storageUri storageUri} instead.
7801 */
7802 readonly storagePath: string | undefined;
7803
7804 /**
7805 * The uri of a directory in which the extension can store global state.
7806 * The directory might not exist on disk and creation is
7807 * up to the extension. However, the parent directory is guaranteed to be existent.
7808 *
7809 * Use {@linkcode ExtensionContext.globalState globalState} to store key value data.
7810 *
7811 * @see {@linkcode FileSystem workspace.fs} for how to read and write files and folders from
7812 * an uri.
7813 */
7814 readonly globalStorageUri: Uri;
7815
7816 /**
7817 * An absolute file path in which the extension can store global state.
7818 * The directory might not exist on disk and creation is
7819 * up to the extension. However, the parent directory is guaranteed to be existent.
7820 *
7821 * Use {@linkcode ExtensionContext.globalState globalState} to store key value data.
7822 *
7823 * @deprecated Use {@link ExtensionContext.globalStorageUri globalStorageUri} instead.
7824 */
7825 readonly globalStoragePath: string;
7826
7827 /**
7828 * The uri of a directory in which the extension can create log files.
7829 * The directory might not exist on disk and creation is up to the extension. However,
7830 * the parent directory is guaranteed to be existent.
7831 *
7832 * @see {@linkcode FileSystem workspace.fs} for how to read and write files and folders from
7833 * an uri.
7834 */
7835 readonly logUri: Uri;
7836
7837 /**
7838 * An absolute file path of a directory in which the extension can create log files.
7839 * The directory might not exist on disk and creation is up to the extension. However,
7840 * the parent directory is guaranteed to be existent.
7841 *
7842 * @deprecated Use {@link ExtensionContext.logUri logUri} instead.
7843 */
7844 readonly logPath: string;
7845
7846 /**
7847 * The mode the extension is running in. See {@link ExtensionMode}
7848 * for possible values and scenarios.
7849 */
7850 readonly extensionMode: ExtensionMode;
7851
7852 /**
7853 * The current `Extension` instance.
7854 */
7855 readonly extension: Extension<any>;
7856
7857 /**
7858 * An object that keeps information about how this extension can use language models.
7859 *
7860 * @see {@link LanguageModelChat.sendRequest}
7861 */
7862 readonly languageModelAccessInformation: LanguageModelAccessInformation;
7863 }
7864
7865 /**
7866 * A memento represents a storage utility. It can store and retrieve
7867 * values.
7868 */
7869 export interface Memento {
7870
7871 /**
7872 * Returns the stored keys.
7873 *
7874 * @returns The stored keys.
7875 */
7876 keys(): readonly string[];
7877
7878 /**
7879 * Return a value.
7880 *
7881 * @param key A string.
7882 * @returns The stored value or `undefined`.
7883 */
7884 get<T>(key: string): T | undefined;
7885
7886 /**
7887 * Return a value.
7888 *
7889 * @param key A string.
7890 * @param defaultValue A value that should be returned when there is no
7891 * value (`undefined`) with the given key.
7892 * @returns The stored value or the defaultValue.
7893 */
7894 get<T>(key: string, defaultValue: T): T;
7895
7896 /**
7897 * Store a value. The value must be JSON-stringifyable.
7898 *
7899 * *Note* that using `undefined` as value removes the key from the underlying
7900 * storage.
7901 *
7902 * @param key A string.
7903 * @param value A value. MUST not contain cyclic references.
7904 */
7905 update(key: string, value: any): Thenable<void>;
7906 }
7907
7908 /**
7909 * The event data that is fired when a secret is added or removed.
7910 */
7911 export interface SecretStorageChangeEvent {
7912 /**
7913 * The key of the secret that has changed.
7914 */
7915 readonly key: string;
7916 }
7917
7918 /**
7919 * Represents a storage utility for secrets, information that is
7920 * sensitive.
7921 */
7922 export interface SecretStorage {
7923 /**
7924 * Retrieve a secret that was stored with key. Returns undefined if there
7925 * is no password matching that key.
7926 * @param key The key the secret was stored under.
7927 * @returns The stored value or `undefined`.
7928 */
7929 get(key: string): Thenable<string | undefined>;
7930
7931 /**
7932 * Store a secret under a given key.
7933 * @param key The key to store the secret under.
7934 * @param value The secret.
7935 */
7936 store(key: string, value: string): Thenable<void>;
7937
7938 /**
7939 * Remove a secret from storage.
7940 * @param key The key the secret was stored under.
7941 */
7942 delete(key: string): Thenable<void>;
7943
7944 /**
7945 * Fires when a secret is stored or deleted.
7946 */
7947 onDidChange: Event<SecretStorageChangeEvent>;
7948 }
7949
7950 /**
7951 * Represents a color theme kind.
7952 */
7953 export enum ColorThemeKind {
7954 /**
7955 * A light color theme.
7956 */
7957 Light = 1,
7958 /**
7959 * A dark color theme.
7960 */
7961 Dark = 2,
7962 /**
7963 * A dark high contrast color theme.
7964 */
7965 HighContrast = 3,
7966 /**
7967 * A light high contrast color theme.
7968 */
7969 HighContrastLight = 4
7970 }
7971
7972 /**
7973 * Represents a color theme.
7974 */
7975 export interface ColorTheme {
7976
7977 /**
7978 * The kind of this color theme: light, dark, high contrast dark and high contrast light.
7979 */
7980 readonly kind: ColorThemeKind;
7981 }
7982
7983 /**
7984 * Controls the behaviour of the terminal's visibility.
7985 */
7986 export enum TaskRevealKind {
7987 /**
7988 * Always brings the terminal to front if the task is executed.
7989 */
7990 Always = 1,
7991
7992 /**
7993 * Only brings the terminal to front if a problem is detected executing the task
7994 * (e.g. the task couldn't be started because).
7995 */
7996 Silent = 2,
7997
7998 /**
7999 * The terminal never comes to front when the task is executed.
8000 */
8001 Never = 3
8002 }
8003
8004 /**
8005 * Controls how the task channel is used between tasks
8006 */
8007 export enum TaskPanelKind {
8008
8009 /**
8010 * Shares a panel with other tasks. This is the default.
8011 */
8012 Shared = 1,
8013
8014 /**
8015 * Uses a dedicated panel for this tasks. The panel is not
8016 * shared with other tasks.
8017 */
8018 Dedicated = 2,
8019
8020 /**
8021 * Creates a new panel whenever this task is executed.
8022 */
8023 New = 3
8024 }
8025
8026 /**
8027 * Controls how the task is presented in the UI.
8028 */
8029 export interface TaskPresentationOptions {
8030 /**
8031 * Controls whether the task output is reveal in the user interface.
8032 * Defaults to `RevealKind.Always`.
8033 */
8034 reveal?: TaskRevealKind;
8035
8036 /**
8037 * Controls whether the command associated with the task is echoed
8038 * in the user interface.
8039 */
8040 echo?: boolean;
8041
8042 /**
8043 * Controls whether the panel showing the task output is taking focus.
8044 */
8045 focus?: boolean;
8046
8047 /**
8048 * Controls if the task panel is used for this task only (dedicated),
8049 * shared between tasks (shared) or if a new panel is created on
8050 * every task execution (new). Defaults to `TaskInstanceKind.Shared`
8051 */
8052 panel?: TaskPanelKind;
8053
8054 /**
8055 * Controls whether to show the "Terminal will be reused by tasks, press any key to close it" message.
8056 */
8057 showReuseMessage?: boolean;
8058
8059 /**
8060 * Controls whether the terminal is cleared before executing the task.
8061 */
8062 clear?: boolean;
8063
8064 /**
8065 * Controls whether the terminal is closed after executing the task.
8066 */
8067 close?: boolean;
8068 }
8069
8070 /**
8071 * A grouping for tasks. The editor by default supports the
8072 * 'Clean', 'Build', 'RebuildAll' and 'Test' group.
8073 */
8074 export class TaskGroup {
8075
8076 /**
8077 * The clean task group;
8078 */
8079 static Clean: TaskGroup;
8080
8081 /**
8082 * The build task group;
8083 */
8084 static Build: TaskGroup;
8085
8086 /**
8087 * The rebuild all task group;
8088 */
8089 static Rebuild: TaskGroup;
8090
8091 /**
8092 * The test all task group;
8093 */
8094 static Test: TaskGroup;
8095
8096 /**
8097 * Whether the task that is part of this group is the default for the group.
8098 * This property cannot be set through API, and is controlled by a user's task configurations.
8099 */
8100 readonly isDefault: boolean | undefined;
8101
8102 /**
8103 * The ID of the task group. Is one of TaskGroup.Clean.id, TaskGroup.Build.id, TaskGroup.Rebuild.id, or TaskGroup.Test.id.
8104 */
8105 readonly id: string;
8106
8107 /**
8108 * Private constructor
8109 *
8110 * @param id Identifier of a task group.
8111 * @param label The human-readable name of a task group.
8112 */
8113 private constructor(id: string, label: string);
8114 }
8115
8116 /**
8117 * A structure that defines a task kind in the system.
8118 * The value must be JSON-stringifyable.
8119 */
8120 export interface TaskDefinition {
8121 /**
8122 * The task definition describing the task provided by an extension.
8123 * Usually a task provider defines more properties to identify
8124 * a task. They need to be defined in the package.json of the
8125 * extension under the 'taskDefinitions' extension point. The npm
8126 * task definition for example looks like this
8127 * ```typescript
8128 * interface NpmTaskDefinition extends TaskDefinition {
8129 * script: string;
8130 * }
8131 * ```
8132 *
8133 * Note that type identifier starting with a '$' are reserved for internal
8134 * usages and shouldn't be used by extensions.
8135 */
8136 readonly type: string;
8137
8138 /**
8139 * Additional attributes of a concrete task definition.
8140 */
8141 [name: string]: any;
8142 }
8143
8144 /**
8145 * Options for a process execution
8146 */
8147 export interface ProcessExecutionOptions {
8148 /**
8149 * The current working directory of the executed program or shell.
8150 * If omitted the tools current workspace root is used.
8151 */
8152 cwd?: string;
8153
8154 /**
8155 * The additional environment of the executed program or shell. If omitted
8156 * the parent process' environment is used. If provided it is merged with
8157 * the parent process' environment.
8158 */
8159 env?: { [key: string]: string };
8160 }
8161
8162 /**
8163 * The execution of a task happens as an external process
8164 * without shell interaction.
8165 */
8166 export class ProcessExecution {
8167
8168 /**
8169 * Creates a process execution.
8170 *
8171 * @param process The process to start.
8172 * @param options Optional options for the started process.
8173 */
8174 constructor(process: string, options?: ProcessExecutionOptions);
8175
8176 /**
8177 * Creates a process execution.
8178 *
8179 * @param process The process to start.
8180 * @param args Arguments to be passed to the process.
8181 * @param options Optional options for the started process.
8182 */
8183 constructor(process: string, args: string[], options?: ProcessExecutionOptions);
8184
8185 /**
8186 * The process to be executed.
8187 */
8188 process: string;
8189
8190 /**
8191 * The arguments passed to the process. Defaults to an empty array.
8192 */
8193 args: string[];
8194
8195 /**
8196 * The process options used when the process is executed.
8197 * Defaults to undefined.
8198 */
8199 options?: ProcessExecutionOptions;
8200 }
8201
8202 /**
8203 * The shell quoting options.
8204 */
8205 export interface ShellQuotingOptions {
8206
8207 /**
8208 * The character used to do character escaping. If a string is provided only spaces
8209 * are escaped. If a `{ escapeChar, charsToEscape }` literal is provide all characters
8210 * in `charsToEscape` are escaped using the `escapeChar`.
8211 */
8212 escape?: string | {
8213 /**
8214 * The escape character.
8215 */
8216 escapeChar: string;
8217 /**
8218 * The characters to escape.
8219 */
8220 charsToEscape: string;
8221 };
8222
8223 /**
8224 * The character used for strong quoting. The string's length must be 1.
8225 */
8226 strong?: string;
8227
8228 /**
8229 * The character used for weak quoting. The string's length must be 1.
8230 */
8231 weak?: string;
8232 }
8233
8234 /**
8235 * Options for a shell execution
8236 */
8237 export interface ShellExecutionOptions {
8238 /**
8239 * The shell executable.
8240 */
8241 executable?: string;
8242
8243 /**
8244 * The arguments to be passed to the shell executable used to run the task. Most shells
8245 * require special arguments to execute a command. For example `bash` requires the `-c`
8246 * argument to execute a command, `PowerShell` requires `-Command` and `cmd` requires both
8247 * `/d` and `/c`.
8248 */
8249 shellArgs?: string[];
8250
8251 /**
8252 * The shell quotes supported by this shell.
8253 */
8254 shellQuoting?: ShellQuotingOptions;
8255
8256 /**
8257 * The current working directory of the executed shell.
8258 * If omitted the tools current workspace root is used.
8259 */
8260 cwd?: string;
8261
8262 /**
8263 * The additional environment of the executed shell. If omitted
8264 * the parent process' environment is used. If provided it is merged with
8265 * the parent process' environment.
8266 */
8267 env?: { [key: string]: string };
8268 }
8269
8270 /**
8271 * Defines how an argument should be quoted if it contains
8272 * spaces or unsupported characters.
8273 */
8274 export enum ShellQuoting {
8275
8276 /**
8277 * Character escaping should be used. This for example
8278 * uses \ on bash and ` on PowerShell.
8279 */
8280 Escape = 1,
8281
8282 /**
8283 * Strong string quoting should be used. This for example
8284 * uses " for Windows cmd and ' for bash and PowerShell.
8285 * Strong quoting treats arguments as literal strings.
8286 * Under PowerShell echo 'The value is $(2 * 3)' will
8287 * print `The value is $(2 * 3)`
8288 */
8289 Strong = 2,
8290
8291 /**
8292 * Weak string quoting should be used. This for example
8293 * uses " for Windows cmd, bash and PowerShell. Weak quoting
8294 * still performs some kind of evaluation inside the quoted
8295 * string. Under PowerShell echo "The value is $(2 * 3)"
8296 * will print `The value is 6`
8297 */
8298 Weak = 3
8299 }
8300
8301 /**
8302 * A string that will be quoted depending on the used shell.
8303 */
8304 export interface ShellQuotedString {
8305 /**
8306 * The actual string value.
8307 */
8308 value: string;
8309
8310 /**
8311 * The quoting style to use.
8312 */
8313 quoting: ShellQuoting;
8314 }
8315
8316 /**
8317 * Represents a task execution that happens inside a shell.
8318 */
8319 export class ShellExecution {
8320 /**
8321 * Creates a shell execution with a full command line.
8322 *
8323 * @param commandLine The command line to execute.
8324 * @param options Optional options for the started the shell.
8325 */
8326 constructor(commandLine: string, options?: ShellExecutionOptions);
8327
8328 /**
8329 * Creates a shell execution with a command and arguments. For the real execution the editor will
8330 * construct a command line from the command and the arguments. This is subject to interpretation
8331 * especially when it comes to quoting. If full control over the command line is needed please
8332 * use the constructor that creates a `ShellExecution` with the full command line.
8333 *
8334 * @param command The command to execute.
8335 * @param args The command arguments.
8336 * @param options Optional options for the started the shell.
8337 */
8338 constructor(command: string | ShellQuotedString, args: (string | ShellQuotedString)[], options?: ShellExecutionOptions);
8339
8340 /**
8341 * The shell command line. Is `undefined` if created with a command and arguments.
8342 */
8343 commandLine: string | undefined;
8344
8345 /**
8346 * The shell command. Is `undefined` if created with a full command line.
8347 */
8348 command: string | ShellQuotedString;
8349
8350 /**
8351 * The shell args. Is `undefined` if created with a full command line.
8352 */
8353 args: (string | ShellQuotedString)[];
8354
8355 /**
8356 * The shell options used when the command line is executed in a shell.
8357 * Defaults to undefined.
8358 */
8359 options?: ShellExecutionOptions;
8360 }
8361
8362 /**
8363 * Class used to execute an extension callback as a task.
8364 */
8365 export class CustomExecution {
8366 /**
8367 * Constructs a CustomExecution task object. The callback will be executed when the task is run, at which point the
8368 * extension should return the Pseudoterminal it will "run in". The task should wait to do further execution until
8369 * {@link Pseudoterminal.open} is called. Task cancellation should be handled using
8370 * {@link Pseudoterminal.close}. When the task is complete fire
8371 * {@link Pseudoterminal.onDidClose}.
8372 * @param callback The callback that will be called when the task is started by a user. Any ${} style variables that
8373 * were in the task definition will be resolved and passed into the callback as `resolvedDefinition`.
8374 */
8375 constructor(callback: (resolvedDefinition: TaskDefinition) => Thenable<Pseudoterminal>);
8376 }
8377
8378 /**
8379 * The scope of a task.
8380 */
8381 export enum TaskScope {
8382 /**
8383 * The task is a global task. Global tasks are currently not supported.
8384 */
8385 Global = 1,
8386
8387 /**
8388 * The task is a workspace task
8389 */
8390 Workspace = 2
8391 }
8392
8393 /**
8394 * Run options for a task.
8395 */
8396 export interface RunOptions {
8397 /**
8398 * Controls whether task variables are re-evaluated on rerun.
8399 */
8400 reevaluateOnRerun?: boolean;
8401 }
8402
8403 /**
8404 * A task to execute
8405 */
8406 export class Task {
8407
8408 /**
8409 * Creates a new task.
8410 *
8411 * @param taskDefinition The task definition as defined in the taskDefinitions extension point.
8412 * @param scope Specifies the task's scope. It is either a global or a workspace task or a task for a specific workspace folder. Global tasks are currently not supported.
8413 * @param name The task's name. Is presented in the user interface.
8414 * @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
8415 * @param execution The process or shell execution.
8416 * @param problemMatchers the names of problem matchers to use, like '$tsc'
8417 * or '$eslint'. Problem matchers can be contributed by an extension using
8418 * the `problemMatchers` extension point.
8419 */
8420 constructor(taskDefinition: TaskDefinition, scope: WorkspaceFolder | TaskScope.Global | TaskScope.Workspace, name: string, source: string, execution?: ProcessExecution | ShellExecution | CustomExecution, problemMatchers?: string | string[]);
8421
8422 /**
8423 * Creates a new task.
8424 *
8425 * @deprecated Use the new constructors that allow specifying a scope for the task.
8426 *
8427 * @param taskDefinition The task definition as defined in the taskDefinitions extension point.
8428 * @param name The task's name. Is presented in the user interface.
8429 * @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
8430 * @param execution The process or shell execution.
8431 * @param problemMatchers the names of problem matchers to use, like '$tsc'
8432 * or '$eslint'. Problem matchers can be contributed by an extension using
8433 * the `problemMatchers` extension point.
8434 */
8435 constructor(taskDefinition: TaskDefinition, name: string, source: string, execution?: ProcessExecution | ShellExecution, problemMatchers?: string | string[]);
8436
8437 /**
8438 * The task's definition.
8439 */
8440 definition: TaskDefinition;
8441
8442 /**
8443 * The task's scope.
8444 */
8445 readonly scope: TaskScope.Global | TaskScope.Workspace | WorkspaceFolder | undefined;
8446
8447 /**
8448 * The task's name
8449 */
8450 name: string;
8451
8452 /**
8453 * A human-readable string which is rendered less prominently on a separate line in places
8454 * where the task's name is displayed. Supports rendering of {@link ThemeIcon theme icons}
8455 * via the `$(<name>)`-syntax.
8456 */
8457 detail?: string;
8458
8459 /**
8460 * The task's execution engine
8461 */
8462 execution?: ProcessExecution | ShellExecution | CustomExecution;
8463
8464 /**
8465 * Whether the task is a background task or not.
8466 */
8467 isBackground: boolean;
8468
8469 /**
8470 * A human-readable string describing the source of this shell task, e.g. 'gulp'
8471 * or 'npm'. Supports rendering of {@link ThemeIcon theme icons} via the `$(<name>)`-syntax.
8472 */
8473 source: string;
8474
8475 /**
8476 * The task group this tasks belongs to. See TaskGroup
8477 * for a predefined set of available groups.
8478 * Defaults to undefined meaning that the task doesn't
8479 * belong to any special group.
8480 */
8481 group?: TaskGroup;
8482
8483 /**
8484 * The presentation options. Defaults to an empty literal.
8485 */
8486 presentationOptions: TaskPresentationOptions;
8487
8488 /**
8489 * The problem matchers attached to the task. Defaults to an empty
8490 * array.
8491 */
8492 problemMatchers: string[];
8493
8494 /**
8495 * Run options for the task
8496 */
8497 runOptions: RunOptions;
8498 }
8499
8500 /**
8501 * A task provider allows to add tasks to the task service.
8502 * A task provider is registered via {@link tasks.registerTaskProvider}.
8503 */
8504 export interface TaskProvider<T extends Task = Task> {
8505 /**
8506 * Provides tasks.
8507 * @param token A cancellation token.
8508 * @returns an array of tasks
8509 */
8510 provideTasks(token: CancellationToken): ProviderResult<T[]>;
8511
8512 /**
8513 * Resolves a task that has no {@linkcode Task.execution execution} set. Tasks are
8514 * often created from information found in the `tasks.json`-file. Such tasks miss
8515 * the information on how to execute them and a task provider must fill in
8516 * the missing information in the `resolveTask`-method. This method will not be
8517 * called for tasks returned from the above `provideTasks` method since those
8518 * tasks are always fully resolved. A valid default implementation for the
8519 * `resolveTask` method is to return `undefined`.
8520 *
8521 * Note that when filling in the properties of `task`, you _must_ be sure to
8522 * use the exact same `TaskDefinition` and not create a new one. Other properties
8523 * may be changed.
8524 *
8525 * @param task The task to resolve.
8526 * @param token A cancellation token.
8527 * @returns The resolved task
8528 */
8529 resolveTask(task: T, token: CancellationToken): ProviderResult<T>;
8530 }
8531
8532 /**
8533 * An object representing an executed Task. It can be used
8534 * to terminate a task.
8535 *
8536 * This interface is not intended to be implemented.
8537 */
8538 export interface TaskExecution {
8539 /**
8540 * The task that got started.
8541 */
8542 task: Task;
8543
8544 /**
8545 * Terminates the task execution.
8546 */
8547 terminate(): void;
8548 }
8549
8550 /**
8551 * An event signaling the start of a task execution.
8552 *
8553 * This interface is not intended to be implemented.
8554 */
8555 interface TaskStartEvent {
8556 /**
8557 * The task item representing the task that got started.
8558 */
8559 readonly execution: TaskExecution;
8560 }
8561
8562 /**
8563 * An event signaling the end of an executed task.
8564 *
8565 * This interface is not intended to be implemented.
8566 */
8567 interface TaskEndEvent {
8568 /**
8569 * The task item representing the task that finished.
8570 */
8571 readonly execution: TaskExecution;
8572 }
8573
8574 /**
8575 * An event signaling the start of a process execution
8576 * triggered through a task
8577 */
8578 export interface TaskProcessStartEvent {
8579
8580 /**
8581 * The task execution for which the process got started.
8582 */
8583 readonly execution: TaskExecution;
8584
8585 /**
8586 * The underlying process id.
8587 */
8588 readonly processId: number;
8589 }
8590
8591 /**
8592 * An event signaling the end of a process execution
8593 * triggered through a task
8594 */
8595 export interface TaskProcessEndEvent {
8596
8597 /**
8598 * The task execution for which the process got started.
8599 */
8600 readonly execution: TaskExecution;
8601
8602 /**
8603 * The process's exit code. Will be `undefined` when the task is terminated.
8604 */
8605 readonly exitCode: number | undefined;
8606 }
8607
8608 /**
8609 * A task filter denotes tasks by their version and types
8610 */
8611 export interface TaskFilter {
8612 /**
8613 * The task version as used in the tasks.json file.
8614 * The string support the package.json semver notation.
8615 */
8616 version?: string;
8617
8618 /**
8619 * The task type to return;
8620 */
8621 type?: string;
8622 }
8623
8624 /**
8625 * Namespace for tasks functionality.
8626 */
8627 export namespace tasks {
8628
8629 /**
8630 * Register a task provider.
8631 *
8632 * @param type The task kind type this provider is registered for.
8633 * @param provider A task provider.
8634 * @returns A {@link Disposable} that unregisters this provider when being disposed.
8635 */
8636 export function registerTaskProvider(type: string, provider: TaskProvider): Disposable;
8637
8638 /**
8639 * Fetches all tasks available in the systems. This includes tasks
8640 * from `tasks.json` files as well as tasks from task providers
8641 * contributed through extensions.
8642 *
8643 * @param filter Optional filter to select tasks of a certain type or version.
8644 * @returns A thenable that resolves to an array of tasks.
8645 */
8646 export function fetchTasks(filter?: TaskFilter): Thenable<Task[]>;
8647
8648 /**
8649 * Executes a task that is managed by the editor. The returned
8650 * task execution can be used to terminate the task.
8651 *
8652 * @throws When running a ShellExecution or a ProcessExecution
8653 * task in an environment where a new process cannot be started.
8654 * In such an environment, only CustomExecution tasks can be run.
8655 *
8656 * @param task the task to execute
8657 * @returns A thenable that resolves to a task execution.
8658 */
8659 export function executeTask(task: Task): Thenable<TaskExecution>;
8660
8661 /**
8662 * The currently active task executions or an empty array.
8663 */
8664 export const taskExecutions: readonly TaskExecution[];
8665
8666 /**
8667 * Fires when a task starts.
8668 */
8669 export const onDidStartTask: Event<TaskStartEvent>;
8670
8671 /**
8672 * Fires when a task ends.
8673 */
8674 export const onDidEndTask: Event<TaskEndEvent>;
8675
8676 /**
8677 * Fires when the underlying process has been started.
8678 * This event will not fire for tasks that don't
8679 * execute an underlying process.
8680 */
8681 export const onDidStartTaskProcess: Event<TaskProcessStartEvent>;
8682
8683 /**
8684 * Fires when the underlying process has ended.
8685 * This event will not fire for tasks that don't
8686 * execute an underlying process.
8687 */
8688 export const onDidEndTaskProcess: Event<TaskProcessEndEvent>;
8689 }
8690
8691 /**
8692 * Enumeration of file types. The types `File` and `Directory` can also be
8693 * a symbolic links, in that case use `FileType.File | FileType.SymbolicLink` and
8694 * `FileType.Directory | FileType.SymbolicLink`.
8695 */
8696 export enum FileType {
8697 /**
8698 * The file type is unknown.
8699 */
8700 Unknown = 0,
8701 /**
8702 * A regular file.
8703 */
8704 File = 1,
8705 /**
8706 * A directory.
8707 */
8708 Directory = 2,
8709 /**
8710 * A symbolic link to a file.
8711 */
8712 SymbolicLink = 64
8713 }
8714
8715 /**
8716 * Permissions of a file.
8717 */
8718 export enum FilePermission {
8719 /**
8720 * The file is readonly.
8721 *
8722 * *Note:* All `FileStat` from a `FileSystemProvider` that is registered with
8723 * the option `isReadonly: true` will be implicitly handled as if `FilePermission.Readonly`
8724 * is set. As a consequence, it is not possible to have a readonly file system provider
8725 * registered where some `FileStat` are not readonly.
8726 */
8727 Readonly = 1
8728 }
8729
8730 /**
8731 * The `FileStat`-type represents metadata about a file
8732 */
8733 export interface FileStat {
8734 /**
8735 * The type of the file, e.g. is a regular file, a directory, or symbolic link
8736 * to a file.
8737 *
8738 * *Note:* This value might be a bitmask, e.g. `FileType.File | FileType.SymbolicLink`.
8739 */
8740 type: FileType;
8741 /**
8742 * The creation timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
8743 */
8744 ctime: number;
8745 /**
8746 * The modification timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
8747 *
8748 * *Note:* If the file changed, it is important to provide an updated `mtime` that advanced
8749 * from the previous value. Otherwise there may be optimizations in place that will not show
8750 * the updated file contents in an editor for example.
8751 */
8752 mtime: number;
8753 /**
8754 * The size in bytes.
8755 *
8756 * *Note:* If the file changed, it is important to provide an updated `size`. Otherwise there
8757 * may be optimizations in place that will not show the updated file contents in an editor for
8758 * example.
8759 */
8760 size: number;
8761 /**
8762 * The permissions of the file, e.g. whether the file is readonly.
8763 *
8764 * *Note:* This value might be a bitmask, e.g. `FilePermission.Readonly | FilePermission.Other`.
8765 */
8766 permissions?: FilePermission;
8767 }
8768
8769 /**
8770 * A type that filesystem providers should use to signal errors.
8771 *
8772 * This class has factory methods for common error-cases, like `FileNotFound` when
8773 * a file or folder doesn't exist, use them like so: `throw vscode.FileSystemError.FileNotFound(someUri);`
8774 */
8775 export class FileSystemError extends Error {
8776
8777 /**
8778 * Create an error to signal that a file or folder wasn't found.
8779 * @param messageOrUri Message or uri.
8780 */
8781 static FileNotFound(messageOrUri?: string | Uri): FileSystemError;
8782
8783 /**
8784 * Create an error to signal that a file or folder already exists, e.g. when
8785 * creating but not overwriting a file.
8786 * @param messageOrUri Message or uri.
8787 */
8788 static FileExists(messageOrUri?: string | Uri): FileSystemError;
8789
8790 /**
8791 * Create an error to signal that a file is not a folder.
8792 * @param messageOrUri Message or uri.
8793 */
8794 static FileNotADirectory(messageOrUri?: string | Uri): FileSystemError;
8795
8796 /**
8797 * Create an error to signal that a file is a folder.
8798 * @param messageOrUri Message or uri.
8799 */
8800 static FileIsADirectory(messageOrUri?: string | Uri): FileSystemError;
8801
8802 /**
8803 * Create an error to signal that an operation lacks required permissions.
8804 * @param messageOrUri Message or uri.
8805 */
8806 static NoPermissions(messageOrUri?: string | Uri): FileSystemError;
8807
8808 /**
8809 * Create an error to signal that the file system is unavailable or too busy to
8810 * complete a request.
8811 * @param messageOrUri Message or uri.
8812 */
8813 static Unavailable(messageOrUri?: string | Uri): FileSystemError;
8814
8815 /**
8816 * Creates a new filesystem error.
8817 *
8818 * @param messageOrUri Message or uri.
8819 */
8820 constructor(messageOrUri?: string | Uri);
8821
8822 /**
8823 * A code that identifies this error.
8824 *
8825 * Possible values are names of errors, like {@linkcode FileSystemError.FileNotFound FileNotFound},
8826 * or `Unknown` for unspecified errors.
8827 */
8828 readonly code: string;
8829 }
8830
8831 /**
8832 * Enumeration of file change types.
8833 */
8834 export enum FileChangeType {
8835
8836 /**
8837 * The contents or metadata of a file have changed.
8838 */
8839 Changed = 1,
8840
8841 /**
8842 * A file has been created.
8843 */
8844 Created = 2,
8845
8846 /**
8847 * A file has been deleted.
8848 */
8849 Deleted = 3,
8850 }
8851
8852 /**
8853 * The event filesystem providers must use to signal a file change.
8854 */
8855 export interface FileChangeEvent {
8856
8857 /**
8858 * The type of change.
8859 */
8860 readonly type: FileChangeType;
8861
8862 /**
8863 * The uri of the file that has changed.
8864 */
8865 readonly uri: Uri;
8866 }
8867
8868 /**
8869 * The filesystem provider defines what the editor needs to read, write, discover,
8870 * and to manage files and folders. It allows extensions to serve files from remote places,
8871 * like ftp-servers, and to seamlessly integrate those into the editor.
8872 *
8873 * * *Note 1:* The filesystem provider API works with {@link Uri uris} and assumes hierarchical
8874 * paths, e.g. `foo:/my/path` is a child of `foo:/my/` and a parent of `foo:/my/path/deeper`.
8875 * * *Note 2:* There is an activation event `onFileSystem:<scheme>` that fires when a file
8876 * or folder is being accessed.
8877 * * *Note 3:* The word 'file' is often used to denote all {@link FileType kinds} of files, e.g.
8878 * folders, symbolic links, and regular files.
8879 */
8880 export interface FileSystemProvider {
8881
8882 /**
8883 * An event to signal that a resource has been created, changed, or deleted. This
8884 * event should fire for resources that are being {@link FileSystemProvider.watch watched}
8885 * by clients of this provider.
8886 *
8887 * *Note:* It is important that the metadata of the file that changed provides an
8888 * updated `mtime` that advanced from the previous value in the {@link FileStat stat} and a
8889 * correct `size` value. Otherwise there may be optimizations in place that will not show
8890 * the change in an editor for example.
8891 */
8892 readonly onDidChangeFile: Event<FileChangeEvent[]>;
8893
8894 /**
8895 * Subscribes to file change events in the file or folder denoted by `uri`. For folders,
8896 * the option `recursive` indicates whether subfolders, sub-subfolders, etc. should
8897 * be watched for file changes as well. With `recursive: false`, only changes to the
8898 * files that are direct children of the folder should trigger an event.
8899 *
8900 * The `excludes` array is used to indicate paths that should be excluded from file
8901 * watching. It is typically derived from the `files.watcherExclude` setting that
8902 * is configurable by the user. Each entry can be be:
8903 * - the absolute path to exclude
8904 * - a relative path to exclude (for example `build/output`)
8905 * - a simple glob pattern (for example `**​/build`, `output/**`)
8906 *
8907 * It is the file system provider's job to call {@linkcode FileSystemProvider.onDidChangeFile onDidChangeFile}
8908 * for every change given these rules. No event should be emitted for files that match any of the provided
8909 * excludes.
8910 *
8911 * @param uri The uri of the file or folder to be watched.
8912 * @param options Configures the watch.
8913 * @returns A disposable that tells the provider to stop watching the `uri`.
8914 */
8915 watch(uri: Uri, options: {
8916 /**
8917 * When enabled also watch subfolders.
8918 */
8919 readonly recursive: boolean;
8920 /**
8921 * A list of paths and pattern to exclude from watching.
8922 */
8923 readonly excludes: readonly string[];
8924 }): Disposable;
8925
8926 /**
8927 * Retrieve metadata about a file.
8928 *
8929 * Note that the metadata for symbolic links should be the metadata of the file they refer to.
8930 * Still, the {@link FileType.SymbolicLink SymbolicLink}-type must be used in addition to the actual type, e.g.
8931 * `FileType.SymbolicLink | FileType.Directory`.
8932 *
8933 * @param uri The uri of the file to retrieve metadata about.
8934 * @returns The file metadata about the file.
8935 * @throws {@linkcode FileSystemError.FileNotFound FileNotFound} when `uri` doesn't exist.
8936 */
8937 stat(uri: Uri): FileStat | Thenable<FileStat>;
8938
8939 /**
8940 * Retrieve all entries of a {@link FileType.Directory directory}.
8941 *
8942 * @param uri The uri of the folder.
8943 * @returns An array of name/type-tuples or a thenable that resolves to such.
8944 * @throws {@linkcode FileSystemError.FileNotFound FileNotFound} when `uri` doesn't exist.
8945 */
8946 readDirectory(uri: Uri): [string, FileType][] | Thenable<[string, FileType][]>;
8947
8948 /**
8949 * Create a new directory (Note, that new files are created via `write`-calls).
8950 *
8951 * @param uri The uri of the new folder.
8952 * @throws {@linkcode FileSystemError.FileNotFound FileNotFound} when the parent of `uri` doesn't exist, e.g. no mkdirp-logic required.
8953 * @throws {@linkcode FileSystemError.FileExists FileExists} when `uri` already exists.
8954 * @throws {@linkcode FileSystemError.NoPermissions NoPermissions} when permissions aren't sufficient.
8955 */
8956 createDirectory(uri: Uri): void | Thenable<void>;
8957
8958 /**
8959 * Read the entire contents of a file.
8960 *
8961 * @param uri The uri of the file.
8962 * @returns An array of bytes or a thenable that resolves to such.
8963 * @throws {@linkcode FileSystemError.FileNotFound FileNotFound} when `uri` doesn't exist.
8964 */
8965 readFile(uri: Uri): Uint8Array | Thenable<Uint8Array>;
8966
8967 /**
8968 * Write data to a file, replacing its entire contents.
8969 *
8970 * @param uri The uri of the file.
8971 * @param content The new content of the file.
8972 * @param options Defines if missing files should or must be created.
8973 * @throws {@linkcode FileSystemError.FileNotFound FileNotFound} when `uri` doesn't exist and `create` is not set.
8974 * @throws {@linkcode FileSystemError.FileNotFound FileNotFound} when the parent of `uri` doesn't exist and `create` is set, e.g. no mkdirp-logic required.
8975 * @throws {@linkcode FileSystemError.FileExists FileExists} when `uri` already exists, `create` is set but `overwrite` is not set.
8976 * @throws {@linkcode FileSystemError.NoPermissions NoPermissions} when permissions aren't sufficient.
8977 */
8978 writeFile(uri: Uri, content: Uint8Array, options: {
8979 /**
8980 * Create the file if it does not exist already.
8981 */
8982 readonly create: boolean;
8983 /**
8984 * Overwrite the file if it does exist.
8985 */
8986 readonly overwrite: boolean;
8987 }): void | Thenable<void>;
8988
8989 /**
8990 * Delete a file.
8991 *
8992 * @param uri The resource that is to be deleted.
8993 * @param options Defines if deletion of folders is recursive.
8994 * @throws {@linkcode FileSystemError.FileNotFound FileNotFound} when `uri` doesn't exist.
8995 * @throws {@linkcode FileSystemError.NoPermissions NoPermissions} when permissions aren't sufficient.
8996 */
8997 delete(uri: Uri, options: {
8998 /**
8999 * Delete the content recursively if a folder is denoted.
9000 */
9001 readonly recursive: boolean;
9002 }): void | Thenable<void>;
9003
9004 /**
9005 * Rename a file or folder.
9006 *
9007 * @param oldUri The existing file.
9008 * @param newUri The new location.
9009 * @param options Defines if existing files should be overwritten.
9010 * @throws {@linkcode FileSystemError.FileNotFound FileNotFound} when `oldUri` doesn't exist.
9011 * @throws {@linkcode FileSystemError.FileNotFound FileNotFound} when parent of `newUri` doesn't exist, e.g. no mkdirp-logic required.
9012 * @throws {@linkcode FileSystemError.FileExists FileExists} when `newUri` exists and when the `overwrite` option is not `true`.
9013 * @throws {@linkcode FileSystemError.NoPermissions NoPermissions} when permissions aren't sufficient.
9014 */
9015 rename(oldUri: Uri, newUri: Uri, options: {
9016 /**
9017 * Overwrite the file if it does exist.
9018 */
9019 readonly overwrite: boolean;
9020 }): void | Thenable<void>;
9021
9022 /**
9023 * Copy files or folders. Implementing this function is optional but it will speedup
9024 * the copy operation.
9025 *
9026 * @param source The existing file.
9027 * @param destination The destination location.
9028 * @param options Defines if existing files should be overwritten.
9029 * @throws {@linkcode FileSystemError.FileNotFound FileNotFound} when `source` doesn't exist.
9030 * @throws {@linkcode FileSystemError.FileNotFound FileNotFound} when parent of `destination` doesn't exist, e.g. no mkdirp-logic required.
9031 * @throws {@linkcode FileSystemError.FileExists FileExists} when `destination` exists and when the `overwrite` option is not `true`.
9032 * @throws {@linkcode FileSystemError.NoPermissions NoPermissions} when permissions aren't sufficient.
9033 */
9034 copy?(source: Uri, destination: Uri, options: {
9035 /**
9036 * Overwrite the file if it does exist.
9037 */
9038 readonly overwrite: boolean;
9039 }): void | Thenable<void>;
9040 }
9041
9042 /**
9043 * The file system interface exposes the editor's built-in and contributed
9044 * {@link FileSystemProvider file system providers}. It allows extensions to work
9045 * with files from the local disk as well as files from remote places, like the
9046 * remote extension host or ftp-servers.
9047 *
9048 * *Note* that an instance of this interface is available as {@linkcode workspace.fs}.
9049 */
9050 export interface FileSystem {
9051
9052 /**
9053 * Retrieve metadata about a file.
9054 *
9055 * @param uri The uri of the file to retrieve metadata about.
9056 * @returns The file metadata about the file.
9057 */
9058 stat(uri: Uri): Thenable<FileStat>;
9059
9060 /**
9061 * Retrieve all entries of a {@link FileType.Directory directory}.
9062 *
9063 * @param uri The uri of the folder.
9064 * @returns An array of name/type-tuples or a thenable that resolves to such.
9065 */
9066 readDirectory(uri: Uri): Thenable<[string, FileType][]>;
9067
9068 /**
9069 * Create a new directory (Note, that new files are created via `write`-calls).
9070 *
9071 * *Note* that missing directories are created automatically, e.g this call has
9072 * `mkdirp` semantics.
9073 *
9074 * @param uri The uri of the new folder.
9075 */
9076 createDirectory(uri: Uri): Thenable<void>;
9077
9078 /**
9079 * Read the entire contents of a file.
9080 *
9081 * @param uri The uri of the file.
9082 * @returns An array of bytes or a thenable that resolves to such.
9083 */
9084 readFile(uri: Uri): Thenable<Uint8Array>;
9085
9086 /**
9087 * Write data to a file, replacing its entire contents.
9088 *
9089 * @param uri The uri of the file.
9090 * @param content The new content of the file.
9091 */
9092 writeFile(uri: Uri, content: Uint8Array): Thenable<void>;
9093
9094 /**
9095 * Delete a file.
9096 *
9097 * @param uri The resource that is to be deleted.
9098 * @param options Defines if trash can should be used and if deletion of folders is recursive
9099 */
9100 delete(uri: Uri, options?: {
9101 /**
9102 * Delete the content recursively if a folder is denoted.
9103 */
9104 recursive?: boolean;
9105 /**
9106 * Use the os's trashcan instead of permanently deleting files whenever possible.
9107 */
9108 useTrash?: boolean;
9109 }): Thenable<void>;
9110
9111 /**
9112 * Rename a file or folder.
9113 *
9114 * @param source The existing file.
9115 * @param target The new location.
9116 * @param options Defines if existing files should be overwritten.
9117 */
9118 rename(source: Uri, target: Uri, options?: {
9119 /**
9120 * Overwrite the file if it does exist.
9121 */
9122 overwrite?: boolean;
9123 }): Thenable<void>;
9124
9125 /**
9126 * Copy files or folders.
9127 *
9128 * @param source The existing file.
9129 * @param target The destination location.
9130 * @param options Defines if existing files should be overwritten.
9131 */
9132 copy(source: Uri, target: Uri, options?: {
9133 /**
9134 * Overwrite the file if it does exist.
9135 */
9136 overwrite?: boolean;
9137 }): Thenable<void>;
9138
9139 /**
9140 * Check if a given file system supports writing files.
9141 *
9142 * Keep in mind that just because a file system supports writing, that does
9143 * not mean that writes will always succeed. There may be permissions issues
9144 * or other errors that prevent writing a file.
9145 *
9146 * @param scheme The scheme of the filesystem, for example `file` or `git`.
9147 *
9148 * @returns `true` if the file system supports writing, `false` if it does not
9149 * support writing (i.e. it is readonly), and `undefined` if the editor does not
9150 * know about the filesystem.
9151 */
9152 isWritableFileSystem(scheme: string): boolean | undefined;
9153 }
9154
9155 /**
9156 * Defines a port mapping used for localhost inside the webview.
9157 */
9158 export interface WebviewPortMapping {
9159 /**
9160 * Localhost port to remap inside the webview.
9161 */
9162 readonly webviewPort: number;
9163
9164 /**
9165 * Destination port. The `webviewPort` is resolved to this port.
9166 */
9167 readonly extensionHostPort: number;
9168 }
9169
9170 /**
9171 * Content settings for a webview.
9172 */
9173 export interface WebviewOptions {
9174 /**
9175 * Controls whether scripts are enabled in the webview content or not.
9176 *
9177 * Defaults to false (scripts-disabled).
9178 */
9179 readonly enableScripts?: boolean;
9180
9181 /**
9182 * Controls whether forms are enabled in the webview content or not.
9183 *
9184 * Defaults to true if {@link WebviewOptions.enableScripts scripts are enabled}. Otherwise defaults to false.
9185 * Explicitly setting this property to either true or false overrides the default.
9186 */
9187 readonly enableForms?: boolean;
9188
9189 /**
9190 * Controls whether command uris are enabled in webview content or not.
9191 *
9192 * Defaults to `false` (command uris are disabled).
9193 *
9194 * If you pass in an array, only the commands in the array are allowed.
9195 */
9196 readonly enableCommandUris?: boolean | readonly string[];
9197
9198 /**
9199 * Root paths from which the webview can load local (filesystem) resources using uris from `asWebviewUri`
9200 *
9201 * Default to the root folders of the current workspace plus the extension's install directory.
9202 *
9203 * Pass in an empty array to disallow access to any local resources.
9204 */
9205 readonly localResourceRoots?: readonly Uri[];
9206
9207 /**
9208 * Mappings of localhost ports used inside the webview.
9209 *
9210 * Port mapping allow webviews to transparently define how localhost ports are resolved. This can be used
9211 * to allow using a static localhost port inside the webview that is resolved to random port that a service is
9212 * running on.
9213 *
9214 * If a webview accesses localhost content, we recommend that you specify port mappings even if
9215 * the `webviewPort` and `extensionHostPort` ports are the same.
9216 *
9217 * *Note* that port mappings only work for `http` or `https` urls. Websocket urls (e.g. `ws://localhost:3000`)
9218 * cannot be mapped to another port.
9219 */
9220 readonly portMapping?: readonly WebviewPortMapping[];
9221 }
9222
9223 /**
9224 * Displays html content, similarly to an iframe.
9225 */
9226 export interface Webview {
9227 /**
9228 * Content settings for the webview.
9229 */
9230 options: WebviewOptions;
9231
9232 /**
9233 * HTML contents of the webview.
9234 *
9235 * This should be a complete, valid html document. Changing this property causes the webview to be reloaded.
9236 *
9237 * Webviews are sandboxed from normal extension process, so all communication with the webview must use
9238 * message passing. To send a message from the extension to the webview, use {@linkcode Webview.postMessage postMessage}.
9239 * To send message from the webview back to an extension, use the `acquireVsCodeApi` function inside the webview
9240 * to get a handle to the editor's api and then call `.postMessage()`:
9241 *
9242 * ```html
9243 * <script>
9244 * const vscode = acquireVsCodeApi(); // acquireVsCodeApi can only be invoked once
9245 * vscode.postMessage({ message: 'hello!' });
9246 * </script>
9247 * ```
9248 *
9249 * To load a resources from the workspace inside a webview, use the {@linkcode Webview.asWebviewUri asWebviewUri} method
9250 * and ensure the resource's directory is listed in {@linkcode WebviewOptions.localResourceRoots}.
9251 *
9252 * Keep in mind that even though webviews are sandboxed, they still allow running scripts and loading arbitrary content,
9253 * so extensions must follow all standard web security best practices when working with webviews. This includes
9254 * properly sanitizing all untrusted input (including content from the workspace) and
9255 * setting a [content security policy](https://aka.ms/vscode-api-webview-csp).
9256 */
9257 html: string;
9258
9259 /**
9260 * Fired when the webview content posts a message.
9261 *
9262 * Webview content can post strings or json serializable objects back to an extension. They cannot
9263 * post `Blob`, `File`, `ImageData` and other DOM specific objects since the extension that receives the
9264 * message does not run in a browser environment.
9265 */
9266 readonly onDidReceiveMessage: Event<any>;
9267
9268 /**
9269 * Post a message to the webview content.
9270 *
9271 * Messages are only delivered if the webview is live (either visible or in the
9272 * background with `retainContextWhenHidden`).
9273 *
9274 * @param message Body of the message. This must be a string or other json serializable object.
9275 *
9276 * For older versions of vscode, if an `ArrayBuffer` is included in `message`,
9277 * it will not be serialized properly and will not be received by the webview.
9278 * Similarly any TypedArrays, such as a `Uint8Array`, will be very inefficiently
9279 * serialized and will also not be recreated as a typed array inside the webview.
9280 *
9281 * However if your extension targets vscode 1.57+ in the `engines` field of its
9282 * `package.json`, any `ArrayBuffer` values that appear in `message` will be more
9283 * efficiently transferred to the webview and will also be correctly recreated inside
9284 * of the webview.
9285 *
9286 * @returns A promise that resolves when the message is posted to a webview or when it is
9287 * dropped because the message was not deliverable.
9288 *
9289 * Returns `true` if the message was posted to the webview. Messages can only be posted to
9290 * live webviews (i.e. either visible webviews or hidden webviews that set `retainContextWhenHidden`).
9291 *
9292 * A response of `true` does not mean that the message was actually received by the webview.
9293 * For example, no message listeners may be have been hooked up inside the webview or the webview may
9294 * have been destroyed after the message was posted but before it was received.
9295 *
9296 * If you want confirm that a message as actually received, you can try having your webview posting a
9297 * confirmation message back to your extension.
9298 */
9299 postMessage(message: any): Thenable<boolean>;
9300
9301 /**
9302 * Convert a uri for the local file system to one that can be used inside webviews.
9303 *
9304 * Webviews cannot directly load resources from the workspace or local file system using `file:` uris. The
9305 * `asWebviewUri` function takes a local `file:` uri and converts it into a uri that can be used inside of
9306 * a webview to load the same resource:
9307 *
9308 * ```ts
9309 * webview.html = `<img src="${webview.asWebviewUri(vscode.Uri.file('/Users/codey/workspace/cat.gif'))}">`
9310 * ```
9311 */
9312 asWebviewUri(localResource: Uri): Uri;
9313
9314 /**
9315 * Content security policy source for webview resources.
9316 *
9317 * This is the origin that should be used in a content security policy rule:
9318 *
9319 * ```ts
9320 * `img-src https: ${webview.cspSource} ...;`
9321 * ```
9322 */
9323 readonly cspSource: string;
9324 }
9325
9326 /**
9327 * Content settings for a webview panel.
9328 */
9329 export interface WebviewPanelOptions {
9330 /**
9331 * Controls if the find widget is enabled in the panel.
9332 *
9333 * Defaults to `false`.
9334 */
9335 readonly enableFindWidget?: boolean;
9336
9337 /**
9338 * Controls if the webview panel's content (iframe) is kept around even when the panel
9339 * is no longer visible.
9340 *
9341 * Normally the webview panel's html context is created when the panel becomes visible
9342 * and destroyed when it is hidden. Extensions that have complex state
9343 * or UI can set the `retainContextWhenHidden` to make the editor keep the webview
9344 * context around, even when the webview moves to a background tab. When a webview using
9345 * `retainContextWhenHidden` becomes hidden, its scripts and other dynamic content are suspended.
9346 * When the panel becomes visible again, the context is automatically restored
9347 * in the exact same state it was in originally. You cannot send messages to a
9348 * hidden webview, even with `retainContextWhenHidden` enabled.
9349 *
9350 * `retainContextWhenHidden` has a high memory overhead and should only be used if
9351 * your panel's context cannot be quickly saved and restored.
9352 */
9353 readonly retainContextWhenHidden?: boolean;
9354 }
9355
9356 /**
9357 * A panel that contains a webview.
9358 */
9359 interface WebviewPanel {
9360 /**
9361 * Identifies the type of the webview panel, such as `'markdown.preview'`.
9362 */
9363 readonly viewType: string;
9364
9365 /**
9366 * Title of the panel shown in UI.
9367 */
9368 title: string;
9369
9370 /**
9371 * Icon for the panel shown in UI.
9372 */
9373 iconPath?: Uri | {
9374 /**
9375 * The icon path for the light theme.
9376 */
9377 readonly light: Uri;
9378 /**
9379 * The icon path for the dark theme.
9380 */
9381 readonly dark: Uri;
9382 };
9383
9384 /**
9385 * {@linkcode Webview} belonging to the panel.
9386 */
9387 readonly webview: Webview;
9388
9389 /**
9390 * Content settings for the webview panel.
9391 */
9392 readonly options: WebviewPanelOptions;
9393
9394 /**
9395 * Editor position of the panel. This property is only set if the webview is in
9396 * one of the editor view columns.
9397 */
9398 readonly viewColumn: ViewColumn | undefined;
9399
9400 /**
9401 * Whether the panel is active (focused by the user).
9402 */
9403 readonly active: boolean;
9404
9405 /**
9406 * Whether the panel is visible.
9407 */
9408 readonly visible: boolean;
9409
9410 /**
9411 * Fired when the panel's view state changes.
9412 */
9413 readonly onDidChangeViewState: Event<WebviewPanelOnDidChangeViewStateEvent>;
9414
9415 /**
9416 * Fired when the panel is disposed.
9417 *
9418 * This may be because the user closed the panel or because `.dispose()` was
9419 * called on it.
9420 *
9421 * Trying to use the panel after it has been disposed throws an exception.
9422 */
9423 readonly onDidDispose: Event<void>;
9424
9425 /**
9426 * Show the webview panel in a given column.
9427 *
9428 * A webview panel may only show in a single column at a time. If it is already showing, this
9429 * method moves it to a new column.
9430 *
9431 * @param viewColumn View column to show the panel in. Shows in the current `viewColumn` if undefined.
9432 * @param preserveFocus When `true`, the webview will not take focus.
9433 */
9434 reveal(viewColumn?: ViewColumn, preserveFocus?: boolean): void;
9435
9436 /**
9437 * Dispose of the webview panel.
9438 *
9439 * This closes the panel if it showing and disposes of the resources owned by the webview.
9440 * Webview panels are also disposed when the user closes the webview panel. Both cases
9441 * fire the `onDispose` event.
9442 */
9443 dispose(): any;
9444 }
9445
9446 /**
9447 * Event fired when a webview panel's view state changes.
9448 */
9449 export interface WebviewPanelOnDidChangeViewStateEvent {
9450 /**
9451 * Webview panel whose view state changed.
9452 */
9453 readonly webviewPanel: WebviewPanel;
9454 }
9455
9456 /**
9457 * Restore webview panels that have been persisted when vscode shuts down.
9458 *
9459 * There are two types of webview persistence:
9460 *
9461 * - Persistence within a session.
9462 * - Persistence across sessions (across restarts of the editor).
9463 *
9464 * A `WebviewPanelSerializer` is only required for the second case: persisting a webview across sessions.
9465 *
9466 * Persistence within a session allows a webview to save its state when it becomes hidden
9467 * and restore its content from this state when it becomes visible again. It is powered entirely
9468 * by the webview content itself. To save off a persisted state, call `acquireVsCodeApi().setState()` with
9469 * any json serializable object. To restore the state again, call `getState()`
9470 *
9471 * ```js
9472 * // Within the webview
9473 * const vscode = acquireVsCodeApi();
9474 *
9475 * // Get existing state
9476 * const oldState = vscode.getState() || { value: 0 };
9477 *
9478 * // Update state
9479 * setState({ value: oldState.value + 1 })
9480 * ```
9481 *
9482 * A `WebviewPanelSerializer` extends this persistence across restarts of the editor. When the editor is shutdown,
9483 * it will save off the state from `setState` of all webviews that have a serializer. When the
9484 * webview first becomes visible after the restart, this state is passed to `deserializeWebviewPanel`.
9485 * The extension can then restore the old `WebviewPanel` from this state.
9486 *
9487 * @param T Type of the webview's state.
9488 */
9489 interface WebviewPanelSerializer<T = unknown> {
9490 /**
9491 * Restore a webview panel from its serialized `state`.
9492 *
9493 * Called when a serialized webview first becomes visible.
9494 *
9495 * @param webviewPanel Webview panel to restore. The serializer should take ownership of this panel. The
9496 * serializer must restore the webview's `.html` and hook up all webview events.
9497 * @param state Persisted state from the webview content.
9498 *
9499 * @returns Thenable indicating that the webview has been fully restored.
9500 */
9501 deserializeWebviewPanel(webviewPanel: WebviewPanel, state: T): Thenable<void>;
9502 }
9503
9504 /**
9505 * A webview based view.
9506 */
9507 export interface WebviewView {
9508 /**
9509 * Identifies the type of the webview view, such as `'hexEditor.dataView'`.
9510 */
9511 readonly viewType: string;
9512
9513 /**
9514 * The underlying webview for the view.
9515 */
9516 readonly webview: Webview;
9517
9518 /**
9519 * View title displayed in the UI.
9520 *
9521 * The view title is initially taken from the extension `package.json` contribution.
9522 */
9523 title?: string;
9524
9525 /**
9526 * Human-readable string which is rendered less prominently in the title.
9527 */
9528 description?: string;
9529
9530 /**
9531 * The badge to display for this webview view.
9532 * To remove the badge, set to undefined.
9533 */
9534 badge?: ViewBadge | undefined;
9535
9536 /**
9537 * Event fired when the view is disposed.
9538 *
9539 * Views are disposed when they are explicitly hidden by a user (this happens when a user
9540 * right clicks in a view and unchecks the webview view).
9541 *
9542 * Trying to use the view after it has been disposed throws an exception.
9543 */
9544 readonly onDidDispose: Event<void>;
9545
9546 /**
9547 * Tracks if the webview is currently visible.
9548 *
9549 * Views are visible when they are on the screen and expanded.
9550 */
9551 readonly visible: boolean;
9552
9553 /**
9554 * Event fired when the visibility of the view changes.
9555 *
9556 * Actions that trigger a visibility change:
9557 *
9558 * - The view is collapsed or expanded.
9559 * - The user switches to a different view group in the sidebar or panel.
9560 *
9561 * Note that hiding a view using the context menu instead disposes of the view and fires `onDidDispose`.
9562 */
9563 readonly onDidChangeVisibility: Event<void>;
9564
9565 /**
9566 * Reveal the view in the UI.
9567 *
9568 * If the view is collapsed, this will expand it.
9569 *
9570 * @param preserveFocus When `true` the view will not take focus.
9571 */
9572 show(preserveFocus?: boolean): void;
9573 }
9574
9575 /**
9576 * Additional information the webview view being resolved.
9577 *
9578 * @param T Type of the webview's state.
9579 */
9580 interface WebviewViewResolveContext<T = unknown> {
9581 /**
9582 * Persisted state from the webview content.
9583 *
9584 * To save resources, the editor normally deallocates webview documents (the iframe content) that are not visible.
9585 * For example, when the user collapse a view or switches to another top level activity in the sidebar, the
9586 * `WebviewView` itself is kept alive but the webview's underlying document is deallocated. It is recreated when
9587 * the view becomes visible again.
9588 *
9589 * You can prevent this behavior by setting `retainContextWhenHidden` in the `WebviewOptions`. However this
9590 * increases resource usage and should be avoided wherever possible. Instead, you can use persisted state to
9591 * save off a webview's state so that it can be quickly recreated as needed.
9592 *
9593 * To save off a persisted state, inside the webview call `acquireVsCodeApi().setState()` with
9594 * any json serializable object. To restore the state again, call `getState()`. For example:
9595 *
9596 * ```js
9597 * // Within the webview
9598 * const vscode = acquireVsCodeApi();
9599 *
9600 * // Get existing state
9601 * const oldState = vscode.getState() || { value: 0 };
9602 *
9603 * // Update state
9604 * setState({ value: oldState.value + 1 })
9605 * ```
9606 *
9607 * The editor ensures that the persisted state is saved correctly when a webview is hidden and across
9608 * editor restarts.
9609 */
9610 readonly state: T | undefined;
9611 }
9612
9613 /**
9614 * Provider for creating `WebviewView` elements.
9615 */
9616 export interface WebviewViewProvider {
9617 /**
9618 * Resolves a webview view.
9619 *
9620 * `resolveWebviewView` is called when a view first becomes visible. This may happen when the view is
9621 * first loaded or when the user hides and then shows a view again.
9622 *
9623 * @param webviewView Webview view to restore. The provider should take ownership of this view. The
9624 * provider must set the webview's `.html` and hook up all webview events it is interested in.
9625 * @param context Additional metadata about the view being resolved.
9626 * @param token Cancellation token indicating that the view being provided is no longer needed.
9627 *
9628 * @returns Optional thenable indicating that the view has been fully resolved.
9629 */
9630 resolveWebviewView(webviewView: WebviewView, context: WebviewViewResolveContext, token: CancellationToken): Thenable<void> | void;
9631 }
9632
9633 /**
9634 * Provider for text based custom editors.
9635 *
9636 * Text based custom editors use a {@linkcode TextDocument} as their data model. This considerably simplifies
9637 * implementing a custom editor as it allows the editor to handle many common operations such as
9638 * undo and backup. The provider is responsible for synchronizing text changes between the webview and the `TextDocument`.
9639 */
9640 export interface CustomTextEditorProvider {
9641
9642 /**
9643 * Resolve a custom editor for a given text resource.
9644 *
9645 * This is called when a user first opens a resource for a `CustomTextEditorProvider`, or if they reopen an
9646 * existing editor using this `CustomTextEditorProvider`.
9647 *
9648 *
9649 * @param document Document for the resource to resolve.
9650 *
9651 * @param webviewPanel The webview panel used to display the editor UI for this resource.
9652 *
9653 * During resolve, the provider must fill in the initial html for the content webview panel and hook up all
9654 * the event listeners on it that it is interested in. The provider can also hold onto the `WebviewPanel` to
9655 * use later for example in a command. See {@linkcode WebviewPanel} for additional details.
9656 *
9657 * @param token A cancellation token that indicates the result is no longer needed.
9658 *
9659 * @returns Thenable indicating that the custom editor has been resolved.
9660 */
9661 resolveCustomTextEditor(document: TextDocument, webviewPanel: WebviewPanel, token: CancellationToken): Thenable<void> | void;
9662 }
9663
9664 /**
9665 * Represents a custom document used by a {@linkcode CustomEditorProvider}.
9666 *
9667 * Custom documents are only used within a given `CustomEditorProvider`. The lifecycle of a `CustomDocument` is
9668 * managed by the editor. When no more references remain to a `CustomDocument`, it is disposed of.
9669 */
9670 interface CustomDocument {
9671 /**
9672 * The associated uri for this document.
9673 */
9674 readonly uri: Uri;
9675
9676 /**
9677 * Dispose of the custom document.
9678 *
9679 * This is invoked by the editor when there are no more references to a given `CustomDocument` (for example when
9680 * all editors associated with the document have been closed.)
9681 */
9682 dispose(): void;
9683 }
9684
9685 /**
9686 * Event triggered by extensions to signal to the editor that an edit has occurred on an {@linkcode CustomDocument}.
9687 *
9688 * @see {@linkcode CustomEditorProvider.onDidChangeCustomDocument}.
9689 */
9690 interface CustomDocumentEditEvent<T extends CustomDocument = CustomDocument> {
9691
9692 /**
9693 * The document that the edit is for.
9694 */
9695 readonly document: T;
9696
9697 /**
9698 * Undo the edit operation.
9699 *
9700 * This is invoked by the editor when the user undoes this edit. To implement `undo`, your
9701 * extension should restore the document and editor to the state they were in just before this
9702 * edit was added to the editor's internal edit stack by `onDidChangeCustomDocument`.
9703 */
9704 undo(): Thenable<void> | void;
9705
9706 /**
9707 * Redo the edit operation.
9708 *
9709 * This is invoked by the editor when the user redoes this edit. To implement `redo`, your
9710 * extension should restore the document and editor to the state they were in just after this
9711 * edit was added to the editor's internal edit stack by `onDidChangeCustomDocument`.
9712 */
9713 redo(): Thenable<void> | void;
9714
9715 /**
9716 * Display name describing the edit.
9717 *
9718 * This will be shown to users in the UI for undo/redo operations.
9719 */
9720 readonly label?: string;
9721 }
9722
9723 /**
9724 * Event triggered by extensions to signal to the editor that the content of a {@linkcode CustomDocument}
9725 * has changed.
9726 *
9727 * @see {@linkcode CustomEditorProvider.onDidChangeCustomDocument}.
9728 */
9729 interface CustomDocumentContentChangeEvent<T extends CustomDocument = CustomDocument> {
9730 /**
9731 * The document that the change is for.
9732 */
9733 readonly document: T;
9734 }
9735
9736 /**
9737 * A backup for an {@linkcode CustomDocument}.
9738 */
9739 interface CustomDocumentBackup {
9740 /**
9741 * Unique identifier for the backup.
9742 *
9743 * This id is passed back to your extension in `openCustomDocument` when opening a custom editor from a backup.
9744 */
9745 readonly id: string;
9746
9747 /**
9748 * Delete the current backup.
9749 *
9750 * This is called by the editor when it is clear the current backup is no longer needed, such as when a new backup
9751 * is made or when the file is saved.
9752 */
9753 delete(): void;
9754 }
9755
9756 /**
9757 * Additional information used to implement {@linkcode CustomDocumentBackup}.
9758 */
9759 interface CustomDocumentBackupContext {
9760 /**
9761 * Suggested file location to write the new backup.
9762 *
9763 * Note that your extension is free to ignore this and use its own strategy for backup.
9764 *
9765 * If the editor is for a resource from the current workspace, `destination` will point to a file inside
9766 * `ExtensionContext.storagePath`. The parent folder of `destination` may not exist, so make sure to created it
9767 * before writing the backup to this location.
9768 */
9769 readonly destination: Uri;
9770 }
9771
9772 /**
9773 * Additional information about the opening custom document.
9774 */
9775 interface CustomDocumentOpenContext {
9776 /**
9777 * The id of the backup to restore the document from or `undefined` if there is no backup.
9778 *
9779 * If this is provided, your extension should restore the editor from the backup instead of reading the file
9780 * from the user's workspace.
9781 */
9782 readonly backupId: string | undefined;
9783
9784 /**
9785 * If the URI is an untitled file, this will be populated with the byte data of that file
9786 *
9787 * If this is provided, your extension should utilize this byte data rather than executing fs APIs on the URI passed in
9788 */
9789 readonly untitledDocumentData: Uint8Array | undefined;
9790 }
9791
9792 /**
9793 * Provider for readonly custom editors that use a custom document model.
9794 *
9795 * Custom editors use {@linkcode CustomDocument} as their document model instead of a {@linkcode TextDocument}.
9796 *
9797 * You should use this type of custom editor when dealing with binary files or more complex scenarios. For simple
9798 * text based documents, use {@linkcode CustomTextEditorProvider} instead.
9799 *
9800 * @param T Type of the custom document returned by this provider.
9801 */
9802 export interface CustomReadonlyEditorProvider<T extends CustomDocument = CustomDocument> {
9803
9804 /**
9805 * Create a new document for a given resource.
9806 *
9807 * `openCustomDocument` is called when the first time an editor for a given resource is opened. The opened
9808 * document is then passed to `resolveCustomEditor` so that the editor can be shown to the user.
9809 *
9810 * Already opened `CustomDocument` are re-used if the user opened additional editors. When all editors for a
9811 * given resource are closed, the `CustomDocument` is disposed of. Opening an editor at this point will
9812 * trigger another call to `openCustomDocument`.
9813 *
9814 * @param uri Uri of the document to open.
9815 * @param openContext Additional information about the opening custom document.
9816 * @param token A cancellation token that indicates the result is no longer needed.
9817 *
9818 * @returns The custom document.
9819 */
9820 openCustomDocument(uri: Uri, openContext: CustomDocumentOpenContext, token: CancellationToken): Thenable<T> | T;
9821
9822 /**
9823 * Resolve a custom editor for a given resource.
9824 *
9825 * This is called whenever the user opens a new editor for this `CustomEditorProvider`.
9826 *
9827 * @param document Document for the resource being resolved.
9828 *
9829 * @param webviewPanel The webview panel used to display the editor UI for this resource.
9830 *
9831 * During resolve, the provider must fill in the initial html for the content webview panel and hook up all
9832 * the event listeners on it that it is interested in. The provider can also hold onto the `WebviewPanel` to
9833 * use later for example in a command. See {@linkcode WebviewPanel} for additional details.
9834 *
9835 * @param token A cancellation token that indicates the result is no longer needed.
9836 *
9837 * @returns Optional thenable indicating that the custom editor has been resolved.
9838 */
9839 resolveCustomEditor(document: T, webviewPanel: WebviewPanel, token: CancellationToken): Thenable<void> | void;
9840 }
9841
9842 /**
9843 * Provider for editable custom editors that use a custom document model.
9844 *
9845 * Custom editors use {@linkcode CustomDocument} as their document model instead of a {@linkcode TextDocument}.
9846 * This gives extensions full control over actions such as edit, save, and backup.
9847 *
9848 * You should use this type of custom editor when dealing with binary files or more complex scenarios. For simple
9849 * text based documents, use {@linkcode CustomTextEditorProvider} instead.
9850 *
9851 * @param T Type of the custom document returned by this provider.
9852 */
9853 export interface CustomEditorProvider<T extends CustomDocument = CustomDocument> extends CustomReadonlyEditorProvider<T> {
9854 /**
9855 * Signal that an edit has occurred inside a custom editor.
9856 *
9857 * This event must be fired by your extension whenever an edit happens in a custom editor. An edit can be
9858 * anything from changing some text, to cropping an image, to reordering a list. Your extension is free to
9859 * define what an edit is and what data is stored on each edit.
9860 *
9861 * Firing `onDidChange` causes the editors to be marked as being dirty. This is cleared when the user either
9862 * saves or reverts the file.
9863 *
9864 * Editors that support undo/redo must fire a `CustomDocumentEditEvent` whenever an edit happens. This allows
9865 * users to undo and redo the edit using the editor's standard keyboard shortcuts. The editor will also mark
9866 * the editor as no longer being dirty if the user undoes all edits to the last saved state.
9867 *
9868 * Editors that support editing but cannot use the editor's standard undo/redo mechanism must fire a `CustomDocumentContentChangeEvent`.
9869 * The only way for a user to clear the dirty state of an editor that does not support undo/redo is to either
9870 * `save` or `revert` the file.
9871 *
9872 * An editor should only ever fire `CustomDocumentEditEvent` events, or only ever fire `CustomDocumentContentChangeEvent` events.
9873 */
9874 readonly onDidChangeCustomDocument: Event<CustomDocumentEditEvent<T>> | Event<CustomDocumentContentChangeEvent<T>>;
9875
9876 /**
9877 * Save a custom document.
9878 *
9879 * This method is invoked by the editor when the user saves a custom editor. This can happen when the user
9880 * triggers save while the custom editor is active, by commands such as `save all`, or by auto save if enabled.
9881 *
9882 * To implement `save`, the implementer must persist the custom editor. This usually means writing the
9883 * file data for the custom document to disk. After `save` completes, any associated editor instances will
9884 * no longer be marked as dirty.
9885 *
9886 * @param document Document to save.
9887 * @param cancellation Token that signals the save is no longer required (for example, if another save was triggered).
9888 *
9889 * @returns Thenable signaling that saving has completed.
9890 */
9891 saveCustomDocument(document: T, cancellation: CancellationToken): Thenable<void>;
9892
9893 /**
9894 * Save a custom document to a different location.
9895 *
9896 * This method is invoked by the editor when the user triggers 'save as' on a custom editor. The implementer must
9897 * persist the custom editor to `destination`.
9898 *
9899 * When the user accepts save as, the current editor is be replaced by an non-dirty editor for the newly saved file.
9900 *
9901 * @param document Document to save.
9902 * @param destination Location to save to.
9903 * @param cancellation Token that signals the save is no longer required.
9904 *
9905 * @returns Thenable signaling that saving has completed.
9906 */
9907 saveCustomDocumentAs(document: T, destination: Uri, cancellation: CancellationToken): Thenable<void>;
9908
9909 /**
9910 * Revert a custom document to its last saved state.
9911 *
9912 * This method is invoked by the editor when the user triggers `File: Revert File` in a custom editor. (Note that
9913 * this is only used using the editor's `File: Revert File` command and not on a `git revert` of the file).
9914 *
9915 * To implement `revert`, the implementer must make sure all editor instances (webviews) for `document`
9916 * are displaying the document in the same state is saved in. This usually means reloading the file from the
9917 * workspace.
9918 *
9919 * @param document Document to revert.
9920 * @param cancellation Token that signals the revert is no longer required.
9921 *
9922 * @returns Thenable signaling that the change has completed.
9923 */
9924 revertCustomDocument(document: T, cancellation: CancellationToken): Thenable<void>;
9925
9926 /**
9927 * Back up a dirty custom document.
9928 *
9929 * Backups are used for hot exit and to prevent data loss. Your `backup` method should persist the resource in
9930 * its current state, i.e. with the edits applied. Most commonly this means saving the resource to disk in
9931 * the `ExtensionContext.storagePath`. When the editor reloads and your custom editor is opened for a resource,
9932 * your extension should first check to see if any backups exist for the resource. If there is a backup, your
9933 * extension should load the file contents from there instead of from the resource in the workspace.
9934 *
9935 * `backup` is triggered approximately one second after the user stops editing the document. If the user
9936 * rapidly edits the document, `backup` will not be invoked until the editing stops.
9937 *
9938 * `backup` is not invoked when `auto save` is enabled (since auto save already persists the resource).
9939 *
9940 * @param document Document to backup.
9941 * @param context Information that can be used to backup the document.
9942 * @param cancellation Token that signals the current backup since a new backup is coming in. It is up to your
9943 * extension to decided how to respond to cancellation. If for example your extension is backing up a large file
9944 * in an operation that takes time to complete, your extension may decide to finish the ongoing backup rather
9945 * than cancelling it to ensure that the editor has some valid backup.
9946 */
9947 backupCustomDocument(document: T, context: CustomDocumentBackupContext, cancellation: CancellationToken): Thenable<CustomDocumentBackup>;
9948 }
9949
9950 /**
9951 * The clipboard provides read and write access to the system's clipboard.
9952 */
9953 export interface Clipboard {
9954
9955 /**
9956 * Read the current clipboard contents as text.
9957 * @returns A thenable that resolves to a string.
9958 */
9959 readText(): Thenable<string>;
9960
9961 /**
9962 * Writes text into the clipboard.
9963 * @returns A thenable that resolves when writing happened.
9964 */
9965 writeText(value: string): Thenable<void>;
9966 }
9967
9968 /**
9969 * Possible kinds of UI that can use extensions.
9970 */
9971 export enum UIKind {
9972
9973 /**
9974 * Extensions are accessed from a desktop application.
9975 */
9976 Desktop = 1,
9977
9978 /**
9979 * Extensions are accessed from a web browser.
9980 */
9981 Web = 2
9982 }
9983
9984 /**
9985 * Log levels
9986 */
9987 export enum LogLevel {
9988
9989 /**
9990 * No messages are logged with this level.
9991 */
9992 Off = 0,
9993
9994 /**
9995 * All messages are logged with this level.
9996 */
9997 Trace = 1,
9998
9999 /**
10000 * Messages with debug and higher log level are logged with this level.
10001 */
10002 Debug = 2,
10003
10004 /**
10005 * Messages with info and higher log level are logged with this level.
10006 */
10007 Info = 3,
10008
10009 /**
10010 * Messages with warning and higher log level are logged with this level.
10011 */
10012 Warning = 4,
10013
10014 /**
10015 * Only error messages are logged with this level.
10016 */
10017 Error = 5
10018 }
10019
10020 /**
10021 * Namespace describing the environment the editor runs in.
10022 */
10023 export namespace env {
10024
10025 /**
10026 * The application name of the editor, like 'VS Code'.
10027 */
10028 export const appName: string;
10029
10030 /**
10031 * The application root folder from which the editor is running.
10032 *
10033 * *Note* that the value is the empty string when running in an
10034 * environment that has no representation of an application root folder.
10035 */
10036 export const appRoot: string;
10037
10038 /**
10039 * The hosted location of the application
10040 * On desktop this is 'desktop'
10041 * In the web this is the specified embedder i.e. 'github.dev', 'codespaces', or 'web' if the embedder
10042 * does not provide that information
10043 */
10044 export const appHost: string;
10045
10046 /**
10047 * The custom uri scheme the editor registers to in the operating system.
10048 */
10049 export const uriScheme: string;
10050
10051 /**
10052 * Represents the preferred user-language, like `de-CH`, `fr`, or `en-US`.
10053 */
10054 export const language: string;
10055
10056 /**
10057 * The system clipboard.
10058 */
10059 export const clipboard: Clipboard;
10060
10061 /**
10062 * A unique identifier for the computer.
10063 */
10064 export const machineId: string;
10065
10066 /**
10067 * A unique identifier for the current session.
10068 * Changes each time the editor is started.
10069 */
10070 export const sessionId: string;
10071
10072 /**
10073 * Indicates that this is a fresh install of the application.
10074 * `true` if within the first day of installation otherwise `false`.
10075 */
10076 export const isNewAppInstall: boolean;
10077
10078 /**
10079 * Indicates whether the users has telemetry enabled.
10080 * Can be observed to determine if the extension should send telemetry.
10081 */
10082 export const isTelemetryEnabled: boolean;
10083
10084 /**
10085 * An {@link Event} which fires when the user enabled or disables telemetry.
10086 * `true` if the user has enabled telemetry or `false` if the user has disabled telemetry.
10087 */
10088 export const onDidChangeTelemetryEnabled: Event<boolean>;
10089
10090 /**
10091 * An {@link Event} which fires when the default shell changes. This fires with the new
10092 * shell path.
10093 */
10094 export const onDidChangeShell: Event<string>;
10095
10096 /**
10097 * Creates a new {@link TelemetryLogger telemetry logger}.
10098 *
10099 * @param sender The telemetry sender that is used by the telemetry logger.
10100 * @param options Options for the telemetry logger.
10101 * @returns A new telemetry logger
10102 */
10103 export function createTelemetryLogger(sender: TelemetrySender, options?: TelemetryLoggerOptions): TelemetryLogger;
10104
10105 /**
10106 * The name of a remote. Defined by extensions, popular samples are `wsl` for the Windows
10107 * Subsystem for Linux or `ssh-remote` for remotes using a secure shell.
10108 *
10109 * *Note* that the value is `undefined` when there is no remote extension host but that the
10110 * value is defined in all extension hosts (local and remote) in case a remote extension host
10111 * exists. Use {@link Extension.extensionKind} to know if
10112 * a specific extension runs remote or not.
10113 */
10114 export const remoteName: string | undefined;
10115
10116 /**
10117 * The detected default shell for the extension host, this is overridden by the
10118 * `terminal.integrated.defaultProfile` setting for the extension host's platform. Note that in
10119 * environments that do not support a shell the value is the empty string.
10120 */
10121 export const shell: string;
10122
10123 /**
10124 * The UI kind property indicates from which UI extensions
10125 * are accessed from. For example, extensions could be accessed
10126 * from a desktop application or a web browser.
10127 */
10128 export const uiKind: UIKind;
10129
10130 /**
10131 * Opens a link externally using the default application. Depending on the
10132 * used scheme this can be:
10133 * * a browser (`http:`, `https:`)
10134 * * a mail client (`mailto:`)
10135 * * VSCode itself (`vscode:` from `vscode.env.uriScheme`)
10136 *
10137 * *Note* that {@linkcode window.showTextDocument showTextDocument} is the right
10138 * way to open a text document inside the editor, not this function.
10139 *
10140 * @param target The uri that should be opened.
10141 * @returns A promise indicating if open was successful.
10142 */
10143 export function openExternal(target: Uri): Thenable<boolean>;
10144
10145 /**
10146 * Resolves a uri to a form that is accessible externally.
10147 *
10148 * #### `http:` or `https:` scheme
10149 *
10150 * Resolves an *external* uri, such as a `http:` or `https:` link, from where the extension is running to a
10151 * uri to the same resource on the client machine.
10152 *
10153 * This is a no-op if the extension is running on the client machine.
10154 *
10155 * If the extension is running remotely, this function automatically establishes a port forwarding tunnel
10156 * from the local machine to `target` on the remote and returns a local uri to the tunnel. The lifetime of
10157 * the port forwarding tunnel is managed by the editor and the tunnel can be closed by the user.
10158 *
10159 * *Note* that uris passed through `openExternal` are automatically resolved and you should not call `asExternalUri` on them.
10160 *
10161 * #### `vscode.env.uriScheme`
10162 *
10163 * Creates a uri that - if opened in a browser (e.g. via `openExternal`) - will result in a registered {@link UriHandler}
10164 * to trigger.
10165 *
10166 * Extensions should not make any assumptions about the resulting uri and should not alter it in any way.
10167 * Rather, extensions can e.g. use this uri in an authentication flow, by adding the uri as callback query
10168 * argument to the server to authenticate to.
10169 *
10170 * *Note* that if the server decides to add additional query parameters to the uri (e.g. a token or secret), it
10171 * will appear in the uri that is passed to the {@link UriHandler}.
10172 *
10173 * **Example** of an authentication flow:
10174 * ```typescript
10175 * vscode.window.registerUriHandler({
10176 * handleUri(uri: vscode.Uri): vscode.ProviderResult<void> {
10177 * if (uri.path === '/did-authenticate') {
10178 * console.log(uri.toString());
10179 * }
10180 * }
10181 * });
10182 *
10183 * const callableUri = await vscode.env.asExternalUri(vscode.Uri.parse(vscode.env.uriScheme + '://my.extension/did-authenticate'));
10184 * await vscode.env.openExternal(callableUri);
10185 * ```
10186 *
10187 * *Note* that extensions should not cache the result of `asExternalUri` as the resolved uri may become invalid due to
10188 * a system or user action — for example, in remote cases, a user may close a port forwarding tunnel that was opened by
10189 * `asExternalUri`.
10190 *
10191 * #### Any other scheme
10192 *
10193 * Any other scheme will be handled as if the provided URI is a workspace URI. In that case, the method will return
10194 * a URI which, when handled, will make the editor open the workspace.
10195 *
10196 * @returns A uri that can be used on the client machine.
10197 */
10198 export function asExternalUri(target: Uri): Thenable<Uri>;
10199
10200 /**
10201 * The current log level of the editor.
10202 */
10203 export const logLevel: LogLevel;
10204
10205 /**
10206 * An {@link Event} which fires when the log level of the editor changes.
10207 */
10208 export const onDidChangeLogLevel: Event<LogLevel>;
10209 }
10210
10211 /**
10212 * Namespace for dealing with commands. In short, a command is a function with a
10213 * unique identifier. The function is sometimes also called _command handler_.
10214 *
10215 * Commands can be added to the editor using the {@link commands.registerCommand registerCommand}
10216 * and {@link commands.registerTextEditorCommand registerTextEditorCommand} functions. Commands
10217 * can be executed {@link commands.executeCommand manually} or from a UI gesture. Those are:
10218 *
10219 * * palette - Use the `commands`-section in `package.json` to make a command show in
10220 * the [command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette).
10221 * * keybinding - Use the `keybindings`-section in `package.json` to enable
10222 * [keybindings](https://code.visualstudio.com/docs/getstarted/keybindings#_advanced-customization)
10223 * for your extension.
10224 *
10225 * Commands from other extensions and from the editor itself are accessible to an extension. However,
10226 * when invoking an editor command not all argument types are supported.
10227 *
10228 * This is a sample that registers a command handler and adds an entry for that command to the palette. First
10229 * register a command handler with the identifier `extension.sayHello`.
10230 * ```javascript
10231 * commands.registerCommand('extension.sayHello', () => {
10232 * window.showInformationMessage('Hello World!');
10233 * });
10234 * ```
10235 * Second, bind the command identifier to a title under which it will show in the palette (`package.json`).
10236 * ```json
10237 * {
10238 * "contributes": {
10239 * "commands": [{
10240 * "command": "extension.sayHello",
10241 * "title": "Hello World"
10242 * }]
10243 * }
10244 * }
10245 * ```
10246 */
10247 export namespace commands {
10248
10249 /**
10250 * Registers a command that can be invoked via a keyboard shortcut,
10251 * a menu item, an action, or directly.
10252 *
10253 * Registering a command with an existing command identifier twice
10254 * will cause an error.
10255 *
10256 * @param command A unique identifier for the command.
10257 * @param callback A command handler function.
10258 * @param thisArg The `this` context used when invoking the handler function.
10259 * @returns Disposable which unregisters this command on disposal.
10260 */
10261 export function registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable;
10262
10263 /**
10264 * Registers a text editor command that can be invoked via a keyboard shortcut,
10265 * a menu item, an action, or directly.
10266 *
10267 * Text editor commands are different from ordinary {@link commands.registerCommand commands} as
10268 * they only execute when there is an active editor when the command is called. Also, the
10269 * command handler of an editor command has access to the active editor and to an
10270 * {@link TextEditorEdit edit}-builder. Note that the edit-builder is only valid while the
10271 * callback executes.
10272 *
10273 * @param command A unique identifier for the command.
10274 * @param callback A command handler function with access to an {@link TextEditor editor} and an {@link TextEditorEdit edit}.
10275 * @param thisArg The `this` context used when invoking the handler function.
10276 * @returns Disposable which unregisters this command on disposal.
10277 */
10278 export function registerTextEditorCommand(command: string, callback: (textEditor: TextEditor, edit: TextEditorEdit, ...args: any[]) => void, thisArg?: any): Disposable;
10279
10280 /**
10281 * Executes the command denoted by the given command identifier.
10282 *
10283 * * *Note 1:* When executing an editor command not all types are allowed to
10284 * be passed as arguments. Allowed are the primitive types `string`, `boolean`,
10285 * `number`, `undefined`, and `null`, as well as {@linkcode Position}, {@linkcode Range}, {@linkcode Uri} and {@linkcode Location}.
10286 * * *Note 2:* There are no restrictions when executing commands that have been contributed
10287 * by extensions.
10288 *
10289 * @param command Identifier of the command to execute.
10290 * @param rest Parameters passed to the command function.
10291 * @returns A thenable that resolves to the returned value of the given command. Returns `undefined` when
10292 * the command handler function doesn't return anything.
10293 */
10294 export function executeCommand<T = unknown>(command: string, ...rest: any[]): Thenable<T>;
10295
10296 /**
10297 * Retrieve the list of all available commands. Commands starting with an underscore are
10298 * treated as internal commands.
10299 *
10300 * @param filterInternal Set `true` to not see internal commands (starting with an underscore)
10301 * @returns Thenable that resolves to a list of command ids.
10302 */
10303 export function getCommands(filterInternal?: boolean): Thenable<string[]>;
10304 }
10305
10306 /**
10307 * Represents the state of a window.
10308 */
10309 export interface WindowState {
10310
10311 /**
10312 * Whether the current window is focused.
10313 */
10314 readonly focused: boolean;
10315
10316 /**
10317 * Whether the window has been interacted with recently. This will change
10318 * immediately on activity, or after a short time of user inactivity.
10319 */
10320 readonly active: boolean;
10321 }
10322
10323 /**
10324 * A uri handler is responsible for handling system-wide {@link Uri uris}.
10325 *
10326 * @see {@link window.registerUriHandler}.
10327 */
10328 export interface UriHandler {
10329
10330 /**
10331 * Handle the provided system-wide {@link Uri}.
10332 *
10333 * @see {@link window.registerUriHandler}.
10334 */
10335 handleUri(uri: Uri): ProviderResult<void>;
10336 }
10337
10338 /**
10339 * Namespace for dealing with the current window of the editor. That is visible
10340 * and active editors, as well as, UI elements to show messages, selections, and
10341 * asking for user input.
10342 */
10343 export namespace window {
10344
10345 /**
10346 * Represents the grid widget within the main editor area
10347 */
10348 export const tabGroups: TabGroups;
10349
10350 /**
10351 * The currently active editor or `undefined`. The active editor is the one
10352 * that currently has focus or, when none has focus, the one that has changed
10353 * input most recently.
10354 */
10355 export let activeTextEditor: TextEditor | undefined;
10356
10357 /**
10358 * The currently visible editors or an empty array.
10359 */
10360 export let visibleTextEditors: readonly TextEditor[];
10361
10362 /**
10363 * An {@link Event} which fires when the {@link window.activeTextEditor active editor}
10364 * has changed. *Note* that the event also fires when the active editor changes
10365 * to `undefined`.
10366 */
10367 export const onDidChangeActiveTextEditor: Event<TextEditor | undefined>;
10368
10369 /**
10370 * An {@link Event} which fires when the array of {@link window.visibleTextEditors visible editors}
10371 * has changed.
10372 */
10373 export const onDidChangeVisibleTextEditors: Event<readonly TextEditor[]>;
10374
10375 /**
10376 * An {@link Event} which fires when the selection in an editor has changed.
10377 */
10378 export const onDidChangeTextEditorSelection: Event<TextEditorSelectionChangeEvent>;
10379
10380 /**
10381 * An {@link Event} which fires when the visible ranges of an editor has changed.
10382 */
10383 export const onDidChangeTextEditorVisibleRanges: Event<TextEditorVisibleRangesChangeEvent>;
10384
10385 /**
10386 * An {@link Event} which fires when the options of an editor have changed.
10387 */
10388 export const onDidChangeTextEditorOptions: Event<TextEditorOptionsChangeEvent>;
10389
10390 /**
10391 * An {@link Event} which fires when the view column of an editor has changed.
10392 */
10393 export const onDidChangeTextEditorViewColumn: Event<TextEditorViewColumnChangeEvent>;
10394
10395 /**
10396 * The currently visible {@link NotebookEditor notebook editors} or an empty array.
10397 */
10398 export const visibleNotebookEditors: readonly NotebookEditor[];
10399
10400 /**
10401 * An {@link Event} which fires when the {@link window.visibleNotebookEditors visible notebook editors}
10402 * has changed.
10403 */
10404 export const onDidChangeVisibleNotebookEditors: Event<readonly NotebookEditor[]>;
10405
10406 /**
10407 * The currently active {@link NotebookEditor notebook editor} or `undefined`. The active editor is the one
10408 * that currently has focus or, when none has focus, the one that has changed
10409 * input most recently.
10410 */
10411 export const activeNotebookEditor: NotebookEditor | undefined;
10412
10413 /**
10414 * An {@link Event} which fires when the {@link window.activeNotebookEditor active notebook editor}
10415 * has changed. *Note* that the event also fires when the active editor changes
10416 * to `undefined`.
10417 */
10418 export const onDidChangeActiveNotebookEditor: Event<NotebookEditor | undefined>;
10419
10420 /**
10421 * An {@link Event} which fires when the {@link NotebookEditor.selections notebook editor selections}
10422 * have changed.
10423 */
10424 export const onDidChangeNotebookEditorSelection: Event<NotebookEditorSelectionChangeEvent>;
10425
10426 /**
10427 * An {@link Event} which fires when the {@link NotebookEditor.visibleRanges notebook editor visible ranges}
10428 * have changed.
10429 */
10430 export const onDidChangeNotebookEditorVisibleRanges: Event<NotebookEditorVisibleRangesChangeEvent>;
10431
10432 /**
10433 * The currently opened terminals or an empty array.
10434 */
10435 export const terminals: readonly Terminal[];
10436
10437 /**
10438 * The currently active terminal or `undefined`. The active terminal is the one that
10439 * currently has focus or most recently had focus.
10440 */
10441 export const activeTerminal: Terminal | undefined;
10442
10443 /**
10444 * An {@link Event} which fires when the {@link window.activeTerminal active terminal}
10445 * has changed. *Note* that the event also fires when the active terminal changes
10446 * to `undefined`.
10447 */
10448 export const onDidChangeActiveTerminal: Event<Terminal | undefined>;
10449
10450 /**
10451 * An {@link Event} which fires when a terminal has been created, either through the
10452 * {@link window.createTerminal createTerminal} API or commands.
10453 */
10454 export const onDidOpenTerminal: Event<Terminal>;
10455
10456 /**
10457 * An {@link Event} which fires when a terminal is disposed.
10458 */
10459 export const onDidCloseTerminal: Event<Terminal>;
10460
10461 /**
10462 * An {@link Event} which fires when a {@link Terminal.state terminal's state} has changed.
10463 */
10464 export const onDidChangeTerminalState: Event<Terminal>;
10465
10466 /**
10467 * Represents the current window's state.
10468 */
10469 export const state: WindowState;
10470
10471 /**
10472 * An {@link Event} which fires when the focus or activity state of the current window
10473 * changes. The value of the event represents whether the window is focused.
10474 */
10475 export const onDidChangeWindowState: Event<WindowState>;
10476
10477 /**
10478 * Show the given document in a text editor. A {@link ViewColumn column} can be provided
10479 * to control where the editor is being shown. Might change the {@link window.activeTextEditor active editor}.
10480 *
10481 * @param document A text document to be shown.
10482 * @param column A view column in which the {@link TextEditor editor} should be shown. The default is the {@link ViewColumn.Active active}.
10483 * Columns that do not exist will be created as needed up to the maximum of {@linkcode ViewColumn.Nine}. Use {@linkcode ViewColumn.Beside}
10484 * to open the editor to the side of the currently active one.
10485 * @param preserveFocus When `true` the editor will not take focus.
10486 * @returns A promise that resolves to an {@link TextEditor editor}.
10487 */
10488 export function showTextDocument(document: TextDocument, column?: ViewColumn, preserveFocus?: boolean): Thenable<TextEditor>;
10489
10490 /**
10491 * Show the given document in a text editor. {@link TextDocumentShowOptions Options} can be provided
10492 * to control options of the editor is being shown. Might change the {@link window.activeTextEditor active editor}.
10493 *
10494 * @param document A text document to be shown.
10495 * @param options {@link TextDocumentShowOptions Editor options} to configure the behavior of showing the {@link TextEditor editor}.
10496 * @returns A promise that resolves to an {@link TextEditor editor}.
10497 */
10498 export function showTextDocument(document: TextDocument, options?: TextDocumentShowOptions): Thenable<TextEditor>;
10499
10500 /**
10501 * A short-hand for `openTextDocument(uri).then(document => showTextDocument(document, options))`.
10502 *
10503 * @see {@link workspace.openTextDocument}
10504 *
10505 * @param uri A resource identifier.
10506 * @param options {@link TextDocumentShowOptions Editor options} to configure the behavior of showing the {@link TextEditor editor}.
10507 * @returns A promise that resolves to an {@link TextEditor editor}.
10508 */
10509 export function showTextDocument(uri: Uri, options?: TextDocumentShowOptions): Thenable<TextEditor>;
10510
10511 /**
10512 * Show the given {@link NotebookDocument} in a {@link NotebookEditor notebook editor}.
10513 *
10514 * @param document A text document to be shown.
10515 * @param options {@link NotebookDocumentShowOptions Editor options} to configure the behavior of showing the {@link NotebookEditor notebook editor}.
10516 *
10517 * @returns A promise that resolves to an {@link NotebookEditor notebook editor}.
10518 */
10519 export function showNotebookDocument(document: NotebookDocument, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
10520
10521 /**
10522 * Create a TextEditorDecorationType that can be used to add decorations to text editors.
10523 *
10524 * @param options Rendering options for the decoration type.
10525 * @returns A new decoration type instance.
10526 */
10527 export function createTextEditorDecorationType(options: DecorationRenderOptions): TextEditorDecorationType;
10528
10529 /**
10530 * Show an information message to users. Optionally provide an array of items which will be presented as
10531 * clickable buttons.
10532 *
10533 * @param message The message to show.
10534 * @param items A set of items that will be rendered as actions in the message.
10535 * @returns A thenable that resolves to the selected item or `undefined` when being dismissed.
10536 */
10537 export function showInformationMessage<T extends string>(message: string, ...items: T[]): Thenable<T | undefined>;
10538
10539 /**
10540 * Show an information message to users. Optionally provide an array of items which will be presented as
10541 * clickable buttons.
10542 *
10543 * @param message The message to show.
10544 * @param options Configures the behaviour of the message.
10545 * @param items A set of items that will be rendered as actions in the message.
10546 * @returns A thenable that resolves to the selected item or `undefined` when being dismissed.
10547 */
10548 export function showInformationMessage<T extends string>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
10549
10550 /**
10551 * Show an information message.
10552 *
10553 * @see {@link window.showInformationMessage showInformationMessage}
10554 *
10555 * @param message The message to show.
10556 * @param items A set of items that will be rendered as actions in the message.
10557 * @returns A thenable that resolves to the selected item or `undefined` when being dismissed.
10558 */
10559 export function showInformationMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T | undefined>;
10560
10561 /**
10562 * Show an information message.
10563 *
10564 * @see {@link window.showInformationMessage showInformationMessage}
10565 *
10566 * @param message The message to show.
10567 * @param options Configures the behaviour of the message.
10568 * @param items A set of items that will be rendered as actions in the message.
10569 * @returns A thenable that resolves to the selected item or `undefined` when being dismissed.
10570 */
10571 export function showInformationMessage<T extends MessageItem>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
10572
10573 /**
10574 * Show a warning message.
10575 *
10576 * @see {@link window.showInformationMessage showInformationMessage}
10577 *
10578 * @param message The message to show.
10579 * @param items A set of items that will be rendered as actions in the message.
10580 * @returns A thenable that resolves to the selected item or `undefined` when being dismissed.
10581 */
10582 export function showWarningMessage<T extends string>(message: string, ...items: T[]): Thenable<T | undefined>;
10583
10584 /**
10585 * Show a warning message.
10586 *
10587 * @see {@link window.showInformationMessage showInformationMessage}
10588 *
10589 * @param message The message to show.
10590 * @param options Configures the behaviour of the message.
10591 * @param items A set of items that will be rendered as actions in the message.
10592 * @returns A thenable that resolves to the selected item or `undefined` when being dismissed.
10593 */
10594 export function showWarningMessage<T extends string>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
10595
10596 /**
10597 * Show a warning message.
10598 *
10599 * @see {@link window.showInformationMessage showInformationMessage}
10600 *
10601 * @param message The message to show.
10602 * @param items A set of items that will be rendered as actions in the message.
10603 * @returns A thenable that resolves to the selected item or `undefined` when being dismissed.
10604 */
10605 export function showWarningMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T | undefined>;
10606
10607 /**
10608 * Show a warning message.
10609 *
10610 * @see {@link window.showInformationMessage showInformationMessage}
10611 *
10612 * @param message The message to show.
10613 * @param options Configures the behaviour of the message.
10614 * @param items A set of items that will be rendered as actions in the message.
10615 * @returns A thenable that resolves to the selected item or `undefined` when being dismissed.
10616 */
10617 export function showWarningMessage<T extends MessageItem>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
10618
10619 /**
10620 * Show an error message.
10621 *
10622 * @see {@link window.showInformationMessage showInformationMessage}
10623 *
10624 * @param message The message to show.
10625 * @param items A set of items that will be rendered as actions in the message.
10626 * @returns A thenable that resolves to the selected item or `undefined` when being dismissed.
10627 */
10628 export function showErrorMessage<T extends string>(message: string, ...items: T[]): Thenable<T | undefined>;
10629
10630 /**
10631 * Show an error message.
10632 *
10633 * @see {@link window.showInformationMessage showInformationMessage}
10634 *
10635 * @param message The message to show.
10636 * @param options Configures the behaviour of the message.
10637 * @param items A set of items that will be rendered as actions in the message.
10638 * @returns A thenable that resolves to the selected item or `undefined` when being dismissed.
10639 */
10640 export function showErrorMessage<T extends string>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
10641
10642 /**
10643 * Show an error message.
10644 *
10645 * @see {@link window.showInformationMessage showInformationMessage}
10646 *
10647 * @param message The message to show.
10648 * @param items A set of items that will be rendered as actions in the message.
10649 * @returns A thenable that resolves to the selected item or `undefined` when being dismissed.
10650 */
10651 export function showErrorMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T | undefined>;
10652
10653 /**
10654 * Show an error message.
10655 *
10656 * @see {@link window.showInformationMessage showInformationMessage}
10657 *
10658 * @param message The message to show.
10659 * @param options Configures the behaviour of the message.
10660 * @param items A set of items that will be rendered as actions in the message.
10661 * @returns A thenable that resolves to the selected item or `undefined` when being dismissed.
10662 */
10663 export function showErrorMessage<T extends MessageItem>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
10664
10665 /**
10666 * Shows a selection list allowing multiple selections.
10667 *
10668 * @param items An array of strings, or a promise that resolves to an array of strings.
10669 * @param options Configures the behavior of the selection list.
10670 * @param token A token that can be used to signal cancellation.
10671 * @returns A promise that resolves to the selected items or `undefined`.
10672 */
10673 export function showQuickPick(items: readonly string[] | Thenable<readonly string[]>, options: QuickPickOptions & { /** literal-type defines return type */canPickMany: true }, token?: CancellationToken): Thenable<string[] | undefined>;
10674
10675 /**
10676 * Shows a selection list.
10677 *
10678 * @param items An array of strings, or a promise that resolves to an array of strings.
10679 * @param options Configures the behavior of the selection list.
10680 * @param token A token that can be used to signal cancellation.
10681 * @returns A promise that resolves to the selection or `undefined`.
10682 */
10683 export function showQuickPick(items: readonly string[] | Thenable<readonly string[]>, options?: QuickPickOptions, token?: CancellationToken): Thenable<string | undefined>;
10684
10685 /**
10686 * Shows a selection list allowing multiple selections.
10687 *
10688 * @param items An array of items, or a promise that resolves to an array of items.
10689 * @param options Configures the behavior of the selection list.
10690 * @param token A token that can be used to signal cancellation.
10691 * @returns A promise that resolves to the selected items or `undefined`.
10692 */
10693 export function showQuickPick<T extends QuickPickItem>(items: readonly T[] | Thenable<readonly T[]>, options: QuickPickOptions & { /** literal-type defines return type */ canPickMany: true }, token?: CancellationToken): Thenable<T[] | undefined>;
10694
10695 /**
10696 * Shows a selection list.
10697 *
10698 * @param items An array of items, or a promise that resolves to an array of items.
10699 * @param options Configures the behavior of the selection list.
10700 * @param token A token that can be used to signal cancellation.
10701 * @returns A promise that resolves to the selected item or `undefined`.
10702 */
10703 export function showQuickPick<T extends QuickPickItem>(items: readonly T[] | Thenable<readonly T[]>, options?: QuickPickOptions, token?: CancellationToken): Thenable<T | undefined>;
10704
10705 /**
10706 * Shows a selection list of {@link workspace.workspaceFolders workspace folders} to pick from.
10707 * Returns `undefined` if no folder is open.
10708 *
10709 * @param options Configures the behavior of the workspace folder list.
10710 * @returns A promise that resolves to the workspace folder or `undefined`.
10711 */
10712 export function showWorkspaceFolderPick(options?: WorkspaceFolderPickOptions): Thenable<WorkspaceFolder | undefined>;
10713
10714 /**
10715 * Shows a file open dialog to the user which allows to select a file
10716 * for opening-purposes.
10717 *
10718 * @param options Options that control the dialog.
10719 * @returns A promise that resolves to the selected resources or `undefined`.
10720 */
10721 export function showOpenDialog(options?: OpenDialogOptions): Thenable<Uri[] | undefined>;
10722
10723 /**
10724 * Shows a file save dialog to the user which allows to select a file
10725 * for saving-purposes.
10726 *
10727 * @param options Options that control the dialog.
10728 * @returns A promise that resolves to the selected resource or `undefined`.
10729 */
10730 export function showSaveDialog(options?: SaveDialogOptions): Thenable<Uri | undefined>;
10731
10732 /**
10733 * Opens an input box to ask the user for input.
10734 *
10735 * The returned value will be `undefined` if the input box was canceled (e.g. pressing ESC). Otherwise the
10736 * returned value will be the string typed by the user or an empty string if the user did not type
10737 * anything but dismissed the input box with OK.
10738 *
10739 * @param options Configures the behavior of the input box.
10740 * @param token A token that can be used to signal cancellation.
10741 * @returns A promise that resolves to a string the user provided or to `undefined` in case of dismissal.
10742 */
10743 export function showInputBox(options?: InputBoxOptions, token?: CancellationToken): Thenable<string | undefined>;
10744
10745 /**
10746 * Creates a {@link QuickPick} to let the user pick an item from a list
10747 * of items of type T.
10748 *
10749 * Note that in many cases the more convenient {@link window.showQuickPick}
10750 * is easier to use. {@link window.createQuickPick} should be used
10751 * when {@link window.showQuickPick} does not offer the required flexibility.
10752 *
10753 * @returns A new {@link QuickPick}.
10754 */
10755 export function createQuickPick<T extends QuickPickItem>(): QuickPick<T>;
10756
10757 /**
10758 * Creates a {@link InputBox} to let the user enter some text input.
10759 *
10760 * Note that in many cases the more convenient {@link window.showInputBox}
10761 * is easier to use. {@link window.createInputBox} should be used
10762 * when {@link window.showInputBox} does not offer the required flexibility.
10763 *
10764 * @returns A new {@link InputBox}.
10765 */
10766 export function createInputBox(): InputBox;
10767
10768 /**
10769 * Creates a new {@link OutputChannel output channel} with the given name and language id
10770 * If language id is not provided, then **Log** is used as default language id.
10771 *
10772 * You can access the visible or active output channel as a {@link TextDocument text document} from {@link window.visibleTextEditors visible editors} or {@link window.activeTextEditor active editor}
10773 * and use the language id to contribute language features like syntax coloring, code lens etc.,
10774 *
10775 * @param name Human-readable string which will be used to represent the channel in the UI.
10776 * @param languageId The identifier of the language associated with the channel.
10777 * @returns A new output channel.
10778 */
10779 export function createOutputChannel(name: string, languageId?: string): OutputChannel;
10780
10781 /**
10782 * Creates a new {@link LogOutputChannel log output channel} with the given name.
10783 *
10784 * @param name Human-readable string which will be used to represent the channel in the UI.
10785 * @param options Options for the log output channel.
10786 * @returns A new log output channel.
10787 */
10788 export function createOutputChannel(name: string, options: { /** literal-type defines return type */log: true }): LogOutputChannel;
10789
10790 /**
10791 * Create and show a new webview panel.
10792 *
10793 * @param viewType Identifies the type of the webview panel.
10794 * @param title Title of the panel.
10795 * @param showOptions Where to show the webview in the editor. If preserveFocus is set, the new webview will not take focus.
10796 * @param options Settings for the new panel.
10797 *
10798 * @returns New webview panel.
10799 */
10800 export function createWebviewPanel(viewType: string, title: string, showOptions: ViewColumn | {
10801 /**
10802 * The view column in which the {@link WebviewPanel} should be shown.
10803 */
10804 readonly viewColumn: ViewColumn;
10805 /**
10806 * An optional flag that when `true` will stop the panel from taking focus.
10807 */
10808 readonly preserveFocus?: boolean;
10809 }, options?: WebviewPanelOptions & WebviewOptions): WebviewPanel;
10810
10811 /**
10812 * Set a message to the status bar. This is a short hand for the more powerful
10813 * status bar {@link window.createStatusBarItem items}.
10814 *
10815 * @param text The message to show, supports icon substitution as in status bar {@link StatusBarItem.text items}.
10816 * @param hideAfterTimeout Timeout in milliseconds after which the message will be disposed.
10817 * @returns A disposable which hides the status bar message.
10818 */
10819 export function setStatusBarMessage(text: string, hideAfterTimeout: number): Disposable;
10820
10821 /**
10822 * Set a message to the status bar. This is a short hand for the more powerful
10823 * status bar {@link window.createStatusBarItem items}.
10824 *
10825 * @param text The message to show, supports icon substitution as in status bar {@link StatusBarItem.text items}.
10826 * @param hideWhenDone Thenable on which completion (resolve or reject) the message will be disposed.
10827 * @returns A disposable which hides the status bar message.
10828 */
10829 export function setStatusBarMessage(text: string, hideWhenDone: Thenable<any>): Disposable;
10830
10831 /**
10832 * Set a message to the status bar. This is a short hand for the more powerful
10833 * status bar {@link window.createStatusBarItem items}.
10834 *
10835 * *Note* that status bar messages stack and that they must be disposed when no
10836 * longer used.
10837 *
10838 * @param text The message to show, supports icon substitution as in status bar {@link StatusBarItem.text items}.
10839 * @returns A disposable which hides the status bar message.
10840 */
10841 export function setStatusBarMessage(text: string): Disposable;
10842
10843 /**
10844 * Show progress in the Source Control viewlet while running the given callback and while
10845 * its returned promise isn't resolve or rejected.
10846 *
10847 * @deprecated Use `withProgress` instead.
10848 *
10849 * @param task A callback returning a promise. Progress increments can be reported with
10850 * the provided {@link Progress}-object.
10851 * @returns The thenable the task did return.
10852 */
10853 export function withScmProgress<R>(task: (progress: Progress<number>) => Thenable<R>): Thenable<R>;
10854
10855 /**
10856 * Show progress in the editor. Progress is shown while running the given callback
10857 * and while the promise it returned isn't resolved nor rejected. The location at which
10858 * progress should show (and other details) is defined via the passed {@linkcode ProgressOptions}.
10859 *
10860 * @param options A {@linkcode ProgressOptions}-object describing the options to use for showing progress, like its location
10861 * @param task A callback returning a promise. Progress state can be reported with
10862 * the provided {@link Progress}-object.
10863 *
10864 * To report discrete progress, use `increment` to indicate how much work has been completed. Each call with
10865 * a `increment` value will be summed up and reflected as overall progress until 100% is reached (a value of
10866 * e.g. `10` accounts for `10%` of work done).
10867 * Note that currently only `ProgressLocation.Notification` is capable of showing discrete progress.
10868 *
10869 * To monitor if the operation has been cancelled by the user, use the provided {@linkcode CancellationToken}.
10870 * Note that currently only `ProgressLocation.Notification` is supporting to show a cancel button to cancel the
10871 * long running operation.
10872 *
10873 * @returns The thenable the task-callback returned.
10874 */
10875 export function withProgress<R>(options: ProgressOptions, task: (progress: Progress<{
10876 /**
10877 * A progress message that represents a chunk of work
10878 */
10879 message?: string;
10880 /**
10881 * An increment for discrete progress. Increments will be summed up until 100% is reached
10882 */
10883 increment?: number;
10884 }>, token: CancellationToken) => Thenable<R>): Thenable<R>;
10885
10886 /**
10887 * Creates a status bar {@link StatusBarItem item}.
10888 *
10889 * @param id The identifier of the item. Must be unique within the extension.
10890 * @param alignment The alignment of the item.
10891 * @param priority The priority of the item. Higher values mean the item should be shown more to the left.
10892 * @returns A new status bar item.
10893 */
10894 export function createStatusBarItem(id: string, alignment?: StatusBarAlignment, priority?: number): StatusBarItem;
10895
10896 /**
10897 * Creates a status bar {@link StatusBarItem item}.
10898 *
10899 * @see {@link createStatusBarItem} for creating a status bar item with an identifier.
10900 * @param alignment The alignment of the item.
10901 * @param priority The priority of the item. Higher values mean the item should be shown more to the left.
10902 * @returns A new status bar item.
10903 */
10904 export function createStatusBarItem(alignment?: StatusBarAlignment, priority?: number): StatusBarItem;
10905
10906 /**
10907 * Creates a {@link Terminal} with a backing shell process. The cwd of the terminal will be the workspace
10908 * directory if it exists.
10909 *
10910 * @param name Optional human-readable string which will be used to represent the terminal in the UI.
10911 * @param shellPath Optional path to a custom shell executable to be used in the terminal.
10912 * @param shellArgs Optional args for the custom shell executable. A string can be used on Windows only which
10913 * allows specifying shell args in
10914 * [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6).
10915 * @returns A new Terminal.
10916 * @throws When running in an environment where a new process cannot be started.
10917 */
10918 export function createTerminal(name?: string, shellPath?: string, shellArgs?: readonly string[] | string): Terminal;
10919
10920 /**
10921 * Creates a {@link Terminal} with a backing shell process.
10922 *
10923 * @param options A TerminalOptions object describing the characteristics of the new terminal.
10924 * @returns A new Terminal.
10925 * @throws When running in an environment where a new process cannot be started.
10926 */
10927 export function createTerminal(options: TerminalOptions): Terminal;
10928
10929 /**
10930 * Creates a {@link Terminal} where an extension controls its input and output.
10931 *
10932 * @param options An {@link ExtensionTerminalOptions} object describing
10933 * the characteristics of the new terminal.
10934 * @returns A new Terminal.
10935 */
10936 export function createTerminal(options: ExtensionTerminalOptions): Terminal;
10937
10938 /**
10939 * Register a {@link TreeDataProvider} for the view contributed using the extension point `views`.
10940 * This will allow you to contribute data to the {@link TreeView} and update if the data changes.
10941 *
10942 * **Note:** To get access to the {@link TreeView} and perform operations on it, use {@link window.createTreeView createTreeView}.
10943 *
10944 * @param viewId Id of the view contributed using the extension point `views`.
10945 * @param treeDataProvider A {@link TreeDataProvider} that provides tree data for the view
10946 * @returns A {@link Disposable disposable} that unregisters the {@link TreeDataProvider}.
10947 */
10948 export function registerTreeDataProvider<T>(viewId: string, treeDataProvider: TreeDataProvider<T>): Disposable;
10949
10950 /**
10951 * Create a {@link TreeView} for the view contributed using the extension point `views`.
10952 * @param viewId Id of the view contributed using the extension point `views`.
10953 * @param options Options for creating the {@link TreeView}
10954 * @returns a {@link TreeView}.
10955 */
10956 export function createTreeView<T>(viewId: string, options: TreeViewOptions<T>): TreeView<T>;
10957
10958 /**
10959 * Registers a {@link UriHandler uri handler} capable of handling system-wide {@link Uri uris}.
10960 * In case there are multiple windows open, the topmost window will handle the uri.
10961 * A uri handler is scoped to the extension it is contributed from; it will only
10962 * be able to handle uris which are directed to the extension itself. A uri must respect
10963 * the following rules:
10964 *
10965 * - The uri-scheme must be `vscode.env.uriScheme`;
10966 * - The uri-authority must be the extension id (e.g. `my.extension`);
10967 * - The uri-path, -query and -fragment parts are arbitrary.
10968 *
10969 * For example, if the `my.extension` extension registers a uri handler, it will only
10970 * be allowed to handle uris with the prefix `product-name://my.extension`.
10971 *
10972 * An extension can only register a single uri handler in its entire activation lifetime.
10973 *
10974 * * *Note:* There is an activation event `onUri` that fires when a uri directed for
10975 * the current extension is about to be handled.
10976 *
10977 * @param handler The uri handler to register for this extension.
10978 * @returns A {@link Disposable disposable} that unregisters the handler.
10979 */
10980 export function registerUriHandler(handler: UriHandler): Disposable;
10981
10982 /**
10983 * Registers a webview panel serializer.
10984 *
10985 * Extensions that support reviving should have an `"onWebviewPanel:viewType"` activation event and
10986 * make sure that `registerWebviewPanelSerializer` is called during activation.
10987 *
10988 * Only a single serializer may be registered at a time for a given `viewType`.
10989 *
10990 * @param viewType Type of the webview panel that can be serialized.
10991 * @param serializer Webview serializer.
10992 * @returns A {@link Disposable disposable} that unregisters the serializer.
10993 */
10994 export function registerWebviewPanelSerializer(viewType: string, serializer: WebviewPanelSerializer): Disposable;
10995
10996 /**
10997 * Register a new provider for webview views.
10998 *
10999 * @param viewId Unique id of the view. This should match the `id` from the
11000 * `views` contribution in the package.json.
11001 * @param provider Provider for the webview views.
11002 *
11003 * @returns Disposable that unregisters the provider.
11004 */
11005 export function registerWebviewViewProvider(viewId: string, provider: WebviewViewProvider, options?: {
11006 /**
11007 * Content settings for the webview created for this view.
11008 */
11009 readonly webviewOptions?: {
11010 /**
11011 * Controls if the webview element itself (iframe) is kept around even when the view
11012 * is no longer visible.
11013 *
11014 * Normally the webview's html context is created when the view becomes visible
11015 * and destroyed when it is hidden. Extensions that have complex state
11016 * or UI can set the `retainContextWhenHidden` to make the editor keep the webview
11017 * context around, even when the webview moves to a background tab. When a webview using
11018 * `retainContextWhenHidden` becomes hidden, its scripts and other dynamic content are suspended.
11019 * When the view becomes visible again, the context is automatically restored
11020 * in the exact same state it was in originally. You cannot send messages to a
11021 * hidden webview, even with `retainContextWhenHidden` enabled.
11022 *
11023 * `retainContextWhenHidden` has a high memory overhead and should only be used if
11024 * your view's context cannot be quickly saved and restored.
11025 */
11026 readonly retainContextWhenHidden?: boolean;
11027 };
11028 }): Disposable;
11029
11030 /**
11031 * Register a provider for custom editors for the `viewType` contributed by the `customEditors` extension point.
11032 *
11033 * When a custom editor is opened, an `onCustomEditor:viewType` activation event is fired. Your extension
11034 * must register a {@linkcode CustomTextEditorProvider}, {@linkcode CustomReadonlyEditorProvider},
11035 * {@linkcode CustomEditorProvider}for `viewType` as part of activation.
11036 *
11037 * @param viewType Unique identifier for the custom editor provider. This should match the `viewType` from the
11038 * `customEditors` contribution point.
11039 * @param provider Provider that resolves custom editors.
11040 * @param options Options for the provider.
11041 *
11042 * @returns Disposable that unregisters the provider.
11043 */
11044 export function registerCustomEditorProvider(viewType: string, provider: CustomTextEditorProvider | CustomReadonlyEditorProvider | CustomEditorProvider, options?: {
11045 /**
11046 * Content settings for the webview panels created for this custom editor.
11047 */
11048 readonly webviewOptions?: WebviewPanelOptions;
11049
11050 /**
11051 * Only applies to `CustomReadonlyEditorProvider | CustomEditorProvider`.
11052 *
11053 * Indicates that the provider allows multiple editor instances to be open at the same time for
11054 * the same resource.
11055 *
11056 * By default, the editor only allows one editor instance to be open at a time for each resource. If the
11057 * user tries to open a second editor instance for the resource, the first one is instead moved to where
11058 * the second one was to be opened.
11059 *
11060 * When `supportsMultipleEditorsPerDocument` is enabled, users can split and create copies of the custom
11061 * editor. In this case, the custom editor must make sure it can properly synchronize the states of all
11062 * editor instances for a resource so that they are consistent.
11063 */
11064 readonly supportsMultipleEditorsPerDocument?: boolean;
11065 }): Disposable;
11066
11067 /**
11068 * Register provider that enables the detection and handling of links within the terminal.
11069 * @param provider The provider that provides the terminal links.
11070 * @returns Disposable that unregisters the provider.
11071 */
11072 export function registerTerminalLinkProvider(provider: TerminalLinkProvider): Disposable;
11073
11074 /**
11075 * Registers a provider for a contributed terminal profile.
11076 *
11077 * @param id The ID of the contributed terminal profile.
11078 * @param provider The terminal profile provider.
11079 * @returns A {@link Disposable disposable} that unregisters the provider.
11080 */
11081 export function registerTerminalProfileProvider(id: string, provider: TerminalProfileProvider): Disposable;
11082 /**
11083 * Register a file decoration provider.
11084 *
11085 * @param provider A {@link FileDecorationProvider}.
11086 * @returns A {@link Disposable} that unregisters the provider.
11087 */
11088 export function registerFileDecorationProvider(provider: FileDecorationProvider): Disposable;
11089
11090 /**
11091 * The currently active color theme as configured in the settings. The active
11092 * theme can be changed via the `workbench.colorTheme` setting.
11093 */
11094 export let activeColorTheme: ColorTheme;
11095
11096 /**
11097 * An {@link Event} which fires when the active color theme is changed or has changes.
11098 */
11099 export const onDidChangeActiveColorTheme: Event<ColorTheme>;
11100 }
11101
11102 /**
11103 * Options for creating a {@link TreeView}
11104 */
11105 export interface TreeViewOptions<T> {
11106
11107 /**
11108 * A data provider that provides tree data.
11109 */
11110 treeDataProvider: TreeDataProvider<T>;
11111
11112 /**
11113 * Whether to show collapse all action or not.
11114 */
11115 showCollapseAll?: boolean;
11116
11117 /**
11118 * Whether the tree supports multi-select. When the tree supports multi-select and a command is executed from the tree,
11119 * the first argument to the command is the tree item that the command was executed on and the second argument is an
11120 * array containing all selected tree items.
11121 */
11122 canSelectMany?: boolean;
11123
11124 /**
11125 * An optional interface to implement drag and drop in the tree view.
11126 */
11127 dragAndDropController?: TreeDragAndDropController<T>;
11128
11129 /**
11130 * By default, when the children of a tree item have already been fetched, child checkboxes are automatically managed based on the checked state of the parent tree item.
11131 * If the tree item is collapsed by default (meaning that the children haven't yet been fetched) then child checkboxes will not be updated.
11132 * To override this behavior and manage child and parent checkbox state in the extension, set this to `true`.
11133 *
11134 * Examples where {@link TreeViewOptions.manageCheckboxStateManually} is false, the default behavior:
11135 *
11136 * 1. A tree item is checked, then its children are fetched. The children will be checked.
11137 *
11138 * 2. A tree item's parent is checked. The tree item and all of it's siblings will be checked.
11139 * - [ ] Parent
11140 * - [ ] Child 1
11141 * - [ ] Child 2
11142 * When the user checks Parent, the tree will look like this:
11143 * - [x] Parent
11144 * - [x] Child 1
11145 * - [x] Child 2
11146 *
11147 * 3. A tree item and all of it's siblings are checked. The parent will be checked.
11148 * - [ ] Parent
11149 * - [ ] Child 1
11150 * - [ ] Child 2
11151 * When the user checks Child 1 and Child 2, the tree will look like this:
11152 * - [x] Parent
11153 * - [x] Child 1
11154 * - [x] Child 2
11155 *
11156 * 4. A tree item is unchecked. The parent will be unchecked.
11157 * - [x] Parent
11158 * - [x] Child 1
11159 * - [x] Child 2
11160 * When the user unchecks Child 1, the tree will look like this:
11161 * - [ ] Parent
11162 * - [ ] Child 1
11163 * - [x] Child 2
11164 */
11165 manageCheckboxStateManually?: boolean;
11166 }
11167
11168 /**
11169 * The event that is fired when an element in the {@link TreeView} is expanded or collapsed
11170 */
11171 export interface TreeViewExpansionEvent<T> {
11172
11173 /**
11174 * Element that is expanded or collapsed.
11175 */
11176 readonly element: T;
11177
11178 }
11179
11180 /**
11181 * The event that is fired when there is a change in {@link TreeView.selection tree view's selection}
11182 */
11183 export interface TreeViewSelectionChangeEvent<T> {
11184
11185 /**
11186 * Selected elements.
11187 */
11188 readonly selection: readonly T[];
11189
11190 }
11191
11192 /**
11193 * The event that is fired when there is a change in {@link TreeView.visible tree view's visibility}
11194 */
11195 export interface TreeViewVisibilityChangeEvent {
11196
11197 /**
11198 * `true` if the {@link TreeView tree view} is visible otherwise `false`.
11199 */
11200 readonly visible: boolean;
11201 }
11202
11203 /**
11204 * A file associated with a {@linkcode DataTransferItem}.
11205 *
11206 * Instances of this type can only be created by the editor and not by extensions.
11207 */
11208 export interface DataTransferFile {
11209 /**
11210 * The name of the file.
11211 */
11212 readonly name: string;
11213
11214 /**
11215 * The full file path of the file.
11216 *
11217 * May be `undefined` on web.
11218 */
11219 readonly uri?: Uri;
11220
11221 /**
11222 * The full file contents of the file.
11223 */
11224 data(): Thenable<Uint8Array>;
11225 }
11226
11227 /**
11228 * Encapsulates data transferred during drag and drop operations.
11229 */
11230 export class DataTransferItem {
11231 /**
11232 * Get a string representation of this item.
11233 *
11234 * If {@linkcode DataTransferItem.value} is an object, this returns the result of json stringifying {@linkcode DataTransferItem.value} value.
11235 */
11236 asString(): Thenable<string>;
11237
11238 /**
11239 * Try getting the {@link DataTransferFile file} associated with this data transfer item.
11240 *
11241 * Note that the file object is only valid for the scope of the drag and drop operation.
11242 *
11243 * @returns The file for the data transfer or `undefined` if the item is either not a file or the
11244 * file data cannot be accessed.
11245 */
11246 asFile(): DataTransferFile | undefined;
11247
11248 /**
11249 * Custom data stored on this item.
11250 *
11251 * You can use `value` to share data across operations. The original object can be retrieved so long as the extension that
11252 * created the `DataTransferItem` runs in the same extension host.
11253 */
11254 readonly value: any;
11255
11256 /**
11257 * @param value Custom data stored on this item. Can be retrieved using {@linkcode DataTransferItem.value}.
11258 */
11259 constructor(value: any);
11260 }
11261
11262 /**
11263 * A map containing a mapping of the mime type of the corresponding transferred data.
11264 *
11265 * Drag and drop controllers that implement {@link TreeDragAndDropController.handleDrag `handleDrag`} can add additional mime types to the
11266 * data transfer. These additional mime types will only be included in the `handleDrop` when the the drag was initiated from
11267 * an element in the same drag and drop controller.
11268 */
11269 export class DataTransfer implements Iterable<[mimeType: string, item: DataTransferItem]> {
11270 /**
11271 * Retrieves the data transfer item for a given mime type.
11272 *
11273 * @param mimeType The mime type to get the data transfer item for, such as `text/plain` or `image/png`.
11274 * Mimes type look ups are case-insensitive.
11275 *
11276 * Special mime types:
11277 * - `text/uri-list` — A string with `toString()`ed Uris separated by `\r\n`. To specify a cursor position in the file,
11278 * set the Uri's fragment to `L3,5`, where 3 is the line number and 5 is the column number.
11279 */
11280 get(mimeType: string): DataTransferItem | undefined;
11281
11282 /**
11283 * Sets a mime type to data transfer item mapping.
11284 *
11285 * @param mimeType The mime type to set the data for. Mimes types stored in lower case, with case-insensitive looks up.
11286 * @param value The data transfer item for the given mime type.
11287 */
11288 set(mimeType: string, value: DataTransferItem): void;
11289
11290 /**
11291 * Allows iteration through the data transfer items.
11292 *
11293 * @param callbackfn Callback for iteration through the data transfer items.
11294 * @param thisArg The `this` context used when invoking the handler function.
11295 */
11296 forEach(callbackfn: (item: DataTransferItem, mimeType: string, dataTransfer: DataTransfer) => void, thisArg?: any): void;
11297
11298 /**
11299 * Get a new iterator with the `[mime, item]` pairs for each element in this data transfer.
11300 */
11301 [Symbol.iterator](): IterableIterator<[mimeType: string, item: DataTransferItem]>;
11302 }
11303
11304 /**
11305 * Provides support for drag and drop in `TreeView`.
11306 */
11307 export interface TreeDragAndDropController<T> {
11308
11309 /**
11310 * The mime types that the {@link TreeDragAndDropController.handleDrop `handleDrop`} method of this `DragAndDropController` supports.
11311 * This could be well-defined, existing, mime types, and also mime types defined by the extension.
11312 *
11313 * To support drops from trees, you will need to add the mime type of that tree.
11314 * This includes drops from within the same tree.
11315 * The mime type of a tree is recommended to be of the format `application/vnd.code.tree.<treeidlowercase>`.
11316 *
11317 * Use the special `files` mime type to support all types of dropped files {@link DataTransferFile files}, regardless of the file's actual mime type.
11318 *
11319 * To learn the mime type of a dragged item:
11320 * 1. Set up your `DragAndDropController`
11321 * 2. Use the Developer: Set Log Level... command to set the level to "Debug"
11322 * 3. Open the developer tools and drag the item with unknown mime type over your tree. The mime types will be logged to the developer console
11323 *
11324 * Note that mime types that cannot be sent to the extension will be omitted.
11325 */
11326 readonly dropMimeTypes: readonly string[];
11327
11328 /**
11329 * The mime types that the {@link TreeDragAndDropController.handleDrag `handleDrag`} method of this `TreeDragAndDropController` may add to the tree data transfer.
11330 * This could be well-defined, existing, mime types, and also mime types defined by the extension.
11331 *
11332 * The recommended mime type of the tree (`application/vnd.code.tree.<treeidlowercase>`) will be automatically added.
11333 */
11334 readonly dragMimeTypes: readonly string[];
11335
11336 /**
11337 * When the user starts dragging items from this `DragAndDropController`, `handleDrag` will be called.
11338 * Extensions can use `handleDrag` to add their {@link DataTransferItem `DataTransferItem`} items to the drag and drop.
11339 *
11340 * When the items are dropped on **another tree item** in **the same tree**, your `DataTransferItem` objects
11341 * will be preserved. Use the recommended mime type for the tree (`application/vnd.code.tree.<treeidlowercase>`) to add
11342 * tree objects in a data transfer. See the documentation for `DataTransferItem` for how best to take advantage of this.
11343 *
11344 * To add a data transfer item that can be dragged into the editor, use the application specific mime type "text/uri-list".
11345 * The data for "text/uri-list" should be a string with `toString()`ed Uris separated by `\r\n`. To specify a cursor position in the file,
11346 * set the Uri's fragment to `L3,5`, where 3 is the line number and 5 is the column number.
11347 *
11348 * @param source The source items for the drag and drop operation.
11349 * @param dataTransfer The data transfer associated with this drag.
11350 * @param token A cancellation token indicating that drag has been cancelled.
11351 */
11352 handleDrag?(source: readonly T[], dataTransfer: DataTransfer, token: CancellationToken): Thenable<void> | void;
11353
11354 /**
11355 * Called when a drag and drop action results in a drop on the tree that this `DragAndDropController` belongs to.
11356 *
11357 * Extensions should fire {@link TreeDataProvider.onDidChangeTreeData onDidChangeTreeData} for any elements that need to be refreshed.
11358 *
11359 * @param dataTransfer The data transfer items of the source of the drag.
11360 * @param target The target tree element that the drop is occurring on. When undefined, the target is the root.
11361 * @param token A cancellation token indicating that the drop has been cancelled.
11362 */
11363 handleDrop?(target: T | undefined, dataTransfer: DataTransfer, token: CancellationToken): Thenable<void> | void;
11364 }
11365
11366 /**
11367 * A badge presenting a value for a view
11368 */
11369 export interface ViewBadge {
11370
11371 /**
11372 * A label to present in tooltip for the badge.
11373 */
11374 readonly tooltip: string;
11375
11376 /**
11377 * The value to present in the badge.
11378 */
11379 readonly value: number;
11380 }
11381
11382 /**
11383 * An event describing the change in a tree item's checkbox state.
11384 */
11385 export interface TreeCheckboxChangeEvent<T> {
11386 /**
11387 * The items that were checked or unchecked.
11388 */
11389 readonly items: ReadonlyArray<[T, TreeItemCheckboxState]>;
11390 }
11391
11392 /**
11393 * Represents a Tree view
11394 */
11395 export interface TreeView<T> extends Disposable {
11396
11397 /**
11398 * Event that is fired when an element is expanded
11399 */
11400 readonly onDidExpandElement: Event<TreeViewExpansionEvent<T>>;
11401
11402 /**
11403 * Event that is fired when an element is collapsed
11404 */
11405 readonly onDidCollapseElement: Event<TreeViewExpansionEvent<T>>;
11406
11407 /**
11408 * Currently selected elements.
11409 */
11410 readonly selection: readonly T[];
11411
11412 /**
11413 * Event that is fired when the {@link TreeView.selection selection} has changed
11414 */
11415 readonly onDidChangeSelection: Event<TreeViewSelectionChangeEvent<T>>;
11416
11417 /**
11418 * `true` if the {@link TreeView tree view} is visible otherwise `false`.
11419 */
11420 readonly visible: boolean;
11421
11422 /**
11423 * Event that is fired when {@link TreeView.visible visibility} has changed
11424 */
11425 readonly onDidChangeVisibility: Event<TreeViewVisibilityChangeEvent>;
11426
11427 /**
11428 * An event to signal that an element or root has either been checked or unchecked.
11429 */
11430 readonly onDidChangeCheckboxState: Event<TreeCheckboxChangeEvent<T>>;
11431
11432 /**
11433 * An optional human-readable message that will be rendered in the view.
11434 * Setting the message to null, undefined, or empty string will remove the message from the view.
11435 */
11436 message?: string;
11437
11438 /**
11439 * The tree view title is initially taken from the extension package.json
11440 * Changes to the title property will be properly reflected in the UI in the title of the view.
11441 */
11442 title?: string;
11443
11444 /**
11445 * An optional human-readable description which is rendered less prominently in the title of the view.
11446 * Setting the title description to null, undefined, or empty string will remove the description from the view.
11447 */
11448 description?: string;
11449
11450 /**
11451 * The badge to display for this TreeView.
11452 * To remove the badge, set to undefined.
11453 */
11454 badge?: ViewBadge | undefined;
11455
11456 /**
11457 * Reveals the given element in the tree view.
11458 * If the tree view is not visible then the tree view is shown and element is revealed.
11459 *
11460 * By default revealed element is selected.
11461 * In order to not to select, set the option `select` to `false`.
11462 * In order to focus, set the option `focus` to `true`.
11463 * In order to expand the revealed element, set the option `expand` to `true`. To expand recursively set `expand` to the number of levels to expand.
11464 *
11465 * * *NOTE:* You can expand only to 3 levels maximum.
11466 * * *NOTE:* The {@link TreeDataProvider} that the `TreeView` {@link window.createTreeView is registered with} with must implement {@link TreeDataProvider.getParent getParent} method to access this API.
11467 */
11468 reveal(element: T, options?: {
11469 /**
11470 * If true, then the element will be selected.
11471 */
11472 select?: boolean;
11473 /**
11474 * If true, then the element will be focused.
11475 */
11476 focus?: boolean;
11477 /**
11478 * If true, then the element will be expanded. If a number is passed, then up to that number of levels of children will be expanded
11479 */
11480 expand?: boolean | number;
11481 }): Thenable<void>;
11482 }
11483
11484 /**
11485 * A data provider that provides tree data
11486 */
11487 export interface TreeDataProvider<T> {
11488 /**
11489 * An optional event to signal that an element or root has changed.
11490 * This will trigger the view to update the changed element/root and its children recursively (if shown).
11491 * To signal that root has changed, do not pass any argument or pass `undefined` or `null`.
11492 */
11493 onDidChangeTreeData?: Event<T | T[] | undefined | null | void>;
11494
11495 /**
11496 * Get {@link TreeItem} representation of the `element`
11497 *
11498 * @param element The element for which {@link TreeItem} representation is asked for.
11499 * @returns TreeItem representation of the element.
11500 */
11501 getTreeItem(element: T): TreeItem | Thenable<TreeItem>;
11502
11503 /**
11504 * Get the children of `element` or root if no element is passed.
11505 *
11506 * @param element The element from which the provider gets children. Can be `undefined`.
11507 * @returns Children of `element` or root if no element is passed.
11508 */
11509 getChildren(element?: T): ProviderResult<T[]>;
11510
11511 /**
11512 * Optional method to return the parent of `element`.
11513 * Return `null` or `undefined` if `element` is a child of root.
11514 *
11515 * **NOTE:** This method should be implemented in order to access {@link TreeView.reveal reveal} API.
11516 *
11517 * @param element The element for which the parent has to be returned.
11518 * @returns Parent of `element`.
11519 */
11520 getParent?(element: T): ProviderResult<T>;
11521
11522 /**
11523 * Called on hover to resolve the {@link TreeItem.tooltip TreeItem} property if it is undefined.
11524 * Called on tree item click/open to resolve the {@link TreeItem.command TreeItem} property if it is undefined.
11525 * Only properties that were undefined can be resolved in `resolveTreeItem`.
11526 * Functionality may be expanded later to include being called to resolve other missing
11527 * properties on selection and/or on open.
11528 *
11529 * Will only ever be called once per TreeItem.
11530 *
11531 * onDidChangeTreeData should not be triggered from within resolveTreeItem.
11532 *
11533 * *Note* that this function is called when tree items are already showing in the UI.
11534 * Because of that, no property that changes the presentation (label, description, etc.)
11535 * can be changed.
11536 *
11537 * @param item Undefined properties of `item` should be set then `item` should be returned.
11538 * @param element The object associated with the TreeItem.
11539 * @param token A cancellation token.
11540 * @returns The resolved tree item or a thenable that resolves to such. It is OK to return the given
11541 * `item`. When no result is returned, the given `item` will be used.
11542 */
11543 resolveTreeItem?(item: TreeItem, element: T, token: CancellationToken): ProviderResult<TreeItem>;
11544 }
11545
11546 /**
11547 * A tree item is an UI element of the tree. Tree items are created by the {@link TreeDataProvider data provider}.
11548 */
11549 export class TreeItem {
11550 /**
11551 * A human-readable string describing this item. When `falsy`, it is derived from {@link TreeItem.resourceUri resourceUri}.
11552 */
11553 label?: string | TreeItemLabel;
11554
11555 /**
11556 * Optional id for the tree item that has to be unique across tree. The id is used to preserve the selection and expansion state of the tree item.
11557 *
11558 * If not provided, an id is generated using the tree item's label. **Note** that when labels change, ids will change and that selection and expansion state cannot be kept stable anymore.
11559 */
11560 id?: string;
11561
11562 /**
11563 * The icon path or {@link ThemeIcon} for the tree item.
11564 * When `falsy`, {@link ThemeIcon.Folder Folder Theme Icon} is assigned, if item is collapsible otherwise {@link ThemeIcon.File File Theme Icon}.
11565 * When a file or folder {@link ThemeIcon} is specified, icon is derived from the current file icon theme for the specified theme icon using {@link TreeItem.resourceUri resourceUri} (if provided).
11566 */
11567 iconPath?: string | Uri | {
11568 /**
11569 * The icon path for the light theme.
11570 */
11571 light: string | Uri;
11572 /**
11573 * The icon path for the dark theme.
11574 */
11575 dark: string | Uri;
11576 } | ThemeIcon;
11577
11578 /**
11579 * A human-readable string which is rendered less prominent.
11580 * When `true`, it is derived from {@link TreeItem.resourceUri resourceUri} and when `falsy`, it is not shown.
11581 */
11582 description?: string | boolean;
11583
11584 /**
11585 * The {@link Uri} of the resource representing this item.
11586 *
11587 * Will be used to derive the {@link TreeItem.label label}, when it is not provided.
11588 * Will be used to derive the icon from current file icon theme, when {@link TreeItem.iconPath iconPath} has {@link ThemeIcon} value.
11589 */
11590 resourceUri?: Uri;
11591
11592 /**
11593 * The tooltip text when you hover over this item.
11594 */
11595 tooltip?: string | MarkdownString | undefined;
11596
11597 /**
11598 * The {@link Command} that should be executed when the tree item is selected.
11599 *
11600 * Please use `vscode.open` or `vscode.diff` as command IDs when the tree item is opening
11601 * something in the editor. Using these commands ensures that the resulting editor will
11602 * appear consistent with how other built-in trees open editors.
11603 */
11604 command?: Command;
11605
11606 /**
11607 * {@link TreeItemCollapsibleState} of the tree item.
11608 */
11609 collapsibleState?: TreeItemCollapsibleState;
11610
11611 /**
11612 * Context value of the tree item. This can be used to contribute item specific actions in the tree.
11613 * For example, a tree item is given a context value as `folder`. When contributing actions to `view/item/context`
11614 * using `menus` extension point, you can specify context value for key `viewItem` in `when` expression like `viewItem == folder`.
11615 * ```json
11616 * "contributes": {
11617 * "menus": {
11618 * "view/item/context": [
11619 * {
11620 * "command": "extension.deleteFolder",
11621 * "when": "viewItem == folder"
11622 * }
11623 * ]
11624 * }
11625 * }
11626 * ```
11627 * This will show action `extension.deleteFolder` only for items with `contextValue` is `folder`.
11628 */
11629 contextValue?: string;
11630
11631 /**
11632 * Accessibility information used when screen reader interacts with this tree item.
11633 * Generally, a TreeItem has no need to set the `role` of the accessibilityInformation;
11634 * however, there are cases where a TreeItem is not displayed in a tree-like way where setting the `role` may make sense.
11635 */
11636 accessibilityInformation?: AccessibilityInformation;
11637
11638 /**
11639 * {@link TreeItemCheckboxState TreeItemCheckboxState} of the tree item.
11640 * {@link TreeDataProvider.onDidChangeTreeData onDidChangeTreeData} should be fired when {@link TreeItem.checkboxState checkboxState} changes.
11641 */
11642 checkboxState?: TreeItemCheckboxState | {
11643 /**
11644 * The {@link TreeItemCheckboxState} of the tree item
11645 */
11646 readonly state: TreeItemCheckboxState;
11647 /**
11648 * A tooltip for the checkbox
11649 */
11650 readonly tooltip?: string;
11651 /**
11652 * Accessibility information used when screen readers interact with this checkbox
11653 */
11654 readonly accessibilityInformation?: AccessibilityInformation;
11655 };
11656
11657 /**
11658 * @param label A human-readable string describing this item
11659 * @param collapsibleState {@link TreeItemCollapsibleState} of the tree item. Default is {@link TreeItemCollapsibleState.None}
11660 */
11661 constructor(label: string | TreeItemLabel, collapsibleState?: TreeItemCollapsibleState);
11662
11663 /**
11664 * @param resourceUri The {@link Uri} of the resource representing this item.
11665 * @param collapsibleState {@link TreeItemCollapsibleState} of the tree item. Default is {@link TreeItemCollapsibleState.None}
11666 */
11667 constructor(resourceUri: Uri, collapsibleState?: TreeItemCollapsibleState);
11668 }
11669
11670 /**
11671 * Collapsible state of the tree item
11672 */
11673 export enum TreeItemCollapsibleState {
11674 /**
11675 * Determines an item can be neither collapsed nor expanded. Implies it has no children.
11676 */
11677 None = 0,
11678 /**
11679 * Determines an item is collapsed
11680 */
11681 Collapsed = 1,
11682 /**
11683 * Determines an item is expanded
11684 */
11685 Expanded = 2
11686 }
11687
11688 /**
11689 * Label describing the {@link TreeItem Tree item}
11690 */
11691 export interface TreeItemLabel {
11692
11693 /**
11694 * A human-readable string describing the {@link TreeItem Tree item}.
11695 */
11696 label: string;
11697
11698 /**
11699 * Ranges in the label to highlight. A range is defined as a tuple of two number where the
11700 * first is the inclusive start index and the second the exclusive end index
11701 */
11702 highlights?: [number, number][];
11703 }
11704
11705 /**
11706 * Checkbox state of the tree item
11707 */
11708 export enum TreeItemCheckboxState {
11709 /**
11710 * Determines an item is unchecked
11711 */
11712 Unchecked = 0,
11713 /**
11714 * Determines an item is checked
11715 */
11716 Checked = 1
11717 }
11718
11719 /**
11720 * Value-object describing what options a terminal should use.
11721 */
11722 export interface TerminalOptions {
11723 /**
11724 * A human-readable string which will be used to represent the terminal in the UI.
11725 */
11726 name?: string;
11727
11728 /**
11729 * A path to a custom shell executable to be used in the terminal.
11730 */
11731 shellPath?: string;
11732
11733 /**
11734 * Args for the custom shell executable. A string can be used on Windows only which allows
11735 * specifying shell args in [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6).
11736 */
11737 shellArgs?: string[] | string;
11738
11739 /**
11740 * A path or Uri for the current working directory to be used for the terminal.
11741 */
11742 cwd?: string | Uri;
11743
11744 /**
11745 * Object with environment variables that will be added to the editor process.
11746 */
11747 env?: { [key: string]: string | null | undefined };
11748
11749 /**
11750 * Whether the terminal process environment should be exactly as provided in
11751 * `TerminalOptions.env`. When this is false (default), the environment will be based on the
11752 * window's environment and also apply configured platform settings like
11753 * `terminal.integrated.env.windows` on top. When this is true, the complete environment
11754 * must be provided as nothing will be inherited from the process or any configuration.
11755 */
11756 strictEnv?: boolean;
11757
11758 /**
11759 * When enabled the terminal will run the process as normal but not be surfaced to the user
11760 * until `Terminal.show` is called. The typical usage for this is when you need to run
11761 * something that may need interactivity but only want to tell the user about it when
11762 * interaction is needed. Note that the terminals will still be exposed to all extensions
11763 * as normal. The hidden terminals will not be restored when the workspace is next opened.
11764 */
11765 hideFromUser?: boolean;
11766
11767 /**
11768 * A message to write to the terminal on first launch, note that this is not sent to the
11769 * process but, rather written directly to the terminal. This supports escape sequences such
11770 * a setting text style.
11771 */
11772 message?: string;
11773
11774 /**
11775 * The icon path or {@link ThemeIcon} for the terminal.
11776 */
11777 iconPath?: Uri | {
11778 /**
11779 * The icon path for the light theme.
11780 */
11781 light: Uri;
11782 /**
11783 * The icon path for the dark theme.
11784 */
11785 dark: Uri;
11786 } | ThemeIcon;
11787
11788 /**
11789 * The icon {@link ThemeColor} for the terminal.
11790 * The `terminal.ansi*` theme keys are
11791 * recommended for the best contrast and consistency across themes.
11792 */
11793 color?: ThemeColor;
11794
11795 /**
11796 * The {@link TerminalLocation} or {@link TerminalEditorLocationOptions} or {@link TerminalSplitLocationOptions} for the terminal.
11797 */
11798 location?: TerminalLocation | TerminalEditorLocationOptions | TerminalSplitLocationOptions;
11799
11800 /**
11801 * Opt-out of the default terminal persistence on restart and reload.
11802 * This will only take effect when `terminal.integrated.enablePersistentSessions` is enabled.
11803 */
11804 isTransient?: boolean;
11805 }
11806
11807 /**
11808 * Value-object describing what options a virtual process terminal should use.
11809 */
11810 export interface ExtensionTerminalOptions {
11811 /**
11812 * A human-readable string which will be used to represent the terminal in the UI.
11813 */
11814 name: string;
11815
11816 /**
11817 * An implementation of {@link Pseudoterminal} that allows an extension to
11818 * control a terminal.
11819 */
11820 pty: Pseudoterminal;
11821
11822 /**
11823 * The icon path or {@link ThemeIcon} for the terminal.
11824 */
11825 iconPath?: Uri | {
11826 /**
11827 * The icon path for the light theme.
11828 */
11829 light: Uri;
11830 /**
11831 * The icon path for the dark theme.
11832 */
11833 dark: Uri;
11834 } | ThemeIcon;
11835
11836 /**
11837 * The icon {@link ThemeColor} for the terminal.
11838 * The standard `terminal.ansi*` theme keys are
11839 * recommended for the best contrast and consistency across themes.
11840 */
11841 color?: ThemeColor;
11842
11843 /**
11844 * The {@link TerminalLocation} or {@link TerminalEditorLocationOptions} or {@link TerminalSplitLocationOptions} for the terminal.
11845 */
11846 location?: TerminalLocation | TerminalEditorLocationOptions | TerminalSplitLocationOptions;
11847
11848 /**
11849 * Opt-out of the default terminal persistence on restart and reload.
11850 * This will only take effect when `terminal.integrated.enablePersistentSessions` is enabled.
11851 */
11852 isTransient?: boolean;
11853 }
11854
11855 /**
11856 * Defines the interface of a terminal pty, enabling extensions to control a terminal.
11857 */
11858 interface Pseudoterminal {
11859 /**
11860 * An event that when fired will write data to the terminal. Unlike
11861 * {@link Terminal.sendText} which sends text to the underlying child
11862 * pseudo-device (the child), this will write the text to parent pseudo-device (the
11863 * _terminal_ itself).
11864 *
11865 * Note writing `\n` will just move the cursor down 1 row, you need to write `\r` as well
11866 * to move the cursor to the left-most cell.
11867 *
11868 * Events fired before {@link Pseudoterminal.open} is called will be be ignored.
11869 *
11870 * **Example:** Write red text to the terminal
11871 * ```typescript
11872 * const writeEmitter = new vscode.EventEmitter<string>();
11873 * const pty: vscode.Pseudoterminal = {
11874 * onDidWrite: writeEmitter.event,
11875 * open: () => writeEmitter.fire('\x1b[31mHello world\x1b[0m'),
11876 * close: () => {}
11877 * };
11878 * vscode.window.createTerminal({ name: 'My terminal', pty });
11879 * ```
11880 *
11881 * **Example:** Move the cursor to the 10th row and 20th column and write an asterisk
11882 * ```typescript
11883 * writeEmitter.fire('\x1b[10;20H*');
11884 * ```
11885 */
11886 onDidWrite: Event<string>;
11887
11888 /**
11889 * An event that when fired allows overriding the {@link Pseudoterminal.setDimensions dimensions} of the
11890 * terminal. Note that when set, the overridden dimensions will only take effect when they
11891 * are lower than the actual dimensions of the terminal (ie. there will never be a scroll
11892 * bar). Set to `undefined` for the terminal to go back to the regular dimensions (fit to
11893 * the size of the panel).
11894 *
11895 * Events fired before {@link Pseudoterminal.open} is called will be be ignored.
11896 *
11897 * **Example:** Override the dimensions of a terminal to 20 columns and 10 rows
11898 * ```typescript
11899 * const dimensionsEmitter = new vscode.EventEmitter<vscode.TerminalDimensions>();
11900 * const pty: vscode.Pseudoterminal = {
11901 * onDidWrite: writeEmitter.event,
11902 * onDidOverrideDimensions: dimensionsEmitter.event,
11903 * open: () => {
11904 * dimensionsEmitter.fire({
11905 * columns: 20,
11906 * rows: 10
11907 * });
11908 * },
11909 * close: () => {}
11910 * };
11911 * vscode.window.createTerminal({ name: 'My terminal', pty });
11912 * ```
11913 */
11914 onDidOverrideDimensions?: Event<TerminalDimensions | undefined>;
11915
11916 /**
11917 * An event that when fired will signal that the pty is closed and dispose of the terminal.
11918 *
11919 * Events fired before {@link Pseudoterminal.open} is called will be be ignored.
11920 *
11921 * A number can be used to provide an exit code for the terminal. Exit codes must be
11922 * positive and a non-zero exit codes signals failure which shows a notification for a
11923 * regular terminal and allows dependent tasks to proceed when used with the
11924 * `CustomExecution` API.
11925 *
11926 * **Example:** Exit the terminal when "y" is pressed, otherwise show a notification.
11927 * ```typescript
11928 * const writeEmitter = new vscode.EventEmitter<string>();
11929 * const closeEmitter = new vscode.EventEmitter<void>();
11930 * const pty: vscode.Pseudoterminal = {
11931 * onDidWrite: writeEmitter.event,
11932 * onDidClose: closeEmitter.event,
11933 * open: () => writeEmitter.fire('Press y to exit successfully'),
11934 * close: () => {},
11935 * handleInput: data => {
11936 * if (data !== 'y') {
11937 * vscode.window.showInformationMessage('Something went wrong');
11938 * }
11939 * closeEmitter.fire();
11940 * }
11941 * };
11942 * const terminal = vscode.window.createTerminal({ name: 'Exit example', pty });
11943 * terminal.show(true);
11944 * ```
11945 */
11946 onDidClose?: Event<void | number>;
11947
11948 /**
11949 * An event that when fired allows changing the name of the terminal.
11950 *
11951 * Events fired before {@link Pseudoterminal.open} is called will be be ignored.
11952 *
11953 * **Example:** Change the terminal name to "My new terminal".
11954 * ```typescript
11955 * const writeEmitter = new vscode.EventEmitter<string>();
11956 * const changeNameEmitter = new vscode.EventEmitter<string>();
11957 * const pty: vscode.Pseudoterminal = {
11958 * onDidWrite: writeEmitter.event,
11959 * onDidChangeName: changeNameEmitter.event,
11960 * open: () => changeNameEmitter.fire('My new terminal'),
11961 * close: () => {}
11962 * };
11963 * vscode.window.createTerminal({ name: 'My terminal', pty });
11964 * ```
11965 */
11966 onDidChangeName?: Event<string>;
11967
11968 /**
11969 * Implement to handle when the pty is open and ready to start firing events.
11970 *
11971 * @param initialDimensions The dimensions of the terminal, this will be undefined if the
11972 * terminal panel has not been opened before this is called.
11973 */
11974 open(initialDimensions: TerminalDimensions | undefined): void;
11975
11976 /**
11977 * Implement to handle when the terminal is closed by an act of the user.
11978 */
11979 close(): void;
11980
11981 /**
11982 * Implement to handle incoming keystrokes in the terminal or when an extension calls
11983 * {@link Terminal.sendText}. `data` contains the keystrokes/text serialized into
11984 * their corresponding VT sequence representation.
11985 *
11986 * @param data The incoming data.
11987 *
11988 * **Example:** Echo input in the terminal. The sequence for enter (`\r`) is translated to
11989 * CRLF to go to a new line and move the cursor to the start of the line.
11990 * ```typescript
11991 * const writeEmitter = new vscode.EventEmitter<string>();
11992 * const pty: vscode.Pseudoterminal = {
11993 * onDidWrite: writeEmitter.event,
11994 * open: () => {},
11995 * close: () => {},
11996 * handleInput: data => writeEmitter.fire(data === '\r' ? '\r\n' : data)
11997 * };
11998 * vscode.window.createTerminal({ name: 'Local echo', pty });
11999 * ```
12000 */
12001 handleInput?(data: string): void;
12002
12003 /**
12004 * Implement to handle when the number of rows and columns that fit into the terminal panel
12005 * changes, for example when font size changes or when the panel is resized. The initial
12006 * state of a terminal's dimensions should be treated as `undefined` until this is triggered
12007 * as the size of a terminal isn't known until it shows up in the user interface.
12008 *
12009 * When dimensions are overridden by
12010 * {@link Pseudoterminal.onDidOverrideDimensions onDidOverrideDimensions}, `setDimensions` will
12011 * continue to be called with the regular panel dimensions, allowing the extension continue
12012 * to react dimension changes.
12013 *
12014 * @param dimensions The new dimensions.
12015 */
12016 setDimensions?(dimensions: TerminalDimensions): void;
12017 }
12018
12019 /**
12020 * Represents the dimensions of a terminal.
12021 */
12022 export interface TerminalDimensions {
12023 /**
12024 * The number of columns in the terminal.
12025 */
12026 readonly columns: number;
12027
12028 /**
12029 * The number of rows in the terminal.
12030 */
12031 readonly rows: number;
12032 }
12033
12034 /**
12035 * Represents how a terminal exited.
12036 */
12037 export interface TerminalExitStatus {
12038 /**
12039 * The exit code that a terminal exited with, it can have the following values:
12040 * - Zero: the terminal process or custom execution succeeded.
12041 * - Non-zero: the terminal process or custom execution failed.
12042 * - `undefined`: the user forcibly closed the terminal or a custom execution exited
12043 * without providing an exit code.
12044 */
12045 readonly code: number | undefined;
12046
12047 /**
12048 * The reason that triggered the exit of a terminal.
12049 */
12050 readonly reason: TerminalExitReason;
12051 }
12052
12053 /**
12054 * Terminal exit reason kind.
12055 */
12056 export enum TerminalExitReason {
12057 /**
12058 * Unknown reason.
12059 */
12060 Unknown = 0,
12061
12062 /**
12063 * The window closed/reloaded.
12064 */
12065 Shutdown = 1,
12066
12067 /**
12068 * The shell process exited.
12069 */
12070 Process = 2,
12071
12072 /**
12073 * The user closed the terminal.
12074 */
12075 User = 3,
12076
12077 /**
12078 * An extension disposed the terminal.
12079 */
12080 Extension = 4,
12081 }
12082
12083 /**
12084 * A type of mutation that can be applied to an environment variable.
12085 */
12086 export enum EnvironmentVariableMutatorType {
12087 /**
12088 * Replace the variable's existing value.
12089 */
12090 Replace = 1,
12091 /**
12092 * Append to the end of the variable's existing value.
12093 */
12094 Append = 2,
12095 /**
12096 * Prepend to the start of the variable's existing value.
12097 */
12098 Prepend = 3
12099 }
12100
12101 /**
12102 * Options applied to the mutator.
12103 */
12104 export interface EnvironmentVariableMutatorOptions {
12105 /**
12106 * Apply to the environment just before the process is created. Defaults to false.
12107 */
12108 applyAtProcessCreation?: boolean;
12109
12110 /**
12111 * Apply to the environment in the shell integration script. Note that this _will not_ apply
12112 * the mutator if shell integration is disabled or not working for some reason. Defaults to
12113 * false.
12114 */
12115 applyAtShellIntegration?: boolean;
12116 }
12117
12118 /**
12119 * A type of mutation and its value to be applied to an environment variable.
12120 */
12121 export interface EnvironmentVariableMutator {
12122 /**
12123 * The type of mutation that will occur to the variable.
12124 */
12125 readonly type: EnvironmentVariableMutatorType;
12126
12127 /**
12128 * The value to use for the variable.
12129 */
12130 readonly value: string;
12131
12132 /**
12133 * Options applied to the mutator.
12134 */
12135 readonly options: EnvironmentVariableMutatorOptions;
12136 }
12137
12138 /**
12139 * A collection of mutations that an extension can apply to a process environment.
12140 */
12141 export interface EnvironmentVariableCollection extends Iterable<[variable: string, mutator: EnvironmentVariableMutator]> {
12142 /**
12143 * Whether the collection should be cached for the workspace and applied to the terminal
12144 * across window reloads. When true the collection will be active immediately such when the
12145 * window reloads. Additionally, this API will return the cached version if it exists. The
12146 * collection will be invalidated when the extension is uninstalled or when the collection
12147 * is cleared. Defaults to true.
12148 */
12149 persistent: boolean;
12150
12151 /**
12152 * A description for the environment variable collection, this will be used to describe the
12153 * changes in the UI.
12154 */
12155 description: string | MarkdownString | undefined;
12156
12157 /**
12158 * Replace an environment variable with a value.
12159 *
12160 * Note that an extension can only make a single change to any one variable, so this will
12161 * overwrite any previous calls to replace, append or prepend.
12162 *
12163 * @param variable The variable to replace.
12164 * @param value The value to replace the variable with.
12165 * @param options Options applied to the mutator, when no options are provided this will
12166 * default to `{ applyAtProcessCreation: true }`.
12167 */
12168 replace(variable: string, value: string, options?: EnvironmentVariableMutatorOptions): void;
12169
12170 /**
12171 * Append a value to an environment variable.
12172 *
12173 * Note that an extension can only make a single change to any one variable, so this will
12174 * overwrite any previous calls to replace, append or prepend.
12175 *
12176 * @param variable The variable to append to.
12177 * @param value The value to append to the variable.
12178 * @param options Options applied to the mutator, when no options are provided this will
12179 * default to `{ applyAtProcessCreation: true }`.
12180 */
12181 append(variable: string, value: string, options?: EnvironmentVariableMutatorOptions): void;
12182
12183 /**
12184 * Prepend a value to an environment variable.
12185 *
12186 * Note that an extension can only make a single change to any one variable, so this will
12187 * overwrite any previous calls to replace, append or prepend.
12188 *
12189 * @param variable The variable to prepend.
12190 * @param value The value to prepend to the variable.
12191 * @param options Options applied to the mutator, when no options are provided this will
12192 * default to `{ applyAtProcessCreation: true }`.
12193 */
12194 prepend(variable: string, value: string, options?: EnvironmentVariableMutatorOptions): void;
12195
12196 /**
12197 * Gets the mutator that this collection applies to a variable, if any.
12198 *
12199 * @param variable The variable to get the mutator for.
12200 */
12201 get(variable: string): EnvironmentVariableMutator | undefined;
12202
12203 /**
12204 * Iterate over each mutator in this collection.
12205 *
12206 * @param callback Function to execute for each entry.
12207 * @param thisArg The `this` context used when invoking the handler function.
12208 */
12209 forEach(callback: (variable: string, mutator: EnvironmentVariableMutator, collection: EnvironmentVariableCollection) => any, thisArg?: any): void;
12210
12211 /**
12212 * Deletes this collection's mutator for a variable.
12213 *
12214 * @param variable The variable to delete the mutator for.
12215 */
12216 delete(variable: string): void;
12217
12218 /**
12219 * Clears all mutators from this collection.
12220 */
12221 clear(): void;
12222 }
12223
12224 /**
12225 * A collection of mutations that an extension can apply to a process environment. Applies to all scopes.
12226 */
12227 export interface GlobalEnvironmentVariableCollection extends EnvironmentVariableCollection {
12228 /**
12229 * Gets scope-specific environment variable collection for the extension. This enables alterations to
12230 * terminal environment variables solely within the designated scope, and is applied in addition to (and
12231 * after) the global collection.
12232 *
12233 * Each object obtained through this method is isolated and does not impact objects for other scopes,
12234 * including the global collection.
12235 *
12236 * @param scope The scope to which the environment variable collection applies to.
12237 *
12238 * If a scope parameter is omitted, collection applicable to all relevant scopes for that parameter is
12239 * returned. For instance, if the 'workspaceFolder' parameter is not specified, the collection that applies
12240 * across all workspace folders will be returned.
12241 *
12242 * @returns Environment variable collection for the passed in scope.
12243 */
12244 getScoped(scope: EnvironmentVariableScope): EnvironmentVariableCollection;
12245 }
12246
12247 /**
12248 * The scope object to which the environment variable collection applies.
12249 */
12250 export interface EnvironmentVariableScope {
12251 /**
12252 * Any specific workspace folder to get collection for.
12253 */
12254 workspaceFolder?: WorkspaceFolder;
12255 }
12256
12257 /**
12258 * A location in the editor at which progress information can be shown. It depends on the
12259 * location how progress is visually represented.
12260 */
12261 export enum ProgressLocation {
12262
12263 /**
12264 * Show progress for the source control viewlet, as overlay for the icon and as progress bar
12265 * inside the viewlet (when visible). Neither supports cancellation nor discrete progress nor
12266 * a label to describe the operation.
12267 */
12268 SourceControl = 1,
12269
12270 /**
12271 * Show progress in the status bar of the editor. Neither supports cancellation nor discrete progress.
12272 * Supports rendering of {@link ThemeIcon theme icons} via the `$(<name>)`-syntax in the progress label.
12273 */
12274 Window = 10,
12275
12276 /**
12277 * Show progress as notification with an optional cancel button. Supports to show infinite and discrete
12278 * progress but does not support rendering of icons.
12279 */
12280 Notification = 15
12281 }
12282
12283 /**
12284 * Value-object describing where and how progress should show.
12285 */
12286 export interface ProgressOptions {
12287
12288 /**
12289 * The location at which progress should show.
12290 */
12291 location: ProgressLocation | {
12292 /**
12293 * The identifier of a view for which progress should be shown.
12294 */
12295 viewId: string;
12296 };
12297
12298 /**
12299 * A human-readable string which will be used to describe the
12300 * operation.
12301 */
12302 title?: string;
12303
12304 /**
12305 * Controls if a cancel button should show to allow the user to
12306 * cancel the long running operation. Note that currently only
12307 * `ProgressLocation.Notification` is supporting to show a cancel
12308 * button.
12309 */
12310 cancellable?: boolean;
12311 }
12312
12313 /**
12314 * A light-weight user input UI that is initially not visible. After
12315 * configuring it through its properties the extension can make it
12316 * visible by calling {@link QuickInput.show}.
12317 *
12318 * There are several reasons why this UI might have to be hidden and
12319 * the extension will be notified through {@link QuickInput.onDidHide}.
12320 * (Examples include: an explicit call to {@link QuickInput.hide},
12321 * the user pressing Esc, some other input UI opening, etc.)
12322 *
12323 * A user pressing Enter or some other gesture implying acceptance
12324 * of the current state does not automatically hide this UI component.
12325 * It is up to the extension to decide whether to accept the user's input
12326 * and if the UI should indeed be hidden through a call to {@link QuickInput.hide}.
12327 *
12328 * When the extension no longer needs this input UI, it should
12329 * {@link QuickInput.dispose} it to allow for freeing up
12330 * any resources associated with it.
12331 *
12332 * See {@link QuickPick} and {@link InputBox} for concrete UIs.
12333 */
12334 export interface QuickInput {
12335
12336 /**
12337 * An optional title.
12338 */
12339 title: string | undefined;
12340
12341 /**
12342 * An optional current step count.
12343 */
12344 step: number | undefined;
12345
12346 /**
12347 * An optional total step count.
12348 */
12349 totalSteps: number | undefined;
12350
12351 /**
12352 * If the UI should allow for user input. Defaults to true.
12353 *
12354 * Change this to false, e.g., while validating user input or
12355 * loading data for the next step in user input.
12356 */
12357 enabled: boolean;
12358
12359 /**
12360 * If the UI should show a progress indicator. Defaults to false.
12361 *
12362 * Change this to true, e.g., while loading more data or validating
12363 * user input.
12364 */
12365 busy: boolean;
12366
12367 /**
12368 * If the UI should stay open even when loosing UI focus. Defaults to false.
12369 * This setting is ignored on iPad and is always false.
12370 */
12371 ignoreFocusOut: boolean;
12372
12373 /**
12374 * Makes the input UI visible in its current configuration. Any other input
12375 * UI will first fire an {@link QuickInput.onDidHide} event.
12376 */
12377 show(): void;
12378
12379 /**
12380 * Hides this input UI. This will also fire an {@link QuickInput.onDidHide}
12381 * event.
12382 */
12383 hide(): void;
12384
12385 /**
12386 * An event signaling when this input UI is hidden.
12387 *
12388 * There are several reasons why this UI might have to be hidden and
12389 * the extension will be notified through {@link QuickInput.onDidHide}.
12390 * (Examples include: an explicit call to {@link QuickInput.hide},
12391 * the user pressing Esc, some other input UI opening, etc.)
12392 */
12393 onDidHide: Event<void>;
12394
12395 /**
12396 * Dispose of this input UI and any associated resources. If it is still
12397 * visible, it is first hidden. After this call the input UI is no longer
12398 * functional and no additional methods or properties on it should be
12399 * accessed. Instead a new input UI should be created.
12400 */
12401 dispose(): void;
12402 }
12403
12404 /**
12405 * A concrete {@link QuickInput} to let the user pick an item from a
12406 * list of items of type T. The items can be filtered through a filter text field and
12407 * there is an option {@link QuickPick.canSelectMany canSelectMany} to allow for
12408 * selecting multiple items.
12409 *
12410 * Note that in many cases the more convenient {@link window.showQuickPick}
12411 * is easier to use. {@link window.createQuickPick} should be used
12412 * when {@link window.showQuickPick} does not offer the required flexibility.
12413 */
12414 export interface QuickPick<T extends QuickPickItem> extends QuickInput {
12415
12416 /**
12417 * Current value of the filter text.
12418 */
12419 value: string;
12420
12421 /**
12422 * Optional placeholder shown in the filter textbox when no filter has been entered.
12423 */
12424 placeholder: string | undefined;
12425
12426 /**
12427 * An event signaling when the value of the filter text has changed.
12428 */
12429 readonly onDidChangeValue: Event<string>;
12430
12431 /**
12432 * An event signaling when the user indicated acceptance of the selected item(s).
12433 */
12434 readonly onDidAccept: Event<void>;
12435
12436 /**
12437 * Buttons for actions in the UI.
12438 */
12439 buttons: readonly QuickInputButton[];
12440
12441 /**
12442 * An event signaling when a top level button (buttons stored in {@link buttons}) was triggered.
12443 * This event does not fire for buttons on a {@link QuickPickItem}.
12444 */
12445 readonly onDidTriggerButton: Event<QuickInputButton>;
12446
12447 /**
12448 * An event signaling when a button in a particular {@link QuickPickItem} was triggered.
12449 * This event does not fire for buttons in the title bar.
12450 */
12451 readonly onDidTriggerItemButton: Event<QuickPickItemButtonEvent<T>>;
12452
12453 /**
12454 * Items to pick from. This can be read and updated by the extension.
12455 */
12456 items: readonly T[];
12457
12458 /**
12459 * If multiple items can be selected at the same time. Defaults to false.
12460 */
12461 canSelectMany: boolean;
12462
12463 /**
12464 * If the filter text should also be matched against the description of the items. Defaults to false.
12465 */
12466 matchOnDescription: boolean;
12467
12468 /**
12469 * If the filter text should also be matched against the detail of the items. Defaults to false.
12470 */
12471 matchOnDetail: boolean;
12472
12473 /**
12474 * An optional flag to maintain the scroll position of the quick pick when the quick pick items are updated. Defaults to false.
12475 */
12476 keepScrollPosition?: boolean;
12477
12478 /**
12479 * Active items. This can be read and updated by the extension.
12480 */
12481 activeItems: readonly T[];
12482
12483 /**
12484 * An event signaling when the active items have changed.
12485 */
12486 readonly onDidChangeActive: Event<readonly T[]>;
12487
12488 /**
12489 * Selected items. This can be read and updated by the extension.
12490 */
12491 selectedItems: readonly T[];
12492
12493 /**
12494 * An event signaling when the selected items have changed.
12495 */
12496 readonly onDidChangeSelection: Event<readonly T[]>;
12497 }
12498
12499 /**
12500 * A concrete {@link QuickInput} to let the user input a text value.
12501 *
12502 * Note that in many cases the more convenient {@link window.showInputBox}
12503 * is easier to use. {@link window.createInputBox} should be used
12504 * when {@link window.showInputBox} does not offer the required flexibility.
12505 */
12506 export interface InputBox extends QuickInput {
12507
12508 /**
12509 * Current input value.
12510 */
12511 value: string;
12512
12513 /**
12514 * Selection range in the input value. Defined as tuple of two number where the
12515 * first is the inclusive start index and the second the exclusive end index. When `undefined` the whole
12516 * pre-filled value will be selected, when empty (start equals end) only the cursor will be set,
12517 * otherwise the defined range will be selected.
12518 *
12519 * This property does not get updated when the user types or makes a selection,
12520 * but it can be updated by the extension.
12521 */
12522 valueSelection: readonly [number, number] | undefined;
12523
12524 /**
12525 * Optional placeholder shown when no value has been input.
12526 */
12527 placeholder: string | undefined;
12528
12529 /**
12530 * If the input value should be hidden. Defaults to false.
12531 */
12532 password: boolean;
12533
12534 /**
12535 * An event signaling when the value has changed.
12536 */
12537 readonly onDidChangeValue: Event<string>;
12538
12539 /**
12540 * An event signaling when the user indicated acceptance of the input value.
12541 */
12542 readonly onDidAccept: Event<void>;
12543
12544 /**
12545 * Buttons for actions in the UI.
12546 */
12547 buttons: readonly QuickInputButton[];
12548
12549 /**
12550 * An event signaling when a button was triggered.
12551 */
12552 readonly onDidTriggerButton: Event<QuickInputButton>;
12553
12554 /**
12555 * An optional prompt text providing some ask or explanation to the user.
12556 */
12557 prompt: string | undefined;
12558
12559 /**
12560 * An optional validation message indicating a problem with the current input value.
12561 * By returning a string, the InputBox will use a default {@link InputBoxValidationSeverity} of Error.
12562 * Returning undefined clears the validation message.
12563 */
12564 validationMessage: string | InputBoxValidationMessage | undefined;
12565 }
12566
12567 /**
12568 * Button for an action in a {@link QuickPick} or {@link InputBox}.
12569 */
12570 export interface QuickInputButton {
12571
12572 /**
12573 * Icon for the button.
12574 */
12575 readonly iconPath: Uri | {
12576 /**
12577 * The icon path for the light theme.
12578 */
12579 light: Uri;
12580 /**
12581 * The icon path for the dark theme.
12582 */
12583 dark: Uri;
12584 } | ThemeIcon;
12585
12586 /**
12587 * An optional tooltip.
12588 */
12589 readonly tooltip?: string | undefined;
12590 }
12591
12592 /**
12593 * Predefined buttons for {@link QuickPick} and {@link InputBox}.
12594 */
12595 export class QuickInputButtons {
12596
12597 /**
12598 * A back button for {@link QuickPick} and {@link InputBox}.
12599 *
12600 * When a navigation 'back' button is needed this one should be used for consistency.
12601 * It comes with a predefined icon, tooltip and location.
12602 */
12603 static readonly Back: QuickInputButton;
12604
12605 /**
12606 * @hidden
12607 */
12608 private constructor();
12609 }
12610
12611 /**
12612 * An event signaling when a button in a particular {@link QuickPickItem} was triggered.
12613 * This event does not fire for buttons in the title bar.
12614 */
12615 export interface QuickPickItemButtonEvent<T extends QuickPickItem> {
12616 /**
12617 * The button that was clicked.
12618 */
12619 readonly button: QuickInputButton;
12620 /**
12621 * The item that the button belongs to.
12622 */
12623 readonly item: T;
12624 }
12625
12626 /**
12627 * An event describing an individual change in the text of a {@link TextDocument document}.
12628 */
12629 export interface TextDocumentContentChangeEvent {
12630 /**
12631 * The range that got replaced.
12632 */
12633 readonly range: Range;
12634 /**
12635 * The offset of the range that got replaced.
12636 */
12637 readonly rangeOffset: number;
12638 /**
12639 * The length of the range that got replaced.
12640 */
12641 readonly rangeLength: number;
12642 /**
12643 * The new text for the range.
12644 */
12645 readonly text: string;
12646 }
12647
12648 /**
12649 * Reasons for why a text document has changed.
12650 */
12651 export enum TextDocumentChangeReason {
12652 /** The text change is caused by an undo operation. */
12653 Undo = 1,
12654
12655 /** The text change is caused by an redo operation. */
12656 Redo = 2,
12657 }
12658
12659 /**
12660 * An event describing a transactional {@link TextDocument document} change.
12661 */
12662 export interface TextDocumentChangeEvent {
12663
12664 /**
12665 * The affected document.
12666 */
12667 readonly document: TextDocument;
12668
12669 /**
12670 * An array of content changes.
12671 */
12672 readonly contentChanges: readonly TextDocumentContentChangeEvent[];
12673
12674 /**
12675 * The reason why the document was changed.
12676 * Is `undefined` if the reason is not known.
12677 */
12678 readonly reason: TextDocumentChangeReason | undefined;
12679 }
12680
12681 /**
12682 * Represents reasons why a text document is saved.
12683 */
12684 export enum TextDocumentSaveReason {
12685
12686 /**
12687 * Manually triggered, e.g. by the user pressing save, by starting debugging,
12688 * or by an API call.
12689 */
12690 Manual = 1,
12691
12692 /**
12693 * Automatic after a delay.
12694 */
12695 AfterDelay = 2,
12696
12697 /**
12698 * When the editor lost focus.
12699 */
12700 FocusOut = 3
12701 }
12702
12703 /**
12704 * An event that is fired when a {@link TextDocument document} will be saved.
12705 *
12706 * To make modifications to the document before it is being saved, call the
12707 * {@linkcode TextDocumentWillSaveEvent.waitUntil waitUntil}-function with a thenable
12708 * that resolves to an array of {@link TextEdit text edits}.
12709 */
12710 export interface TextDocumentWillSaveEvent {
12711
12712 /**
12713 * The document that will be saved.
12714 */
12715 readonly document: TextDocument;
12716
12717 /**
12718 * The reason why save was triggered.
12719 */
12720 readonly reason: TextDocumentSaveReason;
12721
12722 /**
12723 * Allows to pause the event loop and to apply {@link TextEdit pre-save-edits}.
12724 * Edits of subsequent calls to this function will be applied in order. The
12725 * edits will be *ignored* if concurrent modifications of the document happened.
12726 *
12727 * *Note:* This function can only be called during event dispatch and not
12728 * in an asynchronous manner:
12729 *
12730 * ```ts
12731 * workspace.onWillSaveTextDocument(event => {
12732 * // async, will *throw* an error
12733 * setTimeout(() => event.waitUntil(promise));
12734 *
12735 * // sync, OK
12736 * event.waitUntil(promise);
12737 * })
12738 * ```
12739 *
12740 * @param thenable A thenable that resolves to {@link TextEdit pre-save-edits}.
12741 */
12742 waitUntil(thenable: Thenable<readonly TextEdit[]>): void;
12743
12744 /**
12745 * Allows to pause the event loop until the provided thenable resolved.
12746 *
12747 * *Note:* This function can only be called during event dispatch.
12748 *
12749 * @param thenable A thenable that delays saving.
12750 */
12751 waitUntil(thenable: Thenable<any>): void;
12752 }
12753
12754 /**
12755 * An event that is fired when files are going to be created.
12756 *
12757 * To make modifications to the workspace before the files are created,
12758 * call the {@linkcode FileWillCreateEvent.waitUntil waitUntil}-function with a
12759 * thenable that resolves to a {@link WorkspaceEdit workspace edit}.
12760 */
12761 export interface FileWillCreateEvent {
12762
12763 /**
12764 * A cancellation token.
12765 */
12766 readonly token: CancellationToken;
12767
12768 /**
12769 * The files that are going to be created.
12770 */
12771 readonly files: readonly Uri[];
12772
12773 /**
12774 * Allows to pause the event and to apply a {@link WorkspaceEdit workspace edit}.
12775 *
12776 * *Note:* This function can only be called during event dispatch and not
12777 * in an asynchronous manner:
12778 *
12779 * ```ts
12780 * workspace.onWillCreateFiles(event => {
12781 * // async, will *throw* an error
12782 * setTimeout(() => event.waitUntil(promise));
12783 *
12784 * // sync, OK
12785 * event.waitUntil(promise);
12786 * })
12787 * ```
12788 *
12789 * @param thenable A thenable that delays saving.
12790 */
12791 waitUntil(thenable: Thenable<WorkspaceEdit>): void;
12792
12793 /**
12794 * Allows to pause the event until the provided thenable resolves.
12795 *
12796 * *Note:* This function can only be called during event dispatch.
12797 *
12798 * @param thenable A thenable that delays saving.
12799 */
12800 waitUntil(thenable: Thenable<any>): void;
12801 }
12802
12803 /**
12804 * An event that is fired after files are created.
12805 */
12806 export interface FileCreateEvent {
12807
12808 /**
12809 * The files that got created.
12810 */
12811 readonly files: readonly Uri[];
12812 }
12813
12814 /**
12815 * An event that is fired when files are going to be deleted.
12816 *
12817 * To make modifications to the workspace before the files are deleted,
12818 * call the {@link FileWillCreateEvent.waitUntil `waitUntil`}-function with a
12819 * thenable that resolves to a {@link WorkspaceEdit workspace edit}.
12820 */
12821 export interface FileWillDeleteEvent {
12822
12823 /**
12824 * A cancellation token.
12825 */
12826 readonly token: CancellationToken;
12827
12828 /**
12829 * The files that are going to be deleted.
12830 */
12831 readonly files: readonly Uri[];
12832
12833 /**
12834 * Allows to pause the event and to apply a {@link WorkspaceEdit workspace edit}.
12835 *
12836 * *Note:* This function can only be called during event dispatch and not
12837 * in an asynchronous manner:
12838 *
12839 * ```ts
12840 * workspace.onWillCreateFiles(event => {
12841 * // async, will *throw* an error
12842 * setTimeout(() => event.waitUntil(promise));
12843 *
12844 * // sync, OK
12845 * event.waitUntil(promise);
12846 * })
12847 * ```
12848 *
12849 * @param thenable A thenable that delays saving.
12850 */
12851 waitUntil(thenable: Thenable<WorkspaceEdit>): void;
12852
12853 /**
12854 * Allows to pause the event until the provided thenable resolves.
12855 *
12856 * *Note:* This function can only be called during event dispatch.
12857 *
12858 * @param thenable A thenable that delays saving.
12859 */
12860 waitUntil(thenable: Thenable<any>): void;
12861 }
12862
12863 /**
12864 * An event that is fired after files are deleted.
12865 */
12866 export interface FileDeleteEvent {
12867
12868 /**
12869 * The files that got deleted.
12870 */
12871 readonly files: readonly Uri[];
12872 }
12873
12874 /**
12875 * An event that is fired when files are going to be renamed.
12876 *
12877 * To make modifications to the workspace before the files are renamed,
12878 * call the {@link FileWillCreateEvent.waitUntil `waitUntil`}-function with a
12879 * thenable that resolves to a {@link WorkspaceEdit workspace edit}.
12880 */
12881 export interface FileWillRenameEvent {
12882
12883 /**
12884 * A cancellation token.
12885 */
12886 readonly token: CancellationToken;
12887
12888 /**
12889 * The files that are going to be renamed.
12890 */
12891 readonly files: ReadonlyArray<{
12892 /**
12893 * The old uri of a file.
12894 */
12895 readonly oldUri: Uri;
12896 /**
12897 * The new uri of a file.
12898 */
12899 readonly newUri: Uri;
12900 }>;
12901
12902 /**
12903 * Allows to pause the event and to apply a {@link WorkspaceEdit workspace edit}.
12904 *
12905 * *Note:* This function can only be called during event dispatch and not
12906 * in an asynchronous manner:
12907 *
12908 * ```ts
12909 * workspace.onWillCreateFiles(event => {
12910 * // async, will *throw* an error
12911 * setTimeout(() => event.waitUntil(promise));
12912 *
12913 * // sync, OK
12914 * event.waitUntil(promise);
12915 * })
12916 * ```
12917 *
12918 * @param thenable A thenable that delays saving.
12919 */
12920 waitUntil(thenable: Thenable<WorkspaceEdit>): void;
12921
12922 /**
12923 * Allows to pause the event until the provided thenable resolves.
12924 *
12925 * *Note:* This function can only be called during event dispatch.
12926 *
12927 * @param thenable A thenable that delays saving.
12928 */
12929 waitUntil(thenable: Thenable<any>): void;
12930 }
12931
12932 /**
12933 * An event that is fired after files are renamed.
12934 */
12935 export interface FileRenameEvent {
12936
12937 /**
12938 * The files that got renamed.
12939 */
12940 readonly files: ReadonlyArray<{
12941 /**
12942 * The old uri of a file.
12943 */
12944 readonly oldUri: Uri;
12945 /**
12946 * The new uri of a file.
12947 */
12948 readonly newUri: Uri;
12949 }>;
12950 }
12951
12952 /**
12953 * An event describing a change to the set of {@link workspace.workspaceFolders workspace folders}.
12954 */
12955 export interface WorkspaceFoldersChangeEvent {
12956 /**
12957 * Added workspace folders.
12958 */
12959 readonly added: readonly WorkspaceFolder[];
12960
12961 /**
12962 * Removed workspace folders.
12963 */
12964 readonly removed: readonly WorkspaceFolder[];
12965 }
12966
12967 /**
12968 * A workspace folder is one of potentially many roots opened by the editor. All workspace folders
12969 * are equal which means there is no notion of an active or primary workspace folder.
12970 */
12971 export interface WorkspaceFolder {
12972
12973 /**
12974 * The associated uri for this workspace folder.
12975 *
12976 * *Note:* The {@link Uri}-type was intentionally chosen such that future releases of the editor can support
12977 * workspace folders that are not stored on the local disk, e.g. `ftp://server/workspaces/foo`.
12978 */
12979 readonly uri: Uri;
12980
12981 /**
12982 * The name of this workspace folder. Defaults to
12983 * the basename of its {@link Uri.path uri-path}
12984 */
12985 readonly name: string;
12986
12987 /**
12988 * The ordinal number of this workspace folder.
12989 */
12990 readonly index: number;
12991 }
12992
12993 /**
12994 * Namespace for dealing with the current workspace. A workspace is the collection of one
12995 * or more folders that are opened in an editor window (instance).
12996 *
12997 * It is also possible to open an editor without a workspace. For example, when you open a
12998 * new editor window by selecting a file from your platform's File menu, you will not be
12999 * inside a workspace. In this mode, some of the editor's capabilities are reduced but you can
13000 * still open text files and edit them.
13001 *
13002 * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information on
13003 * the concept of workspaces.
13004 *
13005 * The workspace offers support for {@link workspace.createFileSystemWatcher listening} to fs
13006 * events and for {@link workspace.findFiles finding} files. Both perform well and run _outside_
13007 * the editor-process so that they should be always used instead of nodejs-equivalents.
13008 */
13009 export namespace workspace {
13010
13011 /**
13012 * A {@link FileSystem file system} instance that allows to interact with local and remote
13013 * files, e.g. `vscode.workspace.fs.readDirectory(someUri)` allows to retrieve all entries
13014 * of a directory or `vscode.workspace.fs.stat(anotherUri)` returns the meta data for a
13015 * file.
13016 */
13017 export const fs: FileSystem;
13018
13019 /**
13020 * The uri of the first entry of {@linkcode workspace.workspaceFolders workspaceFolders}
13021 * as `string`. `undefined` if there is no first entry.
13022 *
13023 * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information
13024 * on workspaces.
13025 *
13026 * @deprecated Use {@linkcode workspace.workspaceFolders workspaceFolders} instead.
13027 */
13028 export const rootPath: string | undefined;
13029
13030 /**
13031 * List of workspace folders (0-N) that are open in the editor. `undefined` when no workspace
13032 * has been opened.
13033 *
13034 * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information
13035 * on workspaces.
13036 */
13037 export const workspaceFolders: readonly WorkspaceFolder[] | undefined;
13038
13039 /**
13040 * The name of the workspace. `undefined` when no workspace
13041 * has been opened.
13042 *
13043 * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information on
13044 * the concept of workspaces.
13045 */
13046 export const name: string | undefined;
13047
13048 /**
13049 * The location of the workspace file, for example:
13050 *
13051 * `file:///Users/name/Development/myProject.code-workspace`
13052 *
13053 * or
13054 *
13055 * `untitled:1555503116870`
13056 *
13057 * for a workspace that is untitled and not yet saved.
13058 *
13059 * Depending on the workspace that is opened, the value will be:
13060 * * `undefined` when no workspace is opened
13061 * * the path of the workspace file as `Uri` otherwise. if the workspace
13062 * is untitled, the returned URI will use the `untitled:` scheme
13063 *
13064 * The location can e.g. be used with the `vscode.openFolder` command to
13065 * open the workspace again after it has been closed.
13066 *
13067 * **Example:**
13068 * ```typescript
13069 * vscode.commands.executeCommand('vscode.openFolder', uriOfWorkspace);
13070 * ```
13071 *
13072 * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information on
13073 * the concept of workspaces.
13074 *
13075 * **Note:** it is not advised to use `workspace.workspaceFile` to write
13076 * configuration data into the file. You can use `workspace.getConfiguration().update()`
13077 * for that purpose which will work both when a single folder is opened as
13078 * well as an untitled or saved workspace.
13079 */
13080 export const workspaceFile: Uri | undefined;
13081
13082 /**
13083 * An event that is emitted when a workspace folder is added or removed.
13084 *
13085 * **Note:** this event will not fire if the first workspace folder is added, removed or changed,
13086 * because in that case the currently executing extensions (including the one that listens to this
13087 * event) will be terminated and restarted so that the (deprecated) `rootPath` property is updated
13088 * to point to the first workspace folder.
13089 */
13090 export const onDidChangeWorkspaceFolders: Event<WorkspaceFoldersChangeEvent>;
13091
13092 /**
13093 * Returns the {@link WorkspaceFolder workspace folder} that contains a given uri.
13094 * * returns `undefined` when the given uri doesn't match any workspace folder
13095 * * returns the *input* when the given uri is a workspace folder itself
13096 *
13097 * @param uri An uri.
13098 * @returns A workspace folder or `undefined`
13099 */
13100 export function getWorkspaceFolder(uri: Uri): WorkspaceFolder | undefined;
13101
13102 /**
13103 * Returns a path that is relative to the workspace folder or folders.
13104 *
13105 * When there are no {@link workspace.workspaceFolders workspace folders} or when the path
13106 * is not contained in them, the input is returned.
13107 *
13108 * @param pathOrUri A path or uri. When a uri is given its {@link Uri.fsPath fsPath} is used.
13109 * @param includeWorkspaceFolder When `true` and when the given path is contained inside a
13110 * workspace folder the name of the workspace is prepended. Defaults to `true` when there are
13111 * multiple workspace folders and `false` otherwise.
13112 * @returns A path relative to the root or the input.
13113 */
13114 export function asRelativePath(pathOrUri: string | Uri, includeWorkspaceFolder?: boolean): string;
13115
13116 /**
13117 * This method replaces `deleteCount` {@link workspace.workspaceFolders workspace folders} starting at index `start`
13118 * by an optional set of `workspaceFoldersToAdd` on the `vscode.workspace.workspaceFolders` array. This "splice"
13119 * behavior can be used to add, remove and change workspace folders in a single operation.
13120 *
13121 * **Note:** in some cases calling this method may result in the currently executing extensions (including the
13122 * one that called this method) to be terminated and restarted. For example when the first workspace folder is
13123 * added, removed or changed the (deprecated) `rootPath` property is updated to point to the first workspace
13124 * folder. Another case is when transitioning from an empty or single-folder workspace into a multi-folder
13125 * workspace (see also: https://code.visualstudio.com/docs/editor/workspaces).
13126 *
13127 * Use the {@linkcode onDidChangeWorkspaceFolders onDidChangeWorkspaceFolders()} event to get notified when the
13128 * workspace folders have been updated.
13129 *
13130 * **Example:** adding a new workspace folder at the end of workspace folders
13131 * ```typescript
13132 * workspace.updateWorkspaceFolders(workspace.workspaceFolders ? workspace.workspaceFolders.length : 0, null, { uri: ...});
13133 * ```
13134 *
13135 * **Example:** removing the first workspace folder
13136 * ```typescript
13137 * workspace.updateWorkspaceFolders(0, 1);
13138 * ```
13139 *
13140 * **Example:** replacing an existing workspace folder with a new one
13141 * ```typescript
13142 * workspace.updateWorkspaceFolders(0, 1, { uri: ...});
13143 * ```
13144 *
13145 * It is valid to remove an existing workspace folder and add it again with a different name
13146 * to rename that folder.
13147 *
13148 * **Note:** it is not valid to call {@link updateWorkspaceFolders updateWorkspaceFolders()} multiple times
13149 * without waiting for the {@linkcode onDidChangeWorkspaceFolders onDidChangeWorkspaceFolders()} to fire.
13150 *
13151 * @param start the zero-based location in the list of currently opened {@link WorkspaceFolder workspace folders}
13152 * from which to start deleting workspace folders.
13153 * @param deleteCount the optional number of workspace folders to remove.
13154 * @param workspaceFoldersToAdd the optional variable set of workspace folders to add in place of the deleted ones.
13155 * Each workspace is identified with a mandatory URI and an optional name.
13156 * @returns true if the operation was successfully started and false otherwise if arguments were used that would result
13157 * in invalid workspace folder state (e.g. 2 folders with the same URI).
13158 */
13159 export function updateWorkspaceFolders(start: number, deleteCount: number | undefined | null, ...workspaceFoldersToAdd: {
13160 /**
13161 * The uri of a workspace folder that's to be added.
13162 */
13163 readonly uri: Uri;
13164 /**
13165 * The name of a workspace folder that's to be added.
13166 */
13167 readonly name?: string;
13168 }[]): boolean;
13169
13170 /**
13171 * Creates a file system watcher that is notified on file events (create, change, delete)
13172 * depending on the parameters provided.
13173 *
13174 * By default, all opened {@link workspace.workspaceFolders workspace folders} will be watched
13175 * for file changes recursively.
13176 *
13177 * Additional paths can be added for file watching by providing a {@link RelativePattern} with
13178 * a `base` path to watch. If the path is a folder and the `pattern` is complex (e.g. contains
13179 * `**` or path segments), it will be watched recursively and otherwise will be watched
13180 * non-recursively (i.e. only changes to the first level of the path will be reported).
13181 *
13182 * *Note* that paths must exist in the file system to be watched. File watching may stop when
13183 * the watched path is renamed or deleted.
13184 *
13185 * If possible, keep the use of recursive watchers to a minimum because recursive file watching
13186 * is quite resource intense.
13187 *
13188 * Providing a `string` as `globPattern` acts as convenience method for watching file events in
13189 * all opened workspace folders. It cannot be used to add more folders for file watching, nor will
13190 * it report any file events from folders that are not part of the opened workspace folders.
13191 *
13192 * Optionally, flags to ignore certain kinds of events can be provided.
13193 *
13194 * To stop listening to events the watcher must be disposed.
13195 *
13196 * *Note* that file events from recursive file watchers may be excluded based on user configuration.
13197 * The setting `files.watcherExclude` helps to reduce the overhead of file events from folders
13198 * that are known to produce many file changes at once (such as `node_modules` folders). As such,
13199 * it is highly recommended to watch with simple patterns that do not require recursive watchers
13200 * where the exclude settings are ignored and you have full control over the events.
13201 *
13202 * *Note* that symbolic links are not automatically followed for file watching unless the path to
13203 * watch itself is a symbolic link.
13204 *
13205 * *Note* that file changes for the path to be watched may not be delivered when the path itself
13206 * changes. For example, when watching a path `/Users/somename/Desktop` and the path itself is
13207 * being deleted, the watcher may not report an event and may not work anymore from that moment on.
13208 * The underlying behaviour depends on the path that is provided for watching:
13209 * * if the path is within any of the workspace folders, deletions are tracked and reported unless
13210 * excluded via `files.watcherExclude` setting
13211 * * if the path is equal to any of the workspace folders, deletions are not tracked
13212 * * if the path is outside of any of the workspace folders, deletions are not tracked
13213 *
13214 * If you are interested in being notified when the watched path itself is being deleted, you have
13215 * to watch it's parent folder. Make sure to use a simple `pattern` (such as putting the name of the
13216 * folder) to not accidentally watch all sibling folders recursively.
13217 *
13218 * *Note* that the file paths that are reported for having changed may have a different path casing
13219 * compared to the actual casing on disk on case-insensitive platforms (typically macOS and Windows
13220 * but not Linux). We allow a user to open a workspace folder with any desired path casing and try
13221 * to preserve that. This means:
13222 * * if the path is within any of the workspace folders, the path will match the casing of the
13223 * workspace folder up to that portion of the path and match the casing on disk for children
13224 * * if the path is outside of any of the workspace folders, the casing will match the case of the
13225 * path that was provided for watching
13226 * In the same way, symbolic links are preserved, i.e. the file event will report the path of the
13227 * symbolic link as it was provided for watching and not the target.
13228 *
13229 * ### Examples
13230 *
13231 * The basic anatomy of a file watcher is as follows:
13232 *
13233 * ```ts
13234 * const watcher = vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(<folder>, <pattern>));
13235 *
13236 * watcher.onDidChange(uri => { ... }); // listen to files being changed
13237 * watcher.onDidCreate(uri => { ... }); // listen to files/folders being created
13238 * watcher.onDidDelete(uri => { ... }); // listen to files/folders getting deleted
13239 *
13240 * watcher.dispose(); // dispose after usage
13241 * ```
13242 *
13243 * #### Workspace file watching
13244 *
13245 * If you only care about file events in a specific workspace folder:
13246 *
13247 * ```ts
13248 * vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(vscode.workspace.workspaceFolders[0], '**​/*.js'));
13249 * ```
13250 *
13251 * If you want to monitor file events across all opened workspace folders:
13252 *
13253 * ```ts
13254 * vscode.workspace.createFileSystemWatcher('**​/*.js');
13255 * ```
13256 *
13257 * *Note:* the array of workspace folders can be empty if no workspace is opened (empty window).
13258 *
13259 * #### Out of workspace file watching
13260 *
13261 * To watch a folder for changes to *.js files outside the workspace (non recursively), pass in a `Uri` to such
13262 * a folder:
13263 *
13264 * ```ts
13265 * vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(vscode.Uri.file(<path to folder outside workspace>), '*.js'));
13266 * ```
13267 *
13268 * And use a complex glob pattern to watch recursively:
13269 *
13270 * ```ts
13271 * vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(vscode.Uri.file(<path to folder outside workspace>), '**​/*.js'));
13272 * ```
13273 *
13274 * Here is an example for watching the active editor for file changes:
13275 *
13276 * ```ts
13277 * vscode.workspace.createFileSystemWatcher(new vscode.RelativePattern(vscode.window.activeTextEditor.document.uri, '*'));
13278 * ```
13279 *
13280 * @param globPattern A {@link GlobPattern glob pattern} that controls which file events the watcher should report.
13281 * @param ignoreCreateEvents Ignore when files have been created.
13282 * @param ignoreChangeEvents Ignore when files have been changed.
13283 * @param ignoreDeleteEvents Ignore when files have been deleted.
13284 * @returns A new file system watcher instance. Must be disposed when no longer needed.
13285 */
13286 export function createFileSystemWatcher(globPattern: GlobPattern, ignoreCreateEvents?: boolean, ignoreChangeEvents?: boolean, ignoreDeleteEvents?: boolean): FileSystemWatcher;
13287
13288 /**
13289 * Find files across all {@link workspace.workspaceFolders workspace folders} in the workspace.
13290 *
13291 * @example
13292 * findFiles('**​/*.js', '**​/node_modules/**', 10)
13293 *
13294 * @param include A {@link GlobPattern glob pattern} that defines the files to search for. The glob pattern
13295 * will be matched against the file paths of resulting matches relative to their workspace. Use a {@link RelativePattern relative pattern}
13296 * to restrict the search results to a {@link WorkspaceFolder workspace folder}.
13297 * @param exclude A {@link GlobPattern glob pattern} that defines files and folders to exclude. The glob pattern
13298 * will be matched against the file paths of resulting matches relative to their workspace. When `undefined`, default file-excludes (e.g. the `files.exclude`-setting
13299 * but not `search.exclude`) will apply. When `null`, no excludes will apply.
13300 * @param maxResults An upper-bound for the result.
13301 * @param token A token that can be used to signal cancellation to the underlying search engine.
13302 * @returns A thenable that resolves to an array of resource identifiers. Will return no results if no
13303 * {@link workspace.workspaceFolders workspace folders} are opened.
13304 */
13305 export function findFiles(include: GlobPattern, exclude?: GlobPattern | null, maxResults?: number, token?: CancellationToken): Thenable<Uri[]>;
13306
13307 /**
13308 * Saves the editor identified by the given resource and returns the resulting resource or `undefined`
13309 * if save was not successful or no editor with the given resource was found.
13310 *
13311 * **Note** that an editor with the provided resource must be opened in order to be saved.
13312 *
13313 * @param uri the associated uri for the opened editor to save.
13314 * @returns A thenable that resolves when the save operation has finished.
13315 */
13316 export function save(uri: Uri): Thenable<Uri | undefined>;
13317
13318 /**
13319 * Saves the editor identified by the given resource to a new file name as provided by the user and
13320 * returns the resulting resource or `undefined` if save was not successful or cancelled or no editor
13321 * with the given resource was found.
13322 *
13323 * **Note** that an editor with the provided resource must be opened in order to be saved as.
13324 *
13325 * @param uri the associated uri for the opened editor to save as.
13326 * @returns A thenable that resolves when the save-as operation has finished.
13327 */
13328 export function saveAs(uri: Uri): Thenable<Uri | undefined>;
13329
13330 /**
13331 * Save all dirty files.
13332 *
13333 * @param includeUntitled Also save files that have been created during this session.
13334 * @returns A thenable that resolves when the files have been saved. Will return `false`
13335 * for any file that failed to save.
13336 */
13337 export function saveAll(includeUntitled?: boolean): Thenable<boolean>;
13338
13339 /**
13340 * Make changes to one or many resources or create, delete, and rename resources as defined by the given
13341 * {@link WorkspaceEdit workspace edit}.
13342 *
13343 * All changes of a workspace edit are applied in the same order in which they have been added. If
13344 * multiple textual inserts are made at the same position, these strings appear in the resulting text
13345 * in the order the 'inserts' were made, unless that are interleaved with resource edits. Invalid sequences
13346 * like 'delete file a' -> 'insert text in file a' cause failure of the operation.
13347 *
13348 * When applying a workspace edit that consists only of text edits an 'all-or-nothing'-strategy is used.
13349 * A workspace edit with resource creations or deletions aborts the operation, e.g. consecutive edits will
13350 * not be attempted, when a single edit fails.
13351 *
13352 * @param edit A workspace edit.
13353 * @param metadata Optional {@link WorkspaceEditMetadata metadata} for the edit.
13354 * @returns A thenable that resolves when the edit could be applied.
13355 */
13356 export function applyEdit(edit: WorkspaceEdit, metadata?: WorkspaceEditMetadata): Thenable<boolean>;
13357
13358 /**
13359 * All text documents currently known to the editor.
13360 */
13361 export const textDocuments: readonly TextDocument[];
13362
13363 /**
13364 * Opens a document. Will return early if this document is already open. Otherwise
13365 * the document is loaded and the {@link workspace.onDidOpenTextDocument didOpen}-event fires.
13366 *
13367 * The document is denoted by an {@link Uri}. Depending on the {@link Uri.scheme scheme} the
13368 * following rules apply:
13369 * * `file`-scheme: Open a file on disk (`openTextDocument(Uri.file(path))`). Will be rejected if the file
13370 * does not exist or cannot be loaded.
13371 * * `untitled`-scheme: Open a blank untitled file with associated path (`openTextDocument(Uri.file(path).with({ scheme: 'untitled' }))`).
13372 * The language will be derived from the file name.
13373 * * For all other schemes contributed {@link TextDocumentContentProvider text document content providers} and
13374 * {@link FileSystemProvider file system providers} are consulted.
13375 *
13376 * *Note* that the lifecycle of the returned document is owned by the editor and not by the extension. That means an
13377 * {@linkcode workspace.onDidCloseTextDocument onDidClose}-event can occur at any time after opening it.
13378 *
13379 * @param uri Identifies the resource to open.
13380 * @returns A promise that resolves to a {@link TextDocument document}.
13381 */
13382 export function openTextDocument(uri: Uri): Thenable<TextDocument>;
13383
13384 /**
13385 * A short-hand for `openTextDocument(Uri.file(path))`.
13386 *
13387 * @see {@link workspace.openTextDocument}
13388 * @param path A path of a file on disk.
13389 * @returns A promise that resolves to a {@link TextDocument document}.
13390 */
13391 export function openTextDocument(path: string): Thenable<TextDocument>;
13392
13393 /**
13394 * Opens an untitled text document. The editor will prompt the user for a file
13395 * path when the document is to be saved. The `options` parameter allows to
13396 * specify the *language* and/or the *content* of the document.
13397 *
13398 * @param options Options to control how the document will be created.
13399 * @returns A promise that resolves to a {@link TextDocument document}.
13400 */
13401 export function openTextDocument(options?: {
13402 /**
13403 * The {@link TextDocument.languageId language} of the document.
13404 */
13405 language?: string;
13406 /**
13407 * The initial contents of the document.
13408 */
13409 content?: string;
13410 }): Thenable<TextDocument>;
13411
13412 /**
13413 * Register a text document content provider.
13414 *
13415 * Only one provider can be registered per scheme.
13416 *
13417 * @param scheme The uri-scheme to register for.
13418 * @param provider A content provider.
13419 * @returns A {@link Disposable} that unregisters this provider when being disposed.
13420 */
13421 export function registerTextDocumentContentProvider(scheme: string, provider: TextDocumentContentProvider): Disposable;
13422
13423 /**
13424 * An event that is emitted when a {@link TextDocument text document} is opened or when the language id
13425 * of a text document {@link languages.setTextDocumentLanguage has been changed}.
13426 *
13427 * To add an event listener when a visible text document is opened, use the {@link TextEditor} events in the
13428 * {@link window} namespace. Note that:
13429 *
13430 * - The event is emitted before the {@link TextDocument document} is updated in the
13431 * {@link window.activeTextEditor active text editor}
13432 * - When a {@link TextDocument text document} is already open (e.g.: open in another {@link window.visibleTextEditors visible text editor}) this event is not emitted
13433 *
13434 */
13435 export const onDidOpenTextDocument: Event<TextDocument>;
13436
13437 /**
13438 * An event that is emitted when a {@link TextDocument text document} is disposed or when the language id
13439 * of a text document {@link languages.setTextDocumentLanguage has been changed}.
13440 *
13441 * *Note 1:* There is no guarantee that this event fires when an editor tab is closed, use the
13442 * {@linkcode window.onDidChangeVisibleTextEditors onDidChangeVisibleTextEditors}-event to know when editors change.
13443 *
13444 * *Note 2:* A document can be open but not shown in an editor which means this event can fire
13445 * for a document that has not been shown in an editor.
13446 */
13447 export const onDidCloseTextDocument: Event<TextDocument>;
13448
13449 /**
13450 * An event that is emitted when a {@link TextDocument text document} is changed. This usually happens
13451 * when the {@link TextDocument.getText contents} changes but also when other things like the
13452 * {@link TextDocument.isDirty dirty}-state changes.
13453 */
13454 export const onDidChangeTextDocument: Event<TextDocumentChangeEvent>;
13455
13456 /**
13457 * An event that is emitted when a {@link TextDocument text document} will be saved to disk.
13458 *
13459 * *Note 1:* Subscribers can delay saving by registering asynchronous work. For the sake of data integrity the editor
13460 * might save without firing this event. For instance when shutting down with dirty files.
13461 *
13462 * *Note 2:* Subscribers are called sequentially and they can {@link TextDocumentWillSaveEvent.waitUntil delay} saving
13463 * by registering asynchronous work. Protection against misbehaving listeners is implemented as such:
13464 * * there is an overall time budget that all listeners share and if that is exhausted no further listener is called
13465 * * listeners that take a long time or produce errors frequently will not be called anymore
13466 *
13467 * The current thresholds are 1.5 seconds as overall time budget and a listener can misbehave 3 times before being ignored.
13468 */
13469 export const onWillSaveTextDocument: Event<TextDocumentWillSaveEvent>;
13470
13471 /**
13472 * An event that is emitted when a {@link TextDocument text document} is saved to disk.
13473 */
13474 export const onDidSaveTextDocument: Event<TextDocument>;
13475
13476 /**
13477 * All notebook documents currently known to the editor.
13478 */
13479 export const notebookDocuments: readonly NotebookDocument[];
13480
13481 /**
13482 * Open a notebook. Will return early if this notebook is already {@link notebookDocuments loaded}. Otherwise
13483 * the notebook is loaded and the {@linkcode onDidOpenNotebookDocument}-event fires.
13484 *
13485 * *Note* that the lifecycle of the returned notebook is owned by the editor and not by the extension. That means an
13486 * {@linkcode onDidCloseNotebookDocument}-event can occur at any time after.
13487 *
13488 * *Note* that opening a notebook does not show a notebook editor. This function only returns a notebook document which
13489 * can be shown in a notebook editor but it can also be used for other things.
13490 *
13491 * @param uri The resource to open.
13492 * @returns A promise that resolves to a {@link NotebookDocument notebook}
13493 */
13494 export function openNotebookDocument(uri: Uri): Thenable<NotebookDocument>;
13495
13496 /**
13497 * Open an untitled notebook. The editor will prompt the user for a file
13498 * path when the document is to be saved.
13499 *
13500 * @see {@link workspace.openNotebookDocument}
13501 * @param notebookType The notebook type that should be used.
13502 * @param content The initial contents of the notebook.
13503 * @returns A promise that resolves to a {@link NotebookDocument notebook}.
13504 */
13505 export function openNotebookDocument(notebookType: string, content?: NotebookData): Thenable<NotebookDocument>;
13506
13507 /**
13508 * An event that is emitted when a {@link NotebookDocument notebook} has changed.
13509 */
13510 export const onDidChangeNotebookDocument: Event<NotebookDocumentChangeEvent>;
13511
13512 /**
13513 * An event that is emitted when a {@link NotebookDocument notebook document} will be saved to disk.
13514 *
13515 * *Note 1:* Subscribers can delay saving by registering asynchronous work. For the sake of data integrity the editor
13516 * might save without firing this event. For instance when shutting down with dirty files.
13517 *
13518 * *Note 2:* Subscribers are called sequentially and they can {@link NotebookDocumentWillSaveEvent.waitUntil delay} saving
13519 * by registering asynchronous work. Protection against misbehaving listeners is implemented as such:
13520 * * there is an overall time budget that all listeners share and if that is exhausted no further listener is called
13521 * * listeners that take a long time or produce errors frequently will not be called anymore
13522 *
13523 * The current thresholds are 1.5 seconds as overall time budget and a listener can misbehave 3 times before being ignored.
13524 */
13525 export const onWillSaveNotebookDocument: Event<NotebookDocumentWillSaveEvent>;
13526
13527 /**
13528 * An event that is emitted when a {@link NotebookDocument notebook} is saved.
13529 */
13530 export const onDidSaveNotebookDocument: Event<NotebookDocument>;
13531
13532 /**
13533 * Register a {@link NotebookSerializer notebook serializer}.
13534 *
13535 * A notebook serializer must be contributed through the `notebooks` extension point. When opening a notebook file, the editor will send
13536 * the `onNotebook:<notebookType>` activation event, and extensions must register their serializer in return.
13537 *
13538 * @param notebookType A notebook.
13539 * @param serializer A notebook serializer.
13540 * @param options Optional context options that define what parts of a notebook should be persisted
13541 * @returns A {@link Disposable} that unregisters this serializer when being disposed.
13542 */
13543 export function registerNotebookSerializer(notebookType: string, serializer: NotebookSerializer, options?: NotebookDocumentContentOptions): Disposable;
13544
13545 /**
13546 * An event that is emitted when a {@link NotebookDocument notebook} is opened.
13547 */
13548 export const onDidOpenNotebookDocument: Event<NotebookDocument>;
13549
13550 /**
13551 * An event that is emitted when a {@link NotebookDocument notebook} is disposed.
13552 *
13553 * *Note 1:* There is no guarantee that this event fires when an editor tab is closed.
13554 *
13555 * *Note 2:* A notebook can be open but not shown in an editor which means this event can fire
13556 * for a notebook that has not been shown in an editor.
13557 */
13558 export const onDidCloseNotebookDocument: Event<NotebookDocument>;
13559
13560 /**
13561 * An event that is emitted when files are being created.
13562 *
13563 * *Note 1:* This event is triggered by user gestures, like creating a file from the
13564 * explorer, or from the {@linkcode workspace.applyEdit}-api. This event is *not* fired when
13565 * files change on disk, e.g triggered by another application, or when using the
13566 * {@linkcode FileSystem workspace.fs}-api.
13567 *
13568 * *Note 2:* When this event is fired, edits to files that are are being created cannot be applied.
13569 */
13570 export const onWillCreateFiles: Event<FileWillCreateEvent>;
13571
13572 /**
13573 * An event that is emitted when files have been created.
13574 *
13575 * *Note:* This event is triggered by user gestures, like creating a file from the
13576 * explorer, or from the {@linkcode workspace.applyEdit}-api, but this event is *not* fired when
13577 * files change on disk, e.g triggered by another application, or when using the
13578 * {@linkcode FileSystem workspace.fs}-api.
13579 */
13580 export const onDidCreateFiles: Event<FileCreateEvent>;
13581
13582 /**
13583 * An event that is emitted when files are being deleted.
13584 *
13585 * *Note 1:* This event is triggered by user gestures, like deleting a file from the
13586 * explorer, or from the {@linkcode workspace.applyEdit}-api, but this event is *not* fired when
13587 * files change on disk, e.g triggered by another application, or when using the
13588 * {@linkcode FileSystem workspace.fs}-api.
13589 *
13590 * *Note 2:* When deleting a folder with children only one event is fired.
13591 */
13592 export const onWillDeleteFiles: Event<FileWillDeleteEvent>;
13593
13594 /**
13595 * An event that is emitted when files have been deleted.
13596 *
13597 * *Note 1:* This event is triggered by user gestures, like deleting a file from the
13598 * explorer, or from the {@linkcode workspace.applyEdit}-api, but this event is *not* fired when
13599 * files change on disk, e.g triggered by another application, or when using the
13600 * {@linkcode FileSystem workspace.fs}-api.
13601 *
13602 * *Note 2:* When deleting a folder with children only one event is fired.
13603 */
13604 export const onDidDeleteFiles: Event<FileDeleteEvent>;
13605
13606 /**
13607 * An event that is emitted when files are being renamed.
13608 *
13609 * *Note 1:* This event is triggered by user gestures, like renaming a file from the
13610 * explorer, and from the {@linkcode workspace.applyEdit}-api, but this event is *not* fired when
13611 * files change on disk, e.g triggered by another application, or when using the
13612 * {@linkcode FileSystem workspace.fs}-api.
13613 *
13614 * *Note 2:* When renaming a folder with children only one event is fired.
13615 */
13616 export const onWillRenameFiles: Event<FileWillRenameEvent>;
13617
13618 /**
13619 * An event that is emitted when files have been renamed.
13620 *
13621 * *Note 1:* This event is triggered by user gestures, like renaming a file from the
13622 * explorer, and from the {@linkcode workspace.applyEdit}-api, but this event is *not* fired when
13623 * files change on disk, e.g triggered by another application, or when using the
13624 * {@linkcode FileSystem workspace.fs}-api.
13625 *
13626 * *Note 2:* When renaming a folder with children only one event is fired.
13627 */
13628 export const onDidRenameFiles: Event<FileRenameEvent>;
13629
13630 /**
13631 * Get a workspace configuration object.
13632 *
13633 * When a section-identifier is provided only that part of the configuration
13634 * is returned. Dots in the section-identifier are interpreted as child-access,
13635 * like `{ myExt: { setting: { doIt: true }}}` and `getConfiguration('myExt.setting').get('doIt') === true`.
13636 *
13637 * When a scope is provided configuration confined to that scope is returned. Scope can be a resource or a language identifier or both.
13638 *
13639 * @param section A dot-separated identifier.
13640 * @param scope A scope for which the configuration is asked for.
13641 * @returns The full configuration or a subset.
13642 */
13643 export function getConfiguration(section?: string, scope?: ConfigurationScope | null): WorkspaceConfiguration;
13644
13645 /**
13646 * An event that is emitted when the {@link WorkspaceConfiguration configuration} changed.
13647 */
13648 export const onDidChangeConfiguration: Event<ConfigurationChangeEvent>;
13649
13650 /**
13651 * Register a task provider.
13652 *
13653 * @deprecated Use the corresponding function on the `tasks` namespace instead
13654 *
13655 * @param type The task kind type this provider is registered for.
13656 * @param provider A task provider.
13657 * @returns A {@link Disposable} that unregisters this provider when being disposed.
13658 */
13659 export function registerTaskProvider(type: string, provider: TaskProvider): Disposable;
13660
13661 /**
13662 * Register a filesystem provider for a given scheme, e.g. `ftp`.
13663 *
13664 * There can only be one provider per scheme and an error is being thrown when a scheme
13665 * has been claimed by another provider or when it is reserved.
13666 *
13667 * @param scheme The uri-{@link Uri.scheme scheme} the provider registers for.
13668 * @param provider The filesystem provider.
13669 * @param options Immutable metadata about the provider.
13670 * @returns A {@link Disposable} that unregisters this provider when being disposed.
13671 */
13672 export function registerFileSystemProvider(scheme: string, provider: FileSystemProvider, options?: {
13673 /**
13674 * Whether the file system provider use case sensitive compare for {@link Uri.path paths}
13675 */
13676 readonly isCaseSensitive?: boolean;
13677 /**
13678 * Whether the file system provider is readonly, no modifications like write, delete, create are possible.
13679 * If a {@link MarkdownString} is given, it will be shown as the reason why the file system is readonly.
13680 */
13681 readonly isReadonly?: boolean | MarkdownString;
13682 }): Disposable;
13683
13684 /**
13685 * When true, the user has explicitly trusted the contents of the workspace.
13686 */
13687 export const isTrusted: boolean;
13688
13689 /**
13690 * Event that fires when the current workspace has been trusted.
13691 */
13692 export const onDidGrantWorkspaceTrust: Event<void>;
13693 }
13694
13695 /**
13696 * The configuration scope which can be a
13697 * a 'resource' or a languageId or both or
13698 * a '{@link TextDocument}' or
13699 * a '{@link WorkspaceFolder}'
13700 */
13701 export type ConfigurationScope = Uri | TextDocument | WorkspaceFolder | {
13702 /**
13703 * The uri of a {@link TextDocument text document}
13704 */
13705 uri?: Uri;
13706 /**
13707 * The language of a text document
13708 */
13709 languageId: string;
13710 };
13711
13712 /**
13713 * An event describing the change in Configuration
13714 */
13715 export interface ConfigurationChangeEvent {
13716
13717 /**
13718 * Checks if the given section has changed.
13719 * If scope is provided, checks if the section has changed for resources under the given scope.
13720 *
13721 * @param section Configuration name, supports _dotted_ names.
13722 * @param scope A scope in which to check.
13723 * @returns `true` if the given section has changed.
13724 */
13725 affectsConfiguration(section: string, scope?: ConfigurationScope): boolean;
13726 }
13727
13728 /**
13729 * Namespace for participating in language-specific editor [features](https://code.visualstudio.com/docs/editor/editingevolved),
13730 * like IntelliSense, code actions, diagnostics etc.
13731 *
13732 * Many programming languages exist and there is huge variety in syntaxes, semantics, and paradigms. Despite that, features
13733 * like automatic word-completion, code navigation, or code checking have become popular across different tools for different
13734 * programming languages.
13735 *
13736 * The editor provides an API that makes it simple to provide such common features by having all UI and actions already in place and
13737 * by allowing you to participate by providing data only. For instance, to contribute a hover all you have to do is provide a function
13738 * that can be called with a {@link TextDocument} and a {@link Position} returning hover info. The rest, like tracking the
13739 * mouse, positioning the hover, keeping the hover stable etc. is taken care of by the editor.
13740 *
13741 * ```javascript
13742 * languages.registerHoverProvider('javascript', {
13743 * provideHover(document, position, token) {
13744 * return new Hover('I am a hover!');
13745 * }
13746 * });
13747 * ```
13748 *
13749 * Registration is done using a {@link DocumentSelector document selector} which is either a language id, like `javascript` or
13750 * a more complex {@link DocumentFilter filter} like `{ language: 'typescript', scheme: 'file' }`. Matching a document against such
13751 * a selector will result in a {@link languages.match score} that is used to determine if and how a provider shall be used. When
13752 * scores are equal the provider that came last wins. For features that allow full arity, like {@link languages.registerHoverProvider hover},
13753 * the score is only checked to be `>0`, for other features, like {@link languages.registerCompletionItemProvider IntelliSense} the
13754 * score is used for determining the order in which providers are asked to participate.
13755 */
13756 export namespace languages {
13757
13758 /**
13759 * Return the identifiers of all known languages.
13760 * @returns Promise resolving to an array of identifier strings.
13761 */
13762 export function getLanguages(): Thenable<string[]>;
13763
13764 /**
13765 * Set (and change) the {@link TextDocument.languageId language} that is associated
13766 * with the given document.
13767 *
13768 * *Note* that calling this function will trigger the {@linkcode workspace.onDidCloseTextDocument onDidCloseTextDocument} event
13769 * followed by the {@linkcode workspace.onDidOpenTextDocument onDidOpenTextDocument} event.
13770 *
13771 * @param document The document which language is to be changed
13772 * @param languageId The new language identifier.
13773 * @returns A thenable that resolves with the updated document.
13774 */
13775 export function setTextDocumentLanguage(document: TextDocument, languageId: string): Thenable<TextDocument>;
13776
13777 /**
13778 * Compute the match between a document {@link DocumentSelector selector} and a document. Values
13779 * greater than zero mean the selector matches the document.
13780 *
13781 * A match is computed according to these rules:
13782 * 1. When {@linkcode DocumentSelector} is an array, compute the match for each contained `DocumentFilter` or language identifier and take the maximum value.
13783 * 2. A string will be desugared to become the `language`-part of a {@linkcode DocumentFilter}, so `"fooLang"` is like `{ language: "fooLang" }`.
13784 * 3. A {@linkcode DocumentFilter} will be matched against the document by comparing its parts with the document. The following rules apply:
13785 * 1. When the `DocumentFilter` is empty (`{}`) the result is `0`
13786 * 2. When `scheme`, `language`, `pattern`, or `notebook` are defined but one doesn't match, the result is `0`
13787 * 3. Matching against `*` gives a score of `5`, matching via equality or via a glob-pattern gives a score of `10`
13788 * 4. The result is the maximum value of each match
13789 *
13790 * Samples:
13791 * ```js
13792 * // default document from disk (file-scheme)
13793 * doc.uri; //'file:///my/file.js'
13794 * doc.languageId; // 'javascript'
13795 * match('javascript', doc); // 10;
13796 * match({ language: 'javascript' }, doc); // 10;
13797 * match({ language: 'javascript', scheme: 'file' }, doc); // 10;
13798 * match('*', doc); // 5
13799 * match('fooLang', doc); // 0
13800 * match(['fooLang', '*'], doc); // 5
13801 *
13802 * // virtual document, e.g. from git-index
13803 * doc.uri; // 'git:/my/file.js'
13804 * doc.languageId; // 'javascript'
13805 * match('javascript', doc); // 10;
13806 * match({ language: 'javascript', scheme: 'git' }, doc); // 10;
13807 * match('*', doc); // 5
13808 *
13809 * // notebook cell document
13810 * doc.uri; // `vscode-notebook-cell:///my/notebook.ipynb#gl65s2pmha`;
13811 * doc.languageId; // 'python'
13812 * match({ notebookType: 'jupyter-notebook' }, doc) // 10
13813 * match({ notebookType: 'fooNotebook', language: 'python' }, doc) // 0
13814 * match({ language: 'python' }, doc) // 10
13815 * match({ notebookType: '*' }, doc) // 5
13816 * ```
13817 *
13818 * @param selector A document selector.
13819 * @param document A text document.
13820 * @returns A number `>0` when the selector matches and `0` when the selector does not match.
13821 */
13822 export function match(selector: DocumentSelector, document: TextDocument): number;
13823
13824 /**
13825 * An {@link Event} which fires when the global set of diagnostics changes. This is
13826 * newly added and removed diagnostics.
13827 */
13828 export const onDidChangeDiagnostics: Event<DiagnosticChangeEvent>;
13829
13830 /**
13831 * Get all diagnostics for a given resource.
13832 *
13833 * @param resource A resource
13834 * @returns An array of {@link Diagnostic diagnostics} objects or an empty array.
13835 */
13836 export function getDiagnostics(resource: Uri): Diagnostic[];
13837
13838 /**
13839 * Get all diagnostics.
13840 *
13841 * @returns An array of uri-diagnostics tuples or an empty array.
13842 */
13843 export function getDiagnostics(): [Uri, Diagnostic[]][];
13844
13845 /**
13846 * Create a diagnostics collection.
13847 *
13848 * @param name The {@link DiagnosticCollection.name name} of the collection.
13849 * @returns A new diagnostic collection.
13850 */
13851 export function createDiagnosticCollection(name?: string): DiagnosticCollection;
13852
13853 /**
13854 * Creates a new {@link LanguageStatusItem language status item}.
13855 *
13856 * @param id The identifier of the item.
13857 * @param selector The document selector that defines for what editors the item shows.
13858 * @returns A new language status item.
13859 */
13860 export function createLanguageStatusItem(id: string, selector: DocumentSelector): LanguageStatusItem;
13861
13862 /**
13863 * Register a completion provider.
13864 *
13865 * Multiple providers can be registered for a language. In that case providers are sorted
13866 * by their {@link languages.match score} and groups of equal score are sequentially asked for
13867 * completion items. The process stops when one or many providers of a group return a
13868 * result. A failing provider (rejected promise or exception) will not fail the whole
13869 * operation.
13870 *
13871 * A completion item provider can be associated with a set of `triggerCharacters`. When trigger
13872 * characters are being typed, completions are requested but only from providers that registered
13873 * the typed character. Because of that trigger characters should be different than {@link LanguageConfiguration.wordPattern word characters},
13874 * a common trigger character is `.` to trigger member completions.
13875 *
13876 * @param selector A selector that defines the documents this provider is applicable to.
13877 * @param provider A completion provider.
13878 * @param triggerCharacters Trigger completion when the user types one of the characters.
13879 * @returns A {@link Disposable} that unregisters this provider when being disposed.
13880 */
13881 export function registerCompletionItemProvider(selector: DocumentSelector, provider: CompletionItemProvider, ...triggerCharacters: string[]): Disposable;
13882
13883 /**
13884 * Registers an inline completion provider.
13885 *
13886 * Multiple providers can be registered for a language. In that case providers are asked in
13887 * parallel and the results are merged. A failing provider (rejected promise or exception) will
13888 * not cause a failure of the whole operation.
13889 *
13890 * @param selector A selector that defines the documents this provider is applicable to.
13891 * @param provider An inline completion provider.
13892 * @returns A {@link Disposable} that unregisters this provider when being disposed.
13893 */
13894 export function registerInlineCompletionItemProvider(selector: DocumentSelector, provider: InlineCompletionItemProvider): Disposable;
13895
13896 /**
13897 * Register a code action provider.
13898 *
13899 * Multiple providers can be registered for a language. In that case providers are asked in
13900 * parallel and the results are merged. A failing provider (rejected promise or exception) will
13901 * not cause a failure of the whole operation.
13902 *
13903 * @param selector A selector that defines the documents this provider is applicable to.
13904 * @param provider A code action provider.
13905 * @param metadata Metadata about the kind of code actions the provider provides.
13906 * @returns A {@link Disposable} that unregisters this provider when being disposed.
13907 */
13908 export function registerCodeActionsProvider(selector: DocumentSelector, provider: CodeActionProvider, metadata?: CodeActionProviderMetadata): Disposable;
13909
13910 /**
13911 * Register a code lens provider.
13912 *
13913 * Multiple providers can be registered for a language. In that case providers are asked in
13914 * parallel and the results are merged. A failing provider (rejected promise or exception) will
13915 * not cause a failure of the whole operation.
13916 *
13917 * @param selector A selector that defines the documents this provider is applicable to.
13918 * @param provider A code lens provider.
13919 * @returns A {@link Disposable} that unregisters this provider when being disposed.
13920 */
13921 export function registerCodeLensProvider(selector: DocumentSelector, provider: CodeLensProvider): Disposable;
13922
13923 /**
13924 * Register a definition provider.
13925 *
13926 * Multiple providers can be registered for a language. In that case providers are asked in
13927 * parallel and the results are merged. A failing provider (rejected promise or exception) will
13928 * not cause a failure of the whole operation.
13929 *
13930 * @param selector A selector that defines the documents this provider is applicable to.
13931 * @param provider A definition provider.
13932 * @returns A {@link Disposable} that unregisters this provider when being disposed.
13933 */
13934 export function registerDefinitionProvider(selector: DocumentSelector, provider: DefinitionProvider): Disposable;
13935
13936 /**
13937 * Register an implementation provider.
13938 *
13939 * Multiple providers can be registered for a language. In that case providers are asked in
13940 * parallel and the results are merged. A failing provider (rejected promise or exception) will
13941 * not cause a failure of the whole operation.
13942 *
13943 * @param selector A selector that defines the documents this provider is applicable to.
13944 * @param provider An implementation provider.
13945 * @returns A {@link Disposable} that unregisters this provider when being disposed.
13946 */
13947 export function registerImplementationProvider(selector: DocumentSelector, provider: ImplementationProvider): Disposable;
13948
13949 /**
13950 * Register a type definition provider.
13951 *
13952 * Multiple providers can be registered for a language. In that case providers are asked in
13953 * parallel and the results are merged. A failing provider (rejected promise or exception) will
13954 * not cause a failure of the whole operation.
13955 *
13956 * @param selector A selector that defines the documents this provider is applicable to.
13957 * @param provider A type definition provider.
13958 * @returns A {@link Disposable} that unregisters this provider when being disposed.
13959 */
13960 export function registerTypeDefinitionProvider(selector: DocumentSelector, provider: TypeDefinitionProvider): Disposable;
13961
13962 /**
13963 * Register a declaration provider.
13964 *
13965 * Multiple providers can be registered for a language. In that case providers are asked in
13966 * parallel and the results are merged. A failing provider (rejected promise or exception) will
13967 * not cause a failure of the whole operation.
13968 *
13969 * @param selector A selector that defines the documents this provider is applicable to.
13970 * @param provider A declaration provider.
13971 * @returns A {@link Disposable} that unregisters this provider when being disposed.
13972 */
13973 export function registerDeclarationProvider(selector: DocumentSelector, provider: DeclarationProvider): Disposable;
13974
13975 /**
13976 * Register a hover provider.
13977 *
13978 * Multiple providers can be registered for a language. In that case providers are asked in
13979 * parallel and the results are merged. A failing provider (rejected promise or exception) will
13980 * not cause a failure of the whole operation.
13981 *
13982 * @param selector A selector that defines the documents this provider is applicable to.
13983 * @param provider A hover provider.
13984 * @returns A {@link Disposable} that unregisters this provider when being disposed.
13985 */
13986 export function registerHoverProvider(selector: DocumentSelector, provider: HoverProvider): Disposable;
13987
13988 /**
13989 * Register a provider that locates evaluatable expressions in text documents.
13990 * The editor will evaluate the expression in the active debug session and will show the result in the debug hover.
13991 *
13992 * If multiple providers are registered for a language an arbitrary provider will be used.
13993 *
13994 * @param selector A selector that defines the documents this provider is applicable to.
13995 * @param provider An evaluatable expression provider.
13996 * @returns A {@link Disposable} that unregisters this provider when being disposed.
13997 */
13998 export function registerEvaluatableExpressionProvider(selector: DocumentSelector, provider: EvaluatableExpressionProvider): Disposable;
13999
14000 /**
14001 * Register a provider that returns data for the debugger's 'inline value' feature.
14002 * Whenever the generic debugger has stopped in a source file, providers registered for the language of the file
14003 * are called to return textual data that will be shown in the editor at the end of lines.
14004 *
14005 * Multiple providers can be registered for a language. In that case providers are asked in
14006 * parallel and the results are merged. A failing provider (rejected promise or exception) will
14007 * not cause a failure of the whole operation.
14008 *
14009 * @param selector A selector that defines the documents this provider is applicable to.
14010 * @param provider An inline values provider.
14011 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14012 */
14013 export function registerInlineValuesProvider(selector: DocumentSelector, provider: InlineValuesProvider): Disposable;
14014
14015 /**
14016 * Register a document highlight provider.
14017 *
14018 * Multiple providers can be registered for a language. In that case providers are sorted
14019 * by their {@link languages.match score} and groups sequentially asked for document highlights.
14020 * The process stops when a provider returns a `non-falsy` or `non-failure` result.
14021 *
14022 * @param selector A selector that defines the documents this provider is applicable to.
14023 * @param provider A document highlight provider.
14024 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14025 */
14026 export function registerDocumentHighlightProvider(selector: DocumentSelector, provider: DocumentHighlightProvider): Disposable;
14027
14028 /**
14029 * Register a document symbol provider.
14030 *
14031 * Multiple providers can be registered for a language. In that case providers are asked in
14032 * parallel and the results are merged. A failing provider (rejected promise or exception) will
14033 * not cause a failure of the whole operation.
14034 *
14035 * @param selector A selector that defines the documents this provider is applicable to.
14036 * @param provider A document symbol provider.
14037 * @param metaData metadata about the provider
14038 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14039 */
14040 export function registerDocumentSymbolProvider(selector: DocumentSelector, provider: DocumentSymbolProvider, metaData?: DocumentSymbolProviderMetadata): Disposable;
14041
14042 /**
14043 * Register a workspace symbol provider.
14044 *
14045 * Multiple providers can be registered. In that case providers are asked in parallel and
14046 * the results are merged. A failing provider (rejected promise or exception) will not cause
14047 * a failure of the whole operation.
14048 *
14049 * @param provider A workspace symbol provider.
14050 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14051 */
14052 export function registerWorkspaceSymbolProvider(provider: WorkspaceSymbolProvider): Disposable;
14053
14054 /**
14055 * Register a reference provider.
14056 *
14057 * Multiple providers can be registered for a language. In that case providers are asked in
14058 * parallel and the results are merged. A failing provider (rejected promise or exception) will
14059 * not cause a failure of the whole operation.
14060 *
14061 * @param selector A selector that defines the documents this provider is applicable to.
14062 * @param provider A reference provider.
14063 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14064 */
14065 export function registerReferenceProvider(selector: DocumentSelector, provider: ReferenceProvider): Disposable;
14066
14067 /**
14068 * Register a rename provider.
14069 *
14070 * Multiple providers can be registered for a language. In that case providers are sorted
14071 * by their {@link languages.match score} and asked in sequence. The first provider producing a result
14072 * defines the result of the whole operation.
14073 *
14074 * @param selector A selector that defines the documents this provider is applicable to.
14075 * @param provider A rename provider.
14076 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14077 */
14078 export function registerRenameProvider(selector: DocumentSelector, provider: RenameProvider): Disposable;
14079
14080 /**
14081 * Register a semantic tokens provider for a whole document.
14082 *
14083 * Multiple providers can be registered for a language. In that case providers are sorted
14084 * by their {@link languages.match score} and the best-matching provider is used. Failure
14085 * of the selected provider will cause a failure of the whole operation.
14086 *
14087 * @param selector A selector that defines the documents this provider is applicable to.
14088 * @param provider A document semantic tokens provider.
14089 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14090 */
14091 export function registerDocumentSemanticTokensProvider(selector: DocumentSelector, provider: DocumentSemanticTokensProvider, legend: SemanticTokensLegend): Disposable;
14092
14093 /**
14094 * Register a semantic tokens provider for a document range.
14095 *
14096 * *Note:* If a document has both a `DocumentSemanticTokensProvider` and a `DocumentRangeSemanticTokensProvider`,
14097 * the range provider will be invoked only initially, for the time in which the full document provider takes
14098 * to resolve the first request. Once the full document provider resolves the first request, the semantic tokens
14099 * provided via the range provider will be discarded and from that point forward, only the document provider
14100 * will be used.
14101 *
14102 * Multiple providers can be registered for a language. In that case providers are sorted
14103 * by their {@link languages.match score} and the best-matching provider is used. Failure
14104 * of the selected provider will cause a failure of the whole operation.
14105 *
14106 * @param selector A selector that defines the documents this provider is applicable to.
14107 * @param provider A document range semantic tokens provider.
14108 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14109 */
14110 export function registerDocumentRangeSemanticTokensProvider(selector: DocumentSelector, provider: DocumentRangeSemanticTokensProvider, legend: SemanticTokensLegend): Disposable;
14111
14112 /**
14113 * Register a formatting provider for a document.
14114 *
14115 * Multiple providers can be registered for a language. In that case providers are sorted
14116 * by their {@link languages.match score} and the best-matching provider is used. Failure
14117 * of the selected provider will cause a failure of the whole operation.
14118 *
14119 * @param selector A selector that defines the documents this provider is applicable to.
14120 * @param provider A document formatting edit provider.
14121 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14122 */
14123 export function registerDocumentFormattingEditProvider(selector: DocumentSelector, provider: DocumentFormattingEditProvider): Disposable;
14124
14125 /**
14126 * Register a formatting provider for a document range.
14127 *
14128 * *Note:* A document range provider is also a {@link DocumentFormattingEditProvider document formatter}
14129 * which means there is no need to {@link languages.registerDocumentFormattingEditProvider register} a document
14130 * formatter when also registering a range provider.
14131 *
14132 * Multiple providers can be registered for a language. In that case providers are sorted
14133 * by their {@link languages.match score} and the best-matching provider is used. Failure
14134 * of the selected provider will cause a failure of the whole operation.
14135 *
14136 * @param selector A selector that defines the documents this provider is applicable to.
14137 * @param provider A document range formatting edit provider.
14138 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14139 */
14140 export function registerDocumentRangeFormattingEditProvider(selector: DocumentSelector, provider: DocumentRangeFormattingEditProvider): Disposable;
14141
14142 /**
14143 * Register a formatting provider that works on type. The provider is active when the user enables the setting `editor.formatOnType`.
14144 *
14145 * Multiple providers can be registered for a language. In that case providers are sorted
14146 * by their {@link languages.match score} and the best-matching provider is used. Failure
14147 * of the selected provider will cause a failure of the whole operation.
14148 *
14149 * @param selector A selector that defines the documents this provider is applicable to.
14150 * @param provider An on type formatting edit provider.
14151 * @param firstTriggerCharacter A character on which formatting should be triggered, like `}`.
14152 * @param moreTriggerCharacter More trigger characters.
14153 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14154 */
14155 export function registerOnTypeFormattingEditProvider(selector: DocumentSelector, provider: OnTypeFormattingEditProvider, firstTriggerCharacter: string, ...moreTriggerCharacter: string[]): Disposable;
14156
14157 /**
14158 * Register a signature help provider.
14159 *
14160 * Multiple providers can be registered for a language. In that case providers are sorted
14161 * by their {@link languages.match score} and called sequentially until a provider returns a
14162 * valid result.
14163 *
14164 * @param selector A selector that defines the documents this provider is applicable to.
14165 * @param provider A signature help provider.
14166 * @param triggerCharacters Trigger signature help when the user types one of the characters, like `,` or `(`.
14167 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14168 */
14169 export function registerSignatureHelpProvider(selector: DocumentSelector, provider: SignatureHelpProvider, ...triggerCharacters: string[]): Disposable;
14170
14171 /**
14172 * @see {@link languages.registerSignatureHelpProvider}
14173 *
14174 * @param selector A selector that defines the documents this provider is applicable to.
14175 * @param provider A signature help provider.
14176 * @param metadata Information about the provider.
14177 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14178 */
14179 export function registerSignatureHelpProvider(selector: DocumentSelector, provider: SignatureHelpProvider, metadata: SignatureHelpProviderMetadata): Disposable;
14180
14181 /**
14182 * Register a document link provider.
14183 *
14184 * Multiple providers can be registered for a language. In that case providers are asked in
14185 * parallel and the results are merged. A failing provider (rejected promise or exception) will
14186 * not cause a failure of the whole operation.
14187 *
14188 * @param selector A selector that defines the documents this provider is applicable to.
14189 * @param provider A document link provider.
14190 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14191 */
14192 export function registerDocumentLinkProvider(selector: DocumentSelector, provider: DocumentLinkProvider): Disposable;
14193
14194 /**
14195 * Register a color provider.
14196 *
14197 * Multiple providers can be registered for a language. In that case providers are asked in
14198 * parallel and the results are merged. A failing provider (rejected promise or exception) will
14199 * not cause a failure of the whole operation.
14200 *
14201 * @param selector A selector that defines the documents this provider is applicable to.
14202 * @param provider A color provider.
14203 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14204 */
14205 export function registerColorProvider(selector: DocumentSelector, provider: DocumentColorProvider): Disposable;
14206
14207 /**
14208 * Register a inlay hints provider.
14209 *
14210 * Multiple providers can be registered for a language. In that case providers are asked in
14211 * parallel and the results are merged. A failing provider (rejected promise or exception) will
14212 * not cause a failure of the whole operation.
14213 *
14214 * @param selector A selector that defines the documents this provider is applicable to.
14215 * @param provider An inlay hints provider.
14216 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14217 */
14218 export function registerInlayHintsProvider(selector: DocumentSelector, provider: InlayHintsProvider): Disposable;
14219
14220 /**
14221 * Register a folding range provider.
14222 *
14223 * Multiple providers can be registered for a language. In that case providers are asked in
14224 * parallel and the results are merged.
14225 * If multiple folding ranges start at the same position, only the range of the first registered provider is used.
14226 * If a folding range overlaps with an other range that has a smaller position, it is also ignored.
14227 *
14228 * A failing provider (rejected promise or exception) will
14229 * not cause a failure of the whole operation.
14230 *
14231 * @param selector A selector that defines the documents this provider is applicable to.
14232 * @param provider A folding range provider.
14233 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14234 */
14235 export function registerFoldingRangeProvider(selector: DocumentSelector, provider: FoldingRangeProvider): Disposable;
14236
14237 /**
14238 * Register a selection range provider.
14239 *
14240 * Multiple providers can be registered for a language. In that case providers are asked in
14241 * parallel and the results are merged. A failing provider (rejected promise or exception) will
14242 * not cause a failure of the whole operation.
14243 *
14244 * @param selector A selector that defines the documents this provider is applicable to.
14245 * @param provider A selection range provider.
14246 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14247 */
14248 export function registerSelectionRangeProvider(selector: DocumentSelector, provider: SelectionRangeProvider): Disposable;
14249
14250 /**
14251 * Register a call hierarchy provider.
14252 *
14253 * @param selector A selector that defines the documents this provider is applicable to.
14254 * @param provider A call hierarchy provider.
14255 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14256 */
14257 export function registerCallHierarchyProvider(selector: DocumentSelector, provider: CallHierarchyProvider): Disposable;
14258
14259 /**
14260 * Register a type hierarchy provider.
14261 *
14262 * @param selector A selector that defines the documents this provider is applicable to.
14263 * @param provider A type hierarchy provider.
14264 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14265 */
14266 export function registerTypeHierarchyProvider(selector: DocumentSelector, provider: TypeHierarchyProvider): Disposable;
14267
14268 /**
14269 * Register a linked editing range provider.
14270 *
14271 * Multiple providers can be registered for a language. In that case providers are sorted
14272 * by their {@link languages.match score} and the best-matching provider that has a result is used. Failure
14273 * of the selected provider will cause a failure of the whole operation.
14274 *
14275 * @param selector A selector that defines the documents this provider is applicable to.
14276 * @param provider A linked editing range provider.
14277 * @returns A {@link Disposable} that unregisters this provider when being disposed.
14278 */
14279 export function registerLinkedEditingRangeProvider(selector: DocumentSelector, provider: LinkedEditingRangeProvider): Disposable;
14280
14281 /**
14282 * Registers a new {@link DocumentDropEditProvider}.
14283 *
14284 * @param selector A selector that defines the documents this provider applies to.
14285 * @param provider A drop provider.
14286 *
14287 * @returns A {@link Disposable} that unregisters this provider when disposed of.
14288 */
14289 export function registerDocumentDropEditProvider(selector: DocumentSelector, provider: DocumentDropEditProvider): Disposable;
14290
14291 /**
14292 * Set a {@link LanguageConfiguration language configuration} for a language.
14293 *
14294 * @param language A language identifier like `typescript`.
14295 * @param configuration Language configuration.
14296 * @returns A {@link Disposable} that unsets this configuration.
14297 */
14298 export function setLanguageConfiguration(language: string, configuration: LanguageConfiguration): Disposable;
14299 }
14300
14301 /**
14302 * Represents a notebook editor that is attached to a {@link NotebookDocument notebook}.
14303 */
14304 export enum NotebookEditorRevealType {
14305 /**
14306 * The range will be revealed with as little scrolling as possible.
14307 */
14308 Default = 0,
14309
14310 /**
14311 * The range will always be revealed in the center of the viewport.
14312 */
14313 InCenter = 1,
14314
14315 /**
14316 * If the range is outside the viewport, it will be revealed in the center of the viewport.
14317 * Otherwise, it will be revealed with as little scrolling as possible.
14318 */
14319 InCenterIfOutsideViewport = 2,
14320
14321 /**
14322 * The range will always be revealed at the top of the viewport.
14323 */
14324 AtTop = 3
14325 }
14326
14327 /**
14328 * Represents a notebook editor that is attached to a {@link NotebookDocument notebook}.
14329 * Additional properties of the NotebookEditor are available in the proposed
14330 * API, which will be finalized later.
14331 */
14332 export interface NotebookEditor {
14333
14334 /**
14335 * The {@link NotebookDocument notebook document} associated with this notebook editor.
14336 */
14337 readonly notebook: NotebookDocument;
14338
14339 /**
14340 * The primary selection in this notebook editor.
14341 */
14342 selection: NotebookRange;
14343
14344 /**
14345 * All selections in this notebook editor.
14346 *
14347 * The primary selection (or focused range) is `selections[0]`. When the document has no cells, the primary selection is empty `{ start: 0, end: 0 }`;
14348 */
14349 selections: readonly NotebookRange[];
14350
14351 /**
14352 * The current visible ranges in the editor (vertically).
14353 */
14354 readonly visibleRanges: readonly NotebookRange[];
14355
14356 /**
14357 * The column in which this editor shows.
14358 */
14359 readonly viewColumn?: ViewColumn;
14360
14361 /**
14362 * Scroll as indicated by `revealType` in order to reveal the given range.
14363 *
14364 * @param range A range.
14365 * @param revealType The scrolling strategy for revealing `range`.
14366 */
14367 revealRange(range: NotebookRange, revealType?: NotebookEditorRevealType): void;
14368 }
14369
14370 /**
14371 * Renderer messaging is used to communicate with a single renderer. It's returned from {@link notebooks.createRendererMessaging}.
14372 */
14373 export interface NotebookRendererMessaging {
14374 /**
14375 * An event that fires when a message is received from a renderer.
14376 */
14377 readonly onDidReceiveMessage: Event<{
14378 /**
14379 * The {@link NotebookEditor editor} that sent the message.
14380 */
14381 readonly editor: NotebookEditor;
14382 /**
14383 * The actual message.
14384 */
14385 readonly message: any;
14386 }>;
14387
14388 /**
14389 * Send a message to one or all renderer.
14390 *
14391 * @param message Message to send
14392 * @param editor Editor to target with the message. If not provided, the
14393 * message is sent to all renderers.
14394 * @returns a boolean indicating whether the message was successfully
14395 * delivered to any renderer.
14396 */
14397 postMessage(message: any, editor?: NotebookEditor): Thenable<boolean>;
14398 }
14399
14400 /**
14401 * A notebook cell kind.
14402 */
14403 export enum NotebookCellKind {
14404
14405 /**
14406 * A markup-cell is formatted source that is used for display.
14407 */
14408 Markup = 1,
14409
14410 /**
14411 * A code-cell is source that can be {@link NotebookController executed} and that
14412 * produces {@link NotebookCellOutput output}.
14413 */
14414 Code = 2
14415 }
14416
14417 /**
14418 * Represents a cell of a {@link NotebookDocument notebook}, either a {@link NotebookCellKind.Code code}-cell
14419 * or {@link NotebookCellKind.Markup markup}-cell.
14420 *
14421 * NotebookCell instances are immutable and are kept in sync for as long as they are part of their notebook.
14422 */
14423 export interface NotebookCell {
14424
14425 /**
14426 * The index of this cell in its {@link NotebookDocument.cellAt containing notebook}. The
14427 * index is updated when a cell is moved within its notebook. The index is `-1`
14428 * when the cell has been removed from its notebook.
14429 */
14430 readonly index: number;
14431
14432 /**
14433 * The {@link NotebookDocument notebook} that contains this cell.
14434 */
14435 readonly notebook: NotebookDocument;
14436
14437 /**
14438 * The kind of this cell.
14439 */
14440 readonly kind: NotebookCellKind;
14441
14442 /**
14443 * The {@link TextDocument text} of this cell, represented as text document.
14444 */
14445 readonly document: TextDocument;
14446
14447 /**
14448 * The metadata of this cell. Can be anything but must be JSON-stringifyable.
14449 */
14450 readonly metadata: { readonly [key: string]: any };
14451
14452 /**
14453 * The outputs of this cell.
14454 */
14455 readonly outputs: readonly NotebookCellOutput[];
14456
14457 /**
14458 * The most recent {@link NotebookCellExecutionSummary execution summary} for this cell.
14459 */
14460 readonly executionSummary: NotebookCellExecutionSummary | undefined;
14461 }
14462
14463 /**
14464 * Represents a notebook which itself is a sequence of {@link NotebookCell code or markup cells}. Notebook documents are
14465 * created from {@link NotebookData notebook data}.
14466 */
14467 export interface NotebookDocument {
14468
14469 /**
14470 * The associated uri for this notebook.
14471 *
14472 * *Note* that most notebooks use the `file`-scheme, which means they are files on disk. However, **not** all notebooks are
14473 * saved on disk and therefore the `scheme` must be checked before trying to access the underlying file or siblings on disk.
14474 *
14475 * @see {@link FileSystemProvider}
14476 */
14477 readonly uri: Uri;
14478
14479 /**
14480 * The type of notebook.
14481 */
14482 readonly notebookType: string;
14483
14484 /**
14485 * The version number of this notebook (it will strictly increase after each
14486 * change, including undo/redo).
14487 */
14488 readonly version: number;
14489
14490 /**
14491 * `true` if there are unpersisted changes.
14492 */
14493 readonly isDirty: boolean;
14494
14495 /**
14496 * Is this notebook representing an untitled file which has not been saved yet.
14497 */
14498 readonly isUntitled: boolean;
14499
14500 /**
14501 * `true` if the notebook has been closed. A closed notebook isn't synchronized anymore
14502 * and won't be re-used when the same resource is opened again.
14503 */
14504 readonly isClosed: boolean;
14505
14506 /**
14507 * Arbitrary metadata for this notebook. Can be anything but must be JSON-stringifyable.
14508 */
14509 readonly metadata: { [key: string]: any };
14510
14511 /**
14512 * The number of cells in the notebook.
14513 */
14514 readonly cellCount: number;
14515
14516 /**
14517 * Return the cell at the specified index. The index will be adjusted to the notebook.
14518 *
14519 * @param index - The index of the cell to retrieve.
14520 * @returns A {@link NotebookCell cell}.
14521 */
14522 cellAt(index: number): NotebookCell;
14523
14524 /**
14525 * Get the cells of this notebook. A subset can be retrieved by providing
14526 * a range. The range will be adjusted to the notebook.
14527 *
14528 * @param range A notebook range.
14529 * @returns The cells contained by the range or all cells.
14530 */
14531 getCells(range?: NotebookRange): NotebookCell[];
14532
14533 /**
14534 * Save the document. The saving will be handled by the corresponding {@link NotebookSerializer serializer}.
14535 *
14536 * @returns A promise that will resolve to true when the document
14537 * has been saved. Will return false if the file was not dirty or when save failed.
14538 */
14539 save(): Thenable<boolean>;
14540 }
14541
14542 /**
14543 * Describes a change to a notebook cell.
14544 *
14545 * @see {@link NotebookDocumentChangeEvent}
14546 */
14547 export interface NotebookDocumentCellChange {
14548
14549 /**
14550 * The affected cell.
14551 */
14552 readonly cell: NotebookCell;
14553
14554 /**
14555 * The document of the cell or `undefined` when it did not change.
14556 *
14557 * *Note* that you should use the {@link workspace.onDidChangeTextDocument onDidChangeTextDocument}-event
14558 * for detailed change information, like what edits have been performed.
14559 */
14560 readonly document: TextDocument | undefined;
14561
14562 /**
14563 * The new metadata of the cell or `undefined` when it did not change.
14564 */
14565 readonly metadata: { [key: string]: any } | undefined;
14566
14567 /**
14568 * The new outputs of the cell or `undefined` when they did not change.
14569 */
14570 readonly outputs: readonly NotebookCellOutput[] | undefined;
14571
14572 /**
14573 * The new execution summary of the cell or `undefined` when it did not change.
14574 */
14575 readonly executionSummary: NotebookCellExecutionSummary | undefined;
14576 }
14577
14578 /**
14579 * Describes a structural change to a notebook document, e.g newly added and removed cells.
14580 *
14581 * @see {@link NotebookDocumentChangeEvent}
14582 */
14583 export interface NotebookDocumentContentChange {
14584
14585 /**
14586 * The range at which cells have been either added or removed.
14587 *
14588 * Note that no cells have been {@link NotebookDocumentContentChange.removedCells removed}
14589 * when this range is {@link NotebookRange.isEmpty empty}.
14590 */
14591 readonly range: NotebookRange;
14592
14593 /**
14594 * Cells that have been added to the document.
14595 */
14596 readonly addedCells: readonly NotebookCell[];
14597
14598 /**
14599 * Cells that have been removed from the document.
14600 */
14601 readonly removedCells: readonly NotebookCell[];
14602 }
14603
14604 /**
14605 * An event describing a transactional {@link NotebookDocument notebook} change.
14606 */
14607 export interface NotebookDocumentChangeEvent {
14608
14609 /**
14610 * The affected notebook.
14611 */
14612 readonly notebook: NotebookDocument;
14613
14614 /**
14615 * The new metadata of the notebook or `undefined` when it did not change.
14616 */
14617 readonly metadata: { [key: string]: any } | undefined;
14618
14619 /**
14620 * An array of content changes describing added or removed {@link NotebookCell cells}.
14621 */
14622 readonly contentChanges: readonly NotebookDocumentContentChange[];
14623
14624 /**
14625 * An array of {@link NotebookDocumentCellChange cell changes}.
14626 */
14627 readonly cellChanges: readonly NotebookDocumentCellChange[];
14628 }
14629
14630 /**
14631 * An event that is fired when a {@link NotebookDocument notebook document} will be saved.
14632 *
14633 * To make modifications to the document before it is being saved, call the
14634 * {@linkcode NotebookDocumentWillSaveEvent.waitUntil waitUntil}-function with a thenable
14635 * that resolves to a {@link WorkspaceEdit workspace edit}.
14636 */
14637 export interface NotebookDocumentWillSaveEvent {
14638 /**
14639 * A cancellation token.
14640 */
14641 readonly token: CancellationToken;
14642
14643 /**
14644 * The {@link NotebookDocument notebook document} that will be saved.
14645 */
14646 readonly notebook: NotebookDocument;
14647
14648 /**
14649 * The reason why save was triggered.
14650 */
14651 readonly reason: TextDocumentSaveReason;
14652
14653 /**
14654 * Allows to pause the event loop and to apply {@link WorkspaceEdit workspace edit}.
14655 * Edits of subsequent calls to this function will be applied in order. The
14656 * edits will be *ignored* if concurrent modifications of the notebook document happened.
14657 *
14658 * *Note:* This function can only be called during event dispatch and not
14659 * in an asynchronous manner:
14660 *
14661 * ```ts
14662 * workspace.onWillSaveNotebookDocument(event => {
14663 * // async, will *throw* an error
14664 * setTimeout(() => event.waitUntil(promise));
14665 *
14666 * // sync, OK
14667 * event.waitUntil(promise);
14668 * })
14669 * ```
14670 *
14671 * @param thenable A thenable that resolves to {@link WorkspaceEdit workspace edit}.
14672 */
14673 waitUntil(thenable: Thenable<WorkspaceEdit>): void;
14674
14675 /**
14676 * Allows to pause the event loop until the provided thenable resolved.
14677 *
14678 * *Note:* This function can only be called during event dispatch.
14679 *
14680 * @param thenable A thenable that delays saving.
14681 */
14682 waitUntil(thenable: Thenable<any>): void;
14683 }
14684
14685 /**
14686 * The summary of a notebook cell execution.
14687 */
14688 export interface NotebookCellExecutionSummary {
14689
14690 /**
14691 * The order in which the execution happened.
14692 */
14693 readonly executionOrder?: number;
14694
14695 /**
14696 * If the execution finished successfully.
14697 */
14698 readonly success?: boolean;
14699
14700 /**
14701 * The times at which execution started and ended, as unix timestamps
14702 */
14703 readonly timing?: {
14704 /**
14705 * Execution start time.
14706 */
14707 readonly startTime: number;
14708 /**
14709 * Execution end time.
14710 */
14711 readonly endTime: number;
14712 };
14713 }
14714
14715 /**
14716 * A notebook range represents an ordered pair of two cell indices.
14717 * It is guaranteed that start is less than or equal to end.
14718 */
14719 export class NotebookRange {
14720
14721 /**
14722 * The zero-based start index of this range.
14723 */
14724 readonly start: number;
14725
14726 /**
14727 * The exclusive end index of this range (zero-based).
14728 */
14729 readonly end: number;
14730
14731 /**
14732 * `true` if `start` and `end` are equal.
14733 */
14734 readonly isEmpty: boolean;
14735
14736 /**
14737 * Create a new notebook range. If `start` is not
14738 * before or equal to `end`, the values will be swapped.
14739 *
14740 * @param start start index
14741 * @param end end index.
14742 */
14743 constructor(start: number, end: number);
14744
14745 /**
14746 * Derive a new range for this range.
14747 *
14748 * @param change An object that describes a change to this range.
14749 * @returns A range that reflects the given change. Will return `this` range if the change
14750 * is not changing anything.
14751 */
14752 with(change: {
14753 /**
14754 * New start index, defaults to `this.start`.
14755 */
14756 start?: number;
14757 /**
14758 * New end index, defaults to `this.end`.
14759 */
14760 end?: number;
14761 }): NotebookRange;
14762 }
14763
14764 /**
14765 * One representation of a {@link NotebookCellOutput notebook output}, defined by MIME type and data.
14766 */
14767 export class NotebookCellOutputItem {
14768
14769 /**
14770 * Factory function to create a `NotebookCellOutputItem` from a string.
14771 *
14772 * *Note* that an UTF-8 encoder is used to create bytes for the string.
14773 *
14774 * @param value A string.
14775 * @param mime Optional MIME type, defaults to `text/plain`.
14776 * @returns A new output item object.
14777 */
14778 static text(value: string, mime?: string): NotebookCellOutputItem;
14779
14780 /**
14781 * Factory function to create a `NotebookCellOutputItem` from
14782 * a JSON object.
14783 *
14784 * *Note* that this function is not expecting "stringified JSON" but
14785 * an object that can be stringified. This function will throw an error
14786 * when the passed value cannot be JSON-stringified.
14787 *
14788 * @param value A JSON-stringifyable value.
14789 * @param mime Optional MIME type, defaults to `application/json`
14790 * @returns A new output item object.
14791 */
14792 static json(value: any, mime?: string): NotebookCellOutputItem;
14793
14794 /**
14795 * Factory function to create a `NotebookCellOutputItem` that uses
14796 * uses the `application/vnd.code.notebook.stdout` mime type.
14797 *
14798 * @param value A string.
14799 * @returns A new output item object.
14800 */
14801 static stdout(value: string): NotebookCellOutputItem;
14802
14803 /**
14804 * Factory function to create a `NotebookCellOutputItem` that uses
14805 * uses the `application/vnd.code.notebook.stderr` mime type.
14806 *
14807 * @param value A string.
14808 * @returns A new output item object.
14809 */
14810 static stderr(value: string): NotebookCellOutputItem;
14811
14812 /**
14813 * Factory function to create a `NotebookCellOutputItem` that uses
14814 * uses the `application/vnd.code.notebook.error` mime type.
14815 *
14816 * @param value An error object.
14817 * @returns A new output item object.
14818 */
14819 static error(value: Error): NotebookCellOutputItem;
14820
14821 /**
14822 * The mime type which determines how the {@linkcode NotebookCellOutputItem.data data}-property
14823 * is interpreted.
14824 *
14825 * Notebooks have built-in support for certain mime-types, extensions can add support for new
14826 * types and override existing types.
14827 */
14828 mime: string;
14829
14830 /**
14831 * The data of this output item. Must always be an array of unsigned 8-bit integers.
14832 */
14833 data: Uint8Array;
14834
14835 /**
14836 * Create a new notebook cell output item.
14837 *
14838 * @param data The value of the output item.
14839 * @param mime The mime type of the output item.
14840 */
14841 constructor(data: Uint8Array, mime: string);
14842 }
14843
14844 /**
14845 * Notebook cell output represents a result of executing a cell. It is a container type for multiple
14846 * {@link NotebookCellOutputItem output items} where contained items represent the same result but
14847 * use different MIME types.
14848 */
14849 export class NotebookCellOutput {
14850
14851 /**
14852 * The output items of this output. Each item must represent the same result. _Note_ that repeated
14853 * MIME types per output is invalid and that the editor will just pick one of them.
14854 *
14855 * ```ts
14856 * new vscode.NotebookCellOutput([
14857 * vscode.NotebookCellOutputItem.text('Hello', 'text/plain'),
14858 * vscode.NotebookCellOutputItem.text('<i>Hello</i>', 'text/html'),
14859 * vscode.NotebookCellOutputItem.text('_Hello_', 'text/markdown'),
14860 * vscode.NotebookCellOutputItem.text('Hey', 'text/plain'), // INVALID: repeated type, editor will pick just one
14861 * ])
14862 * ```
14863 */
14864 items: NotebookCellOutputItem[];
14865
14866 /**
14867 * Arbitrary metadata for this cell output. Can be anything but must be JSON-stringifyable.
14868 */
14869 metadata?: { [key: string]: any };
14870
14871 /**
14872 * Create new notebook output.
14873 *
14874 * @param items Notebook output items.
14875 * @param metadata Optional metadata.
14876 */
14877 constructor(items: NotebookCellOutputItem[], metadata?: { [key: string]: any });
14878 }
14879
14880 /**
14881 * NotebookCellData is the raw representation of notebook cells. Its is part of {@linkcode NotebookData}.
14882 */
14883 export class NotebookCellData {
14884
14885 /**
14886 * The {@link NotebookCellKind kind} of this cell data.
14887 */
14888 kind: NotebookCellKind;
14889
14890 /**
14891 * The source value of this cell data - either source code or formatted text.
14892 */
14893 value: string;
14894
14895 /**
14896 * The language identifier of the source value of this cell data. Any value from
14897 * {@linkcode languages.getLanguages getLanguages} is possible.
14898 */
14899 languageId: string;
14900
14901 /**
14902 * The outputs of this cell data.
14903 */
14904 outputs?: NotebookCellOutput[];
14905
14906 /**
14907 * Arbitrary metadata of this cell data. Can be anything but must be JSON-stringifyable.
14908 */
14909 metadata?: { [key: string]: any };
14910
14911 /**
14912 * The execution summary of this cell data.
14913 */
14914 executionSummary?: NotebookCellExecutionSummary;
14915
14916 /**
14917 * Create new cell data. Minimal cell data specifies its kind, its source value, and the
14918 * language identifier of its source.
14919 *
14920 * @param kind The kind.
14921 * @param value The source value.
14922 * @param languageId The language identifier of the source value.
14923 */
14924 constructor(kind: NotebookCellKind, value: string, languageId: string);
14925 }
14926
14927 /**
14928 * Raw representation of a notebook.
14929 *
14930 * Extensions are responsible for creating {@linkcode NotebookData} so that the editor
14931 * can create a {@linkcode NotebookDocument}.
14932 *
14933 * @see {@link NotebookSerializer}
14934 */
14935 export class NotebookData {
14936 /**
14937 * The cell data of this notebook data.
14938 */
14939 cells: NotebookCellData[];
14940
14941 /**
14942 * Arbitrary metadata of notebook data.
14943 */
14944 metadata?: { [key: string]: any };
14945
14946 /**
14947 * Create new notebook data.
14948 *
14949 * @param cells An array of cell data.
14950 */
14951 constructor(cells: NotebookCellData[]);
14952 }
14953
14954 /**
14955 * The notebook serializer enables the editor to open notebook files.
14956 *
14957 * At its core the editor only knows a {@link NotebookData notebook data structure} but not
14958 * how that data structure is written to a file, nor how it is read from a file. The
14959 * notebook serializer bridges this gap by deserializing bytes into notebook data and
14960 * vice versa.
14961 */
14962 export interface NotebookSerializer {
14963
14964 /**
14965 * Deserialize contents of a notebook file into the notebook data structure.
14966 *
14967 * @param content Contents of a notebook file.
14968 * @param token A cancellation token.
14969 * @returns Notebook data or a thenable that resolves to such.
14970 */
14971 deserializeNotebook(content: Uint8Array, token: CancellationToken): NotebookData | Thenable<NotebookData>;
14972
14973 /**
14974 * Serialize notebook data into file contents.
14975 *
14976 * @param data A notebook data structure.
14977 * @param token A cancellation token.
14978 * @returns An array of bytes or a thenable that resolves to such.
14979 */
14980 serializeNotebook(data: NotebookData, token: CancellationToken): Uint8Array | Thenable<Uint8Array>;
14981 }
14982
14983 /**
14984 * Notebook content options define what parts of a notebook are persisted. Note
14985 *
14986 * For instance, a notebook serializer can opt-out of saving outputs and in that case the editor doesn't mark a
14987 * notebooks as {@link NotebookDocument.isDirty dirty} when its output has changed.
14988 */
14989 export interface NotebookDocumentContentOptions {
14990 /**
14991 * Controls if output change events will trigger notebook document content change events and
14992 * if it will be used in the diff editor, defaults to false. If the content provider doesn't
14993 * persist the outputs in the file document, this should be set to true.
14994 */
14995 transientOutputs?: boolean;
14996
14997 /**
14998 * Controls if a cell metadata property change event will trigger notebook document content
14999 * change events and if it will be used in the diff editor, defaults to false. If the
15000 * content provider doesn't persist a metadata property in the file document, it should be
15001 * set to true.
15002 */
15003 transientCellMetadata?: { [key: string]: boolean | undefined };
15004
15005 /**
15006 * Controls if a document metadata property change event will trigger notebook document
15007 * content change event and if it will be used in the diff editor, defaults to false. If the
15008 * content provider doesn't persist a metadata property in the file document, it should be
15009 * set to true.
15010 */
15011 transientDocumentMetadata?: { [key: string]: boolean | undefined };
15012 }
15013
15014 /**
15015 * Notebook controller affinity for notebook documents.
15016 *
15017 * @see {@link NotebookController.updateNotebookAffinity}
15018 */
15019 export enum NotebookControllerAffinity {
15020 /**
15021 * Default affinity.
15022 */
15023 Default = 1,
15024 /**
15025 * A controller is preferred for a notebook.
15026 */
15027 Preferred = 2
15028 }
15029
15030 /**
15031 * A notebook controller represents an entity that can execute notebook cells. This is often referred to as a kernel.
15032 *
15033 * There can be multiple controllers and the editor will let users choose which controller to use for a certain notebook. The
15034 * {@linkcode NotebookController.notebookType notebookType}-property defines for what kind of notebooks a controller is for and
15035 * the {@linkcode NotebookController.updateNotebookAffinity updateNotebookAffinity}-function allows controllers to set a preference
15036 * for specific notebook documents. When a controller has been selected its
15037 * {@link NotebookController.onDidChangeSelectedNotebooks onDidChangeSelectedNotebooks}-event fires.
15038 *
15039 * When a cell is being run the editor will invoke the {@linkcode NotebookController.executeHandler executeHandler} and a controller
15040 * is expected to create and finalize a {@link NotebookCellExecution notebook cell execution}. However, controllers are also free
15041 * to create executions by themselves.
15042 */
15043 export interface NotebookController {
15044
15045 /**
15046 * The identifier of this notebook controller.
15047 *
15048 * _Note_ that controllers are remembered by their identifier and that extensions should use
15049 * stable identifiers across sessions.
15050 */
15051 readonly id: string;
15052
15053 /**
15054 * The notebook type this controller is for.
15055 */
15056 readonly notebookType: string;
15057
15058 /**
15059 * An array of language identifiers that are supported by this
15060 * controller. Any language identifier from {@linkcode languages.getLanguages getLanguages}
15061 * is possible. When falsy all languages are supported.
15062 *
15063 * Samples:
15064 * ```js
15065 * // support JavaScript and TypeScript
15066 * myController.supportedLanguages = ['javascript', 'typescript']
15067 *
15068 * // support all languages
15069 * myController.supportedLanguages = undefined; // falsy
15070 * myController.supportedLanguages = []; // falsy
15071 * ```
15072 */
15073 supportedLanguages?: string[];
15074
15075 /**
15076 * The human-readable label of this notebook controller.
15077 */
15078 label: string;
15079
15080 /**
15081 * The human-readable description which is rendered less prominent.
15082 */
15083 description?: string;
15084
15085 /**
15086 * The human-readable detail which is rendered less prominent.
15087 */
15088 detail?: string;
15089
15090 /**
15091 * Whether this controller supports execution order so that the
15092 * editor can render placeholders for them.
15093 */
15094 supportsExecutionOrder?: boolean;
15095
15096 /**
15097 * Create a cell execution task.
15098 *
15099 * _Note_ that there can only be one execution per cell at a time and that an error is thrown if
15100 * a cell execution is created while another is still active.
15101 *
15102 * This should be used in response to the {@link NotebookController.executeHandler execution handler}
15103 * being called or when cell execution has been started else, e.g when a cell was already
15104 * executing or when cell execution was triggered from another source.
15105 *
15106 * @param cell The notebook cell for which to create the execution.
15107 * @returns A notebook cell execution.
15108 */
15109 createNotebookCellExecution(cell: NotebookCell): NotebookCellExecution;
15110
15111 /**
15112 * The execute handler is invoked when the run gestures in the UI are selected, e.g Run Cell, Run All,
15113 * Run Selection etc. The execute handler is responsible for creating and managing {@link NotebookCellExecution execution}-objects.
15114 */
15115 executeHandler: (cells: NotebookCell[], notebook: NotebookDocument, controller: NotebookController) => void | Thenable<void>;
15116
15117 /**
15118 * Optional interrupt handler.
15119 *
15120 * By default cell execution is canceled via {@link NotebookCellExecution.token tokens}. Cancellation
15121 * tokens require that a controller can keep track of its execution so that it can cancel a specific execution at a later
15122 * point. Not all scenarios allow for that, eg. REPL-style controllers often work by interrupting whatever is currently
15123 * running. For those cases the interrupt handler exists - it can be thought of as the equivalent of `SIGINT`
15124 * or `Control+C` in terminals.
15125 *
15126 * _Note_ that supporting {@link NotebookCellExecution.token cancellation tokens} is preferred and that interrupt handlers should
15127 * only be used when tokens cannot be supported.
15128 */
15129 interruptHandler?: (notebook: NotebookDocument) => void | Thenable<void>;
15130
15131 /**
15132 * An event that fires whenever a controller has been selected or un-selected for a notebook document.
15133 *
15134 * There can be multiple controllers for a notebook and in that case a controllers needs to be _selected_. This is a user gesture
15135 * and happens either explicitly or implicitly when interacting with a notebook for which a controller was _suggested_. When possible,
15136 * the editor _suggests_ a controller that is most likely to be _selected_.
15137 *
15138 * _Note_ that controller selection is persisted (by the controllers {@link NotebookController.id id}) and restored as soon as a
15139 * controller is re-created or as a notebook is {@link workspace.onDidOpenNotebookDocument opened}.
15140 */
15141 readonly onDidChangeSelectedNotebooks: Event<{
15142 /**
15143 * The notebook for which the controller has been selected or un-selected.
15144 */
15145 readonly notebook: NotebookDocument;
15146 /**
15147 * Whether the controller has been selected or un-selected.
15148 */
15149 readonly selected: boolean;
15150 }>;
15151
15152 /**
15153 * A controller can set affinities for specific notebook documents. This allows a controller
15154 * to be presented more prominent for some notebooks.
15155 *
15156 * @param notebook The notebook for which a priority is set.
15157 * @param affinity A controller affinity
15158 */
15159 updateNotebookAffinity(notebook: NotebookDocument, affinity: NotebookControllerAffinity): void;
15160
15161 /**
15162 * Dispose and free associated resources.
15163 */
15164 dispose(): void;
15165 }
15166
15167 /**
15168 * A NotebookCellExecution is how {@link NotebookController notebook controller} modify a notebook cell as
15169 * it is executing.
15170 *
15171 * When a cell execution object is created, the cell enters the {@linkcode NotebookCellExecutionState.Pending Pending} state.
15172 * When {@linkcode NotebookCellExecution.start start(...)} is called on the execution task, it enters the {@linkcode NotebookCellExecutionState.Executing Executing} state. When
15173 * {@linkcode NotebookCellExecution.end end(...)} is called, it enters the {@linkcode NotebookCellExecutionState.Idle Idle} state.
15174 */
15175 export interface NotebookCellExecution {
15176
15177 /**
15178 * The {@link NotebookCell cell} for which this execution has been created.
15179 */
15180 readonly cell: NotebookCell;
15181
15182 /**
15183 * A cancellation token which will be triggered when the cell execution is canceled
15184 * from the UI.
15185 *
15186 * _Note_ that the cancellation token will not be triggered when the {@link NotebookController controller}
15187 * that created this execution uses an {@link NotebookController.interruptHandler interrupt-handler}.
15188 */
15189 readonly token: CancellationToken;
15190
15191 /**
15192 * Set and unset the order of this cell execution.
15193 */
15194 executionOrder: number | undefined;
15195
15196 /**
15197 * Signal that the execution has begun.
15198 *
15199 * @param startTime The time that execution began, in milliseconds in the Unix epoch. Used to drive the clock
15200 * that shows for how long a cell has been running. If not given, the clock won't be shown.
15201 */
15202 start(startTime?: number): void;
15203
15204 /**
15205 * Signal that execution has ended.
15206 *
15207 * @param success If true, a green check is shown on the cell status bar.
15208 * If false, a red X is shown.
15209 * If undefined, no check or X icon is shown.
15210 * @param endTime The time that execution finished, in milliseconds in the Unix epoch.
15211 */
15212 end(success: boolean | undefined, endTime?: number): void;
15213
15214 /**
15215 * Clears the output of the cell that is executing or of another cell that is affected by this execution.
15216 *
15217 * @param cell Cell for which output is cleared. Defaults to the {@link NotebookCellExecution.cell cell} of
15218 * this execution.
15219 * @returns A thenable that resolves when the operation finished.
15220 */
15221 clearOutput(cell?: NotebookCell): Thenable<void>;
15222
15223 /**
15224 * Replace the output of the cell that is executing or of another cell that is affected by this execution.
15225 *
15226 * @param out Output that replaces the current output.
15227 * @param cell Cell for which output is cleared. Defaults to the {@link NotebookCellExecution.cell cell} of
15228 * this execution.
15229 * @returns A thenable that resolves when the operation finished.
15230 */
15231 replaceOutput(out: NotebookCellOutput | readonly NotebookCellOutput[], cell?: NotebookCell): Thenable<void>;
15232
15233 /**
15234 * Append to the output of the cell that is executing or to another cell that is affected by this execution.
15235 *
15236 * @param out Output that is appended to the current output.
15237 * @param cell Cell for which output is cleared. Defaults to the {@link NotebookCellExecution.cell cell} of
15238 * this execution.
15239 * @returns A thenable that resolves when the operation finished.
15240 */
15241 appendOutput(out: NotebookCellOutput | readonly NotebookCellOutput[], cell?: NotebookCell): Thenable<void>;
15242
15243 /**
15244 * Replace all output items of existing cell output.
15245 *
15246 * @param items Output items that replace the items of existing output.
15247 * @param output Output object that already exists.
15248 * @returns A thenable that resolves when the operation finished.
15249 */
15250 replaceOutputItems(items: NotebookCellOutputItem | readonly NotebookCellOutputItem[], output: NotebookCellOutput): Thenable<void>;
15251
15252 /**
15253 * Append output items to existing cell output.
15254 *
15255 * @param items Output items that are append to existing output.
15256 * @param output Output object that already exists.
15257 * @returns A thenable that resolves when the operation finished.
15258 */
15259 appendOutputItems(items: NotebookCellOutputItem | readonly NotebookCellOutputItem[], output: NotebookCellOutput): Thenable<void>;
15260 }
15261
15262 /**
15263 * Represents the alignment of status bar items.
15264 */
15265 export enum NotebookCellStatusBarAlignment {
15266
15267 /**
15268 * Aligned to the left side.
15269 */
15270 Left = 1,
15271
15272 /**
15273 * Aligned to the right side.
15274 */
15275 Right = 2
15276 }
15277
15278 /**
15279 * A contribution to a cell's status bar
15280 */
15281 export class NotebookCellStatusBarItem {
15282 /**
15283 * The text to show for the item.
15284 */
15285 text: string;
15286
15287 /**
15288 * Whether the item is aligned to the left or right.
15289 */
15290 alignment: NotebookCellStatusBarAlignment;
15291
15292 /**
15293 * An optional {@linkcode Command} or identifier of a command to run on click.
15294 *
15295 * The command must be {@link commands.getCommands known}.
15296 *
15297 * Note that if this is a {@linkcode Command} object, only the {@linkcode Command.command command} and {@linkcode Command.arguments arguments}
15298 * are used by the editor.
15299 */
15300 command?: string | Command;
15301
15302 /**
15303 * A tooltip to show when the item is hovered.
15304 */
15305 tooltip?: string;
15306
15307 /**
15308 * The priority of the item. A higher value item will be shown more to the left.
15309 */
15310 priority?: number;
15311
15312 /**
15313 * Accessibility information used when a screen reader interacts with this item.
15314 */
15315 accessibilityInformation?: AccessibilityInformation;
15316
15317 /**
15318 * Creates a new NotebookCellStatusBarItem.
15319 * @param text The text to show for the item.
15320 * @param alignment Whether the item is aligned to the left or right.
15321 */
15322 constructor(text: string, alignment: NotebookCellStatusBarAlignment);
15323 }
15324
15325 /**
15326 * A provider that can contribute items to the status bar that appears below a cell's editor.
15327 */
15328 export interface NotebookCellStatusBarItemProvider {
15329 /**
15330 * An optional event to signal that statusbar items have changed. The provide method will be called again.
15331 */
15332 onDidChangeCellStatusBarItems?: Event<void>;
15333
15334 /**
15335 * The provider will be called when the cell scrolls into view, when its content, outputs, language, or metadata change, and when it changes execution state.
15336 * @param cell The cell for which to return items.
15337 * @param token A token triggered if this request should be cancelled.
15338 * @returns One or more {@link NotebookCellStatusBarItem cell statusbar items}
15339 */
15340 provideCellStatusBarItems(cell: NotebookCell, token: CancellationToken): ProviderResult<NotebookCellStatusBarItem | NotebookCellStatusBarItem[]>;
15341 }
15342
15343 /**
15344 * Namespace for notebooks.
15345 *
15346 * The notebooks functionality is composed of three loosely coupled components:
15347 *
15348 * 1. {@link NotebookSerializer} enable the editor to open, show, and save notebooks
15349 * 2. {@link NotebookController} own the execution of notebooks, e.g they create output from code cells.
15350 * 3. NotebookRenderer present notebook output in the editor. They run in a separate context.
15351 */
15352 export namespace notebooks {
15353
15354 /**
15355 * Creates a new notebook controller.
15356 *
15357 * @param id Identifier of the controller. Must be unique per extension.
15358 * @param notebookType A notebook type for which this controller is for.
15359 * @param label The label of the controller.
15360 * @param handler The execute-handler of the controller.
15361 * @returns A new notebook controller.
15362 */
15363 export function createNotebookController(id: string, notebookType: string, label: string, handler?: (cells: NotebookCell[], notebook: NotebookDocument, controller: NotebookController) => void | Thenable<void>): NotebookController;
15364
15365 /**
15366 * Register a {@link NotebookCellStatusBarItemProvider cell statusbar item provider} for the given notebook type.
15367 *
15368 * @param notebookType The notebook type to register for.
15369 * @param provider A cell status bar provider.
15370 * @returns A {@link Disposable} that unregisters this provider when being disposed.
15371 */
15372 export function registerNotebookCellStatusBarItemProvider(notebookType: string, provider: NotebookCellStatusBarItemProvider): Disposable;
15373
15374 /**
15375 * Creates a new messaging instance used to communicate with a specific renderer.
15376 *
15377 * * *Note 1:* Extensions can only create renderer that they have defined in their `package.json`-file
15378 * * *Note 2:* A renderer only has access to messaging if `requiresMessaging` is set to `always` or `optional` in
15379 * its `notebookRenderer` contribution.
15380 *
15381 * @param rendererId The renderer ID to communicate with
15382 * @returns A new notebook renderer messaging object.
15383 */
15384 export function createRendererMessaging(rendererId: string): NotebookRendererMessaging;
15385 }
15386
15387 /**
15388 * Represents the input box in the Source Control viewlet.
15389 */
15390 export interface SourceControlInputBox {
15391
15392 /**
15393 * Setter and getter for the contents of the input box.
15394 */
15395 value: string;
15396
15397 /**
15398 * A string to show as placeholder in the input box to guide the user.
15399 */
15400 placeholder: string;
15401
15402 /**
15403 * Controls whether the input box is enabled (default is `true`).
15404 */
15405 enabled: boolean;
15406
15407 /**
15408 * Controls whether the input box is visible (default is `true`).
15409 */
15410 visible: boolean;
15411 }
15412
15413 /**
15414 * A quick diff provider provides a {@link Uri uri} to the original state of a
15415 * modified resource. The editor will use this information to render ad'hoc diffs
15416 * within the text.
15417 */
15418 export interface QuickDiffProvider {
15419
15420 /**
15421 * Provide a {@link Uri} to the original resource of any given resource uri.
15422 *
15423 * @param uri The uri of the resource open in a text editor.
15424 * @param token A cancellation token.
15425 * @returns A thenable that resolves to uri of the matching original resource.
15426 */
15427 provideOriginalResource?(uri: Uri, token: CancellationToken): ProviderResult<Uri>;
15428 }
15429
15430 /**
15431 * The theme-aware decorations for a
15432 * {@link SourceControlResourceState source control resource state}.
15433 */
15434 export interface SourceControlResourceThemableDecorations {
15435
15436 /**
15437 * The icon path for a specific
15438 * {@link SourceControlResourceState source control resource state}.
15439 */
15440 readonly iconPath?: string | Uri | ThemeIcon;
15441 }
15442
15443 /**
15444 * The decorations for a {@link SourceControlResourceState source control resource state}.
15445 * Can be independently specified for light and dark themes.
15446 */
15447 export interface SourceControlResourceDecorations extends SourceControlResourceThemableDecorations {
15448
15449 /**
15450 * Whether the {@link SourceControlResourceState source control resource state} should
15451 * be striked-through in the UI.
15452 */
15453 readonly strikeThrough?: boolean;
15454
15455 /**
15456 * Whether the {@link SourceControlResourceState source control resource state} should
15457 * be faded in the UI.
15458 */
15459 readonly faded?: boolean;
15460
15461 /**
15462 * The title for a specific
15463 * {@link SourceControlResourceState source control resource state}.
15464 */
15465 readonly tooltip?: string;
15466
15467 /**
15468 * The light theme decorations.
15469 */
15470 readonly light?: SourceControlResourceThemableDecorations;
15471
15472 /**
15473 * The dark theme decorations.
15474 */
15475 readonly dark?: SourceControlResourceThemableDecorations;
15476 }
15477
15478 /**
15479 * An source control resource state represents the state of an underlying workspace
15480 * resource within a certain {@link SourceControlResourceGroup source control group}.
15481 */
15482 export interface SourceControlResourceState {
15483
15484 /**
15485 * The {@link Uri} of the underlying resource inside the workspace.
15486 */
15487 readonly resourceUri: Uri;
15488
15489 /**
15490 * The {@link Command} which should be run when the resource
15491 * state is open in the Source Control viewlet.
15492 */
15493 readonly command?: Command;
15494
15495 /**
15496 * The {@link SourceControlResourceDecorations decorations} for this source control
15497 * resource state.
15498 */
15499 readonly decorations?: SourceControlResourceDecorations;
15500
15501 /**
15502 * Context value of the resource state. This can be used to contribute resource specific actions.
15503 * For example, if a resource is given a context value as `diffable`. When contributing actions to `scm/resourceState/context`
15504 * using `menus` extension point, you can specify context value for key `scmResourceState` in `when` expressions, like `scmResourceState == diffable`.
15505 * ```json
15506 * "contributes": {
15507 * "menus": {
15508 * "scm/resourceState/context": [
15509 * {
15510 * "command": "extension.diff",
15511 * "when": "scmResourceState == diffable"
15512 * }
15513 * ]
15514 * }
15515 * }
15516 * ```
15517 * This will show action `extension.diff` only for resources with `contextValue` is `diffable`.
15518 */
15519 readonly contextValue?: string;
15520 }
15521
15522 /**
15523 * A source control resource group is a collection of
15524 * {@link SourceControlResourceState source control resource states}.
15525 */
15526 export interface SourceControlResourceGroup {
15527
15528 /**
15529 * The id of this source control resource group.
15530 */
15531 readonly id: string;
15532
15533 /**
15534 * The label of this source control resource group.
15535 */
15536 label: string;
15537
15538 /**
15539 * Whether this source control resource group is hidden when it contains
15540 * no {@link SourceControlResourceState source control resource states}.
15541 */
15542 hideWhenEmpty?: boolean;
15543
15544 /**
15545 * This group's collection of
15546 * {@link SourceControlResourceState source control resource states}.
15547 */
15548 resourceStates: SourceControlResourceState[];
15549
15550 /**
15551 * Dispose this source control resource group.
15552 */
15553 dispose(): void;
15554 }
15555
15556 /**
15557 * An source control is able to provide {@link SourceControlResourceState resource states}
15558 * to the editor and interact with the editor in several source control related ways.
15559 */
15560 export interface SourceControl {
15561
15562 /**
15563 * The id of this source control.
15564 */
15565 readonly id: string;
15566
15567 /**
15568 * The human-readable label of this source control.
15569 */
15570 readonly label: string;
15571
15572 /**
15573 * The (optional) Uri of the root of this source control.
15574 */
15575 readonly rootUri: Uri | undefined;
15576
15577 /**
15578 * The {@link SourceControlInputBox input box} for this source control.
15579 */
15580 readonly inputBox: SourceControlInputBox;
15581
15582 /**
15583 * The UI-visible count of {@link SourceControlResourceState resource states} of
15584 * this source control.
15585 *
15586 * If undefined, this source control will
15587 * - display its UI-visible count as zero, and
15588 * - contribute the count of its {@link SourceControlResourceState resource states} to the UI-visible aggregated count for all source controls
15589 */
15590 count?: number;
15591
15592 /**
15593 * An optional {@link QuickDiffProvider quick diff provider}.
15594 */
15595 quickDiffProvider?: QuickDiffProvider;
15596
15597 /**
15598 * Optional commit template string.
15599 *
15600 * The Source Control viewlet will populate the Source Control
15601 * input with this value when appropriate.
15602 */
15603 commitTemplate?: string;
15604
15605 /**
15606 * Optional accept input command.
15607 *
15608 * This command will be invoked when the user accepts the value
15609 * in the Source Control input.
15610 */
15611 acceptInputCommand?: Command;
15612
15613 /**
15614 * Optional status bar commands.
15615 *
15616 * These commands will be displayed in the editor's status bar.
15617 */
15618 statusBarCommands?: Command[];
15619
15620 /**
15621 * Create a new {@link SourceControlResourceGroup resource group}.
15622 */
15623 createResourceGroup(id: string, label: string): SourceControlResourceGroup;
15624
15625 /**
15626 * Dispose this source control.
15627 */
15628 dispose(): void;
15629 }
15630
15631 /**
15632 * Namespace for source control mangement.
15633 */
15634 export namespace scm {
15635
15636 /**
15637 * The {@link SourceControlInputBox input box} for the last source control
15638 * created by the extension.
15639 *
15640 * @deprecated Use SourceControl.inputBox instead
15641 */
15642 export const inputBox: SourceControlInputBox;
15643
15644 /**
15645 * Creates a new {@link SourceControl source control} instance.
15646 *
15647 * @param id An `id` for the source control. Something short, e.g.: `git`.
15648 * @param label A human-readable string for the source control. E.g.: `Git`.
15649 * @param rootUri An optional Uri of the root of the source control. E.g.: `Uri.parse(workspaceRoot)`.
15650 * @returns An instance of {@link SourceControl source control}.
15651 */
15652 export function createSourceControl(id: string, label: string, rootUri?: Uri): SourceControl;
15653 }
15654
15655 /**
15656 * A DebugProtocolMessage is an opaque stand-in type for the [ProtocolMessage](https://microsoft.github.io/debug-adapter-protocol/specification#Base_Protocol_ProtocolMessage) type defined in the Debug Adapter Protocol.
15657 */
15658 export interface DebugProtocolMessage {
15659 // Properties: see [ProtocolMessage details](https://microsoft.github.io/debug-adapter-protocol/specification#Base_Protocol_ProtocolMessage).
15660 }
15661
15662 /**
15663 * A DebugProtocolSource is an opaque stand-in type for the [Source](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Source) type defined in the Debug Adapter Protocol.
15664 */
15665 export interface DebugProtocolSource {
15666 // Properties: see [Source details](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Source).
15667 }
15668
15669 /**
15670 * A DebugProtocolBreakpoint is an opaque stand-in type for the [Breakpoint](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Breakpoint) type defined in the Debug Adapter Protocol.
15671 */
15672 export interface DebugProtocolBreakpoint {
15673 // Properties: see [Breakpoint details](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Breakpoint).
15674 }
15675
15676 /**
15677 * Configuration for a debug session.
15678 */
15679 export interface DebugConfiguration {
15680 /**
15681 * The type of the debug session.
15682 */
15683 type: string;
15684
15685 /**
15686 * The name of the debug session.
15687 */
15688 name: string;
15689
15690 /**
15691 * The request type of the debug session.
15692 */
15693 request: string;
15694
15695 /**
15696 * Additional debug type specific properties.
15697 */
15698 [key: string]: any;
15699 }
15700
15701 /**
15702 * A debug session.
15703 */
15704 export interface DebugSession {
15705
15706 /**
15707 * The unique ID of this debug session.
15708 */
15709 readonly id: string;
15710
15711 /**
15712 * The debug session's type from the {@link DebugConfiguration debug configuration}.
15713 */
15714 readonly type: string;
15715
15716 /**
15717 * The parent session of this debug session, if it was created as a child.
15718 * @see DebugSessionOptions.parentSession
15719 */
15720 readonly parentSession?: DebugSession;
15721
15722 /**
15723 * The debug session's name is initially taken from the {@link DebugConfiguration debug configuration}.
15724 * Any changes will be properly reflected in the UI.
15725 */
15726 name: string;
15727
15728 /**
15729 * The workspace folder of this session or `undefined` for a folderless setup.
15730 */
15731 readonly workspaceFolder: WorkspaceFolder | undefined;
15732
15733 /**
15734 * The "resolved" {@link DebugConfiguration debug configuration} of this session.
15735 * "Resolved" means that
15736 * - all variables have been substituted and
15737 * - platform specific attribute sections have been "flattened" for the matching platform and removed for non-matching platforms.
15738 */
15739 readonly configuration: DebugConfiguration;
15740
15741 /**
15742 * Send a custom request to the debug adapter.
15743 */
15744 customRequest(command: string, args?: any): Thenable<any>;
15745
15746 /**
15747 * Maps a breakpoint in the editor to the corresponding Debug Adapter Protocol (DAP) breakpoint that is managed by the debug adapter of the debug session.
15748 * If no DAP breakpoint exists (either because the editor breakpoint was not yet registered or because the debug adapter is not interested in the breakpoint), the value `undefined` is returned.
15749 *
15750 * @param breakpoint A {@link Breakpoint} in the editor.
15751 * @returns A promise that resolves to the Debug Adapter Protocol breakpoint or `undefined`.
15752 */
15753 getDebugProtocolBreakpoint(breakpoint: Breakpoint): Thenable<DebugProtocolBreakpoint | undefined>;
15754 }
15755
15756 /**
15757 * A custom Debug Adapter Protocol event received from a {@link DebugSession debug session}.
15758 */
15759 export interface DebugSessionCustomEvent {
15760 /**
15761 * The {@link DebugSession debug session} for which the custom event was received.
15762 */
15763 readonly session: DebugSession;
15764
15765 /**
15766 * Type of event.
15767 */
15768 readonly event: string;
15769
15770 /**
15771 * Event specific information.
15772 */
15773 readonly body: any;
15774 }
15775
15776 /**
15777 * A debug configuration provider allows to add debug configurations to the debug service
15778 * and to resolve launch configurations before they are used to start a debug session.
15779 * A debug configuration provider is registered via {@link debug.registerDebugConfigurationProvider}.
15780 */
15781 export interface DebugConfigurationProvider {
15782 /**
15783 * Provides {@link DebugConfiguration debug configuration} to the debug service. If more than one debug configuration provider is
15784 * registered for the same type, debug configurations are concatenated in arbitrary order.
15785 *
15786 * @param folder The workspace folder for which the configurations are used or `undefined` for a folderless setup.
15787 * @param token A cancellation token.
15788 * @returns An array of {@link DebugConfiguration debug configurations}.
15789 */
15790 provideDebugConfigurations?(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult<DebugConfiguration[]>;
15791
15792 /**
15793 * Resolves a {@link DebugConfiguration debug configuration} by filling in missing values or by adding/changing/removing attributes.
15794 * If more than one debug configuration provider is registered for the same type, the resolveDebugConfiguration calls are chained
15795 * in arbitrary order and the initial debug configuration is piped through the chain.
15796 * Returning the value 'undefined' prevents the debug session from starting.
15797 * Returning the value 'null' prevents the debug session from starting and opens the underlying debug configuration instead.
15798 *
15799 * @param folder The workspace folder from which the configuration originates from or `undefined` for a folderless setup.
15800 * @param debugConfiguration The {@link DebugConfiguration debug configuration} to resolve.
15801 * @param token A cancellation token.
15802 * @returns The resolved debug configuration or undefined or null.
15803 */
15804 resolveDebugConfiguration?(folder: WorkspaceFolder | undefined, debugConfiguration: DebugConfiguration, token?: CancellationToken): ProviderResult<DebugConfiguration>;
15805
15806 /**
15807 * This hook is directly called after 'resolveDebugConfiguration' but with all variables substituted.
15808 * It can be used to resolve or verify a {@link DebugConfiguration debug configuration} by filling in missing values or by adding/changing/removing attributes.
15809 * If more than one debug configuration provider is registered for the same type, the 'resolveDebugConfigurationWithSubstitutedVariables' calls are chained
15810 * in arbitrary order and the initial debug configuration is piped through the chain.
15811 * Returning the value 'undefined' prevents the debug session from starting.
15812 * Returning the value 'null' prevents the debug session from starting and opens the underlying debug configuration instead.
15813 *
15814 * @param folder The workspace folder from which the configuration originates from or `undefined` for a folderless setup.
15815 * @param debugConfiguration The {@link DebugConfiguration debug configuration} to resolve.
15816 * @param token A cancellation token.
15817 * @returns The resolved debug configuration or undefined or null.
15818 */
15819 resolveDebugConfigurationWithSubstitutedVariables?(folder: WorkspaceFolder | undefined, debugConfiguration: DebugConfiguration, token?: CancellationToken): ProviderResult<DebugConfiguration>;
15820 }
15821
15822 /**
15823 * Represents a debug adapter executable and optional arguments and runtime options passed to it.
15824 */
15825 export class DebugAdapterExecutable {
15826
15827 /**
15828 * Creates a description for a debug adapter based on an executable program.
15829 *
15830 * @param command The command or executable path that implements the debug adapter.
15831 * @param args Optional arguments to be passed to the command or executable.
15832 * @param options Optional options to be used when starting the command or executable.
15833 */
15834 constructor(command: string, args?: string[], options?: DebugAdapterExecutableOptions);
15835
15836 /**
15837 * The command or path of the debug adapter executable.
15838 * A command must be either an absolute path of an executable or the name of an command to be looked up via the PATH environment variable.
15839 * The special value 'node' will be mapped to the editor's built-in Node.js runtime.
15840 */
15841 readonly command: string;
15842
15843 /**
15844 * The arguments passed to the debug adapter executable. Defaults to an empty array.
15845 */
15846 readonly args: string[];
15847
15848 /**
15849 * Optional options to be used when the debug adapter is started.
15850 * Defaults to undefined.
15851 */
15852 readonly options?: DebugAdapterExecutableOptions;
15853 }
15854
15855 /**
15856 * Options for a debug adapter executable.
15857 */
15858 export interface DebugAdapterExecutableOptions {
15859
15860 /**
15861 * The additional environment of the executed program or shell. If omitted
15862 * the parent process' environment is used. If provided it is merged with
15863 * the parent process' environment.
15864 */
15865 env?: { [key: string]: string };
15866
15867 /**
15868 * The current working directory for the executed debug adapter.
15869 */
15870 cwd?: string;
15871 }
15872
15873 /**
15874 * Represents a debug adapter running as a socket based server.
15875 */
15876 export class DebugAdapterServer {
15877
15878 /**
15879 * The port.
15880 */
15881 readonly port: number;
15882
15883 /**
15884 * The host.
15885 */
15886 readonly host?: string | undefined;
15887
15888 /**
15889 * Create a description for a debug adapter running as a socket based server.
15890 */
15891 constructor(port: number, host?: string);
15892 }
15893
15894 /**
15895 * Represents a debug adapter running as a Named Pipe (on Windows)/UNIX Domain Socket (on non-Windows) based server.
15896 */
15897 export class DebugAdapterNamedPipeServer {
15898 /**
15899 * The path to the NamedPipe/UNIX Domain Socket.
15900 */
15901 readonly path: string;
15902
15903 /**
15904 * Create a description for a debug adapter running as a Named Pipe (on Windows)/UNIX Domain Socket (on non-Windows) based server.
15905 */
15906 constructor(path: string);
15907 }
15908
15909 /**
15910 * A debug adapter that implements the Debug Adapter Protocol can be registered with the editor if it implements the DebugAdapter interface.
15911 */
15912 export interface DebugAdapter extends Disposable {
15913
15914 /**
15915 * An event which fires after the debug adapter has sent a Debug Adapter Protocol message to the editor.
15916 * Messages can be requests, responses, or events.
15917 */
15918 readonly onDidSendMessage: Event<DebugProtocolMessage>;
15919
15920 /**
15921 * Handle a Debug Adapter Protocol message.
15922 * Messages can be requests, responses, or events.
15923 * Results or errors are returned via onSendMessage events.
15924 * @param message A Debug Adapter Protocol message
15925 */
15926 handleMessage(message: DebugProtocolMessage): void;
15927 }
15928
15929 /**
15930 * A debug adapter descriptor for an inline implementation.
15931 */
15932 export class DebugAdapterInlineImplementation {
15933
15934 /**
15935 * Create a descriptor for an inline implementation of a debug adapter.
15936 */
15937 constructor(implementation: DebugAdapter);
15938 }
15939
15940 /**
15941 * Represents the different types of debug adapters
15942 */
15943 export type DebugAdapterDescriptor = DebugAdapterExecutable | DebugAdapterServer | DebugAdapterNamedPipeServer | DebugAdapterInlineImplementation;
15944
15945 /**
15946 * A debug adaper factory that creates {@link DebugAdapterDescriptor debug adapter descriptors}.
15947 */
15948 export interface DebugAdapterDescriptorFactory {
15949 /**
15950 * 'createDebugAdapterDescriptor' is called at the start of a debug session to provide details about the debug adapter to use.
15951 * These details must be returned as objects of type {@link DebugAdapterDescriptor}.
15952 * Currently two types of debug adapters are supported:
15953 * - a debug adapter executable is specified as a command path and arguments (see {@link DebugAdapterExecutable}),
15954 * - a debug adapter server reachable via a communication port (see {@link DebugAdapterServer}).
15955 * If the method is not implemented the default behavior is this:
15956 * createDebugAdapter(session: DebugSession, executable: DebugAdapterExecutable) {
15957 * if (typeof session.configuration.debugServer === 'number') {
15958 * return new DebugAdapterServer(session.configuration.debugServer);
15959 * }
15960 * return executable;
15961 * }
15962 * @param session The {@link DebugSession debug session} for which the debug adapter will be used.
15963 * @param executable The debug adapter's executable information as specified in the package.json (or undefined if no such information exists).
15964 * @returns a {@link DebugAdapterDescriptor debug adapter descriptor} or undefined.
15965 */
15966 createDebugAdapterDescriptor(session: DebugSession, executable: DebugAdapterExecutable | undefined): ProviderResult<DebugAdapterDescriptor>;
15967 }
15968
15969 /**
15970 * A Debug Adapter Tracker is a means to track the communication between the editor and a Debug Adapter.
15971 */
15972 export interface DebugAdapterTracker {
15973 /**
15974 * A session with the debug adapter is about to be started.
15975 */
15976 onWillStartSession?(): void;
15977 /**
15978 * The debug adapter is about to receive a Debug Adapter Protocol message from the editor.
15979 */
15980 onWillReceiveMessage?(message: any): void;
15981 /**
15982 * The debug adapter has sent a Debug Adapter Protocol message to the editor.
15983 */
15984 onDidSendMessage?(message: any): void;
15985 /**
15986 * The debug adapter session is about to be stopped.
15987 */
15988 onWillStopSession?(): void;
15989 /**
15990 * An error with the debug adapter has occurred.
15991 */
15992 onError?(error: Error): void;
15993 /**
15994 * The debug adapter has exited with the given exit code or signal.
15995 */
15996 onExit?(code: number | undefined, signal: string | undefined): void;
15997 }
15998
15999 /**
16000 * A debug adaper factory that creates {@link DebugAdapterTracker debug adapter trackers}.
16001 */
16002 export interface DebugAdapterTrackerFactory {
16003 /**
16004 * The method 'createDebugAdapterTracker' is called at the start of a debug session in order
16005 * to return a "tracker" object that provides read-access to the communication between the editor and a debug adapter.
16006 *
16007 * @param session The {@link DebugSession debug session} for which the debug adapter tracker will be used.
16008 * @returns A {@link DebugAdapterTracker debug adapter tracker} or undefined.
16009 */
16010 createDebugAdapterTracker(session: DebugSession): ProviderResult<DebugAdapterTracker>;
16011 }
16012
16013 /**
16014 * Represents the debug console.
16015 */
16016 export interface DebugConsole {
16017 /**
16018 * Append the given value to the debug console.
16019 *
16020 * @param value A string, falsy values will not be printed.
16021 */
16022 append(value: string): void;
16023
16024 /**
16025 * Append the given value and a line feed character
16026 * to the debug console.
16027 *
16028 * @param value A string, falsy values will be printed.
16029 */
16030 appendLine(value: string): void;
16031 }
16032
16033 /**
16034 * An event describing the changes to the set of {@link Breakpoint breakpoints}.
16035 */
16036 export interface BreakpointsChangeEvent {
16037 /**
16038 * Added breakpoints.
16039 */
16040 readonly added: readonly Breakpoint[];
16041
16042 /**
16043 * Removed breakpoints.
16044 */
16045 readonly removed: readonly Breakpoint[];
16046
16047 /**
16048 * Changed breakpoints.
16049 */
16050 readonly changed: readonly Breakpoint[];
16051 }
16052
16053 /**
16054 * The base class of all breakpoint types.
16055 */
16056 export class Breakpoint {
16057 /**
16058 * The unique ID of the breakpoint.
16059 */
16060 readonly id: string;
16061 /**
16062 * Is breakpoint enabled.
16063 */
16064 readonly enabled: boolean;
16065 /**
16066 * An optional expression for conditional breakpoints.
16067 */
16068 readonly condition?: string | undefined;
16069 /**
16070 * An optional expression that controls how many hits of the breakpoint are ignored.
16071 */
16072 readonly hitCondition?: string | undefined;
16073 /**
16074 * An optional message that gets logged when this breakpoint is hit. Embedded expressions within {} are interpolated by the debug adapter.
16075 */
16076 readonly logMessage?: string | undefined;
16077
16078 /**
16079 * Creates a new breakpoint
16080 *
16081 * @param enabled Is breakpoint enabled.
16082 * @param condition Expression for conditional breakpoints
16083 * @param hitCondition Expression that controls how many hits of the breakpoint are ignored
16084 * @param logMessage Log message to display when breakpoint is hit
16085 */
16086 protected constructor(enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string);
16087 }
16088
16089 /**
16090 * A breakpoint specified by a source location.
16091 */
16092 export class SourceBreakpoint extends Breakpoint {
16093 /**
16094 * The source and line position of this breakpoint.
16095 */
16096 readonly location: Location;
16097
16098 /**
16099 * Create a new breakpoint for a source location.
16100 */
16101 constructor(location: Location, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string);
16102 }
16103
16104 /**
16105 * A breakpoint specified by a function name.
16106 */
16107 export class FunctionBreakpoint extends Breakpoint {
16108 /**
16109 * The name of the function to which this breakpoint is attached.
16110 */
16111 readonly functionName: string;
16112
16113 /**
16114 * Create a new function breakpoint.
16115 */
16116 constructor(functionName: string, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string);
16117 }
16118
16119 /**
16120 * Debug console mode used by debug session, see {@link DebugSessionOptions options}.
16121 */
16122 export enum DebugConsoleMode {
16123 /**
16124 * Debug session should have a separate debug console.
16125 */
16126 Separate = 0,
16127
16128 /**
16129 * Debug session should share debug console with its parent session.
16130 * This value has no effect for sessions which do not have a parent session.
16131 */
16132 MergeWithParent = 1
16133 }
16134
16135 /**
16136 * Options for {@link debug.startDebugging starting a debug session}.
16137 */
16138 export interface DebugSessionOptions {
16139
16140 /**
16141 * When specified the newly created debug session is registered as a "child" session of this
16142 * "parent" debug session.
16143 */
16144 parentSession?: DebugSession;
16145
16146 /**
16147 * Controls whether lifecycle requests like 'restart' are sent to the newly created session or its parent session.
16148 * By default (if the property is false or missing), lifecycle requests are sent to the new session.
16149 * This property is ignored if the session has no parent session.
16150 */
16151 lifecycleManagedByParent?: boolean;
16152
16153 /**
16154 * Controls whether this session should have a separate debug console or share it
16155 * with the parent session. Has no effect for sessions which do not have a parent session.
16156 * Defaults to Separate.
16157 */
16158 consoleMode?: DebugConsoleMode;
16159
16160 /**
16161 * Controls whether this session should run without debugging, thus ignoring breakpoints.
16162 * When this property is not specified, the value from the parent session (if there is one) is used.
16163 */
16164 noDebug?: boolean;
16165
16166 /**
16167 * Controls if the debug session's parent session is shown in the CALL STACK view even if it has only a single child.
16168 * By default, the debug session will never hide its parent.
16169 * If compact is true, debug sessions with a single child are hidden in the CALL STACK view to make the tree more compact.
16170 */
16171 compact?: boolean;
16172
16173 /**
16174 * When true, a save will not be triggered for open editors when starting a debug session, regardless of the value of the `debug.saveBeforeStart` setting.
16175 */
16176 suppressSaveBeforeStart?: boolean;
16177
16178 /**
16179 * When true, the debug toolbar will not be shown for this session.
16180 */
16181 suppressDebugToolbar?: boolean;
16182
16183 /**
16184 * When true, the window statusbar color will not be changed for this session.
16185 */
16186 suppressDebugStatusbar?: boolean;
16187
16188 /**
16189 * When true, the debug viewlet will not be automatically revealed for this session.
16190 */
16191 suppressDebugView?: boolean;
16192
16193 /**
16194 * Signals to the editor that the debug session was started from a test run
16195 * request. This is used to link the lifecycle of the debug session and
16196 * test run in UI actions.
16197 */
16198 testRun?: TestRun;
16199 }
16200
16201 /**
16202 * A DebugConfigurationProviderTriggerKind specifies when the `provideDebugConfigurations` method of a `DebugConfigurationProvider` is triggered.
16203 * Currently there are two situations: to provide the initial debug configurations for a newly created launch.json or
16204 * to provide dynamically generated debug configurations when the user asks for them through the UI (e.g. via the "Select and Start Debugging" command).
16205 * A trigger kind is used when registering a `DebugConfigurationProvider` with {@link debug.registerDebugConfigurationProvider}.
16206 */
16207 export enum DebugConfigurationProviderTriggerKind {
16208 /**
16209 * `DebugConfigurationProvider.provideDebugConfigurations` is called to provide the initial debug configurations for a newly created launch.json.
16210 */
16211 Initial = 1,
16212 /**
16213 * `DebugConfigurationProvider.provideDebugConfigurations` is called to provide dynamically generated debug configurations when the user asks for them through the UI (e.g. via the "Select and Start Debugging" command).
16214 */
16215 Dynamic = 2
16216 }
16217
16218 /**
16219 * Represents a thread in a debug session.
16220 */
16221 export class DebugThread {
16222 /**
16223 * Debug session for thread.
16224 */
16225 readonly session: DebugSession;
16226
16227 /**
16228 * ID of the associated thread in the debug protocol.
16229 */
16230 readonly threadId: number;
16231
16232 /**
16233 * @hidden
16234 */
16235 private constructor(session: DebugSession, threadId: number);
16236 }
16237
16238 /**
16239 * Represents a stack frame in a debug session.
16240 */
16241 export class DebugStackFrame {
16242 /**
16243 * Debug session for thread.
16244 */
16245 readonly session: DebugSession;
16246
16247 /**
16248 * ID of the associated thread in the debug protocol.
16249 */
16250 readonly threadId: number;
16251 /**
16252 * ID of the stack frame in the debug protocol.
16253 */
16254 readonly frameId: number;
16255
16256 /**
16257 * @hidden
16258 */
16259 private constructor(session: DebugSession, threadId: number, frameId: number);
16260 }
16261
16262 /**
16263 * Namespace for debug functionality.
16264 */
16265 export namespace debug {
16266
16267 /**
16268 * The currently active {@link DebugSession debug session} or `undefined`. The active debug session is the one
16269 * represented by the debug action floating window or the one currently shown in the drop down menu of the debug action floating window.
16270 * If no debug session is active, the value is `undefined`.
16271 */
16272 export let activeDebugSession: DebugSession | undefined;
16273
16274 /**
16275 * The currently active {@link DebugConsole debug console}.
16276 * If no debug session is active, output sent to the debug console is not shown.
16277 */
16278 export let activeDebugConsole: DebugConsole;
16279
16280 /**
16281 * List of breakpoints.
16282 */
16283 export let breakpoints: readonly Breakpoint[];
16284
16285 /**
16286 * An {@link Event} which fires when the {@link debug.activeDebugSession active debug session}
16287 * has changed. *Note* that the event also fires when the active debug session changes
16288 * to `undefined`.
16289 */
16290 export const onDidChangeActiveDebugSession: Event<DebugSession | undefined>;
16291
16292 /**
16293 * An {@link Event} which fires when a new {@link DebugSession debug session} has been started.
16294 */
16295 export const onDidStartDebugSession: Event<DebugSession>;
16296
16297 /**
16298 * An {@link Event} which fires when a custom DAP event is received from the {@link DebugSession debug session}.
16299 */
16300 export const onDidReceiveDebugSessionCustomEvent: Event<DebugSessionCustomEvent>;
16301
16302 /**
16303 * An {@link Event} which fires when a {@link DebugSession debug session} has terminated.
16304 */
16305 export const onDidTerminateDebugSession: Event<DebugSession>;
16306
16307 /**
16308 * An {@link Event} that is emitted when the set of breakpoints is added, removed, or changed.
16309 */
16310 export const onDidChangeBreakpoints: Event<BreakpointsChangeEvent>;
16311
16312 /**
16313 * The currently focused thread or stack frame, or `undefined` if no
16314 * thread or stack is focused. A thread can be focused any time there is
16315 * an active debug session, while a stack frame can only be focused when
16316 * a session is paused and the call stack has been retrieved.
16317 */
16318 export const activeStackItem: DebugThread | DebugStackFrame | undefined;
16319
16320 /**
16321 * An event which fires when the {@link debug.activeStackItem} has changed.
16322 */
16323 export const onDidChangeActiveStackItem: Event<DebugThread | DebugStackFrame | undefined>;
16324
16325 /**
16326 * Register a {@link DebugConfigurationProvider debug configuration provider} for a specific debug type.
16327 * The optional {@link DebugConfigurationProviderTriggerKind triggerKind} can be used to specify when the `provideDebugConfigurations` method of the provider is triggered.
16328 * Currently two trigger kinds are possible: with the value `Initial` (or if no trigger kind argument is given) the `provideDebugConfigurations` method is used to provide the initial debug configurations to be copied into a newly created launch.json.
16329 * With the trigger kind `Dynamic` the `provideDebugConfigurations` method is used to dynamically determine debug configurations to be presented to the user (in addition to the static configurations from the launch.json).
16330 * Please note that the `triggerKind` argument only applies to the `provideDebugConfigurations` method: so the `resolveDebugConfiguration` methods are not affected at all.
16331 * Registering a single provider with resolve methods for different trigger kinds, results in the same resolve methods called multiple times.
16332 * More than one provider can be registered for the same type.
16333 *
16334 * @param debugType The debug type for which the provider is registered.
16335 * @param provider The {@link DebugConfigurationProvider debug configuration provider} to register.
16336 * @param triggerKind The {@link DebugConfigurationProviderTriggerKind trigger} for which the 'provideDebugConfiguration' method of the provider is registered. If `triggerKind` is missing, the value `DebugConfigurationProviderTriggerKind.Initial` is assumed.
16337 * @returns A {@link Disposable} that unregisters this provider when being disposed.
16338 */
16339 export function registerDebugConfigurationProvider(debugType: string, provider: DebugConfigurationProvider, triggerKind?: DebugConfigurationProviderTriggerKind): Disposable;
16340
16341 /**
16342 * Register a {@link DebugAdapterDescriptorFactory debug adapter descriptor factory} for a specific debug type.
16343 * An extension is only allowed to register a DebugAdapterDescriptorFactory for the debug type(s) defined by the extension. Otherwise an error is thrown.
16344 * Registering more than one DebugAdapterDescriptorFactory for a debug type results in an error.
16345 *
16346 * @param debugType The debug type for which the factory is registered.
16347 * @param factory The {@link DebugAdapterDescriptorFactory debug adapter descriptor factory} to register.
16348 * @returns A {@link Disposable} that unregisters this factory when being disposed.
16349 */
16350 export function registerDebugAdapterDescriptorFactory(debugType: string, factory: DebugAdapterDescriptorFactory): Disposable;
16351
16352 /**
16353 * Register a debug adapter tracker factory for the given debug type.
16354 *
16355 * @param debugType The debug type for which the factory is registered or '*' for matching all debug types.
16356 * @param factory The {@link DebugAdapterTrackerFactory debug adapter tracker factory} to register.
16357 * @returns A {@link Disposable} that unregisters this factory when being disposed.
16358 */
16359 export function registerDebugAdapterTrackerFactory(debugType: string, factory: DebugAdapterTrackerFactory): Disposable;
16360
16361 /**
16362 * Start debugging by using either a named launch or named compound configuration,
16363 * or by directly passing a {@link DebugConfiguration}.
16364 * The named configurations are looked up in '.vscode/launch.json' found in the given folder.
16365 * Before debugging starts, all unsaved files are saved and the launch configurations are brought up-to-date.
16366 * Folder specific variables used in the configuration (e.g. '${workspaceFolder}') are resolved against the given folder.
16367 * @param folder The {@link WorkspaceFolder workspace folder} for looking up named configurations and resolving variables or `undefined` for a non-folder setup.
16368 * @param nameOrConfiguration Either the name of a debug or compound configuration or a {@link DebugConfiguration} object.
16369 * @param parentSessionOrOptions Debug session options. When passed a parent {@link DebugSession debug session}, assumes options with just this parent session.
16370 * @returns A thenable that resolves when debugging could be successfully started.
16371 */
16372 export function startDebugging(folder: WorkspaceFolder | undefined, nameOrConfiguration: string | DebugConfiguration, parentSessionOrOptions?: DebugSession | DebugSessionOptions): Thenable<boolean>;
16373
16374 /**
16375 * Stop the given debug session or stop all debug sessions if session is omitted.
16376 *
16377 * @param session The {@link DebugSession debug session} to stop; if omitted all sessions are stopped.
16378 * @returns A thenable that resolves when the session(s) have been stopped.
16379 */
16380 export function stopDebugging(session?: DebugSession): Thenable<void>;
16381
16382 /**
16383 * Add breakpoints.
16384 * @param breakpoints The breakpoints to add.
16385 */
16386 export function addBreakpoints(breakpoints: readonly Breakpoint[]): void;
16387
16388 /**
16389 * Remove breakpoints.
16390 * @param breakpoints The breakpoints to remove.
16391 */
16392 export function removeBreakpoints(breakpoints: readonly Breakpoint[]): void;
16393
16394 /**
16395 * Converts a "Source" descriptor object received via the Debug Adapter Protocol into a Uri that can be used to load its contents.
16396 * If the source descriptor is based on a path, a file Uri is returned.
16397 * If the source descriptor uses a reference number, a specific debug Uri (scheme 'debug') is constructed that requires a corresponding ContentProvider and a running debug session
16398 *
16399 * If the "Source" descriptor has insufficient information for creating the Uri, an error is thrown.
16400 *
16401 * @param source An object conforming to the [Source](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Source) type defined in the Debug Adapter Protocol.
16402 * @param session An optional debug session that will be used when the source descriptor uses a reference number to load the contents from an active debug session.
16403 * @returns A uri that can be used to load the contents of the source.
16404 */
16405 export function asDebugSourceUri(source: DebugProtocolSource, session?: DebugSession): Uri;
16406 }
16407
16408 /**
16409 * Namespace for dealing with installed extensions. Extensions are represented
16410 * by an {@link Extension}-interface which enables reflection on them.
16411 *
16412 * Extension writers can provide APIs to other extensions by returning their API public
16413 * surface from the `activate`-call.
16414 *
16415 * ```javascript
16416 * export function activate(context: vscode.ExtensionContext) {
16417 * let api = {
16418 * sum(a, b) {
16419 * return a + b;
16420 * },
16421 * mul(a, b) {
16422 * return a * b;
16423 * }
16424 * };
16425 * // 'export' public api-surface
16426 * return api;
16427 * }
16428 * ```
16429 * When depending on the API of another extension add an `extensionDependencies`-entry
16430 * to `package.json`, and use the {@link extensions.getExtension getExtension}-function
16431 * and the {@link Extension.exports exports}-property, like below:
16432 *
16433 * ```javascript
16434 * let mathExt = extensions.getExtension('genius.math');
16435 * let importedApi = mathExt.exports;
16436 *
16437 * console.log(importedApi.mul(42, 1));
16438 * ```
16439 */
16440 export namespace extensions {
16441
16442 /**
16443 * Get an extension by its full identifier in the form of: `publisher.name`.
16444 *
16445 * @param extensionId An extension identifier.
16446 * @returns An extension or `undefined`.
16447 */
16448 export function getExtension<T = any>(extensionId: string): Extension<T> | undefined;
16449
16450 /**
16451 * All extensions currently known to the system.
16452 */
16453 export const all: readonly Extension<any>[];
16454
16455 /**
16456 * An event which fires when `extensions.all` changes. This can happen when extensions are
16457 * installed, uninstalled, enabled or disabled.
16458 */
16459 export const onDidChange: Event<void>;
16460 }
16461
16462 /**
16463 * Collapsible state of a {@link CommentThread comment thread}
16464 */
16465 export enum CommentThreadCollapsibleState {
16466 /**
16467 * Determines an item is collapsed
16468 */
16469 Collapsed = 0,
16470
16471 /**
16472 * Determines an item is expanded
16473 */
16474 Expanded = 1
16475 }
16476
16477 /**
16478 * Comment mode of a {@link Comment}
16479 */
16480 export enum CommentMode {
16481 /**
16482 * Displays the comment editor
16483 */
16484 Editing = 0,
16485
16486 /**
16487 * Displays the preview of the comment
16488 */
16489 Preview = 1
16490 }
16491
16492 /**
16493 * The state of a comment thread.
16494 */
16495 export enum CommentThreadState {
16496 /**
16497 * Unresolved thread state
16498 */
16499 Unresolved = 0,
16500 /**
16501 * Resolved thread state
16502 */
16503 Resolved = 1
16504 }
16505
16506 /**
16507 * A collection of {@link Comment comments} representing a conversation at a particular range in a document.
16508 */
16509 export interface CommentThread {
16510 /**
16511 * The uri of the document the thread has been created on.
16512 */
16513 readonly uri: Uri;
16514
16515 /**
16516 * The range the comment thread is located within the document. The thread icon will be shown
16517 * at the last line of the range.
16518 */
16519 range: Range;
16520
16521 /**
16522 * The ordered comments of the thread.
16523 */
16524 comments: readonly Comment[];
16525
16526 /**
16527 * Whether the thread should be collapsed or expanded when opening the document.
16528 * Defaults to Collapsed.
16529 */
16530 collapsibleState: CommentThreadCollapsibleState;
16531
16532 /**
16533 * Whether the thread supports reply.
16534 * Defaults to true.
16535 */
16536 canReply: boolean;
16537
16538 /**
16539 * Context value of the comment thread. This can be used to contribute thread specific actions.
16540 * For example, a comment thread is given a context value as `editable`. When contributing actions to `comments/commentThread/title`
16541 * using `menus` extension point, you can specify context value for key `commentThread` in `when` expression like `commentThread == editable`.
16542 * ```json
16543 * "contributes": {
16544 * "menus": {
16545 * "comments/commentThread/title": [
16546 * {
16547 * "command": "extension.deleteCommentThread",
16548 * "when": "commentThread == editable"
16549 * }
16550 * ]
16551 * }
16552 * }
16553 * ```
16554 * This will show action `extension.deleteCommentThread` only for comment threads with `contextValue` is `editable`.
16555 */
16556 contextValue?: string;
16557
16558 /**
16559 * The optional human-readable label describing the {@link CommentThread Comment Thread}
16560 */
16561 label?: string;
16562
16563 /**
16564 * The optional state of a comment thread, which may affect how the comment is displayed.
16565 */
16566 state?: CommentThreadState;
16567
16568 /**
16569 * Dispose this comment thread.
16570 *
16571 * Once disposed, this comment thread will be removed from visible editors and Comment Panel when appropriate.
16572 */
16573 dispose(): void;
16574 }
16575
16576 /**
16577 * Author information of a {@link Comment}
16578 */
16579 export interface CommentAuthorInformation {
16580 /**
16581 * The display name of the author of the comment
16582 */
16583 name: string;
16584
16585 /**
16586 * The optional icon path for the author
16587 */
16588 iconPath?: Uri;
16589 }
16590
16591 /**
16592 * Reactions of a {@link Comment}
16593 */
16594 export interface CommentReaction {
16595 /**
16596 * The human-readable label for the reaction
16597 */
16598 readonly label: string;
16599
16600 /**
16601 * Icon for the reaction shown in UI.
16602 */
16603 readonly iconPath: string | Uri;
16604
16605 /**
16606 * The number of users who have reacted to this reaction
16607 */
16608 readonly count: number;
16609
16610 /**
16611 * Whether the {@link CommentAuthorInformation author} of the comment has reacted to this reaction
16612 */
16613 readonly authorHasReacted: boolean;
16614 }
16615
16616 /**
16617 * A comment is displayed within the editor or the Comments Panel, depending on how it is provided.
16618 */
16619 export interface Comment {
16620 /**
16621 * The human-readable comment body
16622 */
16623 body: string | MarkdownString;
16624
16625 /**
16626 * {@link CommentMode Comment mode} of the comment
16627 */
16628 mode: CommentMode;
16629
16630 /**
16631 * The {@link CommentAuthorInformation author information} of the comment
16632 */
16633 author: CommentAuthorInformation;
16634
16635 /**
16636 * Context value of the comment. This can be used to contribute comment specific actions.
16637 * For example, a comment is given a context value as `editable`. When contributing actions to `comments/comment/title`
16638 * using `menus` extension point, you can specify context value for key `comment` in `when` expression like `comment == editable`.
16639 * ```json
16640 * "contributes": {
16641 * "menus": {
16642 * "comments/comment/title": [
16643 * {
16644 * "command": "extension.deleteComment",
16645 * "when": "comment == editable"
16646 * }
16647 * ]
16648 * }
16649 * }
16650 * ```
16651 * This will show action `extension.deleteComment` only for comments with `contextValue` is `editable`.
16652 */
16653 contextValue?: string;
16654
16655 /**
16656 * Optional reactions of the {@link Comment}
16657 */
16658 reactions?: CommentReaction[];
16659
16660 /**
16661 * Optional label describing the {@link Comment}
16662 * Label will be rendered next to authorName if exists.
16663 */
16664 label?: string;
16665
16666 /**
16667 * Optional timestamp that will be displayed in comments.
16668 * The date will be formatted according to the user's locale and settings.
16669 */
16670 timestamp?: Date;
16671 }
16672
16673 /**
16674 * Command argument for actions registered in `comments/commentThread/context`.
16675 */
16676 export interface CommentReply {
16677 /**
16678 * The active {@link CommentThread comment thread}
16679 */
16680 thread: CommentThread;
16681
16682 /**
16683 * The value in the comment editor
16684 */
16685 text: string;
16686 }
16687
16688 /**
16689 * Commenting range provider for a {@link CommentController comment controller}.
16690 */
16691 export interface CommentingRangeProvider {
16692 /**
16693 * Provide a list of ranges which allow new comment threads creation or null for a given document
16694 */
16695 provideCommentingRanges(document: TextDocument, token: CancellationToken): ProviderResult<Range[]>;
16696 }
16697
16698 /**
16699 * Represents a {@link CommentController comment controller}'s {@link CommentController.options options}.
16700 */
16701 export interface CommentOptions {
16702 /**
16703 * An optional string to show on the comment input box when it's collapsed.
16704 */
16705 prompt?: string;
16706
16707 /**
16708 * An optional string to show as placeholder in the comment input box when it's focused.
16709 */
16710 placeHolder?: string;
16711 }
16712
16713 /**
16714 * A comment controller is able to provide {@link CommentThread comments} support to the editor and
16715 * provide users various ways to interact with comments.
16716 */
16717 export interface CommentController {
16718 /**
16719 * The id of this comment controller.
16720 */
16721 readonly id: string;
16722
16723 /**
16724 * The human-readable label of this comment controller.
16725 */
16726 readonly label: string;
16727
16728 /**
16729 * Comment controller options
16730 */
16731 options?: CommentOptions;
16732
16733 /**
16734 * Optional commenting range provider. Provide a list {@link Range ranges} which support commenting to any given resource uri.
16735 *
16736 * If not provided, users cannot leave any comments.
16737 */
16738 commentingRangeProvider?: CommentingRangeProvider;
16739
16740 /**
16741 * Create a {@link CommentThread comment thread}. The comment thread will be displayed in visible text editors (if the resource matches)
16742 * and Comments Panel once created.
16743 *
16744 * @param uri The uri of the document the thread has been created on.
16745 * @param range The range the comment thread is located within the document.
16746 * @param comments The ordered comments of the thread.
16747 */
16748 createCommentThread(uri: Uri, range: Range, comments: readonly Comment[]): CommentThread;
16749
16750 /**
16751 * Optional reaction handler for creating and deleting reactions on a {@link Comment}.
16752 */
16753 reactionHandler?: (comment: Comment, reaction: CommentReaction) => Thenable<void>;
16754
16755 /**
16756 * Dispose this comment controller.
16757 *
16758 * Once disposed, all {@link CommentThread comment threads} created by this comment controller will also be removed from the editor
16759 * and Comments Panel.
16760 */
16761 dispose(): void;
16762 }
16763
16764 namespace comments {
16765 /**
16766 * Creates a new {@link CommentController comment controller} instance.
16767 *
16768 * @param id An `id` for the comment controller.
16769 * @param label A human-readable string for the comment controller.
16770 * @returns An instance of {@link CommentController comment controller}.
16771 */
16772 export function createCommentController(id: string, label: string): CommentController;
16773 }
16774
16775 /**
16776 * Represents a session of a currently logged in user.
16777 */
16778 export interface AuthenticationSession {
16779 /**
16780 * The identifier of the authentication session.
16781 */
16782 readonly id: string;
16783
16784 /**
16785 * The access token.
16786 */
16787 readonly accessToken: string;
16788
16789 /**
16790 * The account associated with the session.
16791 */
16792 readonly account: AuthenticationSessionAccountInformation;
16793
16794 /**
16795 * The permissions granted by the session's access token. Available scopes
16796 * are defined by the {@link AuthenticationProvider}.
16797 */
16798 readonly scopes: readonly string[];
16799 }
16800
16801 /**
16802 * The information of an account associated with an {@link AuthenticationSession}.
16803 */
16804 export interface AuthenticationSessionAccountInformation {
16805 /**
16806 * The unique identifier of the account.
16807 */
16808 readonly id: string;
16809
16810 /**
16811 * The human-readable name of the account.
16812 */
16813 readonly label: string;
16814 }
16815
16816 /**
16817 * Optional options to be used when calling {@link authentication.getSession} with the flag `forceNewSession`.
16818 */
16819 export interface AuthenticationForceNewSessionOptions {
16820 /**
16821 * An optional message that will be displayed to the user when we ask to re-authenticate. Providing additional context
16822 * as to why you are asking a user to re-authenticate can help increase the odds that they will accept.
16823 */
16824 detail?: string;
16825 }
16826
16827 /**
16828 * Options to be used when getting an {@link AuthenticationSession} from an {@link AuthenticationProvider}.
16829 */
16830 export interface AuthenticationGetSessionOptions {
16831 /**
16832 * Whether the existing session preference should be cleared.
16833 *
16834 * For authentication providers that support being signed into multiple accounts at once, the user will be
16835 * prompted to select an account to use when {@link authentication.getSession getSession} is called. This preference
16836 * is remembered until {@link authentication.getSession getSession} is called with this flag.
16837 *
16838 * Note:
16839 * The preference is extension specific. So if one extension calls {@link authentication.getSession getSession}, it will not
16840 * affect the session preference for another extension calling {@link authentication.getSession getSession}. Additionally,
16841 * the preference is set for the current workspace and also globally. This means that new workspaces will use the "global"
16842 * value at first and then when this flag is provided, a new value can be set for that workspace. This also means
16843 * that pre-existing workspaces will not lose their preference if a new workspace sets this flag.
16844 *
16845 * Defaults to false.
16846 */
16847 clearSessionPreference?: boolean;
16848
16849 /**
16850 * Whether login should be performed if there is no matching session.
16851 *
16852 * If true, a modal dialog will be shown asking the user to sign in. If false, a numbered badge will be shown
16853 * on the accounts activity bar icon. An entry for the extension will be added under the menu to sign in. This
16854 * allows quietly prompting the user to sign in.
16855 *
16856 * If there is a matching session but the extension has not been granted access to it, setting this to true
16857 * will also result in an immediate modal dialog, and false will add a numbered badge to the accounts icon.
16858 *
16859 * Defaults to false.
16860 *
16861 * Note: you cannot use this option with {@link AuthenticationGetSessionOptions.silent silent}.
16862 */
16863 createIfNone?: boolean;
16864
16865 /**
16866 * Whether we should attempt to reauthenticate even if there is already a session available.
16867 *
16868 * If true, a modal dialog will be shown asking the user to sign in again. This is mostly used for scenarios
16869 * where the token needs to be re minted because it has lost some authorization.
16870 *
16871 * If there are no existing sessions and forceNewSession is true, it will behave identically to
16872 * {@link AuthenticationGetSessionOptions.createIfNone createIfNone}.
16873 *
16874 * This defaults to false.
16875 */
16876 forceNewSession?: boolean | AuthenticationForceNewSessionOptions;
16877
16878 /**
16879 * Whether we should show the indication to sign in in the Accounts menu.
16880 *
16881 * If false, the user will be shown a badge on the Accounts menu with an option to sign in for the extension.
16882 * If true, no indication will be shown.
16883 *
16884 * Defaults to false.
16885 *
16886 * Note: you cannot use this option with any other options that prompt the user like {@link AuthenticationGetSessionOptions.createIfNone createIfNone}.
16887 */
16888 silent?: boolean;
16889 }
16890
16891 /**
16892 * Basic information about an {@link AuthenticationProvider}
16893 */
16894 export interface AuthenticationProviderInformation {
16895 /**
16896 * The unique identifier of the authentication provider.
16897 */
16898 readonly id: string;
16899
16900 /**
16901 * The human-readable name of the authentication provider.
16902 */
16903 readonly label: string;
16904 }
16905
16906 /**
16907 * An {@link Event} which fires when an {@link AuthenticationSession} is added, removed, or changed.
16908 */
16909 export interface AuthenticationSessionsChangeEvent {
16910 /**
16911 * The {@link AuthenticationProvider} that has had its sessions change.
16912 */
16913 readonly provider: AuthenticationProviderInformation;
16914 }
16915
16916 /**
16917 * Options for creating an {@link AuthenticationProvider}.
16918 */
16919 export interface AuthenticationProviderOptions {
16920 /**
16921 * Whether it is possible to be signed into multiple accounts at once with this provider.
16922 * If not specified, will default to false.
16923 */
16924 readonly supportsMultipleAccounts?: boolean;
16925 }
16926
16927 /**
16928 * An {@link Event} which fires when an {@link AuthenticationSession} is added, removed, or changed.
16929 */
16930 export interface AuthenticationProviderAuthenticationSessionsChangeEvent {
16931 /**
16932 * The {@link AuthenticationSession AuthenticationSessions} of the {@link AuthenticationProvider} that have been added.
16933 */
16934 readonly added: readonly AuthenticationSession[] | undefined;
16935
16936 /**
16937 * The {@link AuthenticationSession AuthenticationSessions} of the {@link AuthenticationProvider} that have been removed.
16938 */
16939 readonly removed: readonly AuthenticationSession[] | undefined;
16940
16941 /**
16942 * The {@link AuthenticationSession AuthenticationSessions} of the {@link AuthenticationProvider} that have been changed.
16943 * A session changes when its data excluding the id are updated. An example of this is a session refresh that results in a new
16944 * access token being set for the session.
16945 */
16946 readonly changed: readonly AuthenticationSession[] | undefined;
16947 }
16948
16949 /**
16950 * A provider for performing authentication to a service.
16951 */
16952 export interface AuthenticationProvider {
16953 /**
16954 * An {@link Event} which fires when the array of sessions has changed, or data
16955 * within a session has changed.
16956 */
16957 readonly onDidChangeSessions: Event<AuthenticationProviderAuthenticationSessionsChangeEvent>;
16958
16959 /**
16960 * Get a list of sessions.
16961 * @param scopes An optional list of scopes. If provided, the sessions returned should match
16962 * these permissions, otherwise all sessions should be returned.
16963 * @returns A promise that resolves to an array of authentication sessions.
16964 */
16965 getSessions(scopes?: readonly string[]): Thenable<readonly AuthenticationSession[]>;
16966
16967 /**
16968 * Prompts a user to login.
16969 *
16970 * If login is successful, the onDidChangeSessions event should be fired.
16971 *
16972 * If login fails, a rejected promise should be returned.
16973 *
16974 * If the provider has specified that it does not support multiple accounts,
16975 * then this should never be called if there is already an existing session matching these
16976 * scopes.
16977 * @param scopes A list of scopes, permissions, that the new session should be created with.
16978 * @returns A promise that resolves to an authentication session.
16979 */
16980 createSession(scopes: readonly string[]): Thenable<AuthenticationSession>;
16981
16982 /**
16983 * Removes the session corresponding to session id.
16984 *
16985 * If the removal is successful, the onDidChangeSessions event should be fired.
16986 *
16987 * If a session cannot be removed, the provider should reject with an error message.
16988 * @param sessionId The id of the session to remove.
16989 */
16990 removeSession(sessionId: string): Thenable<void>;
16991 }
16992
16993
16994 /**
16995 * Namespace for authentication.
16996 */
16997 export namespace authentication {
16998 /**
16999 * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
17000 * registered, or if the user does not consent to sharing authentication information with
17001 * the extension. If there are multiple sessions with the same scopes, the user will be shown a
17002 * quickpick to select which account they would like to use.
17003 *
17004 * Currently, there are only two authentication providers that are contributed from built in extensions
17005 * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
17006 * @param providerId The id of the provider to use
17007 * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
17008 * @param options The {@link AuthenticationGetSessionOptions} to use
17009 * @returns A thenable that resolves to an authentication session
17010 */
17011 export function getSession(providerId: string, scopes: readonly string[], options: AuthenticationGetSessionOptions & { /** */createIfNone: true }): Thenable<AuthenticationSession>;
17012
17013 /**
17014 * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
17015 * registered, or if the user does not consent to sharing authentication information with
17016 * the extension. If there are multiple sessions with the same scopes, the user will be shown a
17017 * quickpick to select which account they would like to use.
17018 *
17019 * Currently, there are only two authentication providers that are contributed from built in extensions
17020 * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
17021 * @param providerId The id of the provider to use
17022 * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
17023 * @param options The {@link AuthenticationGetSessionOptions} to use
17024 * @returns A thenable that resolves to an authentication session
17025 */
17026 export function getSession(providerId: string, scopes: readonly string[], options: AuthenticationGetSessionOptions & { /** literal-type defines return type */forceNewSession: true | AuthenticationForceNewSessionOptions }): Thenable<AuthenticationSession>;
17027
17028 /**
17029 * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
17030 * registered, or if the user does not consent to sharing authentication information with
17031 * the extension. If there are multiple sessions with the same scopes, the user will be shown a
17032 * quickpick to select which account they would like to use.
17033 *
17034 * Currently, there are only two authentication providers that are contributed from built in extensions
17035 * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
17036 * @param providerId The id of the provider to use
17037 * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
17038 * @param options The {@link AuthenticationGetSessionOptions} to use
17039 * @returns A thenable that resolves to an authentication session if available, or undefined if there are no sessions
17040 */
17041 export function getSession(providerId: string, scopes: readonly string[], options?: AuthenticationGetSessionOptions): Thenable<AuthenticationSession | undefined>;
17042
17043 /**
17044 * An {@link Event} which fires when the authentication sessions of an authentication provider have
17045 * been added, removed, or changed.
17046 */
17047 export const onDidChangeSessions: Event<AuthenticationSessionsChangeEvent>;
17048
17049 /**
17050 * Register an authentication provider.
17051 *
17052 * There can only be one provider per id and an error is being thrown when an id
17053 * has already been used by another provider. Ids are case-sensitive.
17054 *
17055 * @param id The unique identifier of the provider.
17056 * @param label The human-readable name of the provider.
17057 * @param provider The authentication provider provider.
17058 * @param options Additional options for the provider.
17059 * @returns A {@link Disposable} that unregisters this provider when being disposed.
17060 */
17061 export function registerAuthenticationProvider(id: string, label: string, provider: AuthenticationProvider, options?: AuthenticationProviderOptions): Disposable;
17062 }
17063
17064 /**
17065 * Namespace for localization-related functionality in the extension API. To use this properly,
17066 * you must have `l10n` defined in your extension manifest and have bundle.l10n.<language>.json files.
17067 * For more information on how to generate bundle.l10n.<language>.json files, check out the
17068 * [vscode-l10n repo](https://github.com/microsoft/vscode-l10n).
17069 *
17070 * Note: Built-in extensions (for example, Git, TypeScript Language Features, GitHub Authentication)
17071 * are excluded from the `l10n` property requirement. In other words, they do not need to specify
17072 * a `l10n` in the extension manifest because their translated strings come from Language Packs.
17073 */
17074 export namespace l10n {
17075 /**
17076 * Marks a string for localization. If a localized bundle is available for the language specified by
17077 * {@link env.language} and the bundle has a localized value for this message, then that localized
17078 * value will be returned (with injected {@link args} values for any templated values).
17079 *
17080 * @param message - The message to localize. Supports index templating where strings like `{0}` and `{1}` are
17081 * replaced by the item at that index in the {@link args} array.
17082 * @param args - The arguments to be used in the localized string. The index of the argument is used to
17083 * match the template placeholder in the localized string.
17084 * @returns localized string with injected arguments.
17085 *
17086 * @example
17087 * l10n.t('Hello {0}!', 'World');
17088 */
17089 export function t(message: string, ...args: Array<string | number | boolean>): string;
17090
17091 /**
17092 * Marks a string for localization. If a localized bundle is available for the language specified by
17093 * {@link env.language} and the bundle has a localized value for this message, then that localized
17094 * value will be returned (with injected {@link args} values for any templated values).
17095 *
17096 * @param message The message to localize. Supports named templating where strings like `{foo}` and `{bar}` are
17097 * replaced by the value in the Record for that key (foo, bar, etc).
17098 * @param args The arguments to be used in the localized string. The name of the key in the record is used to
17099 * match the template placeholder in the localized string.
17100 * @returns localized string with injected arguments.
17101 *
17102 * @example
17103 * l10n.t('Hello {name}', { name: 'Erich' });
17104 */
17105 export function t(message: string, args: Record<string, any>): string;
17106 /**
17107 * Marks a string for localization. If a localized bundle is available for the language specified by
17108 * {@link env.language} and the bundle has a localized value for this message, then that localized
17109 * value will be returned (with injected args values for any templated values).
17110 *
17111 * @param options The options to use when localizing the message.
17112 * @returns localized string with injected arguments.
17113 */
17114 export function t(options: {
17115 /**
17116 * The message to localize. If {@link options.args args} is an array, this message supports index templating where strings like
17117 * `{0}` and `{1}` are replaced by the item at that index in the {@link options.args args} array. If `args` is a `Record<string, any>`,
17118 * this supports named templating where strings like `{foo}` and `{bar}` are replaced by the value in
17119 * the Record for that key (foo, bar, etc).
17120 */
17121 message: string;
17122 /**
17123 * The arguments to be used in the localized string. As an array, the index of the argument is used to
17124 * match the template placeholder in the localized string. As a Record, the key is used to match the template
17125 * placeholder in the localized string.
17126 */
17127 args?: Array<string | number | boolean> | Record<string, any>;
17128 /**
17129 * A comment to help translators understand the context of the message.
17130 */
17131 comment: string | string[];
17132 }): string;
17133 /**
17134 * The bundle of localized strings that have been loaded for the extension.
17135 * It's undefined if no bundle has been loaded. The bundle is typically not loaded if
17136 * there was no bundle found or when we are running with the default language.
17137 */
17138 export const bundle: { [key: string]: string } | undefined;
17139 /**
17140 * The URI of the localization bundle that has been loaded for the extension.
17141 * It's undefined if no bundle has been loaded. The bundle is typically not loaded if
17142 * there was no bundle found or when we are running with the default language.
17143 */
17144 export const uri: Uri | undefined;
17145 }
17146
17147 /**
17148 * Namespace for testing functionality. Tests are published by registering
17149 * {@link TestController} instances, then adding {@link TestItem TestItems}.
17150 * Controllers may also describe how to run tests by creating one or more
17151 * {@link TestRunProfile} instances.
17152 */
17153 export namespace tests {
17154 /**
17155 * Creates a new test controller.
17156 *
17157 * @param id Identifier for the controller, must be globally unique.
17158 * @param label A human-readable label for the controller.
17159 * @returns An instance of the {@link TestController}.
17160 */
17161 export function createTestController(id: string, label: string): TestController;
17162 }
17163
17164 /**
17165 * The kind of executions that {@link TestRunProfile TestRunProfiles} control.
17166 */
17167 export enum TestRunProfileKind {
17168 /**
17169 * The `Run` test profile kind.
17170 */
17171 Run = 1,
17172 /**
17173 * The `Debug` test profile kind.
17174 */
17175 Debug = 2,
17176 /**
17177 * The `Coverage` test profile kind.
17178 */
17179 Coverage = 3,
17180 }
17181
17182 /**
17183 * Tags can be associated with {@link TestItem TestItems} and
17184 * {@link TestRunProfile TestRunProfiles}. A profile with a tag can only
17185 * execute tests that include that tag in their {@link TestItem.tags} array.
17186 */
17187 export class TestTag {
17188 /**
17189 * ID of the test tag. `TestTag` instances with the same ID are considered
17190 * to be identical.
17191 */
17192 readonly id: string;
17193
17194 /**
17195 * Creates a new TestTag instance.
17196 * @param id ID of the test tag.
17197 */
17198 constructor(id: string);
17199 }
17200
17201 /**
17202 * A TestRunProfile describes one way to execute tests in a {@link TestController}.
17203 */
17204 export interface TestRunProfile {
17205 /**
17206 * Label shown to the user in the UI.
17207 *
17208 * Note that the label has some significance if the user requests that
17209 * tests be re-run in a certain way. For example, if tests were run
17210 * normally and the user requests to re-run them in debug mode, the editor
17211 * will attempt use a configuration with the same label of the `Debug`
17212 * kind. If there is no such configuration, the default will be used.
17213 */
17214 label: string;
17215
17216 /**
17217 * Configures what kind of execution this profile controls. If there
17218 * are no profiles for a kind, it will not be available in the UI.
17219 */
17220 readonly kind: TestRunProfileKind;
17221
17222 /**
17223 * Controls whether this profile is the default action that will
17224 * be taken when its kind is actioned. For example, if the user clicks
17225 * the generic "run all" button, then the default profile for
17226 * {@link TestRunProfileKind.Run} will be executed, although the
17227 * user can configure this.
17228 *
17229 * Changes the user makes in their default profiles will be reflected
17230 * in this property after a {@link onDidChangeDefault} event.
17231 */
17232 isDefault: boolean;
17233
17234 /**
17235 * Fired when a user has changed whether this is a default profile. The
17236 * event contains the new value of {@link isDefault}
17237 */
17238 onDidChangeDefault: Event<boolean>;
17239
17240 /**
17241 * Whether this profile supports continuous running of requests. If so,
17242 * then {@link TestRunRequest.continuous} may be set to `true`. Defaults
17243 * to false.
17244 */
17245 supportsContinuousRun: boolean;
17246
17247 /**
17248 * Associated tag for the profile. If this is set, only {@link TestItem}
17249 * instances with the same tag will be eligible to execute in this profile.
17250 */
17251 tag: TestTag | undefined;
17252
17253 /**
17254 * If this method is present, a configuration gear will be present in the
17255 * UI, and this method will be invoked when it's clicked. When called,
17256 * you can take other editor actions, such as showing a quick pick or
17257 * opening a configuration file.
17258 */
17259 configureHandler: (() => void) | undefined;
17260
17261 /**
17262 * Handler called to start a test run. When invoked, the function should call
17263 * {@link TestController.createTestRun} at least once, and all test runs
17264 * associated with the request should be created before the function returns
17265 * or the returned promise is resolved.
17266 *
17267 * If {@link supportsContinuousRun} is set, then {@link TestRunRequest.continuous}
17268 * may be `true`. In this case, the profile should observe changes to
17269 * source code and create new test runs by calling {@link TestController.createTestRun},
17270 * until the cancellation is requested on the `token`.
17271 *
17272 * @param request Request information for the test run.
17273 * @param cancellationToken Token that signals the used asked to abort the
17274 * test run. If cancellation is requested on this token, all {@link TestRun}
17275 * instances associated with the request will be
17276 * automatically cancelled as well.
17277 */
17278 runHandler: (request: TestRunRequest, token: CancellationToken) => Thenable<void> | void;
17279
17280 /**
17281 * An extension-provided function that provides detailed statement and
17282 * function-level coverage for a file. The editor will call this when more
17283 * detail is needed for a file, such as when it's opened in an editor or
17284 * expanded in the **Test Coverage** view.
17285 *
17286 * The {@link FileCoverage} object passed to this function is the same instance
17287 * emitted on {@link TestRun.addCoverage} calls associated with this profile.
17288 */
17289 loadDetailedCoverage?: (testRun: TestRun, fileCoverage: FileCoverage, token: CancellationToken) => Thenable<FileCoverageDetail[]>;
17290
17291 /**
17292 * Deletes the run profile.
17293 */
17294 dispose(): void;
17295 }
17296
17297 /**
17298 * Entry point to discover and execute tests. It contains {@link TestController.items} which
17299 * are used to populate the editor UI, and is associated with
17300 * {@link TestController.createRunProfile run profiles} to allow
17301 * for tests to be executed.
17302 */
17303 export interface TestController {
17304 /**
17305 * The id of the controller passed in {@link tests.createTestController}.
17306 * This must be globally unique.
17307 */
17308 readonly id: string;
17309
17310 /**
17311 * Human-readable label for the test controller.
17312 */
17313 label: string;
17314
17315 /**
17316 * A collection of "top-level" {@link TestItem} instances, which can in
17317 * turn have their own {@link TestItem.children children} to form the
17318 * "test tree."
17319 *
17320 * The extension controls when to add tests. For example, extensions should
17321 * add tests for a file when {@link workspace.onDidOpenTextDocument}
17322 * fires in order for decorations for tests within a file to be visible.
17323 *
17324 * However, the editor may sometimes explicitly request children using the
17325 * {@link resolveHandler} See the documentation on that method for more details.
17326 */
17327 readonly items: TestItemCollection;
17328
17329 /**
17330 * Creates a profile used for running tests. Extensions must create
17331 * at least one profile in order for tests to be run.
17332 * @param label A human-readable label for this profile.
17333 * @param kind Configures what kind of execution this profile manages.
17334 * @param runHandler Function called to start a test run.
17335 * @param isDefault Whether this is the default action for its kind.
17336 * @param tag Profile test tag.
17337 * @param supportsContinuousRun Whether the profile supports continuous running.
17338 * @returns An instance of a {@link TestRunProfile}, which is automatically
17339 * associated with this controller.
17340 */
17341 createRunProfile(label: string, kind: TestRunProfileKind, runHandler: (request: TestRunRequest, token: CancellationToken) => Thenable<void> | void, isDefault?: boolean, tag?: TestTag, supportsContinuousRun?: boolean): TestRunProfile;
17342
17343 /**
17344 * A function provided by the extension that the editor may call to request
17345 * children of a test item, if the {@link TestItem.canResolveChildren} is
17346 * `true`. When called, the item should discover children and call
17347 * {@link TestController.createTestItem} as children are discovered.
17348 *
17349 * Generally the extension manages the lifecycle of test items, but under
17350 * certain conditions the editor may request the children of a specific
17351 * item to be loaded. For example, if the user requests to re-run tests
17352 * after reloading the editor, the editor may need to call this method
17353 * to resolve the previously-run tests.
17354 *
17355 * The item in the explorer will automatically be marked as "busy" until
17356 * the function returns or the returned thenable resolves.
17357 *
17358 * @param item An unresolved test item for which children are being
17359 * requested, or `undefined` to resolve the controller's initial {@link TestController.items items}.
17360 */
17361 resolveHandler?: (item: TestItem | undefined) => Thenable<void> | void;
17362
17363 /**
17364 * If this method is present, a refresh button will be present in the
17365 * UI, and this method will be invoked when it's clicked. When called,
17366 * the extension should scan the workspace for any new, changed, or
17367 * removed tests.
17368 *
17369 * It's recommended that extensions try to update tests in realtime, using
17370 * a {@link FileSystemWatcher} for example, and use this method as a fallback.
17371 *
17372 * @returns A thenable that resolves when tests have been refreshed.
17373 */
17374 refreshHandler: ((token: CancellationToken) => Thenable<void> | void) | undefined;
17375
17376 /**
17377 * Creates a {@link TestRun}. This should be called by the
17378 * {@link TestRunProfile} when a request is made to execute tests, and may
17379 * also be called if a test run is detected externally. Once created, tests
17380 * that are included in the request will be moved into the queued state.
17381 *
17382 * All runs created using the same `request` instance will be grouped
17383 * together. This is useful if, for example, a single suite of tests is
17384 * run on multiple platforms.
17385 *
17386 * @param request Test run request. Only tests inside the `include` may be
17387 * modified, and tests in its `exclude` are ignored.
17388 * @param name The human-readable name of the run. This can be used to
17389 * disambiguate multiple sets of results in a test run. It is useful if
17390 * tests are run across multiple platforms, for example.
17391 * @param persist Whether the results created by the run should be
17392 * persisted in the editor. This may be false if the results are coming from
17393 * a file already saved externally, such as a coverage information file.
17394 * @returns An instance of the {@link TestRun}. It will be considered "running"
17395 * from the moment this method is invoked until {@link TestRun.end} is called.
17396 */
17397 createTestRun(request: TestRunRequest, name?: string, persist?: boolean): TestRun;
17398
17399 /**
17400 * Creates a new managed {@link TestItem} instance. It can be added into
17401 * the {@link TestItem.children} of an existing item, or into the
17402 * {@link TestController.items}.
17403 *
17404 * @param id Identifier for the TestItem. The test item's ID must be unique
17405 * in the {@link TestItemCollection} it's added to.
17406 * @param label Human-readable label of the test item.
17407 * @param uri URI this TestItem is associated with. May be a file or directory.
17408 */
17409 createTestItem(id: string, label: string, uri?: Uri): TestItem;
17410
17411 /**
17412 * Marks an item's results as being outdated. This is commonly called when
17413 * code or configuration changes and previous results should no longer
17414 * be considered relevant. The same logic used to mark results as outdated
17415 * may be used to drive {@link TestRunRequest.continuous continuous test runs}.
17416 *
17417 * If an item is passed to this method, test results for the item and all of
17418 * its children will be marked as outdated. If no item is passed, then all
17419 * test owned by the TestController will be marked as outdated.
17420 *
17421 * Any test runs started before the moment this method is called, including
17422 * runs which may still be ongoing, will be marked as outdated and deprioritized
17423 * in the editor's UI.
17424 *
17425 * @param item Item to mark as outdated. If undefined, all the controller's items are marked outdated.
17426 */
17427 invalidateTestResults(items?: TestItem | readonly TestItem[]): void;
17428
17429 /**
17430 * Unregisters the test controller, disposing of its associated tests
17431 * and unpersisted results.
17432 */
17433 dispose(): void;
17434 }
17435
17436 /**
17437 * A TestRunRequest is a precursor to a {@link TestRun}, which in turn is
17438 * created by passing a request to {@link TestController.createTestRun}. The
17439 * TestRunRequest contains information about which tests should be run, which
17440 * should not be run, and how they are run (via the {@link TestRunRequest.profile profile}).
17441 *
17442 * In general, TestRunRequests are created by the editor and pass to
17443 * {@link TestRunProfile.runHandler}, however you can also create test
17444 * requests and runs outside of the `runHandler`.
17445 */
17446 export class TestRunRequest {
17447 /**
17448 * A filter for specific tests to run. If given, the extension should run
17449 * all of the included tests and all their children, excluding any tests
17450 * that appear in {@link TestRunRequest.exclude}. If this property is
17451 * undefined, then the extension should simply run all tests.
17452 *
17453 * The process of running tests should resolve the children of any test
17454 * items who have not yet been resolved.
17455 */
17456 readonly include: readonly TestItem[] | undefined;
17457
17458 /**
17459 * An array of tests the user has marked as excluded from the test included
17460 * in this run; exclusions should apply after inclusions.
17461 *
17462 * May be omitted if no exclusions were requested. Test controllers should
17463 * not run excluded tests or any children of excluded tests.
17464 */
17465 readonly exclude: readonly TestItem[] | undefined;
17466
17467 /**
17468 * The profile used for this request. This will always be defined
17469 * for requests issued from the editor UI, though extensions may
17470 * programmatically create requests not associated with any profile.
17471 */
17472 readonly profile: TestRunProfile | undefined;
17473
17474 /**
17475 * Whether the profile should run continuously as source code changes. Only
17476 * relevant for profiles that set {@link TestRunProfile.supportsContinuousRun}.
17477 */
17478 readonly continuous?: boolean;
17479
17480 /**
17481 * Controls how test Test Results view is focused. If true, the editor
17482 * will keep the maintain the user's focus. If false, the editor will
17483 * prefer to move focus into the Test Results view, although
17484 * this may be configured by users.
17485 */
17486 readonly preserveFocus: boolean;
17487
17488 /**
17489 * @param include Array of specific tests to run, or undefined to run all tests
17490 * @param exclude An array of tests to exclude from the run.
17491 * @param profile The run profile used for this request.
17492 * @param continuous Whether to run tests continuously as source changes.
17493 * @param preserveFocus Whether to preserve the user's focus when the run is started
17494 */
17495 constructor(include?: readonly TestItem[], exclude?: readonly TestItem[], profile?: TestRunProfile, continuous?: boolean, preserveFocus?: boolean);
17496 }
17497
17498 /**
17499 * A TestRun represents an in-progress or completed test run and
17500 * provides methods to report the state of individual tests in the run.
17501 */
17502 export interface TestRun {
17503 /**
17504 * The human-readable name of the run. This can be used to
17505 * disambiguate multiple sets of results in a test run. It is useful if
17506 * tests are run across multiple platforms, for example.
17507 */
17508 readonly name: string | undefined;
17509
17510 /**
17511 * A cancellation token which will be triggered when the test run is
17512 * canceled from the UI.
17513 */
17514 readonly token: CancellationToken;
17515
17516 /**
17517 * Whether the test run will be persisted across reloads by the editor.
17518 */
17519 readonly isPersisted: boolean;
17520
17521 /**
17522 * Indicates a test is queued for later execution.
17523 * @param test Test item to update.
17524 */
17525 enqueued(test: TestItem): void;
17526
17527 /**
17528 * Indicates a test has started running.
17529 * @param test Test item to update.
17530 */
17531 started(test: TestItem): void;
17532
17533 /**
17534 * Indicates a test has been skipped.
17535 * @param test Test item to update.
17536 */
17537 skipped(test: TestItem): void;
17538
17539 /**
17540 * Indicates a test has failed. You should pass one or more
17541 * {@link TestMessage TestMessages} to describe the failure.
17542 * @param test Test item to update.
17543 * @param message Messages associated with the test failure.
17544 * @param duration How long the test took to execute, in milliseconds.
17545 */
17546 failed(test: TestItem, message: TestMessage | readonly TestMessage[], duration?: number): void;
17547
17548 /**
17549 * Indicates a test has errored. You should pass one or more
17550 * {@link TestMessage TestMessages} to describe the failure. This differs
17551 * from the "failed" state in that it indicates a test that couldn't be
17552 * executed at all, from a compilation error for example.
17553 * @param test Test item to update.
17554 * @param message Messages associated with the test failure.
17555 * @param duration How long the test took to execute, in milliseconds.
17556 */
17557 errored(test: TestItem, message: TestMessage | readonly TestMessage[], duration?: number): void;
17558
17559 /**
17560 * Indicates a test has passed.
17561 * @param test Test item to update.
17562 * @param duration How long the test took to execute, in milliseconds.
17563 */
17564 passed(test: TestItem, duration?: number): void;
17565
17566 /**
17567 * Appends raw output from the test runner. On the user's request, the
17568 * output will be displayed in a terminal. ANSI escape sequences,
17569 * such as colors and text styles, are supported. New lines must be given
17570 * as CRLF (`\r\n`) rather than LF (`\n`).
17571 *
17572 * @param output Output text to append.
17573 * @param location Indicate that the output was logged at the given
17574 * location.
17575 * @param test Test item to associate the output with.
17576 */
17577 appendOutput(output: string, location?: Location, test?: TestItem): void;
17578
17579 /**
17580 * Adds coverage for a file in the run.
17581 */
17582 addCoverage(fileCoverage: FileCoverage): void;
17583
17584 /**
17585 * Signals the end of the test run. Any tests included in the run whose
17586 * states have not been updated will have their state reset.
17587 */
17588 end(): void;
17589
17590 /**
17591 * An event fired when the editor is no longer interested in data
17592 * associated with the test run.
17593 */
17594 onDidDispose: Event<void>;
17595 }
17596
17597 /**
17598 * Collection of test items, found in {@link TestItem.children} and
17599 * {@link TestController.items}.
17600 */
17601 export interface TestItemCollection extends Iterable<[id: string, testItem: TestItem]> {
17602 /**
17603 * Gets the number of items in the collection.
17604 */
17605 readonly size: number;
17606
17607 /**
17608 * Replaces the items stored by the collection.
17609 * @param items Items to store.
17610 */
17611 replace(items: readonly TestItem[]): void;
17612
17613 /**
17614 * Iterate over each entry in this collection.
17615 *
17616 * @param callback Function to execute for each entry.
17617 * @param thisArg The `this` context used when invoking the handler function.
17618 */
17619 forEach(callback: (item: TestItem, collection: TestItemCollection) => unknown, thisArg?: any): void;
17620
17621 /**
17622 * Adds the test item to the children. If an item with the same ID already
17623 * exists, it'll be replaced.
17624 * @param item Item to add.
17625 */
17626 add(item: TestItem): void;
17627
17628 /**
17629 * Removes a single test item from the collection.
17630 * @param itemId Item ID to delete.
17631 */
17632 delete(itemId: string): void;
17633
17634 /**
17635 * Efficiently gets a test item by ID, if it exists, in the children.
17636 * @param itemId Item ID to get.
17637 * @returns The found item or undefined if it does not exist.
17638 */
17639 get(itemId: string): TestItem | undefined;
17640 }
17641
17642 /**
17643 * An item shown in the "test explorer" view.
17644 *
17645 * A `TestItem` can represent either a test suite or a test itself, since
17646 * they both have similar capabilities.
17647 */
17648 export interface TestItem {
17649 /**
17650 * Identifier for the `TestItem`. This is used to correlate
17651 * test results and tests in the document with those in the workspace
17652 * (test explorer). This cannot change for the lifetime of the `TestItem`,
17653 * and must be unique among its parent's direct children.
17654 */
17655 readonly id: string;
17656
17657 /**
17658 * URI this `TestItem` is associated with. May be a file or directory.
17659 */
17660 readonly uri: Uri | undefined;
17661
17662 /**
17663 * The children of this test item. For a test suite, this may contain the
17664 * individual test cases or nested suites.
17665 */
17666 readonly children: TestItemCollection;
17667
17668 /**
17669 * The parent of this item. It's set automatically, and is undefined
17670 * top-level items in the {@link TestController.items} and for items that
17671 * aren't yet included in another item's {@link TestItem.children children}.
17672 */
17673 readonly parent: TestItem | undefined;
17674
17675 /**
17676 * Tags associated with this test item. May be used in combination with
17677 * {@link TestRunProfile.tag tags}, or simply as an organizational feature.
17678 */
17679 tags: readonly TestTag[];
17680
17681 /**
17682 * Indicates whether this test item may have children discovered by resolving.
17683 *
17684 * If true, this item is shown as expandable in the Test Explorer view and
17685 * expanding the item will cause {@link TestController.resolveHandler}
17686 * to be invoked with the item.
17687 *
17688 * Default to `false`.
17689 */
17690 canResolveChildren: boolean;
17691
17692 /**
17693 * Controls whether the item is shown as "busy" in the Test Explorer view.
17694 * This is useful for showing status while discovering children.
17695 *
17696 * Defaults to `false`.
17697 */
17698 busy: boolean;
17699
17700 /**
17701 * Display name describing the test case.
17702 */
17703 label: string;
17704
17705 /**
17706 * Optional description that appears next to the label.
17707 */
17708 description?: string;
17709
17710 /**
17711 * A string that should be used when comparing this item
17712 * with other items. When `falsy` the {@link TestItem.label label}
17713 * is used.
17714 */
17715 sortText?: string | undefined;
17716
17717 /**
17718 * Location of the test item in its {@link TestItem.uri uri}.
17719 *
17720 * This is only meaningful if the `uri` points to a file.
17721 */
17722 range: Range | undefined;
17723
17724 /**
17725 * Optional error encountered while loading the test.
17726 *
17727 * Note that this is not a test result and should only be used to represent errors in
17728 * test discovery, such as syntax errors.
17729 */
17730 error: string | MarkdownString | undefined;
17731 }
17732
17733 /**
17734 * Message associated with the test state. Can be linked to a specific
17735 * source range -- useful for assertion failures, for example.
17736 */
17737 export class TestMessage {
17738 /**
17739 * Human-readable message text to display.
17740 */
17741 message: string | MarkdownString;
17742
17743 /**
17744 * Expected test output. If given with {@link TestMessage.actualOutput actualOutput }, a diff view will be shown.
17745 */
17746 expectedOutput?: string;
17747
17748 /**
17749 * Actual test output. If given with {@link TestMessage.expectedOutput expectedOutput }, a diff view will be shown.
17750 */
17751 actualOutput?: string;
17752
17753 /**
17754 * Associated file location.
17755 */
17756 location?: Location;
17757
17758 /**
17759 * Context value of the test item. This can be used to contribute message-
17760 * specific actions to the test peek view. The value set here can be found
17761 * in the `testMessage` property of the following `menus` contribution points:
17762 *
17763 * - `testing/message/context` - context menu for the message in the results tree
17764 * - `testing/message/content` - a prominent button overlaying editor content where
17765 * the message is displayed.
17766 *
17767 * For example:
17768 *
17769 * ```json
17770 * "contributes": {
17771 * "menus": {
17772 * "testing/message/content": [
17773 * {
17774 * "command": "extension.deleteCommentThread",
17775 * "when": "testMessage == canApplyRichDiff"
17776 * }
17777 * ]
17778 * }
17779 * }
17780 * ```
17781 *
17782 * The command will be called with an object containing:
17783 * - `test`: the {@link TestItem} the message is associated with, *if* it
17784 * is still present in the {@link TestController.items} collection.
17785 * - `message`: the {@link TestMessage} instance.
17786 */
17787 contextValue?: string;
17788
17789 /**
17790 * Creates a new TestMessage that will present as a diff in the editor.
17791 * @param message Message to display to the user.
17792 * @param expected Expected output.
17793 * @param actual Actual output.
17794 */
17795 static diff(message: string | MarkdownString, expected: string, actual: string): TestMessage;
17796
17797 /**
17798 * Creates a new TestMessage instance.
17799 * @param message The message to show to the user.
17800 */
17801 constructor(message: string | MarkdownString);
17802 }
17803
17804 /**
17805 * A class that contains information about a covered resource. A count can
17806 * be give for lines, branches, and declarations in a file.
17807 */
17808 export class TestCoverageCount {
17809 /**
17810 * Number of items covered in the file.
17811 */
17812 covered: number;
17813 /**
17814 * Total number of covered items in the file.
17815 */
17816 total: number;
17817
17818 /**
17819 * @param covered Value for {@link TestCoverageCount.covered}
17820 * @param total Value for {@link TestCoverageCount.total}
17821 */
17822 constructor(covered: number, total: number);
17823 }
17824
17825 /**
17826 * Contains coverage metadata for a file.
17827 */
17828 export class FileCoverage {
17829 /**
17830 * File URI.
17831 */
17832 readonly uri: Uri;
17833
17834 /**
17835 * Statement coverage information. If the reporter does not provide statement
17836 * coverage information, this can instead be used to represent line coverage.
17837 */
17838 statementCoverage: TestCoverageCount;
17839
17840 /**
17841 * Branch coverage information.
17842 */
17843 branchCoverage?: TestCoverageCount;
17844
17845 /**
17846 * Declaration coverage information. Depending on the reporter and
17847 * language, this may be types such as functions, methods, or namespaces.
17848 */
17849 declarationCoverage?: TestCoverageCount;
17850
17851 /**
17852 * Creates a {@link FileCoverage} instance with counts filled in from
17853 * the coverage details.
17854 * @param uri Covered file URI
17855 * @param detailed Detailed coverage information
17856 */
17857 static fromDetails(uri: Uri, details: readonly FileCoverageDetail[]): FileCoverage;
17858
17859 /**
17860 * @param uri Covered file URI
17861 * @param statementCoverage Statement coverage information. If the reporter
17862 * does not provide statement coverage information, this can instead be
17863 * used to represent line coverage.
17864 * @param branchCoverage Branch coverage information
17865 * @param declarationCoverage Declaration coverage information
17866 */
17867 constructor(
17868 uri: Uri,
17869 statementCoverage: TestCoverageCount,
17870 branchCoverage?: TestCoverageCount,
17871 declarationCoverage?: TestCoverageCount,
17872 );
17873 }
17874
17875 /**
17876 * Contains coverage information for a single statement or line.
17877 */
17878 export class StatementCoverage {
17879 /**
17880 * The number of times this statement was executed, or a boolean indicating
17881 * whether it was executed if the exact count is unknown. If zero or false,
17882 * the statement will be marked as un-covered.
17883 */
17884 executed: number | boolean;
17885
17886 /**
17887 * Statement location.
17888 */
17889 location: Position | Range;
17890
17891 /**
17892 * Coverage from branches of this line or statement. If it's not a
17893 * conditional, this will be empty.
17894 */
17895 branches: BranchCoverage[];
17896
17897 /**
17898 * @param location The statement position.
17899 * @param executed The number of times this statement was executed, or a
17900 * boolean indicating whether it was executed if the exact count is
17901 * unknown. If zero or false, the statement will be marked as un-covered.
17902 * @param branches Coverage from branches of this line. If it's not a
17903 * conditional, this should be omitted.
17904 */
17905 constructor(executed: number | boolean, location: Position | Range, branches?: BranchCoverage[]);
17906 }
17907
17908 /**
17909 * Contains coverage information for a branch of a {@link StatementCoverage}.
17910 */
17911 export class BranchCoverage {
17912 /**
17913 * The number of times this branch was executed, or a boolean indicating
17914 * whether it was executed if the exact count is unknown. If zero or false,
17915 * the branch will be marked as un-covered.
17916 */
17917 executed: number | boolean;
17918
17919 /**
17920 * Branch location.
17921 */
17922 location?: Position | Range;
17923
17924 /**
17925 * Label for the branch, used in the context of "the ${label} branch was
17926 * not taken," for example.
17927 */
17928 label?: string;
17929
17930 /**
17931 * @param executed The number of times this branch was executed, or a
17932 * boolean indicating whether it was executed if the exact count is
17933 * unknown. If zero or false, the branch will be marked as un-covered.
17934 * @param location The branch position.
17935 */
17936 constructor(executed: number | boolean, location?: Position | Range, label?: string);
17937 }
17938
17939 /**
17940 * Contains coverage information for a declaration. Depending on the reporter
17941 * and language, this may be types such as functions, methods, or namespaces.
17942 */
17943 export class DeclarationCoverage {
17944 /**
17945 * Name of the declaration.
17946 */
17947 name: string;
17948
17949 /**
17950 * The number of times this declaration was executed, or a boolean
17951 * indicating whether it was executed if the exact count is unknown. If
17952 * zero or false, the declaration will be marked as un-covered.
17953 */
17954 executed: number | boolean;
17955
17956 /**
17957 * Declaration location.
17958 */
17959 location: Position | Range;
17960
17961 /**
17962 * @param executed The number of times this declaration was executed, or a
17963 * boolean indicating whether it was executed if the exact count is
17964 * unknown. If zero or false, the declaration will be marked as un-covered.
17965 * @param location The declaration position.
17966 */
17967 constructor(name: string, executed: number | boolean, location: Position | Range);
17968 }
17969
17970 /**
17971 * Coverage details returned from {@link TestRunProfile.loadDetailedCoverage}.
17972 */
17973 export type FileCoverageDetail = StatementCoverage | DeclarationCoverage;
17974
17975 /**
17976 * The tab represents a single text based resource.
17977 */
17978 export class TabInputText {
17979 /**
17980 * The uri represented by the tab.
17981 */
17982 readonly uri: Uri;
17983 /**
17984 * Constructs a text tab input with the given URI.
17985 * @param uri The URI of the tab.
17986 */
17987 constructor(uri: Uri);
17988 }
17989
17990 /**
17991 * The tab represents two text based resources
17992 * being rendered as a diff.
17993 */
17994 export class TabInputTextDiff {
17995 /**
17996 * The uri of the original text resource.
17997 */
17998 readonly original: Uri;
17999 /**
18000 * The uri of the modified text resource.
18001 */
18002 readonly modified: Uri;
18003 /**
18004 * Constructs a new text diff tab input with the given URIs.
18005 * @param original The uri of the original text resource.
18006 * @param modified The uri of the modified text resource.
18007 */
18008 constructor(original: Uri, modified: Uri);
18009 }
18010
18011 /**
18012 * The tab represents a custom editor.
18013 */
18014 export class TabInputCustom {
18015 /**
18016 * The uri that the tab is representing.
18017 */
18018 readonly uri: Uri;
18019 /**
18020 * The type of custom editor.
18021 */
18022 readonly viewType: string;
18023 /**
18024 * Constructs a custom editor tab input.
18025 * @param uri The uri of the tab.
18026 * @param viewType The viewtype of the custom editor.
18027 */
18028 constructor(uri: Uri, viewType: string);
18029 }
18030
18031 /**
18032 * The tab represents a webview.
18033 */
18034 export class TabInputWebview {
18035 /**
18036 * The type of webview. Maps to {@linkcode WebviewPanel.viewType WebviewPanel's viewType}
18037 */
18038 readonly viewType: string;
18039 /**
18040 * Constructs a webview tab input with the given view type.
18041 * @param viewType The type of webview. Maps to {@linkcode WebviewPanel.viewType WebviewPanel's viewType}
18042 */
18043 constructor(viewType: string);
18044 }
18045
18046 /**
18047 * The tab represents a notebook.
18048 */
18049 export class TabInputNotebook {
18050 /**
18051 * The uri that the tab is representing.
18052 */
18053 readonly uri: Uri;
18054 /**
18055 * The type of notebook. Maps to {@linkcode NotebookDocument.notebookType NotebookDocuments's notebookType}
18056 */
18057 readonly notebookType: string;
18058 /**
18059 * Constructs a new tab input for a notebook.
18060 * @param uri The uri of the notebook.
18061 * @param notebookType The type of notebook. Maps to {@linkcode NotebookDocument.notebookType NotebookDocuments's notebookType}
18062 */
18063 constructor(uri: Uri, notebookType: string);
18064 }
18065
18066 /**
18067 * The tabs represents two notebooks in a diff configuration.
18068 */
18069 export class TabInputNotebookDiff {
18070 /**
18071 * The uri of the original notebook.
18072 */
18073 readonly original: Uri;
18074 /**
18075 * The uri of the modified notebook.
18076 */
18077 readonly modified: Uri;
18078 /**
18079 * The type of notebook. Maps to {@linkcode NotebookDocument.notebookType NotebookDocuments's notebookType}
18080 */
18081 readonly notebookType: string;
18082 /**
18083 * Constructs a notebook diff tab input.
18084 * @param original The uri of the original unmodified notebook.
18085 * @param modified The uri of the modified notebook.
18086 * @param notebookType The type of notebook. Maps to {@linkcode NotebookDocument.notebookType NotebookDocuments's notebookType}
18087 */
18088 constructor(original: Uri, modified: Uri, notebookType: string);
18089 }
18090
18091 /**
18092 * The tab represents a terminal in the editor area.
18093 */
18094 export class TabInputTerminal {
18095 /**
18096 * Constructs a terminal tab input.
18097 */
18098 constructor();
18099 }
18100
18101 /**
18102 * Represents a tab within a {@link TabGroup group of tabs}.
18103 * Tabs are merely the graphical representation within the editor area.
18104 * A backing editor is not a guarantee.
18105 */
18106 export interface Tab {
18107
18108 /**
18109 * The text displayed on the tab.
18110 */
18111 readonly label: string;
18112
18113 /**
18114 * The group which the tab belongs to.
18115 */
18116 readonly group: TabGroup;
18117
18118 /**
18119 * Defines the structure of the tab i.e. text, notebook, custom, etc.
18120 * Resource and other useful properties are defined on the tab kind.
18121 */
18122 readonly input: TabInputText | TabInputTextDiff | TabInputCustom | TabInputWebview | TabInputNotebook | TabInputNotebookDiff | TabInputTerminal | unknown;
18123
18124 /**
18125 * Whether or not the tab is currently active.
18126 * This is dictated by being the selected tab in the group.
18127 */
18128 readonly isActive: boolean;
18129
18130 /**
18131 * Whether or not the dirty indicator is present on the tab.
18132 */
18133 readonly isDirty: boolean;
18134
18135 /**
18136 * Whether or not the tab is pinned (pin icon is present).
18137 */
18138 readonly isPinned: boolean;
18139
18140 /**
18141 * Whether or not the tab is in preview mode.
18142 */
18143 readonly isPreview: boolean;
18144 }
18145
18146 /**
18147 * An event describing change to tabs.
18148 */
18149 export interface TabChangeEvent {
18150 /**
18151 * The tabs that have been opened.
18152 */
18153 readonly opened: readonly Tab[];
18154 /**
18155 * The tabs that have been closed.
18156 */
18157 readonly closed: readonly Tab[];
18158 /**
18159 * Tabs that have changed, e.g have changed
18160 * their {@link Tab.isActive active} state.
18161 */
18162 readonly changed: readonly Tab[];
18163 }
18164
18165 /**
18166 * An event describing changes to tab groups.
18167 */
18168 export interface TabGroupChangeEvent {
18169 /**
18170 * Tab groups that have been opened.
18171 */
18172 readonly opened: readonly TabGroup[];
18173 /**
18174 * Tab groups that have been closed.
18175 */
18176 readonly closed: readonly TabGroup[];
18177 /**
18178 * Tab groups that have changed, e.g have changed
18179 * their {@link TabGroup.isActive active} state.
18180 */
18181 readonly changed: readonly TabGroup[];
18182 }
18183
18184 /**
18185 * Represents a group of tabs. A tab group itself consists of multiple tabs.
18186 */
18187 export interface TabGroup {
18188 /**
18189 * Whether or not the group is currently active.
18190 *
18191 * *Note* that only one tab group is active at a time, but that multiple tab
18192 * groups can have an {@link activeTab active tab}.
18193 *
18194 * @see {@link Tab.isActive}
18195 */
18196 readonly isActive: boolean;
18197
18198 /**
18199 * The view column of the group.
18200 */
18201 readonly viewColumn: ViewColumn;
18202
18203 /**
18204 * The active {@link Tab tab} in the group. This is the tab whose contents are currently
18205 * being rendered.
18206 *
18207 * *Note* that there can be one active tab per group but there can only be one {@link TabGroups.activeTabGroup active group}.
18208 */
18209 readonly activeTab: Tab | undefined;
18210
18211 /**
18212 * The list of tabs contained within the group.
18213 * This can be empty if the group has no tabs open.
18214 */
18215 readonly tabs: readonly Tab[];
18216 }
18217
18218 /**
18219 * Represents the main editor area which consists of multiple groups which contain tabs.
18220 */
18221 export interface TabGroups {
18222 /**
18223 * All the groups within the group container.
18224 */
18225 readonly all: readonly TabGroup[];
18226
18227 /**
18228 * The currently active group.
18229 */
18230 readonly activeTabGroup: TabGroup;
18231
18232 /**
18233 * An {@link Event event} which fires when {@link TabGroup tab groups} have changed.
18234 */
18235 readonly onDidChangeTabGroups: Event<TabGroupChangeEvent>;
18236
18237 /**
18238 * An {@link Event event} which fires when {@link Tab tabs} have changed.
18239 */
18240 readonly onDidChangeTabs: Event<TabChangeEvent>;
18241
18242 /**
18243 * Closes the tab. This makes the tab object invalid and the tab
18244 * should no longer be used for further actions.
18245 * Note: In the case of a dirty tab, a confirmation dialog will be shown which may be cancelled. If cancelled the tab is still valid
18246 *
18247 * @param tab The tab to close.
18248 * @param preserveFocus When `true` focus will remain in its current position. If `false` it will jump to the next tab.
18249 * @returns A promise that resolves to `true` when all tabs have been closed.
18250 */
18251 close(tab: Tab | readonly Tab[], preserveFocus?: boolean): Thenable<boolean>;
18252
18253 /**
18254 * Closes the tab group. This makes the tab group object invalid and the tab group
18255 * should no longer be used for further actions.
18256 * @param tabGroup The tab group to close.
18257 * @param preserveFocus When `true` focus will remain in its current position.
18258 * @returns A promise that resolves to `true` when all tab groups have been closed.
18259 */
18260 close(tabGroup: TabGroup | readonly TabGroup[], preserveFocus?: boolean): Thenable<boolean>;
18261 }
18262
18263 /**
18264 * A special value wrapper denoting a value that is safe to not clean.
18265 * This is to be used when you can guarantee no identifiable information is contained in the value and the cleaning is improperly redacting it.
18266 */
18267 export class TelemetryTrustedValue<T = any> {
18268
18269 /**
18270 * The value that is trusted to not contain PII.
18271 */
18272 readonly value: T;
18273
18274 /**
18275 * Creates a new telementry trusted value.
18276 *
18277 * @param value A value to trust
18278 */
18279 constructor(value: T);
18280 }
18281
18282 /**
18283 * A telemetry logger which can be used by extensions to log usage and error telementry.
18284 *
18285 * A logger wraps around an {@link TelemetrySender sender} but it guarantees that
18286 * - user settings to disable or tweak telemetry are respected, and that
18287 * - potential sensitive data is removed
18288 *
18289 * It also enables an "echo UI" that prints whatever data is send and it allows the editor
18290 * to forward unhandled errors to the respective extensions.
18291 *
18292 * To get an instance of a `TelemetryLogger`, use
18293 * {@link env.createTelemetryLogger `createTelemetryLogger`}.
18294 */
18295 export interface TelemetryLogger {
18296
18297 /**
18298 * An {@link Event} which fires when the enablement state of usage or error telemetry changes.
18299 */
18300 readonly onDidChangeEnableStates: Event<TelemetryLogger>;
18301
18302 /**
18303 * Whether or not usage telemetry is enabled for this logger.
18304 */
18305 readonly isUsageEnabled: boolean;
18306
18307 /**
18308 * Whether or not error telemetry is enabled for this logger.
18309 */
18310 readonly isErrorsEnabled: boolean;
18311
18312 /**
18313 * Log a usage event.
18314 *
18315 * After completing cleaning, telemetry setting checks, and data mix-in calls `TelemetrySender.sendEventData` to log the event.
18316 * Automatically supports echoing to extension telemetry output channel.
18317 * @param eventName The event name to log
18318 * @param data The data to log
18319 */
18320 logUsage(eventName: string, data?: Record<string, any | TelemetryTrustedValue>): void;
18321
18322 /**
18323 * Log an error event.
18324 *
18325 * After completing cleaning, telemetry setting checks, and data mix-in calls `TelemetrySender.sendEventData` to log the event. Differs from `logUsage` in that it will log the event if the telemetry setting is Error+.
18326 * Automatically supports echoing to extension telemetry output channel.
18327 * @param eventName The event name to log
18328 * @param data The data to log
18329 */
18330 logError(eventName: string, data?: Record<string, any | TelemetryTrustedValue>): void;
18331
18332 /**
18333 * Log an error event.
18334 *
18335 * Calls `TelemetrySender.sendErrorData`. Does cleaning, telemetry checks, and data mix-in.
18336 * Automatically supports echoing to extension telemetry output channel.
18337 * Will also automatically log any exceptions thrown within the extension host process.
18338 * @param error The error object which contains the stack trace cleaned of PII
18339 * @param data Additional data to log alongside the stack trace
18340 */
18341 logError(error: Error, data?: Record<string, any | TelemetryTrustedValue>): void;
18342
18343 /**
18344 * Dispose this object and free resources.
18345 */
18346 dispose(): void;
18347 }
18348
18349 /**
18350 * The telemetry sender is the contract between a telemetry logger and some telemetry service. **Note** that extensions must NOT
18351 * call the methods of their sender directly as the logger provides extra guards and cleaning.
18352 *
18353 * ```js
18354 * const sender: vscode.TelemetrySender = {...};
18355 * const logger = vscode.env.createTelemetryLogger(sender);
18356 *
18357 * // GOOD - uses the logger
18358 * logger.logUsage('myEvent', { myData: 'myValue' });
18359 *
18360 * // BAD - uses the sender directly: no data cleansing, ignores user settings, no echoing to the telemetry output channel etc
18361 * sender.logEvent('myEvent', { myData: 'myValue' });
18362 * ```
18363 */
18364 export interface TelemetrySender {
18365 /**
18366 * Function to send event data without a stacktrace. Used within a {@link TelemetryLogger}
18367 *
18368 * @param eventName The name of the event which you are logging
18369 * @param data A serializable key value pair that is being logged
18370 */
18371 sendEventData(eventName: string, data?: Record<string, any>): void;
18372
18373 /**
18374 * Function to send an error. Used within a {@link TelemetryLogger}
18375 *
18376 * @param error The error being logged
18377 * @param data Any additional data to be collected with the exception
18378 */
18379 sendErrorData(error: Error, data?: Record<string, any>): void;
18380
18381 /**
18382 * Optional flush function which will give this sender a chance to send any remaining events
18383 * as its {@link TelemetryLogger} is being disposed
18384 */
18385 flush?(): void | Thenable<void>;
18386 }
18387
18388 /**
18389 * Options for creating a {@link TelemetryLogger}
18390 */
18391 export interface TelemetryLoggerOptions {
18392 /**
18393 * Whether or not you want to avoid having the built-in common properties such as os, extension name, etc injected into the data object.
18394 * Defaults to `false` if not defined.
18395 */
18396 readonly ignoreBuiltInCommonProperties?: boolean;
18397
18398 /**
18399 * Whether or not unhandled errors on the extension host caused by your extension should be logged to your sender.
18400 * Defaults to `false` if not defined.
18401 */
18402 readonly ignoreUnhandledErrors?: boolean;
18403
18404 /**
18405 * Any additional common properties which should be injected into the data object.
18406 */
18407 readonly additionalCommonProperties?: Record<string, any>;
18408 }
18409
18410 /**
18411 * Represents a user request in chat history.
18412 */
18413 export class ChatRequestTurn {
18414 /**
18415 * The prompt as entered by the user.
18416 *
18417 * Information about references used in this request is stored in {@link ChatRequestTurn.references}.
18418 *
18419 * *Note* that the {@link ChatParticipant.name name} of the participant and the {@link ChatCommand.name command}
18420 * are not part of the prompt.
18421 */
18422 readonly prompt: string;
18423
18424 /**
18425 * The id of the chat participant to which this request was directed.
18426 */
18427 readonly participant: string;
18428
18429 /**
18430 * The name of the {@link ChatCommand command} that was selected for this request.
18431 */
18432 readonly command?: string;
18433
18434 /**
18435 * The references that were used in this message.
18436 */
18437 readonly references: ChatPromptReference[];
18438
18439 /**
18440 * @hidden
18441 */
18442 private constructor(prompt: string, command: string | undefined, references: ChatPromptReference[], participant: string);
18443 }
18444
18445 /**
18446 * Represents a chat participant's response in chat history.
18447 */
18448 export class ChatResponseTurn {
18449 /**
18450 * The content that was received from the chat participant. Only the stream parts that represent actual content (not metadata) are represented.
18451 */
18452 readonly response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart>;
18453
18454 /**
18455 * The result that was received from the chat participant.
18456 */
18457 readonly result: ChatResult;
18458
18459 /**
18460 * The id of the chat participant that this response came from.
18461 */
18462 readonly participant: string;
18463
18464 /**
18465 * The name of the command that this response came from.
18466 */
18467 readonly command?: string;
18468
18469 /**
18470 * @hidden
18471 */
18472 private constructor(response: ReadonlyArray<ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart | ChatResponseCommandButtonPart>, result: ChatResult, participant: string);
18473 }
18474
18475 /**
18476 * Extra context passed to a participant.
18477 */
18478 export interface ChatContext {
18479 /**
18480 * All of the chat messages so far in the current chat session. Currently, only chat messages for the current participant are included.
18481 */
18482 readonly history: ReadonlyArray<ChatRequestTurn | ChatResponseTurn>;
18483 }
18484
18485 /**
18486 * Represents an error result from a chat request.
18487 */
18488 export interface ChatErrorDetails {
18489 /**
18490 * An error message that is shown to the user.
18491 */
18492 message: string;
18493
18494 /**
18495 * If set to true, the response will be partly blurred out.
18496 */
18497 responseIsFiltered?: boolean;
18498 }
18499
18500 /**
18501 * The result of a chat request.
18502 */
18503 export interface ChatResult {
18504 /**
18505 * If the request resulted in an error, this property defines the error details.
18506 */
18507 errorDetails?: ChatErrorDetails;
18508
18509 /**
18510 * Arbitrary metadata for this result. Can be anything, but must be JSON-stringifyable.
18511 */
18512 readonly metadata?: { readonly [key: string]: any };
18513 }
18514
18515 /**
18516 * Represents the type of user feedback received.
18517 */
18518 export enum ChatResultFeedbackKind {
18519 /**
18520 * The user marked the result as unhelpful.
18521 */
18522 Unhelpful = 0,
18523
18524 /**
18525 * The user marked the result as helpful.
18526 */
18527 Helpful = 1,
18528 }
18529
18530 /**
18531 * Represents user feedback for a result.
18532 */
18533 export interface ChatResultFeedback {
18534 /**
18535 * The ChatResult for which the user is providing feedback.
18536 * This object has the same properties as the result returned from the participant callback, including `metadata`, but is not the same instance.
18537 */
18538 readonly result: ChatResult;
18539
18540 /**
18541 * The kind of feedback that was received.
18542 */
18543 readonly kind: ChatResultFeedbackKind;
18544 }
18545
18546 /**
18547 * A followup question suggested by the participant.
18548 */
18549 export interface ChatFollowup {
18550 /**
18551 * The message to send to the chat.
18552 */
18553 prompt: string;
18554
18555 /**
18556 * A title to show the user. The prompt will be shown by default, when this is unspecified.
18557 */
18558 label?: string;
18559
18560 /**
18561 * By default, the followup goes to the same participant/command. But this property can be set to invoke a different participant by ID.
18562 * Followups can only invoke a participant that was contributed by the same extension.
18563 */
18564 participant?: string;
18565
18566 /**
18567 * By default, the followup goes to the same participant/command. But this property can be set to invoke a different command.
18568 */
18569 command?: string;
18570 }
18571
18572 /**
18573 * Will be invoked once after each request to get suggested followup questions to show the user. The user can click the followup to send it to the chat.
18574 */
18575 export interface ChatFollowupProvider {
18576 /**
18577 * Provide followups for the given result.
18578 * @param result This object has the same properties as the result returned from the participant callback, including `metadata`, but is not the same instance.
18579 * @param token A cancellation token.
18580 */
18581 provideFollowups(result: ChatResult, context: ChatContext, token: CancellationToken): ProviderResult<ChatFollowup[]>;
18582 }
18583
18584 /**
18585 * A chat request handler is a callback that will be invoked when a request is made to a chat participant.
18586 */
18587 export type ChatRequestHandler = (request: ChatRequest, context: ChatContext, response: ChatResponseStream, token: CancellationToken) => ProviderResult<ChatResult | void>;
18588
18589 /**
18590 * A chat participant can be invoked by the user in a chat session, using the `@` prefix. When it is invoked, it handles the chat request and is solely
18591 * responsible for providing a response to the user. A ChatParticipant is created using {@link chat.createChatParticipant}.
18592 */
18593 export interface ChatParticipant {
18594 /**
18595 * A unique ID for this participant.
18596 */
18597 readonly id: string;
18598
18599 /**
18600 * An icon for the participant shown in UI.
18601 */
18602 iconPath?: Uri | {
18603 /**
18604 * The icon path for the light theme.
18605 */
18606 light: Uri;
18607 /**
18608 * The icon path for the dark theme.
18609 */
18610 dark: Uri;
18611 } | ThemeIcon;
18612
18613 /**
18614 * The handler for requests to this participant.
18615 */
18616 requestHandler: ChatRequestHandler;
18617
18618 /**
18619 * This provider will be called once after each request to retrieve suggested followup questions.
18620 */
18621 followupProvider?: ChatFollowupProvider;
18622
18623 /**
18624 * An event that fires whenever feedback for a result is received, e.g. when a user up- or down-votes
18625 * a result.
18626 *
18627 * The passed {@link ChatResultFeedback.result result} is guaranteed to be the same instance that was
18628 * previously returned from this chat participant.
18629 */
18630 onDidReceiveFeedback: Event<ChatResultFeedback>;
18631
18632 /**
18633 * Dispose this participant and free resources.
18634 */
18635 dispose(): void;
18636 }
18637
18638 /**
18639 * A reference to a value that the user added to their chat request.
18640 */
18641 export interface ChatPromptReference {
18642 /**
18643 * A unique identifier for this kind of reference.
18644 */
18645 readonly id: string;
18646
18647 /**
18648 * The start and end index of the reference in the {@link ChatRequest.prompt prompt}. When undefined, the reference was not part of the prompt text.
18649 *
18650 * *Note* that the indices take the leading `#`-character into account which means they can
18651 * used to modify the prompt as-is.
18652 */
18653 readonly range?: [start: number, end: number];
18654
18655 /**
18656 * A description of this value that could be used in an LLM prompt.
18657 */
18658 readonly modelDescription?: string;
18659
18660 /**
18661 * The value of this reference. The `string | Uri | Location` types are used today, but this could expand in the future.
18662 */
18663 readonly value: string | Uri | Location | unknown;
18664 }
18665
18666 /**
18667 * A request to a chat participant.
18668 */
18669 export interface ChatRequest {
18670 /**
18671 * The prompt as entered by the user.
18672 *
18673 * Information about references used in this request is stored in {@link ChatRequest.references}.
18674 *
18675 * *Note* that the {@link ChatParticipant.name name} of the participant and the {@link ChatCommand.name command}
18676 * are not part of the prompt.
18677 */
18678 readonly prompt: string;
18679
18680 /**
18681 * The name of the {@link ChatCommand command} that was selected for this request.
18682 */
18683 readonly command: string | undefined;
18684
18685 /**
18686 * The list of references and their values that are referenced in the prompt.
18687 *
18688 * *Note* that the prompt contains references as authored and that it is up to the participant
18689 * to further modify the prompt, for instance by inlining reference values or creating links to
18690 * headings which contain the resolved values. References are sorted in reverse by their range
18691 * in the prompt. That means the last reference in the prompt is the first in this list. This simplifies
18692 * string-manipulation of the prompt.
18693 */
18694 readonly references: readonly ChatPromptReference[];
18695 }
18696
18697 /**
18698 * The ChatResponseStream is how a participant is able to return content to the chat view. It provides several methods for streaming different types of content
18699 * which will be rendered in an appropriate way in the chat view. A participant can use the helper method for the type of content it wants to return, or it
18700 * can instantiate a {@link ChatResponsePart} and use the generic {@link ChatResponseStream.push} method to return it.
18701 */
18702 export interface ChatResponseStream {
18703 /**
18704 * Push a markdown part to this stream. Short-hand for
18705 * `push(new ChatResponseMarkdownPart(value))`.
18706 *
18707 * @see {@link ChatResponseStream.push}
18708 * @param value A markdown string or a string that should be interpreted as markdown. The boolean form of {@link MarkdownString.isTrusted} is NOT supported.
18709 */
18710 markdown(value: string | MarkdownString): void;
18711
18712 /**
18713 * Push an anchor part to this stream. Short-hand for
18714 * `push(new ChatResponseAnchorPart(value, title))`.
18715 * An anchor is an inline reference to some type of resource.
18716 *
18717 * @param value A uri, location, or symbol information.
18718 * @param title An optional title that is rendered with value.
18719 */
18720 anchor(value: Uri | Location, title?: string): void;
18721
18722 /**
18723 * Push a command button part to this stream. Short-hand for
18724 * `push(new ChatResponseCommandButtonPart(value, title))`.
18725 *
18726 * @param command A Command that will be executed when the button is clicked.
18727 */
18728 button(command: Command): void;
18729
18730 /**
18731 * Push a filetree part to this stream. Short-hand for
18732 * `push(new ChatResponseFileTreePart(value))`.
18733 *
18734 * @param value File tree data.
18735 * @param baseUri The base uri to which this file tree is relative.
18736 */
18737 filetree(value: ChatResponseFileTree[], baseUri: Uri): void;
18738
18739 /**
18740 * Push a progress part to this stream. Short-hand for
18741 * `push(new ChatResponseProgressPart(value))`.
18742 *
18743 * @param value A progress message
18744 */
18745 progress(value: string): void;
18746
18747 /**
18748 * Push a reference to this stream. Short-hand for
18749 * `push(new ChatResponseReferencePart(value))`.
18750 *
18751 * *Note* that the reference is not rendered inline with the response.
18752 *
18753 * @param value A uri or location
18754 * @param iconPath Icon for the reference shown in UI
18755 */
18756 reference(value: Uri | Location, iconPath?: Uri | ThemeIcon | {
18757 /**
18758 * The icon path for the light theme.
18759 */
18760 light: Uri;
18761 /**
18762 * The icon path for the dark theme.
18763 */
18764 dark: Uri;
18765 }): void;
18766
18767 /**
18768 * Pushes a part to this stream.
18769 *
18770 * @param part A response part, rendered or metadata
18771 */
18772 push(part: ChatResponsePart): void;
18773 }
18774
18775 /**
18776 * Represents a part of a chat response that is formatted as Markdown.
18777 */
18778 export class ChatResponseMarkdownPart {
18779 /**
18780 * A markdown string or a string that should be interpreted as markdown.
18781 */
18782 value: MarkdownString;
18783
18784 /**
18785 * Create a new ChatResponseMarkdownPart.
18786 *
18787 * @param value A markdown string or a string that should be interpreted as markdown. The boolean form of {@link MarkdownString.isTrusted} is NOT supported.
18788 */
18789 constructor(value: string | MarkdownString);
18790 }
18791
18792 /**
18793 * Represents a file tree structure in a chat response.
18794 */
18795 export interface ChatResponseFileTree {
18796 /**
18797 * The name of the file or directory.
18798 */
18799 name: string;
18800
18801 /**
18802 * An array of child file trees, if the current file tree is a directory.
18803 */
18804 children?: ChatResponseFileTree[];
18805 }
18806
18807 /**
18808 * Represents a part of a chat response that is a file tree.
18809 */
18810 export class ChatResponseFileTreePart {
18811 /**
18812 * File tree data.
18813 */
18814 value: ChatResponseFileTree[];
18815
18816 /**
18817 * The base uri to which this file tree is relative
18818 */
18819 baseUri: Uri;
18820
18821 /**
18822 * Create a new ChatResponseFileTreePart.
18823 * @param value File tree data.
18824 * @param baseUri The base uri to which this file tree is relative.
18825 */
18826 constructor(value: ChatResponseFileTree[], baseUri: Uri);
18827 }
18828
18829 /**
18830 * Represents a part of a chat response that is an anchor, that is rendered as a link to a target.
18831 */
18832 export class ChatResponseAnchorPart {
18833 /**
18834 * The target of this anchor.
18835 */
18836 value: Uri | Location;
18837
18838 /**
18839 * An optional title that is rendered with value.
18840 */
18841 title?: string;
18842
18843 /**
18844 * Create a new ChatResponseAnchorPart.
18845 * @param value A uri or location.
18846 * @param title An optional title that is rendered with value.
18847 */
18848 constructor(value: Uri | Location, title?: string);
18849 }
18850
18851 /**
18852 * Represents a part of a chat response that is a progress message.
18853 */
18854 export class ChatResponseProgressPart {
18855 /**
18856 * The progress message
18857 */
18858 value: string;
18859
18860 /**
18861 * Create a new ChatResponseProgressPart.
18862 * @param value A progress message
18863 */
18864 constructor(value: string);
18865 }
18866
18867 /**
18868 * Represents a part of a chat response that is a reference, rendered separately from the content.
18869 */
18870 export class ChatResponseReferencePart {
18871 /**
18872 * The reference target.
18873 */
18874 value: Uri | Location;
18875
18876 /**
18877 * The icon for the reference.
18878 */
18879 iconPath?: Uri | ThemeIcon | {
18880 /**
18881 * The icon path for the light theme.
18882 */
18883 light: Uri;
18884 /**
18885 * The icon path for the dark theme.
18886 */
18887 dark: Uri;
18888 };
18889
18890 /**
18891 * Create a new ChatResponseReferencePart.
18892 * @param value A uri or location
18893 * @param iconPath Icon for the reference shown in UI
18894 */
18895 constructor(value: Uri | Location, iconPath?: Uri | ThemeIcon | {
18896 /**
18897 * The icon path for the light theme.
18898 */
18899 light: Uri;
18900 /**
18901 * The icon path for the dark theme.
18902 */
18903 dark: Uri;
18904 });
18905 }
18906
18907 /**
18908 * Represents a part of a chat response that is a button that executes a command.
18909 */
18910 export class ChatResponseCommandButtonPart {
18911 /**
18912 * The command that will be executed when the button is clicked.
18913 */
18914 value: Command;
18915
18916 /**
18917 * Create a new ChatResponseCommandButtonPart.
18918 * @param value A Command that will be executed when the button is clicked.
18919 */
18920 constructor(value: Command);
18921 }
18922
18923 /**
18924 * Represents the different chat response types.
18925 */
18926 export type ChatResponsePart = ChatResponseMarkdownPart | ChatResponseFileTreePart | ChatResponseAnchorPart
18927 | ChatResponseProgressPart | ChatResponseReferencePart | ChatResponseCommandButtonPart;
18928
18929
18930 /**
18931 * Namespace for chat functionality. Users interact with chat participants by sending messages
18932 * to them in the chat view. Chat participants can respond with markdown or other types of content
18933 * via the {@link ChatResponseStream}.
18934 */
18935 export namespace chat {
18936 /**
18937 * Create a new {@link ChatParticipant chat participant} instance.
18938 *
18939 * @param id A unique identifier for the participant.
18940 * @param handler A request handler for the participant.
18941 * @returns A new chat participant
18942 */
18943 export function createChatParticipant(id: string, handler: ChatRequestHandler): ChatParticipant;
18944 }
18945
18946 /**
18947 * Represents the role of a chat message. This is either the user or the assistant.
18948 */
18949 export enum LanguageModelChatMessageRole {
18950 /**
18951 * The user role, e.g the human interacting with a language model.
18952 */
18953 User = 1,
18954
18955 /**
18956 * The assistant role, e.g. the language model generating responses.
18957 */
18958 Assistant = 2
18959 }
18960
18961 /**
18962 * Represents a message in a chat. Can assume different roles, like user or assistant.
18963 */
18964 export class LanguageModelChatMessage {
18965
18966 /**
18967 * Utility to create a new user message.
18968 *
18969 * @param content The content of the message.
18970 * @param name The optional name of a user for the message.
18971 */
18972 static User(content: string, name?: string): LanguageModelChatMessage;
18973
18974 /**
18975 * Utility to create a new assistant message.
18976 *
18977 * @param content The content of the message.
18978 * @param name The optional name of a user for the message.
18979 */
18980 static Assistant(content: string, name?: string): LanguageModelChatMessage;
18981
18982 /**
18983 * The role of this message.
18984 */
18985 role: LanguageModelChatMessageRole;
18986
18987 /**
18988 * The content of this message.
18989 */
18990 content: string;
18991
18992 /**
18993 * The optional name of a user for this message.
18994 */
18995 name: string | undefined;
18996
18997 /**
18998 * Create a new user message.
18999 *
19000 * @param role The role of the message.
19001 * @param content The content of the message.
19002 * @param name The optional name of a user for the message.
19003 */
19004 constructor(role: LanguageModelChatMessageRole, content: string, name?: string);
19005 }
19006
19007 /**
19008 * Represents a language model response.
19009 *
19010 * @see {@link LanguageModelAccess.chatRequest}
19011 */
19012 export interface LanguageModelChatResponse {
19013
19014 /**
19015 * An async iterable that is a stream of text chunks forming the overall response.
19016 *
19017 * *Note* that this stream will error when during data receiving an error occurs. Consumers of
19018 * the stream should handle the errors accordingly.
19019 *
19020 * To cancel the stream, the consumer can {@link CancellationTokenSource.cancel cancel} the token that was used to make the request
19021 * or break from the for-loop.
19022 *
19023 * @example
19024 * ```ts
19025 * try {
19026 * // consume stream
19027 * for await (const chunk of response.text) {
19028 * console.log(chunk);
19029 * }
19030 *
19031 * } catch(e) {
19032 * // stream ended with an error
19033 * console.error(e);
19034 * }
19035 * ```
19036 */
19037 text: AsyncIterable<string>;
19038 }
19039
19040 /**
19041 * Represents a language model for making chat requests.
19042 *
19043 * @see {@link lm.selectChatModels}
19044 */
19045 export interface LanguageModelChat {
19046
19047 /**
19048 * Human-readable name of the language model.
19049 */
19050 readonly name: string;
19051
19052 /**
19053 * Opaque identifier of the language model.
19054 */
19055 readonly id: string;
19056
19057 /**
19058 * A well-known identifier of the vendor of the language model. An example is `copilot`, but
19059 * values are defined by extensions contributing chat models and need to be looked up with them.
19060 */
19061 readonly vendor: string;
19062
19063 /**
19064 * Opaque family-name of the language model. Values might be `gpt-3.5-turbo`, `gpt4`, `phi2`, or `llama`
19065 * but they are defined by extensions contributing languages and subject to change.
19066 */
19067 readonly family: string;
19068
19069 /**
19070 * Opaque version string of the model. This is defined by the extension contributing the language model
19071 * and subject to change.
19072 */
19073 readonly version: string;
19074
19075 /**
19076 * The maximum number of tokens that can be sent to the model in a single request.
19077 */
19078 readonly maxInputTokens: number;
19079
19080 /**
19081 * Make a chat request using a language model.
19082 *
19083 * *Note* that language model use may be subject to access restrictions and user consent. Calling this function
19084 * for the first time (for a extension) will show a consent dialog to the user and because of that this function
19085 * must _only be called in response to a user action!_ Extension can use {@link LanguageModelAccessInformation.canSendRequest}
19086 * to check if they have the necessary permissions to make a request.
19087 *
19088 * This function will return a rejected promise if making a request to the language model is not
19089 * possible. Reasons for this can be:
19090 *
19091 * - user consent not given, see {@link LanguageModelError.NoPermissions `NoPermissions`}
19092 * - model does not exist anymore, see {@link LanguageModelError.NotFound `NotFound`}
19093 * - quota limits exceeded, see {@link LanguageModelError.Blocked `Blocked`}
19094 * - other issues in which case extension must check {@link LanguageModelError.cause `LanguageModelError.cause`}
19095 *
19096 * @param messages An array of message instances.
19097 * @param options Options that control the request.
19098 * @param token A cancellation token which controls the request. See {@link CancellationTokenSource} for how to create one.
19099 * @returns A thenable that resolves to a {@link LanguageModelChatResponse}. The promise will reject when the request couldn't be made.
19100 */
19101 sendRequest(messages: LanguageModelChatMessage[], options?: LanguageModelChatRequestOptions, token?: CancellationToken): Thenable<LanguageModelChatResponse>;
19102
19103 /**
19104 * Count the number of tokens in a message using the model specific tokenizer-logic.
19105
19106 * @param text A string or a message instance.
19107 * @param token Optional cancellation token. See {@link CancellationTokenSource} for how to create one.
19108 * @returns A thenable that resolves to the number of tokens.
19109 */
19110 countTokens(text: string | LanguageModelChatMessage, token?: CancellationToken): Thenable<number>;
19111 }
19112
19113 /**
19114 * Describes how to select language models for chat requests.
19115 *
19116 * @see {@link lm.selectChatModels}
19117 */
19118 export interface LanguageModelChatSelector {
19119
19120 /**
19121 * A vendor of language models.
19122 * @see {@link LanguageModelChat.vendor}
19123 */
19124 vendor?: string;
19125
19126 /**
19127 * A family of language models.
19128 * @see {@link LanguageModelChat.family}
19129 */
19130 family?: string;
19131
19132 /**
19133 * The version of a language model.
19134 * @see {@link LanguageModelChat.version}
19135 */
19136 version?: string;
19137
19138 /**
19139 * The identifier of a language model.
19140 * @see {@link LanguageModelChat.id}
19141 */
19142 id?: string;
19143 }
19144
19145 /**
19146 * An error type for language model specific errors.
19147 *
19148 * Consumers of language models should check the code property to determine specific
19149 * failure causes, like `if(someError.code === vscode.LanguageModelError.NotFound.name) {...}`
19150 * for the case of referring to an unknown language model. For unspecified errors the `cause`-property
19151 * will contain the actual error.
19152 */
19153 export class LanguageModelError extends Error {
19154
19155 /**
19156 * The requestor does not have permissions to use this
19157 * language model
19158 */
19159 static NoPermissions(message?: string): LanguageModelError;
19160
19161 /**
19162 * The requestor is blocked from using this language model.
19163 */
19164 static Blocked(message?: string): LanguageModelError;
19165
19166 /**
19167 * The language model does not exist.
19168 */
19169 static NotFound(message?: string): LanguageModelError;
19170
19171 /**
19172 * A code that identifies this error.
19173 *
19174 * Possible values are names of errors, like {@linkcode LanguageModelError.NotFound NotFound},
19175 * or `Unknown` for unspecified errors from the language model itself. In the latter case the
19176 * `cause`-property will contain the actual error.
19177 */
19178 readonly code: string;
19179 }
19180
19181 /**
19182 * Options for making a chat request using a language model.
19183 *
19184 * @see {@link LanguageModelChat.sendRequest}
19185 */
19186 export interface LanguageModelChatRequestOptions {
19187
19188 /**
19189 * A human-readable message that explains why access to a language model is needed and what feature is enabled by it.
19190 */
19191 justification?: string;
19192
19193 /**
19194 * A set of options that control the behavior of the language model. These options are specific to the language model
19195 * and need to be lookup in the respective documentation.
19196 */
19197 modelOptions?: { [name: string]: any };
19198 }
19199
19200 /**
19201 * Namespace for language model related functionality.
19202 */
19203 export namespace lm {
19204
19205 /**
19206 * An event that is fired when the set of available chat models changes.
19207 */
19208 export const onDidChangeChatModels: Event<void>;
19209
19210 /**
19211 * Select chat models by a {@link LanguageModelChatSelector selector}. This can yield multiple or no chat models and
19212 * extensions must handle these cases, esp. when no chat model exists, gracefully.
19213 *
19214 * ```ts
19215 * const models = await vscode.lm.selectChatModels({ family: 'gpt-3.5-turbo' });
19216 * if (models.length > 0) {
19217 * const [first] = models;
19218 * const response = await first.sendRequest(...)
19219 * // ...
19220 * } else {
19221 * // NO chat models available
19222 * }
19223 * ```
19224 *
19225 * A selector can be written to broadly match all models of a given vendor or family, or it can narrowly select one model by ID.
19226 * Keep in mind that the available set of models will change over time, but also that prompts may perform differently in
19227 * different models.
19228 *
19229 * *Note* that extensions can hold on to the results returned by this function and use them later. However, when the
19230 * {@link onDidChangeChatModels}-event is fired the list of chat models might have changed and extensions should re-query.
19231 *
19232 * @param selector A chat model selector. When omitted all chat models are returned.
19233 * @returns An array of chat models, can be empty!
19234 */
19235 export function selectChatModels(selector?: LanguageModelChatSelector): Thenable<LanguageModelChat[]>;
19236 }
19237
19238 /**
19239 * Represents extension specific information about the access to language models.
19240 */
19241 export interface LanguageModelAccessInformation {
19242
19243 /**
19244 * An event that fires when access information changes.
19245 */
19246 onDidChange: Event<void>;
19247
19248 /**
19249 * Checks if a request can be made to a language model.
19250 *
19251 * *Note* that calling this function will not trigger a consent UI but just checks for a persisted state.
19252 *
19253 * @param chat A language model chat object.
19254 * @return `true` if a request can be made, `false` if not, `undefined` if the language
19255 * model does not exist or consent hasn't been asked for.
19256 */
19257 canSendRequest(chat: LanguageModelChat): boolean | undefined;
19258 }
19259}
19260
19261/**
19262 * Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise,
19263 * and others. This API makes no assumption about what promise library is being used which
19264 * enables reusing existing code without migrating to a specific promise implementation. Still,
19265 * we recommend the use of native promises which are available in this editor.
19266 */
19267interface Thenable<T> extends PromiseLike<T> { }