UNPKG

506 kBTypeScriptView Raw
1// Type definitions for Visual Studio Code 1.56
2// Project: https://github.com/microsoft/vscode
3// Definitions by: Visual Studio Code Team, Microsoft <https://github.com/microsoft>
4// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
5
6/*---------------------------------------------------------------------------------------------
7 * Copyright (c) Microsoft Corporation. All rights reserved.
8 * Licensed under the MIT License.
9 * See https://github.com/microsoft/vscode/blob/main/LICENSE.txt for license information.
10 *--------------------------------------------------------------------------------------------*/
11
12/**
13 * Type Definition for Visual Studio Code 1.56 Extension API
14 * See https://code.visualstudio.com/api for more information
15 */
16
17declare module 'vscode' {
18
19 /**
20 * The version of the editor.
21 */
22 export const version: string;
23
24 /**
25 * Represents a reference to a command. Provides a title which
26 * will be used to represent a command in the UI and, optionally,
27 * an array of arguments which will be passed to the command handler
28 * function when invoked.
29 */
30 export interface Command {
31 /**
32 * Title of the command, like `save`.
33 */
34 title: string;
35
36 /**
37 * The identifier of the actual command handler.
38 * @see [commands.registerCommand](#commands.registerCommand).
39 */
40 command: string;
41
42 /**
43 * A tooltip for the command, when represented in the UI.
44 */
45 tooltip?: string;
46
47 /**
48 * Arguments that the command handler should be
49 * invoked with.
50 */
51 arguments?: any[];
52 }
53
54 /**
55 * Represents a line of text, such as a line of source code.
56 *
57 * TextLine objects are __immutable__. When a [document](#TextDocument) changes,
58 * previously retrieved lines will not represent the latest state.
59 */
60 export interface TextLine {
61
62 /**
63 * The zero-based line number.
64 */
65 readonly lineNumber: number;
66
67 /**
68 * The text of this line without the line separator characters.
69 */
70 readonly text: string;
71
72 /**
73 * The range this line covers without the line separator characters.
74 */
75 readonly range: Range;
76
77 /**
78 * The range this line covers with the line separator characters.
79 */
80 readonly rangeIncludingLineBreak: Range;
81
82 /**
83 * The offset of the first character which is not a whitespace character as defined
84 * by `/\s/`. **Note** that if a line is all whitespace the length of the line is returned.
85 */
86 readonly firstNonWhitespaceCharacterIndex: number;
87
88 /**
89 * Whether this line is whitespace only, shorthand
90 * for [TextLine.firstNonWhitespaceCharacterIndex](#TextLine.firstNonWhitespaceCharacterIndex) === [TextLine.text.length](#TextLine.text).
91 */
92 readonly isEmptyOrWhitespace: boolean;
93 }
94
95 /**
96 * Represents a text document, such as a source file. Text documents have
97 * [lines](#TextLine) and knowledge about an underlying resource like a file.
98 */
99 export interface TextDocument {
100
101 /**
102 * The associated uri for this document.
103 *
104 * *Note* that most documents use the `file`-scheme, which means they are files on disk. However, **not** all documents are
105 * saved on disk and therefore the `scheme` must be checked before trying to access the underlying file or siblings on disk.
106 *
107 * @see [FileSystemProvider](#FileSystemProvider)
108 * @see [TextDocumentContentProvider](#TextDocumentContentProvider)
109 */
110 readonly uri: Uri;
111
112 /**
113 * The file system path of the associated resource. Shorthand
114 * notation for [TextDocument.uri.fsPath](#TextDocument.uri). Independent of the uri scheme.
115 */
116 readonly fileName: string;
117
118 /**
119 * Is this document representing an untitled file which has never been saved yet. *Note* that
120 * this does not mean the document will be saved to disk, use [`uri.scheme`](#Uri.scheme)
121 * to figure out where a document will be [saved](#FileSystemProvider), e.g. `file`, `ftp` etc.
122 */
123 readonly isUntitled: boolean;
124
125 /**
126 * The identifier of the language associated with this document.
127 */
128 readonly languageId: string;
129
130 /**
131 * The version number of this document (it will strictly increase after each
132 * change, including undo/redo).
133 */
134 readonly version: number;
135
136 /**
137 * `true` if there are unpersisted changes.
138 */
139 readonly isDirty: boolean;
140
141 /**
142 * `true` if the document has been closed. A closed document isn't synchronized anymore
143 * and won't be re-used when the same resource is opened again.
144 */
145 readonly isClosed: boolean;
146
147 /**
148 * Save the underlying file.
149 *
150 * @return A promise that will resolve to true when the file
151 * has been saved. If the file was not dirty or the save failed,
152 * will return false.
153 */
154 save(): Thenable<boolean>;
155
156 /**
157 * The [end of line](#EndOfLine) sequence that is predominately
158 * used in this document.
159 */
160 readonly eol: EndOfLine;
161
162 /**
163 * The number of lines in this document.
164 */
165 readonly lineCount: number;
166
167 /**
168 * Returns a text line denoted by the line number. Note
169 * that the returned object is *not* live and changes to the
170 * document are not reflected.
171 *
172 * @param line A line number in [0, lineCount).
173 * @return A [line](#TextLine).
174 */
175 lineAt(line: number): TextLine;
176
177 /**
178 * Returns a text line denoted by the position. Note
179 * that the returned object is *not* live and changes to the
180 * document are not reflected.
181 *
182 * The position will be [adjusted](#TextDocument.validatePosition).
183 *
184 * @see [TextDocument.lineAt](#TextDocument.lineAt)
185 * @param position A position.
186 * @return A [line](#TextLine).
187 */
188 lineAt(position: Position): TextLine;
189
190 /**
191 * Converts the position to a zero-based offset.
192 *
193 * The position will be [adjusted](#TextDocument.validatePosition).
194 *
195 * @param position A position.
196 * @return A valid zero-based offset.
197 */
198 offsetAt(position: Position): number;
199
200 /**
201 * Converts a zero-based offset to a position.
202 *
203 * @param offset A zero-based offset.
204 * @return A valid [position](#Position).
205 */
206 positionAt(offset: number): Position;
207
208 /**
209 * Get the text of this document. A substring can be retrieved by providing
210 * a range. The range will be [adjusted](#TextDocument.validateRange).
211 *
212 * @param range Include only the text included by the range.
213 * @return The text inside the provided range or the entire text.
214 */
215 getText(range?: Range): string;
216
217 /**
218 * Get a word-range at the given position. By default words are defined by
219 * common separators, like space, -, _, etc. In addition, per language custom
220 * [word definitions](#LanguageConfiguration.wordPattern) can be defined. It
221 * is also possible to provide a custom regular expression.
222 *
223 * * *Note 1:* A custom regular expression must not match the empty string and
224 * if it does, it will be ignored.
225 * * *Note 2:* A custom regular expression will fail to match multiline strings
226 * and in the name of speed regular expressions should not match words with
227 * spaces. Use [`TextLine.text`](#TextLine.text) for more complex, non-wordy, scenarios.
228 *
229 * The position will be [adjusted](#TextDocument.validatePosition).
230 *
231 * @param position A position.
232 * @param regex Optional regular expression that describes what a word is.
233 * @return A range spanning a word, or `undefined`.
234 */
235 getWordRangeAtPosition(position: Position, regex?: RegExp): Range | undefined;
236
237 /**
238 * Ensure a range is completely contained in this document.
239 *
240 * @param range A range.
241 * @return The given range or a new, adjusted range.
242 */
243 validateRange(range: Range): Range;
244
245 /**
246 * Ensure a position is contained in the range of this document.
247 *
248 * @param position A position.
249 * @return The given position or a new, adjusted position.
250 */
251 validatePosition(position: Position): Position;
252 }
253
254 /**
255 * Represents a line and character position, such as
256 * the position of the cursor.
257 *
258 * Position objects are __immutable__. Use the [with](#Position.with) or
259 * [translate](#Position.translate) methods to derive new positions
260 * from an existing position.
261 */
262 export class Position {
263
264 /**
265 * The zero-based line value.
266 */
267 readonly line: number;
268
269 /**
270 * The zero-based character value.
271 */
272 readonly character: number;
273
274 /**
275 * @param line A zero-based line value.
276 * @param character A zero-based character value.
277 */
278 constructor(line: number, character: number);
279
280 /**
281 * Check if this position is before `other`.
282 *
283 * @param other A position.
284 * @return `true` if position is on a smaller line
285 * or on the same line on a smaller character.
286 */
287 isBefore(other: Position): boolean;
288
289 /**
290 * Check if this position is before or equal to `other`.
291 *
292 * @param other A position.
293 * @return `true` if position is on a smaller line
294 * or on the same line on a smaller or equal character.
295 */
296 isBeforeOrEqual(other: Position): boolean;
297
298 /**
299 * Check if this position is after `other`.
300 *
301 * @param other A position.
302 * @return `true` if position is on a greater line
303 * or on the same line on a greater character.
304 */
305 isAfter(other: Position): boolean;
306
307 /**
308 * Check if this position is after or equal to `other`.
309 *
310 * @param other A position.
311 * @return `true` if position is on a greater line
312 * or on the same line on a greater or equal character.
313 */
314 isAfterOrEqual(other: Position): boolean;
315
316 /**
317 * Check if this position is equal to `other`.
318 *
319 * @param other A position.
320 * @return `true` if the line and character of the given position are equal to
321 * the line and character of this position.
322 */
323 isEqual(other: Position): boolean;
324
325 /**
326 * Compare this to `other`.
327 *
328 * @param other A position.
329 * @return A number smaller than zero if this position is before the given position,
330 * a number greater than zero if this position is after the given position, or zero when
331 * this and the given position are equal.
332 */
333 compareTo(other: Position): number;
334
335 /**
336 * Create a new position relative to this position.
337 *
338 * @param lineDelta Delta value for the line value, default is `0`.
339 * @param characterDelta Delta value for the character value, default is `0`.
340 * @return A position which line and character is the sum of the current line and
341 * character and the corresponding deltas.
342 */
343 translate(lineDelta?: number, characterDelta?: number): Position;
344
345 /**
346 * Derived a new position relative to this position.
347 *
348 * @param change An object that describes a delta to this position.
349 * @return A position that reflects the given delta. Will return `this` position if the change
350 * is not changing anything.
351 */
352 translate(change: { lineDelta?: number; characterDelta?: number; }): Position;
353
354 /**
355 * Create a new position derived from this position.
356 *
357 * @param line Value that should be used as line value, default is the [existing value](#Position.line)
358 * @param character Value that should be used as character value, default is the [existing value](#Position.character)
359 * @return A position where line and character are replaced by the given values.
360 */
361 with(line?: number, character?: number): Position;
362
363 /**
364 * Derived a new position from this position.
365 *
366 * @param change An object that describes a change to this position.
367 * @return A position that reflects the given change. Will return `this` position if the change
368 * is not changing anything.
369 */
370 with(change: { line?: number; character?: number; }): Position;
371 }
372
373 /**
374 * A range represents an ordered pair of two positions.
375 * It is guaranteed that [start](#Range.start).isBeforeOrEqual([end](#Range.end))
376 *
377 * Range objects are __immutable__. Use the [with](#Range.with),
378 * [intersection](#Range.intersection), or [union](#Range.union) methods
379 * to derive new ranges from an existing range.
380 */
381 export class Range {
382
383 /**
384 * The start position. It is before or equal to [end](#Range.end).
385 */
386 readonly start: Position;
387
388 /**
389 * The end position. It is after or equal to [start](#Range.start).
390 */
391 readonly end: Position;
392
393 /**
394 * Create a new range from two positions. If `start` is not
395 * before or equal to `end`, the values will be swapped.
396 *
397 * @param start A position.
398 * @param end A position.
399 */
400 constructor(start: Position, end: Position);
401
402 /**
403 * Create a new range from number coordinates. It is a shorter equivalent of
404 * using `new Range(new Position(startLine, startCharacter), new Position(endLine, endCharacter))`
405 *
406 * @param startLine A zero-based line value.
407 * @param startCharacter A zero-based character value.
408 * @param endLine A zero-based line value.
409 * @param endCharacter A zero-based character value.
410 */
411 constructor(startLine: number, startCharacter: number, endLine: number, endCharacter: number);
412
413 /**
414 * `true` if `start` and `end` are equal.
415 */
416 isEmpty: boolean;
417
418 /**
419 * `true` if `start.line` and `end.line` are equal.
420 */
421 isSingleLine: boolean;
422
423 /**
424 * Check if a position or a range is contained in this range.
425 *
426 * @param positionOrRange A position or a range.
427 * @return `true` if the position or range is inside or equal
428 * to this range.
429 */
430 contains(positionOrRange: Position | Range): boolean;
431
432 /**
433 * Check if `other` equals this range.
434 *
435 * @param other A range.
436 * @return `true` when start and end are [equal](#Position.isEqual) to
437 * start and end of this range.
438 */
439 isEqual(other: Range): boolean;
440
441 /**
442 * Intersect `range` with this range and returns a new range or `undefined`
443 * if the ranges have no overlap.
444 *
445 * @param range A range.
446 * @return A range of the greater start and smaller end positions. Will
447 * return undefined when there is no overlap.
448 */
449 intersection(range: Range): Range | undefined;
450
451 /**
452 * Compute the union of `other` with this range.
453 *
454 * @param other A range.
455 * @return A range of smaller start position and the greater end position.
456 */
457 union(other: Range): Range;
458
459 /**
460 * Derived a new range from this range.
461 *
462 * @param start A position that should be used as start. The default value is the [current start](#Range.start).
463 * @param end A position that should be used as end. The default value is the [current end](#Range.end).
464 * @return A range derived from this range with the given start and end position.
465 * If start and end are not different `this` range will be returned.
466 */
467 with(start?: Position, end?: Position): Range;
468
469 /**
470 * Derived a new range from this range.
471 *
472 * @param change An object that describes a change to this range.
473 * @return A range that reflects the given change. Will return `this` range if the change
474 * is not changing anything.
475 */
476 with(change: { start?: Position, end?: Position }): Range;
477 }
478
479 /**
480 * Represents a text selection in an editor.
481 */
482 export class Selection extends Range {
483
484 /**
485 * The position at which the selection starts.
486 * This position might be before or after [active](#Selection.active).
487 */
488 anchor: Position;
489
490 /**
491 * The position of the cursor.
492 * This position might be before or after [anchor](#Selection.anchor).
493 */
494 active: Position;
495
496 /**
497 * Create a selection from two positions.
498 *
499 * @param anchor A position.
500 * @param active A position.
501 */
502 constructor(anchor: Position, active: Position);
503
504 /**
505 * Create a selection from four coordinates.
506 *
507 * @param anchorLine A zero-based line value.
508 * @param anchorCharacter A zero-based character value.
509 * @param activeLine A zero-based line value.
510 * @param activeCharacter A zero-based character value.
511 */
512 constructor(anchorLine: number, anchorCharacter: number, activeLine: number, activeCharacter: number);
513
514 /**
515 * A selection is reversed if [active](#Selection.active).isBefore([anchor](#Selection.anchor)).
516 */
517 isReversed: boolean;
518 }
519
520 /**
521 * Represents sources that can cause [selection change events](#window.onDidChangeTextEditorSelection).
522 */
523 export enum TextEditorSelectionChangeKind {
524 /**
525 * Selection changed due to typing in the editor.
526 */
527 Keyboard = 1,
528 /**
529 * Selection change due to clicking in the editor.
530 */
531 Mouse = 2,
532 /**
533 * Selection changed because a command ran.
534 */
535 Command = 3
536 }
537
538 /**
539 * Represents an event describing the change in a [text editor's selections](#TextEditor.selections).
540 */
541 export interface TextEditorSelectionChangeEvent {
542 /**
543 * The [text editor](#TextEditor) for which the selections have changed.
544 */
545 readonly textEditor: TextEditor;
546 /**
547 * The new value for the [text editor's selections](#TextEditor.selections).
548 */
549 readonly selections: ReadonlyArray<Selection>;
550 /**
551 * The [change kind](#TextEditorSelectionChangeKind) which has triggered this
552 * event. Can be `undefined`.
553 */
554 readonly kind?: TextEditorSelectionChangeKind;
555 }
556
557 /**
558 * Represents an event describing the change in a [text editor's visible ranges](#TextEditor.visibleRanges).
559 */
560 export interface TextEditorVisibleRangesChangeEvent {
561 /**
562 * The [text editor](#TextEditor) for which the visible ranges have changed.
563 */
564 readonly textEditor: TextEditor;
565 /**
566 * The new value for the [text editor's visible ranges](#TextEditor.visibleRanges).
567 */
568 readonly visibleRanges: ReadonlyArray<Range>;
569 }
570
571 /**
572 * Represents an event describing the change in a [text editor's options](#TextEditor.options).
573 */
574 export interface TextEditorOptionsChangeEvent {
575 /**
576 * The [text editor](#TextEditor) for which the options have changed.
577 */
578 readonly textEditor: TextEditor;
579 /**
580 * The new value for the [text editor's options](#TextEditor.options).
581 */
582 readonly options: TextEditorOptions;
583 }
584
585 /**
586 * Represents an event describing the change of a [text editor's view column](#TextEditor.viewColumn).
587 */
588 export interface TextEditorViewColumnChangeEvent {
589 /**
590 * The [text editor](#TextEditor) for which the view column has changed.
591 */
592 readonly textEditor: TextEditor;
593 /**
594 * The new value for the [text editor's view column](#TextEditor.viewColumn).
595 */
596 readonly viewColumn: ViewColumn;
597 }
598
599 /**
600 * Rendering style of the cursor.
601 */
602 export enum TextEditorCursorStyle {
603 /**
604 * Render the cursor as a vertical thick line.
605 */
606 Line = 1,
607 /**
608 * Render the cursor as a block filled.
609 */
610 Block = 2,
611 /**
612 * Render the cursor as a thick horizontal line.
613 */
614 Underline = 3,
615 /**
616 * Render the cursor as a vertical thin line.
617 */
618 LineThin = 4,
619 /**
620 * Render the cursor as a block outlined.
621 */
622 BlockOutline = 5,
623 /**
624 * Render the cursor as a thin horizontal line.
625 */
626 UnderlineThin = 6
627 }
628
629 /**
630 * Rendering style of the line numbers.
631 */
632 export enum TextEditorLineNumbersStyle {
633 /**
634 * Do not render the line numbers.
635 */
636 Off = 0,
637 /**
638 * Render the line numbers.
639 */
640 On = 1,
641 /**
642 * Render the line numbers with values relative to the primary cursor location.
643 */
644 Relative = 2
645 }
646
647 /**
648 * Represents a [text editor](#TextEditor)'s [options](#TextEditor.options).
649 */
650 export interface TextEditorOptions {
651
652 /**
653 * The size in spaces a tab takes. This is used for two purposes:
654 * - the rendering width of a tab character;
655 * - the number of spaces to insert when [insertSpaces](#TextEditorOptions.insertSpaces) is true.
656 *
657 * When getting a text editor's options, this property will always be a number (resolved).
658 * When setting a text editor's options, this property is optional and it can be a number or `"auto"`.
659 */
660 tabSize?: number | string;
661
662 /**
663 * When pressing Tab insert [n](#TextEditorOptions.tabSize) spaces.
664 * When getting a text editor's options, this property will always be a boolean (resolved).
665 * When setting a text editor's options, this property is optional and it can be a boolean or `"auto"`.
666 */
667 insertSpaces?: boolean | string;
668
669 /**
670 * The rendering style of the cursor in this editor.
671 * When getting a text editor's options, this property will always be present.
672 * When setting a text editor's options, this property is optional.
673 */
674 cursorStyle?: TextEditorCursorStyle;
675
676 /**
677 * Render relative line numbers w.r.t. the current line number.
678 * When getting a text editor's options, this property will always be present.
679 * When setting a text editor's options, this property is optional.
680 */
681 lineNumbers?: TextEditorLineNumbersStyle;
682 }
683
684 /**
685 * Represents a handle to a set of decorations
686 * sharing the same [styling options](#DecorationRenderOptions) in a [text editor](#TextEditor).
687 *
688 * To get an instance of a `TextEditorDecorationType` use
689 * [createTextEditorDecorationType](#window.createTextEditorDecorationType).
690 */
691 export interface TextEditorDecorationType {
692
693 /**
694 * Internal representation of the handle.
695 */
696 readonly key: string;
697
698 /**
699 * Remove this decoration type and all decorations on all text editors using it.
700 */
701 dispose(): void;
702 }
703
704 /**
705 * Represents different [reveal](#TextEditor.revealRange) strategies in a text editor.
706 */
707 export enum TextEditorRevealType {
708 /**
709 * The range will be revealed with as little scrolling as possible.
710 */
711 Default = 0,
712 /**
713 * The range will always be revealed in the center of the viewport.
714 */
715 InCenter = 1,
716 /**
717 * If the range is outside the viewport, it will be revealed in the center of the viewport.
718 * Otherwise, it will be revealed with as little scrolling as possible.
719 */
720 InCenterIfOutsideViewport = 2,
721 /**
722 * The range will always be revealed at the top of the viewport.
723 */
724 AtTop = 3
725 }
726
727 /**
728 * Represents different positions for rendering a decoration in an [overview ruler](#DecorationRenderOptions.overviewRulerLane).
729 * The overview ruler supports three lanes.
730 */
731 export enum OverviewRulerLane {
732 Left = 1,
733 Center = 2,
734 Right = 4,
735 Full = 7
736 }
737
738 /**
739 * Describes the behavior of decorations when typing/editing at their edges.
740 */
741 export enum DecorationRangeBehavior {
742 /**
743 * The decoration's range will widen when edits occur at the start or end.
744 */
745 OpenOpen = 0,
746 /**
747 * The decoration's range will not widen when edits occur at the start of end.
748 */
749 ClosedClosed = 1,
750 /**
751 * The decoration's range will widen when edits occur at the start, but not at the end.
752 */
753 OpenClosed = 2,
754 /**
755 * The decoration's range will widen when edits occur at the end, but not at the start.
756 */
757 ClosedOpen = 3
758 }
759
760 /**
761 * Represents options to configure the behavior of showing a [document](#TextDocument) in an [editor](#TextEditor).
762 */
763 export interface TextDocumentShowOptions {
764 /**
765 * An optional view column in which the [editor](#TextEditor) should be shown.
766 * The default is the [active](#ViewColumn.Active), other values are adjusted to
767 * be `Min(column, columnCount + 1)`, the [active](#ViewColumn.Active)-column is
768 * not adjusted. Use [`ViewColumn.Beside`](#ViewColumn.Beside) to open the
769 * editor to the side of the currently active one.
770 */
771 viewColumn?: ViewColumn;
772
773 /**
774 * An optional flag that when `true` will stop the [editor](#TextEditor) from taking focus.
775 */
776 preserveFocus?: boolean;
777
778 /**
779 * An optional flag that controls if an [editor](#TextEditor)-tab will be replaced
780 * with the next editor or if it will be kept.
781 */
782 preview?: boolean;
783
784 /**
785 * An optional selection to apply for the document in the [editor](#TextEditor).
786 */
787 selection?: Range;
788 }
789
790 /**
791 * A reference to one of the workbench colors as defined in https://code.visualstudio.com/docs/getstarted/theme-color-reference.
792 * Using a theme color is preferred over a custom color as it gives theme authors and users the possibility to change the color.
793 */
794 export class ThemeColor {
795
796 /**
797 * Creates a reference to a theme color.
798 * @param id of the color. The available colors are listed in https://code.visualstudio.com/docs/getstarted/theme-color-reference.
799 */
800 constructor(id: string);
801 }
802
803 /**
804 * A reference to a named icon. Currently, [File](#ThemeIcon.File), [Folder](#ThemeIcon.Folder),
805 * and [ThemeIcon ids](https://code.visualstudio.com/api/references/icons-in-labels#icon-listing) are supported.
806 * Using a theme icon is preferred over a custom icon as it gives product theme authors the possibility to change the icons.
807 *
808 * *Note* that theme icons can also be rendered inside labels and descriptions. Places that support theme icons spell this out
809 * and they use the `$(<name>)`-syntax, for instance `quickPick.label = "Hello World $(globe)"`.
810 */
811 export class ThemeIcon {
812 /**
813 * Reference to an icon representing a file. The icon is taken from the current file icon theme or a placeholder icon is used.
814 */
815 static readonly File: ThemeIcon;
816
817 /**
818 * Reference to an icon representing a folder. The icon is taken from the current file icon theme or a placeholder icon is used.
819 */
820 static readonly Folder: ThemeIcon;
821
822 /**
823 * The id of the icon. The available icons are listed in https://code.visualstudio.com/api/references/icons-in-labels#icon-listing.
824 */
825 readonly id: string;
826
827 /**
828 * The optional ThemeColor of the icon. The color is currently only used in [TreeItem](#TreeItem).
829 */
830 readonly color?: ThemeColor;
831
832 /**
833 * Creates a reference to a theme icon.
834 * @param id id of the icon. The available icons are listed in https://code.visualstudio.com/api/references/icons-in-labels#icon-listing.
835 * @param color optional `ThemeColor` for the icon. The color is currently only used in [TreeItem](#TreeItem).
836 */
837 constructor(id: string, color?: ThemeColor);
838 }
839
840 /**
841 * Represents theme specific rendering styles for a [text editor decoration](#TextEditorDecorationType).
842 */
843 export interface ThemableDecorationRenderOptions {
844 /**
845 * Background color of the decoration. Use rgba() and define transparent background colors to play well with other decorations.
846 * Alternatively a color from the color registry can be [referenced](#ThemeColor).
847 */
848 backgroundColor?: string | ThemeColor;
849
850 /**
851 * CSS styling property that will be applied to text enclosed by a decoration.
852 */
853 outline?: string;
854
855 /**
856 * CSS styling property that will be applied to text enclosed by a decoration.
857 * Better use 'outline' for setting one or more of the individual outline properties.
858 */
859 outlineColor?: string | ThemeColor;
860
861 /**
862 * CSS styling property that will be applied to text enclosed by a decoration.
863 * Better use 'outline' for setting one or more of the individual outline properties.
864 */
865 outlineStyle?: string;
866
867 /**
868 * CSS styling property that will be applied to text enclosed by a decoration.
869 * Better use 'outline' for setting one or more of the individual outline properties.
870 */
871 outlineWidth?: string;
872
873 /**
874 * CSS styling property that will be applied to text enclosed by a decoration.
875 */
876 border?: string;
877
878 /**
879 * CSS styling property that will be applied to text enclosed by a decoration.
880 * Better use 'border' for setting one or more of the individual border properties.
881 */
882 borderColor?: string | ThemeColor;
883
884 /**
885 * CSS styling property that will be applied to text enclosed by a decoration.
886 * Better use 'border' for setting one or more of the individual border properties.
887 */
888 borderRadius?: string;
889
890 /**
891 * CSS styling property that will be applied to text enclosed by a decoration.
892 * Better use 'border' for setting one or more of the individual border properties.
893 */
894 borderSpacing?: string;
895
896 /**
897 * CSS styling property that will be applied to text enclosed by a decoration.
898 * Better use 'border' for setting one or more of the individual border properties.
899 */
900 borderStyle?: string;
901
902 /**
903 * CSS styling property that will be applied to text enclosed by a decoration.
904 * Better use 'border' for setting one or more of the individual border properties.
905 */
906 borderWidth?: string;
907
908 /**
909 * CSS styling property that will be applied to text enclosed by a decoration.
910 */
911 fontStyle?: string;
912
913 /**
914 * CSS styling property that will be applied to text enclosed by a decoration.
915 */
916 fontWeight?: string;
917
918 /**
919 * CSS styling property that will be applied to text enclosed by a decoration.
920 */
921 textDecoration?: string;
922
923 /**
924 * CSS styling property that will be applied to text enclosed by a decoration.
925 */
926 cursor?: string;
927
928 /**
929 * CSS styling property that will be applied to text enclosed by a decoration.
930 */
931 color?: string | ThemeColor;
932
933 /**
934 * CSS styling property that will be applied to text enclosed by a decoration.
935 */
936 opacity?: string;
937
938 /**
939 * CSS styling property that will be applied to text enclosed by a decoration.
940 */
941 letterSpacing?: string;
942
943 /**
944 * An **absolute path** or an URI to an image to be rendered in the gutter.
945 */
946 gutterIconPath?: string | Uri;
947
948 /**
949 * Specifies the size of the gutter icon.
950 * Available values are 'auto', 'contain', 'cover' and any percentage value.
951 * For further information: https://msdn.microsoft.com/en-us/library/jj127316(v=vs.85).aspx
952 */
953 gutterIconSize?: string;
954
955 /**
956 * The color of the decoration in the overview ruler. Use rgba() and define transparent colors to play well with other decorations.
957 */
958 overviewRulerColor?: string | ThemeColor;
959
960 /**
961 * Defines the rendering options of the attachment that is inserted before the decorated text.
962 */
963 before?: ThemableDecorationAttachmentRenderOptions;
964
965 /**
966 * Defines the rendering options of the attachment that is inserted after the decorated text.
967 */
968 after?: ThemableDecorationAttachmentRenderOptions;
969 }
970
971 export interface ThemableDecorationAttachmentRenderOptions {
972 /**
973 * Defines a text content that is shown in the attachment. Either an icon or a text can be shown, but not both.
974 */
975 contentText?: string;
976 /**
977 * An **absolute path** or an URI to an image to be rendered in the attachment. Either an icon
978 * or a text can be shown, but not both.
979 */
980 contentIconPath?: string | Uri;
981 /**
982 * CSS styling property that will be applied to the decoration attachment.
983 */
984 border?: string;
985 /**
986 * CSS styling property that will be applied to text enclosed by a decoration.
987 */
988 borderColor?: string | ThemeColor;
989 /**
990 * CSS styling property that will be applied to the decoration attachment.
991 */
992 fontStyle?: string;
993 /**
994 * CSS styling property that will be applied to the decoration attachment.
995 */
996 fontWeight?: string;
997 /**
998 * CSS styling property that will be applied to the decoration attachment.
999 */
1000 textDecoration?: string;
1001 /**
1002 * CSS styling property that will be applied to the decoration attachment.
1003 */
1004 color?: string | ThemeColor;
1005 /**
1006 * CSS styling property that will be applied to the decoration attachment.
1007 */
1008 backgroundColor?: string | ThemeColor;
1009 /**
1010 * CSS styling property that will be applied to the decoration attachment.
1011 */
1012 margin?: string;
1013 /**
1014 * CSS styling property that will be applied to the decoration attachment.
1015 */
1016 width?: string;
1017 /**
1018 * CSS styling property that will be applied to the decoration attachment.
1019 */
1020 height?: string;
1021 }
1022
1023 /**
1024 * Represents rendering styles for a [text editor decoration](#TextEditorDecorationType).
1025 */
1026 export interface DecorationRenderOptions extends ThemableDecorationRenderOptions {
1027 /**
1028 * Should the decoration be rendered also on the whitespace after the line text.
1029 * Defaults to `false`.
1030 */
1031 isWholeLine?: boolean;
1032
1033 /**
1034 * Customize the growing behavior of the decoration when edits occur at the edges of the decoration's range.
1035 * Defaults to `DecorationRangeBehavior.OpenOpen`.
1036 */
1037 rangeBehavior?: DecorationRangeBehavior;
1038
1039 /**
1040 * The position in the overview ruler where the decoration should be rendered.
1041 */
1042 overviewRulerLane?: OverviewRulerLane;
1043
1044 /**
1045 * Overwrite options for light themes.
1046 */
1047 light?: ThemableDecorationRenderOptions;
1048
1049 /**
1050 * Overwrite options for dark themes.
1051 */
1052 dark?: ThemableDecorationRenderOptions;
1053 }
1054
1055 /**
1056 * Represents options for a specific decoration in a [decoration set](#TextEditorDecorationType).
1057 */
1058 export interface DecorationOptions {
1059
1060 /**
1061 * Range to which this decoration is applied. The range must not be empty.
1062 */
1063 range: Range;
1064
1065 /**
1066 * A message that should be rendered when hovering over the decoration.
1067 */
1068 hoverMessage?: MarkedString | MarkedString[];
1069
1070 /**
1071 * Render options applied to the current decoration. For performance reasons, keep the
1072 * number of decoration specific options small, and use decoration types wherever possible.
1073 */
1074 renderOptions?: DecorationInstanceRenderOptions;
1075 }
1076
1077 export interface ThemableDecorationInstanceRenderOptions {
1078 /**
1079 * Defines the rendering options of the attachment that is inserted before the decorated text.
1080 */
1081 before?: ThemableDecorationAttachmentRenderOptions;
1082
1083 /**
1084 * Defines the rendering options of the attachment that is inserted after the decorated text.
1085 */
1086 after?: ThemableDecorationAttachmentRenderOptions;
1087 }
1088
1089 export interface DecorationInstanceRenderOptions extends ThemableDecorationInstanceRenderOptions {
1090 /**
1091 * Overwrite options for light themes.
1092 */
1093 light?: ThemableDecorationInstanceRenderOptions;
1094
1095 /**
1096 * Overwrite options for dark themes.
1097 */
1098 dark?: ThemableDecorationInstanceRenderOptions;
1099 }
1100
1101 /**
1102 * Represents an editor that is attached to a [document](#TextDocument).
1103 */
1104 export interface TextEditor {
1105
1106 /**
1107 * The document associated with this text editor. The document will be the same for the entire lifetime of this text editor.
1108 */
1109 readonly document: TextDocument;
1110
1111 /**
1112 * The primary selection on this text editor. Shorthand for `TextEditor.selections[0]`.
1113 */
1114 selection: Selection;
1115
1116 /**
1117 * The selections in this text editor. The primary selection is always at index 0.
1118 */
1119 selections: Selection[];
1120
1121 /**
1122 * The current visible ranges in the editor (vertically).
1123 * This accounts only for vertical scrolling, and not for horizontal scrolling.
1124 */
1125 readonly visibleRanges: Range[];
1126
1127 /**
1128 * Text editor options.
1129 */
1130 options: TextEditorOptions;
1131
1132 /**
1133 * The column in which this editor shows. Will be `undefined` in case this
1134 * isn't one of the main editors, e.g. an embedded editor, or when the editor
1135 * column is larger than three.
1136 */
1137 readonly viewColumn?: ViewColumn;
1138
1139 /**
1140 * Perform an edit on the document associated with this text editor.
1141 *
1142 * The given callback-function is invoked with an [edit-builder](#TextEditorEdit) which must
1143 * be used to make edits. Note that the edit-builder is only valid while the
1144 * callback executes.
1145 *
1146 * @param callback A function which can create edits using an [edit-builder](#TextEditorEdit).
1147 * @param options The undo/redo behavior around this edit. By default, undo stops will be created before and after this edit.
1148 * @return A promise that resolves with a value indicating if the edits could be applied.
1149 */
1150 edit(callback: (editBuilder: TextEditorEdit) => void, options?: { undoStopBefore: boolean; undoStopAfter: boolean; }): Thenable<boolean>;
1151
1152 /**
1153 * Insert a [snippet](#SnippetString) and put the editor into snippet mode. "Snippet mode"
1154 * means the editor adds placeholders and additional cursors so that the user can complete
1155 * or accept the snippet.
1156 *
1157 * @param snippet The snippet to insert in this edit.
1158 * @param location Position or range at which to insert the snippet, defaults to the current editor selection or selections.
1159 * @param options The undo/redo behavior around this edit. By default, undo stops will be created before and after this edit.
1160 * @return A promise that resolves with a value indicating if the snippet could be inserted. Note that the promise does not signal
1161 * that the snippet is completely filled-in or accepted.
1162 */
1163 insertSnippet(snippet: SnippetString, location?: Position | Range | ReadonlyArray<Position> | ReadonlyArray<Range>, options?: { undoStopBefore: boolean; undoStopAfter: boolean; }): Thenable<boolean>;
1164
1165 /**
1166 * Adds a set of decorations to the text editor. If a set of decorations already exists with
1167 * the given [decoration type](#TextEditorDecorationType), they will be replaced.
1168 *
1169 * @see [createTextEditorDecorationType](#window.createTextEditorDecorationType).
1170 *
1171 * @param decorationType A decoration type.
1172 * @param rangesOrOptions Either [ranges](#Range) or more detailed [options](#DecorationOptions).
1173 */
1174 setDecorations(decorationType: TextEditorDecorationType, rangesOrOptions: Range[] | DecorationOptions[]): void;
1175
1176 /**
1177 * Scroll as indicated by `revealType` in order to reveal the given range.
1178 *
1179 * @param range A range.
1180 * @param revealType The scrolling strategy for revealing `range`.
1181 */
1182 revealRange(range: Range, revealType?: TextEditorRevealType): void;
1183
1184 /**
1185 * Show the text editor.
1186 *
1187 * @deprecated Use [window.showTextDocument](#window.showTextDocument) instead.
1188 *
1189 * @param column The [column](#ViewColumn) in which to show this editor.
1190 * This method shows unexpected behavior and will be removed in the next major update.
1191 */
1192 show(column?: ViewColumn): void;
1193
1194 /**
1195 * Hide the text editor.
1196 *
1197 * @deprecated Use the command `workbench.action.closeActiveEditor` instead.
1198 * This method shows unexpected behavior and will be removed in the next major update.
1199 */
1200 hide(): void;
1201 }
1202
1203 /**
1204 * Represents an end of line character sequence in a [document](#TextDocument).
1205 */
1206 export enum EndOfLine {
1207 /**
1208 * The line feed `\n` character.
1209 */
1210 LF = 1,
1211 /**
1212 * The carriage return line feed `\r\n` sequence.
1213 */
1214 CRLF = 2
1215 }
1216
1217 /**
1218 * A complex edit that will be applied in one transaction on a TextEditor.
1219 * 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.)
1220 * they can be applied on a [document](#TextDocument) associated with a [text editor](#TextEditor).
1221 */
1222 export interface TextEditorEdit {
1223 /**
1224 * Replace a certain text region with a new value.
1225 * You can use \r\n or \n in `value` and they will be normalized to the current [document](#TextDocument).
1226 *
1227 * @param location The range this operation should remove.
1228 * @param value The new text this operation should insert after removing `location`.
1229 */
1230 replace(location: Position | Range | Selection, value: string): void;
1231
1232 /**
1233 * Insert text at a location.
1234 * You can use \r\n or \n in `value` and they will be normalized to the current [document](#TextDocument).
1235 * Although the equivalent text edit can be made with [replace](#TextEditorEdit.replace), `insert` will produce a different resulting selection (it will get moved).
1236 *
1237 * @param location The position where the new text should be inserted.
1238 * @param value The new text this operation should insert.
1239 */
1240 insert(location: Position, value: string): void;
1241
1242 /**
1243 * Delete a certain text region.
1244 *
1245 * @param location The range this operation should remove.
1246 */
1247 delete(location: Range | Selection): void;
1248
1249 /**
1250 * Set the end of line sequence.
1251 *
1252 * @param endOfLine The new end of line for the [document](#TextDocument).
1253 */
1254 setEndOfLine(endOfLine: EndOfLine): void;
1255 }
1256
1257 /**
1258 * A universal resource identifier representing either a file on disk
1259 * or another resource, like untitled resources.
1260 */
1261 export class Uri {
1262
1263 /**
1264 * Create an URI from a string, e.g. `http://www.msft.com/some/path`,
1265 * `file:///usr/home`, or `scheme:with/path`.
1266 *
1267 * *Note* that for a while uris without a `scheme` were accepted. That is not correct
1268 * as all uris should have a scheme. To avoid breakage of existing code the optional
1269 * `strict`-argument has been added. We *strongly* advise to use it, e.g. `Uri.parse('my:uri', true)`
1270 *
1271 * @see [Uri.toString](#Uri.toString)
1272 * @param value The string value of an Uri.
1273 * @param strict Throw an error when `value` is empty or when no `scheme` can be parsed.
1274 * @return A new Uri instance.
1275 */
1276 static parse(value: string, strict?: boolean): Uri;
1277
1278 /**
1279 * Create an URI from a file system path. The [scheme](#Uri.scheme)
1280 * will be `file`.
1281 *
1282 * The *difference* between `Uri#parse` and `Uri#file` is that the latter treats the argument
1283 * as path, not as stringified-uri. E.g. `Uri.file(path)` is *not* the same as
1284 * `Uri.parse('file://' + path)` because the path might contain characters that are
1285 * interpreted (# and ?). See the following sample:
1286 * ```ts
1287 const good = URI.file('/coding/c#/project1');
1288 good.scheme === 'file';
1289 good.path === '/coding/c#/project1';
1290 good.fragment === '';
1291
1292 const bad = URI.parse('file://' + '/coding/c#/project1');
1293 bad.scheme === 'file';
1294 bad.path === '/coding/c'; // path is now broken
1295 bad.fragment === '/project1';
1296 ```
1297 *
1298 * @param path A file system or UNC path.
1299 * @return A new Uri instance.
1300 */
1301 static file(path: string): Uri;
1302
1303 /**
1304 * Create a new uri which path is the result of joining
1305 * the path of the base uri with the provided path segments.
1306 *
1307 * - Note 1: `joinPath` only affects the path component
1308 * and all other components (scheme, authority, query, and fragment) are
1309 * left as they are.
1310 * - Note 2: The base uri must have a path; an error is thrown otherwise.
1311 *
1312 * The path segments are normalized in the following ways:
1313 * - sequences of path separators (`/` or `\`) are replaced with a single separator
1314 * - for `file`-uris on windows, the backslash-character (`\`) is considered a path-separator
1315 * - the `..`-segment denotes the parent segment, the `.` denotes the current segment
1316 * - paths have a root which always remains, for instance on windows drive-letters are roots
1317 * so that is true: `joinPath(Uri.file('file:///c:/root'), '../../other').fsPath === 'c:/other'`
1318 *
1319 * @param base An uri. Must have a path.
1320 * @param pathSegments One more more path fragments
1321 * @returns A new uri which path is joined with the given fragments
1322 */
1323 static joinPath(base: Uri, ...pathSegments: string[]): Uri;
1324
1325 /**
1326 * Use the `file` and `parse` factory functions to create new `Uri` objects.
1327 */
1328 private constructor(scheme: string, authority: string, path: string, query: string, fragment: string);
1329
1330 /**
1331 * Scheme is the `http` part of `http://www.msft.com/some/path?query#fragment`.
1332 * The part before the first colon.
1333 */
1334 readonly scheme: string;
1335
1336 /**
1337 * Authority is the `www.msft.com` part of `http://www.msft.com/some/path?query#fragment`.
1338 * The part between the first double slashes and the next slash.
1339 */
1340 readonly authority: string;
1341
1342 /**
1343 * Path is the `/some/path` part of `http://www.msft.com/some/path?query#fragment`.
1344 */
1345 readonly path: string;
1346
1347 /**
1348 * Query is the `query` part of `http://www.msft.com/some/path?query#fragment`.
1349 */
1350 readonly query: string;
1351
1352 /**
1353 * Fragment is the `fragment` part of `http://www.msft.com/some/path?query#fragment`.
1354 */
1355 readonly fragment: string;
1356
1357 /**
1358 * The string representing the corresponding file system path of this Uri.
1359 *
1360 * Will handle UNC paths and normalize windows drive letters to lower-case. Also
1361 * uses the platform specific path separator.
1362 *
1363 * * Will *not* validate the path for invalid characters and semantics.
1364 * * Will *not* look at the scheme of this Uri.
1365 * * The resulting string shall *not* be used for display purposes but
1366 * for disk operations, like `readFile` et al.
1367 *
1368 * The *difference* to the [`path`](#Uri.path)-property is the use of the platform specific
1369 * path separator and the handling of UNC paths. The sample below outlines the difference:
1370 * ```ts
1371 const u = URI.parse('file://server/c$/folder/file.txt')
1372 u.authority === 'server'
1373 u.path === '/shares/c$/file.txt'
1374 u.fsPath === '\\server\c$\folder\file.txt'
1375 ```
1376 */
1377 readonly fsPath: string;
1378
1379 /**
1380 * Derive a new Uri from this Uri.
1381 *
1382 * ```ts
1383 * let file = Uri.parse('before:some/file/path');
1384 * let other = file.with({ scheme: 'after' });
1385 * assert.ok(other.toString() === 'after:some/file/path');
1386 * ```
1387 *
1388 * @param change An object that describes a change to this Uri. To unset components use `null` or
1389 * the empty string.
1390 * @return A new Uri that reflects the given change. Will return `this` Uri if the change
1391 * is not changing anything.
1392 */
1393 with(change: { scheme?: string; authority?: string; path?: string; query?: string; fragment?: string }): Uri;
1394
1395 /**
1396 * Returns a string representation of this Uri. The representation and normalization
1397 * of a URI depends on the scheme.
1398 *
1399 * * The resulting string can be safely used with [Uri.parse](#Uri.parse).
1400 * * The resulting string shall *not* be used for display purposes.
1401 *
1402 * *Note* that the implementation will encode _aggressive_ which often leads to unexpected,
1403 * but not incorrect, results. For instance, colons are encoded to `%3A` which might be unexpected
1404 * in file-uri. Also `&` and `=` will be encoded which might be unexpected for http-uris. For stability
1405 * reasons this cannot be changed anymore. If you suffer from too aggressive encoding you should use
1406 * the `skipEncoding`-argument: `uri.toString(true)`.
1407 *
1408 * @param skipEncoding Do not percentage-encode the result, defaults to `false`. Note that
1409 * the `#` and `?` characters occurring in the path will always be encoded.
1410 * @returns A string representation of this Uri.
1411 */
1412 toString(skipEncoding?: boolean): string;
1413
1414 /**
1415 * Returns a JSON representation of this Uri.
1416 *
1417 * @return An object.
1418 */
1419 toJSON(): any;
1420 }
1421
1422 /**
1423 * A cancellation token is passed to an asynchronous or long running
1424 * operation to request cancellation, like cancelling a request
1425 * for completion items because the user continued to type.
1426 *
1427 * To get an instance of a `CancellationToken` use a
1428 * [CancellationTokenSource](#CancellationTokenSource).
1429 */
1430 export interface CancellationToken {
1431
1432 /**
1433 * Is `true` when the token has been cancelled, `false` otherwise.
1434 */
1435 isCancellationRequested: boolean;
1436
1437 /**
1438 * An [event](#Event) which fires upon cancellation.
1439 */
1440 onCancellationRequested: Event<any>;
1441 }
1442
1443 /**
1444 * A cancellation source creates and controls a [cancellation token](#CancellationToken).
1445 */
1446 export class CancellationTokenSource {
1447
1448 /**
1449 * The cancellation token of this source.
1450 */
1451 token: CancellationToken;
1452
1453 /**
1454 * Signal cancellation on the token.
1455 */
1456 cancel(): void;
1457
1458 /**
1459 * Dispose object and free resources.
1460 */
1461 dispose(): void;
1462 }
1463
1464 /**
1465 * An error type that should be used to signal cancellation of an operation.
1466 *
1467 * This type can be used in response to a [cancellation token](#CancellationToken)
1468 * being cancelled or when an operation is being cancelled by the
1469 * executor of that operation.
1470 */
1471 export class CancellationError extends Error {
1472
1473 /**
1474 * Creates a new cancellation error.
1475 */
1476 constructor();
1477 }
1478
1479 /**
1480 * Represents a type which can release resources, such
1481 * as event listening or a timer.
1482 */
1483 export class Disposable {
1484
1485 /**
1486 * Combine many disposable-likes into one. Use this method
1487 * when having objects with a dispose function which are not
1488 * instances of Disposable.
1489 *
1490 * @param disposableLikes Objects that have at least a `dispose`-function member.
1491 * @return Returns a new disposable which, upon dispose, will
1492 * dispose all provided disposables.
1493 */
1494 static from(...disposableLikes: { dispose: () => any }[]): Disposable;
1495
1496 /**
1497 * Creates a new Disposable calling the provided function
1498 * on dispose.
1499 * @param callOnDispose Function that disposes something.
1500 */
1501 constructor(callOnDispose: Function);
1502
1503 /**
1504 * Dispose this object.
1505 */
1506 dispose(): any;
1507 }
1508
1509 /**
1510 * Represents a typed event.
1511 *
1512 * A function that represents an event to which you subscribe by calling it with
1513 * a listener function as argument.
1514 *
1515 * @example
1516 * item.onDidChange(function(event) { console.log("Event happened: " + event); });
1517 */
1518 export interface Event<T> {
1519
1520 /**
1521 * A function that represents an event to which you subscribe by calling it with
1522 * a listener function as argument.
1523 *
1524 * @param listener The listener function will be called when the event happens.
1525 * @param thisArgs The `this`-argument which will be used when calling the event listener.
1526 * @param disposables An array to which a [disposable](#Disposable) will be added.
1527 * @return A disposable which unsubscribes the event listener.
1528 */
1529 (listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]): Disposable;
1530 }
1531
1532 /**
1533 * An event emitter can be used to create and manage an [event](#Event) for others
1534 * to subscribe to. One emitter always owns one event.
1535 *
1536 * Use this class if you want to provide event from within your extension, for instance
1537 * inside a [TextDocumentContentProvider](#TextDocumentContentProvider) or when providing
1538 * API to other extensions.
1539 */
1540 export class EventEmitter<T> {
1541
1542 /**
1543 * The event listeners can subscribe to.
1544 */
1545 event: Event<T>;
1546
1547 /**
1548 * Notify all subscribers of the [event](#EventEmitter.event). Failure
1549 * of one or more listener will not fail this function call.
1550 *
1551 * @param data The event object.
1552 */
1553 fire(data: T): void;
1554
1555 /**
1556 * Dispose this object and free resources.
1557 */
1558 dispose(): void;
1559 }
1560
1561 /**
1562 * A file system watcher notifies about changes to files and folders
1563 * on disk or from other [FileSystemProviders](#FileSystemProvider).
1564 *
1565 * To get an instance of a `FileSystemWatcher` use
1566 * [createFileSystemWatcher](#workspace.createFileSystemWatcher).
1567 */
1568 export interface FileSystemWatcher extends Disposable {
1569
1570 /**
1571 * true if this file system watcher has been created such that
1572 * it ignores creation file system events.
1573 */
1574 ignoreCreateEvents: boolean;
1575
1576 /**
1577 * true if this file system watcher has been created such that
1578 * it ignores change file system events.
1579 */
1580 ignoreChangeEvents: boolean;
1581
1582 /**
1583 * true if this file system watcher has been created such that
1584 * it ignores delete file system events.
1585 */
1586 ignoreDeleteEvents: boolean;
1587
1588 /**
1589 * An event which fires on file/folder creation.
1590 */
1591 onDidCreate: Event<Uri>;
1592
1593 /**
1594 * An event which fires on file/folder change.
1595 */
1596 onDidChange: Event<Uri>;
1597
1598 /**
1599 * An event which fires on file/folder deletion.
1600 */
1601 onDidDelete: Event<Uri>;
1602 }
1603
1604 /**
1605 * A text document content provider allows to add readonly documents
1606 * to the editor, such as source from a dll or generated html from md.
1607 *
1608 * Content providers are [registered](#workspace.registerTextDocumentContentProvider)
1609 * for a [uri-scheme](#Uri.scheme). When a uri with that scheme is to
1610 * be [loaded](#workspace.openTextDocument) the content provider is
1611 * asked.
1612 */
1613 export interface TextDocumentContentProvider {
1614
1615 /**
1616 * An event to signal a resource has changed.
1617 */
1618 onDidChange?: Event<Uri>;
1619
1620 /**
1621 * Provide textual content for a given uri.
1622 *
1623 * The editor will use the returned string-content to create a readonly
1624 * [document](#TextDocument). Resources allocated should be released when
1625 * the corresponding document has been [closed](#workspace.onDidCloseTextDocument).
1626 *
1627 * **Note**: The contents of the created [document](#TextDocument) might not be
1628 * identical to the provided text due to end-of-line-sequence normalization.
1629 *
1630 * @param uri An uri which scheme matches the scheme this provider was [registered](#workspace.registerTextDocumentContentProvider) for.
1631 * @param token A cancellation token.
1632 * @return A string or a thenable that resolves to such.
1633 */
1634 provideTextDocumentContent(uri: Uri, token: CancellationToken): ProviderResult<string>;
1635 }
1636
1637 /**
1638 * Represents an item that can be selected from
1639 * a list of items.
1640 */
1641 export interface QuickPickItem {
1642
1643 /**
1644 * A human-readable string which is rendered prominent. Supports rendering of [theme icons](#ThemeIcon) via
1645 * the `$(<name>)`-syntax.
1646 */
1647 label: string;
1648
1649 /**
1650 * A human-readable string which is rendered less prominent in the same line. Supports rendering of
1651 * [theme icons](#ThemeIcon) via the `$(<name>)`-syntax.
1652 */
1653 description?: string;
1654
1655 /**
1656 * A human-readable string which is rendered less prominent in a separate line. Supports rendering of
1657 * [theme icons](#ThemeIcon) via the `$(<name>)`-syntax.
1658 */
1659 detail?: string;
1660
1661 /**
1662 * Optional flag indicating if this item is picked initially.
1663 * (Only honored when the picker allows multiple selections.)
1664 *
1665 * @see [QuickPickOptions.canPickMany](#QuickPickOptions.canPickMany)
1666 */
1667 picked?: boolean;
1668
1669 /**
1670 * Always show this item.
1671 */
1672 alwaysShow?: boolean;
1673 }
1674
1675 /**
1676 * Options to configure the behavior of the quick pick UI.
1677 */
1678 export interface QuickPickOptions {
1679
1680 /**
1681 * An optional string that represents the title of the quick pick.
1682 */
1683 title?: string;
1684
1685 /**
1686 * An optional flag to include the description when filtering the picks.
1687 */
1688 matchOnDescription?: boolean;
1689
1690 /**
1691 * An optional flag to include the detail when filtering the picks.
1692 */
1693 matchOnDetail?: boolean;
1694
1695 /**
1696 * An optional string to show as placeholder in the input box to guide the user what to pick on.
1697 */
1698 placeHolder?: string;
1699
1700 /**
1701 * Set to `true` to keep the picker open when focus moves to another part of the editor or to another window.
1702 */
1703 ignoreFocusOut?: boolean;
1704
1705 /**
1706 * An optional flag to make the picker accept multiple selections, if true the result is an array of picks.
1707 */
1708 canPickMany?: boolean;
1709
1710 /**
1711 * An optional function that is invoked whenever an item is selected.
1712 */
1713 onDidSelectItem?(item: QuickPickItem | string): any;
1714 }
1715
1716 /**
1717 * Options to configure the behaviour of the [workspace folder](#WorkspaceFolder) pick UI.
1718 */
1719 export interface WorkspaceFolderPickOptions {
1720
1721 /**
1722 * An optional string to show as placeholder in the input box to guide the user what to pick on.
1723 */
1724 placeHolder?: string;
1725
1726 /**
1727 * Set to `true` to keep the picker open when focus moves to another part of the editor or to another window.
1728 */
1729 ignoreFocusOut?: boolean;
1730 }
1731
1732 /**
1733 * Options to configure the behaviour of a file open dialog.
1734 *
1735 * * Note 1: On Windows and Linux, a file dialog cannot be both a file selector and a folder selector, so if you
1736 * set both `canSelectFiles` and `canSelectFolders` to `true` on these platforms, a folder selector will be shown.
1737 * * Note 2: Explicitly setting `canSelectFiles` and `canSelectFolders` to `false` is futile
1738 * and the editor then silently adjusts the options to select files.
1739 */
1740 export interface OpenDialogOptions {
1741 /**
1742 * The resource the dialog shows when opened.
1743 */
1744 defaultUri?: Uri;
1745
1746 /**
1747 * A human-readable string for the open button.
1748 */
1749 openLabel?: string;
1750
1751 /**
1752 * Allow to select files, defaults to `true`.
1753 */
1754 canSelectFiles?: boolean;
1755
1756 /**
1757 * Allow to select folders, defaults to `false`.
1758 */
1759 canSelectFolders?: boolean;
1760
1761 /**
1762 * Allow to select many files or folders.
1763 */
1764 canSelectMany?: boolean;
1765
1766 /**
1767 * A set of file filters that are used by the dialog. Each entry is a human-readable label,
1768 * like "TypeScript", and an array of extensions, e.g.
1769 * ```ts
1770 * {
1771 * 'Images': ['png', 'jpg']
1772 * 'TypeScript': ['ts', 'tsx']
1773 * }
1774 * ```
1775 */
1776 filters?: { [name: string]: string[] };
1777
1778 /**
1779 * Dialog title.
1780 *
1781 * This parameter might be ignored, as not all operating systems display a title on open dialogs
1782 * (for example, macOS).
1783 */
1784 title?: string;
1785 }
1786
1787 /**
1788 * Options to configure the behaviour of a file save dialog.
1789 */
1790 export interface SaveDialogOptions {
1791 /**
1792 * The resource the dialog shows when opened.
1793 */
1794 defaultUri?: Uri;
1795
1796 /**
1797 * A human-readable string for the save button.
1798 */
1799 saveLabel?: string;
1800
1801 /**
1802 * A set of file filters that are used by the dialog. Each entry is a human-readable label,
1803 * like "TypeScript", and an array of extensions, e.g.
1804 * ```ts
1805 * {
1806 * 'Images': ['png', 'jpg']
1807 * 'TypeScript': ['ts', 'tsx']
1808 * }
1809 * ```
1810 */
1811 filters?: { [name: string]: string[] };
1812
1813 /**
1814 * Dialog title.
1815 *
1816 * This parameter might be ignored, as not all operating systems display a title on save dialogs
1817 * (for example, macOS).
1818 */
1819 title?: string;
1820 }
1821
1822 /**
1823 * Represents an action that is shown with an information, warning, or
1824 * error message.
1825 *
1826 * @see [showInformationMessage](#window.showInformationMessage)
1827 * @see [showWarningMessage](#window.showWarningMessage)
1828 * @see [showErrorMessage](#window.showErrorMessage)
1829 */
1830 export interface MessageItem {
1831
1832 /**
1833 * A short title like 'Retry', 'Open Log' etc.
1834 */
1835 title: string;
1836
1837 /**
1838 * A hint for modal dialogs that the item should be triggered
1839 * when the user cancels the dialog (e.g. by pressing the ESC
1840 * key).
1841 *
1842 * Note: this option is ignored for non-modal messages.
1843 */
1844 isCloseAffordance?: boolean;
1845 }
1846
1847 /**
1848 * Options to configure the behavior of the message.
1849 *
1850 * @see [showInformationMessage](#window.showInformationMessage)
1851 * @see [showWarningMessage](#window.showWarningMessage)
1852 * @see [showErrorMessage](#window.showErrorMessage)
1853 */
1854 export interface MessageOptions {
1855
1856 /**
1857 * Indicates that this message should be modal.
1858 */
1859 modal?: boolean;
1860 }
1861
1862 /**
1863 * Options to configure the behavior of the input box UI.
1864 */
1865 export interface InputBoxOptions {
1866
1867 /**
1868 * An optional string that represents the title of the input box.
1869 */
1870 title?: string;
1871
1872 /**
1873 * The value to prefill in the input box.
1874 */
1875 value?: string;
1876
1877 /**
1878 * Selection of the prefilled [`value`](#InputBoxOptions.value). Defined as tuple of two number where the
1879 * first is the inclusive start index and the second the exclusive end index. When `undefined` the whole
1880 * word will be selected, when empty (start equals end) only the cursor will be set,
1881 * otherwise the defined range will be selected.
1882 */
1883 valueSelection?: [number, number];
1884
1885 /**
1886 * The text to display underneath the input box.
1887 */
1888 prompt?: string;
1889
1890 /**
1891 * An optional string to show as placeholder in the input box to guide the user what to type.
1892 */
1893 placeHolder?: string;
1894
1895 /**
1896 * Controls if a password input is shown. Password input hides the typed text.
1897 */
1898 password?: boolean;
1899
1900 /**
1901 * Set to `true` to keep the input box open when focus moves to another part of the editor or to another window.
1902 */
1903 ignoreFocusOut?: boolean;
1904
1905 /**
1906 * An optional function that will be called to validate input and to give a hint
1907 * to the user.
1908 *
1909 * @param value The current value of the input box.
1910 * @return A human-readable string which is presented as diagnostic message.
1911 * Return `undefined`, `null`, or the empty string when 'value' is valid.
1912 */
1913 validateInput?(value: string): string | undefined | null | Thenable<string | undefined | null>;
1914 }
1915
1916 /**
1917 * A relative pattern is a helper to construct glob patterns that are matched
1918 * relatively to a base file path. The base path can either be an absolute file
1919 * path as string or uri or a [workspace folder](#WorkspaceFolder), which is the
1920 * preferred way of creating the relative pattern.
1921 */
1922 export class RelativePattern {
1923
1924 /**
1925 * A base file path to which this pattern will be matched against relatively.
1926 */
1927 base: string;
1928
1929 /**
1930 * A file glob pattern like `*.{ts,js}` that will be matched on file paths
1931 * relative to the base path.
1932 *
1933 * Example: Given a base of `/home/work/folder` and a file path of `/home/work/folder/index.js`,
1934 * the file glob pattern will match on `index.js`.
1935 */
1936 pattern: string;
1937
1938 /**
1939 * Creates a new relative pattern object with a base file path and pattern to match. This pattern
1940 * will be matched on file paths relative to the base.
1941 *
1942 * Example:
1943 * ```ts
1944 * const folder = vscode.workspace.workspaceFolders?.[0];
1945 * if (folder) {
1946 *
1947 * // Match any TypeScript file in the root of this workspace folder
1948 * const pattern1 = new vscode.RelativePattern(folder, '*.ts');
1949 *
1950 * // Match any TypeScript file in `someFolder` inside this workspace folder
1951 * const pattern2 = new vscode.RelativePattern(folder, 'someFolder/*.ts');
1952 * }
1953 * ```
1954 *
1955 * @param base A base to which this pattern will be matched against relatively. It is recommended
1956 * to pass in a [workspace folder](#WorkspaceFolder) if the pattern should match inside the workspace.
1957 * Otherwise, a uri or string should only be used if the pattern is for a file path outside the workspace.
1958 * @param pattern A file glob pattern like `*.{ts,js}` that will be matched on paths relative to the base.
1959 */
1960 constructor(base: WorkspaceFolder | Uri | string, pattern: string)
1961 }
1962
1963 /**
1964 * A file glob pattern to match file paths against. This can either be a glob pattern string
1965 * (like `**​/*.{ts,js}` or `*.{ts,js}`) or a [relative pattern](#RelativePattern).
1966 *
1967 * Glob patterns can have the following syntax:
1968 * * `*` to match one or more characters in a path segment
1969 * * `?` to match on one character in a path segment
1970 * * `**` to match any number of path segments, including none
1971 * * `{}` to group conditions (e.g. `**​/*.{ts,js}` matches all TypeScript and JavaScript files)
1972 * * `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
1973 * * `[!...]` 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`)
1974 *
1975 * Note: a backslash (`\`) is not valid within a glob pattern. If you have an existing file
1976 * path to match against, consider to use the [relative pattern](#RelativePattern) support
1977 * that takes care of converting any backslash into slash. Otherwise, make sure to convert
1978 * any backslash to slash when creating the glob pattern.
1979 */
1980 export type GlobPattern = string | RelativePattern;
1981
1982 /**
1983 * A document filter denotes a document by different properties like
1984 * the [language](#TextDocument.languageId), the [scheme](#Uri.scheme) of
1985 * its resource, or a glob-pattern that is applied to the [path](#TextDocument.fileName).
1986 *
1987 * @example <caption>A language filter that applies to typescript files on disk</caption>
1988 * { language: 'typescript', scheme: 'file' }
1989 *
1990 * @example <caption>A language filter that applies to all package.json paths</caption>
1991 * { language: 'json', scheme: 'untitled', pattern: '**​/package.json' }
1992 */
1993 export interface DocumentFilter {
1994
1995 /**
1996 * A language id, like `typescript`.
1997 */
1998 readonly language?: string;
1999
2000 /**
2001 * A Uri [scheme](#Uri.scheme), like `file` or `untitled`.
2002 */
2003 readonly scheme?: string;
2004
2005 /**
2006 * A [glob pattern](#GlobPattern) that is matched on the absolute path of the document. Use a [relative pattern](#RelativePattern)
2007 * to filter documents to a [workspace folder](#WorkspaceFolder).
2008 */
2009 readonly pattern?: GlobPattern;
2010 }
2011
2012 /**
2013 * A language selector is the combination of one or many language identifiers
2014 * and [language filters](#DocumentFilter).
2015 *
2016 * *Note* that a document selector that is just a language identifier selects *all*
2017 * documents, even those that are not saved on disk. Only use such selectors when
2018 * a feature works without further context, e.g. without the need to resolve related
2019 * 'files'.
2020 *
2021 * @example
2022 * let sel:DocumentSelector = { scheme: 'file', language: 'typescript' };
2023 */
2024 export type DocumentSelector = DocumentFilter | string | ReadonlyArray<DocumentFilter | string>;
2025
2026 /**
2027 * A provider result represents the values a provider, like the [`HoverProvider`](#HoverProvider),
2028 * may return. For once this is the actual result type `T`, like `Hover`, or a thenable that resolves
2029 * to that type `T`. In addition, `null` and `undefined` can be returned - either directly or from a
2030 * thenable.
2031 *
2032 * The snippets below are all valid implementations of the [`HoverProvider`](#HoverProvider):
2033 *
2034 * ```ts
2035 * let a: HoverProvider = {
2036 * provideHover(doc, pos, token): ProviderResult<Hover> {
2037 * return new Hover('Hello World');
2038 * }
2039 * }
2040 *
2041 * let b: HoverProvider = {
2042 * provideHover(doc, pos, token): ProviderResult<Hover> {
2043 * return new Promise(resolve => {
2044 * resolve(new Hover('Hello World'));
2045 * });
2046 * }
2047 * }
2048 *
2049 * let c: HoverProvider = {
2050 * provideHover(doc, pos, token): ProviderResult<Hover> {
2051 * return; // undefined
2052 * }
2053 * }
2054 * ```
2055 */
2056 export type ProviderResult<T> = T | undefined | null | Thenable<T | undefined | null>;
2057
2058 /**
2059 * Kind of a code action.
2060 *
2061 * Kinds are a hierarchical list of identifiers separated by `.`, e.g. `"refactor.extract.function"`.
2062 *
2063 * Code action kinds are used by VS Code for UI elements such as the refactoring context menu. Users
2064 * can also trigger code actions with a specific kind with the `editor.action.codeAction` command.
2065 */
2066 export class CodeActionKind {
2067 /**
2068 * Empty kind.
2069 */
2070 static readonly Empty: CodeActionKind;
2071
2072 /**
2073 * Base kind for quickfix actions: `quickfix`.
2074 *
2075 * Quick fix actions address a problem in the code and are shown in the normal code action context menu.
2076 */
2077 static readonly QuickFix: CodeActionKind;
2078
2079 /**
2080 * Base kind for refactoring actions: `refactor`
2081 *
2082 * Refactoring actions are shown in the refactoring context menu.
2083 */
2084 static readonly Refactor: CodeActionKind;
2085
2086 /**
2087 * Base kind for refactoring extraction actions: `refactor.extract`
2088 *
2089 * Example extract actions:
2090 *
2091 * - Extract method
2092 * - Extract function
2093 * - Extract variable
2094 * - Extract interface from class
2095 * - ...
2096 */
2097 static readonly RefactorExtract: CodeActionKind;
2098
2099 /**
2100 * Base kind for refactoring inline actions: `refactor.inline`
2101 *
2102 * Example inline actions:
2103 *
2104 * - Inline function
2105 * - Inline variable
2106 * - Inline constant
2107 * - ...
2108 */
2109 static readonly RefactorInline: CodeActionKind;
2110
2111 /**
2112 * Base kind for refactoring rewrite actions: `refactor.rewrite`
2113 *
2114 * Example rewrite actions:
2115 *
2116 * - Convert JavaScript function to class
2117 * - Add or remove parameter
2118 * - Encapsulate field
2119 * - Make method static
2120 * - Move method to base class
2121 * - ...
2122 */
2123 static readonly RefactorRewrite: CodeActionKind;
2124
2125 /**
2126 * Base kind for source actions: `source`
2127 *
2128 * Source code actions apply to the entire file. They must be explicitly requested and will not show in the
2129 * normal [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) menu. Source actions
2130 * can be run on save using `editor.codeActionsOnSave` and are also shown in the `source` context menu.
2131 */
2132 static readonly Source: CodeActionKind;
2133
2134 /**
2135 * Base kind for an organize imports source action: `source.organizeImports`.
2136 */
2137 static readonly SourceOrganizeImports: CodeActionKind;
2138
2139 /**
2140 * Base kind for auto-fix source actions: `source.fixAll`.
2141 *
2142 * Fix all actions automatically fix errors that have a clear fix that do not require user input.
2143 * They should not suppress errors or perform unsafe fixes such as generating new types or classes.
2144 */
2145 static readonly SourceFixAll: CodeActionKind;
2146
2147 private constructor(value: string);
2148
2149 /**
2150 * String value of the kind, e.g. `"refactor.extract.function"`.
2151 */
2152 readonly value: string;
2153
2154 /**
2155 * Create a new kind by appending a more specific selector to the current kind.
2156 *
2157 * Does not modify the current kind.
2158 */
2159 append(parts: string): CodeActionKind;
2160
2161 /**
2162 * Checks if this code action kind intersects `other`.
2163 *
2164 * The kind `"refactor.extract"` for example intersects `refactor`, `"refactor.extract"` and ``"refactor.extract.function"`,
2165 * but not `"unicorn.refactor.extract"`, or `"refactor.extractAll"`.
2166 *
2167 * @param other Kind to check.
2168 */
2169 intersects(other: CodeActionKind): boolean;
2170
2171 /**
2172 * Checks if `other` is a sub-kind of this `CodeActionKind`.
2173 *
2174 * The kind `"refactor.extract"` for example contains `"refactor.extract"` and ``"refactor.extract.function"`,
2175 * but not `"unicorn.refactor.extract"`, or `"refactor.extractAll"` or `refactor`.
2176 *
2177 * @param other Kind to check.
2178 */
2179 contains(other: CodeActionKind): boolean;
2180 }
2181
2182 /**
2183 * The reason why code actions were requested.
2184 */
2185 export enum CodeActionTriggerKind {
2186 /**
2187 * Code actions were explicitly requested by the user or by an extension.
2188 */
2189 Invoke = 1,
2190
2191 /**
2192 * Code actions were requested automatically.
2193 *
2194 * This typically happens when current selection in a file changes, but can
2195 * also be triggered when file content changes.
2196 */
2197 Automatic = 2,
2198 }
2199
2200 /**
2201 * Contains additional diagnostic information about the context in which
2202 * a [code action](#CodeActionProvider.provideCodeActions) is run.
2203 */
2204 export interface CodeActionContext {
2205 /**
2206 * The reason why code actions were requested.
2207 */
2208 readonly triggerKind: CodeActionTriggerKind;
2209
2210 /**
2211 * An array of diagnostics.
2212 */
2213 readonly diagnostics: ReadonlyArray<Diagnostic>;
2214
2215 /**
2216 * Requested kind of actions to return.
2217 *
2218 * Actions not of this kind are filtered out before being shown by the [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action).
2219 */
2220 readonly only?: CodeActionKind;
2221 }
2222
2223 /**
2224 * A code action represents a change that can be performed in code, e.g. to fix a problem or
2225 * to refactor code.
2226 *
2227 * A CodeAction must set either [`edit`](#CodeAction.edit) and/or a [`command`](#CodeAction.command). If both are supplied, the `edit` is applied first, then the command is executed.
2228 */
2229 export class CodeAction {
2230
2231 /**
2232 * A short, human-readable, title for this code action.
2233 */
2234 title: string;
2235
2236 /**
2237 * A [workspace edit](#WorkspaceEdit) this code action performs.
2238 */
2239 edit?: WorkspaceEdit;
2240
2241 /**
2242 * [Diagnostics](#Diagnostic) that this code action resolves.
2243 */
2244 diagnostics?: Diagnostic[];
2245
2246 /**
2247 * A [command](#Command) this code action executes.
2248 *
2249 * If this command throws an exception, VS Code displays the exception message to users in the editor at the
2250 * current cursor position.
2251 */
2252 command?: Command;
2253
2254 /**
2255 * [Kind](#CodeActionKind) of the code action.
2256 *
2257 * Used to filter code actions.
2258 */
2259 kind?: CodeActionKind;
2260
2261 /**
2262 * Marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted
2263 * by keybindings.
2264 *
2265 * A quick fix should be marked preferred if it properly addresses the underlying error.
2266 * A refactoring should be marked preferred if it is the most reasonable choice of actions to take.
2267 */
2268 isPreferred?: boolean;
2269
2270 /**
2271 * Marks that the code action cannot currently be applied.
2272 *
2273 * - Disabled code actions are not shown in automatic [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action)
2274 * code action menu.
2275 *
2276 * - Disabled actions are shown as faded out in the code action menu when the user request a more specific type
2277 * of code action, such as refactorings.
2278 *
2279 * - If the user has a [keybinding](https://code.visualstudio.com/docs/editor/refactoring#_keybindings-for-code-actions)
2280 * that auto applies a code action and only a disabled code actions are returned, VS Code will show the user an
2281 * error message with `reason` in the editor.
2282 */
2283 disabled?: {
2284 /**
2285 * Human readable description of why the code action is currently disabled.
2286 *
2287 * This is displayed in the code actions UI.
2288 */
2289 readonly reason: string;
2290 };
2291
2292 /**
2293 * Creates a new code action.
2294 *
2295 * A code action must have at least a [title](#CodeAction.title) and [edits](#CodeAction.edit)
2296 * and/or a [command](#CodeAction.command).
2297 *
2298 * @param title The title of the code action.
2299 * @param kind The kind of the code action.
2300 */
2301 constructor(title: string, kind?: CodeActionKind);
2302 }
2303
2304 /**
2305 * The code action interface defines the contract between extensions and
2306 * the [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature.
2307 *
2308 * A code action can be any command that is [known](#commands.getCommands) to the system.
2309 */
2310 export interface CodeActionProvider<T extends CodeAction = CodeAction> {
2311 /**
2312 * Provide commands for the given document and range.
2313 *
2314 * @param document The document in which the command was invoked.
2315 * @param range The selector or range for which the command was invoked. This will always be a selection if
2316 * there is a currently active editor.
2317 * @param context Context carrying additional information.
2318 * @param token A cancellation token.
2319 *
2320 * @return An array of code actions, such as quick fixes or refactorings. The lack of a result can be signaled
2321 * by returning `undefined`, `null`, or an empty array.
2322 *
2323 * We also support returning `Command` for legacy reasons, however all new extensions should return
2324 * `CodeAction` object instead.
2325 */
2326 provideCodeActions(document: TextDocument, range: Range | Selection, context: CodeActionContext, token: CancellationToken): ProviderResult<(Command | T)[]>;
2327
2328 /**
2329 * Given a code action fill in its [`edit`](#CodeAction.edit)-property. Changes to
2330 * all other properties, like title, are ignored. A code action that has an edit
2331 * will not be resolved.
2332 *
2333 * *Note* that a code action provider that returns commands, not code actions, cannot successfully
2334 * implement this function. Returning commands is deprecated and instead code actions should be
2335 * returned.
2336 *
2337 * @param codeAction A code action.
2338 * @param token A cancellation token.
2339 * @return The resolved code action or a thenable that resolves to such. It is OK to return the given
2340 * `item`. When no result is returned, the given `item` will be used.
2341 */
2342 resolveCodeAction?(codeAction: T, token: CancellationToken): ProviderResult<T>;
2343 }
2344
2345 /**
2346 * Metadata about the type of code actions that a [CodeActionProvider](#CodeActionProvider) provides.
2347 */
2348 export interface CodeActionProviderMetadata {
2349 /**
2350 * List of [CodeActionKinds](#CodeActionKind) that a [CodeActionProvider](#CodeActionProvider) may return.
2351 *
2352 * This list is used to determine if a given `CodeActionProvider` should be invoked or not.
2353 * To avoid unnecessary computation, every `CodeActionProvider` should list use `providedCodeActionKinds`. The
2354 * list of kinds may either be generic, such as `[CodeActionKind.Refactor]`, or list out every kind provided,
2355 * such as `[CodeActionKind.Refactor.Extract.append('function'), CodeActionKind.Refactor.Extract.append('constant'), ...]`.
2356 */
2357 readonly providedCodeActionKinds?: ReadonlyArray<CodeActionKind>;
2358
2359 /**
2360 * Static documentation for a class of code actions.
2361 *
2362 * Documentation from the provider is shown in the code actions menu if either:
2363 *
2364 * - Code actions of `kind` are requested by VS Code. In this case, VS Code will show the documentation that
2365 * most closely matches the requested code action kind. For example, if a provider has documentation for
2366 * both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`,
2367 * VS Code will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`.
2368 *
2369 * - Any code actions of `kind` are returned by the provider.
2370 *
2371 * At most one documentation entry will be shown per provider.
2372 */
2373 readonly documentation?: ReadonlyArray<{
2374 /**
2375 * The kind of the code action being documented.
2376 *
2377 * If the kind is generic, such as `CodeActionKind.Refactor`, the documentation will be shown whenever any
2378 * refactorings are returned. If the kind if more specific, such as `CodeActionKind.RefactorExtract`, the
2379 * documentation will only be shown when extract refactoring code actions are returned.
2380 */
2381 readonly kind: CodeActionKind;
2382
2383 /**
2384 * Command that displays the documentation to the user.
2385 *
2386 * This can display the documentation directly in VS Code or open a website using [`env.openExternal`](#env.openExternal);
2387 *
2388 * The title of this documentation code action is taken from [`Command.title`](#Command.title)
2389 */
2390 readonly command: Command;
2391 }>;
2392 }
2393
2394 /**
2395 * A code lens represents a [command](#Command) that should be shown along with
2396 * source text, like the number of references, a way to run tests, etc.
2397 *
2398 * A code lens is _unresolved_ when no command is associated to it. For performance
2399 * reasons the creation of a code lens and resolving should be done to two stages.
2400 *
2401 * @see [CodeLensProvider.provideCodeLenses](#CodeLensProvider.provideCodeLenses)
2402 * @see [CodeLensProvider.resolveCodeLens](#CodeLensProvider.resolveCodeLens)
2403 */
2404 export class CodeLens {
2405
2406 /**
2407 * The range in which this code lens is valid. Should only span a single line.
2408 */
2409 range: Range;
2410
2411 /**
2412 * The command this code lens represents.
2413 */
2414 command?: Command;
2415
2416 /**
2417 * `true` when there is a command associated.
2418 */
2419 readonly isResolved: boolean;
2420
2421 /**
2422 * Creates a new code lens object.
2423 *
2424 * @param range The range to which this code lens applies.
2425 * @param command The command associated to this code lens.
2426 */
2427 constructor(range: Range, command?: Command);
2428 }
2429
2430 /**
2431 * A code lens provider adds [commands](#Command) to source text. The commands will be shown
2432 * as dedicated horizontal lines in between the source text.
2433 */
2434 export interface CodeLensProvider<T extends CodeLens = CodeLens> {
2435
2436 /**
2437 * An optional event to signal that the code lenses from this provider have changed.
2438 */
2439 onDidChangeCodeLenses?: Event<void>;
2440
2441 /**
2442 * Compute a list of [lenses](#CodeLens). This call should return as fast as possible and if
2443 * computing the commands is expensive implementors should only return code lens objects with the
2444 * range set and implement [resolve](#CodeLensProvider.resolveCodeLens).
2445 *
2446 * @param document The document in which the command was invoked.
2447 * @param token A cancellation token.
2448 * @return An array of code lenses or a thenable that resolves to such. The lack of a result can be
2449 * signaled by returning `undefined`, `null`, or an empty array.
2450 */
2451 provideCodeLenses(document: TextDocument, token: CancellationToken): ProviderResult<T[]>;
2452
2453 /**
2454 * This function will be called for each visible code lens, usually when scrolling and after
2455 * calls to [compute](#CodeLensProvider.provideCodeLenses)-lenses.
2456 *
2457 * @param codeLens Code lens that must be resolved.
2458 * @param token A cancellation token.
2459 * @return The given, resolved code lens or thenable that resolves to such.
2460 */
2461 resolveCodeLens?(codeLens: T, token: CancellationToken): ProviderResult<T>;
2462 }
2463
2464 /**
2465 * Information about where a symbol is defined.
2466 *
2467 * Provides additional metadata over normal {@link Location location} definitions, including the range of
2468 * the defining symbol
2469 */
2470 export type DefinitionLink = LocationLink;
2471
2472 /**
2473 * The definition of a symbol represented as one or many {@link Location locations}.
2474 * For most programming languages there is only one location at which a symbol is
2475 * defined.
2476 */
2477 export type Definition = Location | Location[];
2478
2479 /**
2480 * The definition provider interface defines the contract between extensions and
2481 * the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
2482 * and peek definition features.
2483 */
2484 export interface DefinitionProvider {
2485
2486 /**
2487 * Provide the definition of the symbol at the given position and document.
2488 *
2489 * @param document The document in which the command was invoked.
2490 * @param position The position at which the command was invoked.
2491 * @param token A cancellation token.
2492 * @return A definition or a thenable that resolves to such. The lack of a result can be
2493 * signaled by returning `undefined` or `null`.
2494 */
2495 provideDefinition(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
2496 }
2497
2498 /**
2499 * The implementation provider interface defines the contract between extensions and
2500 * the go to implementation feature.
2501 */
2502 export interface ImplementationProvider {
2503
2504 /**
2505 * Provide the implementations of the symbol at the given position and document.
2506 *
2507 * @param document The document in which the command was invoked.
2508 * @param position The position at which the command was invoked.
2509 * @param token A cancellation token.
2510 * @return A definition or a thenable that resolves to such. The lack of a result can be
2511 * signaled by returning `undefined` or `null`.
2512 */
2513 provideImplementation(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
2514 }
2515
2516 /**
2517 * The type definition provider defines the contract between extensions and
2518 * the go to type definition feature.
2519 */
2520 export interface TypeDefinitionProvider {
2521
2522 /**
2523 * Provide the type definition of the symbol at the given position and document.
2524 *
2525 * @param document The document in which the command was invoked.
2526 * @param position The position at which the command was invoked.
2527 * @param token A cancellation token.
2528 * @return A definition or a thenable that resolves to such. The lack of a result can be
2529 * signaled by returning `undefined` or `null`.
2530 */
2531 provideTypeDefinition(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
2532 }
2533
2534 /**
2535 * The declaration of a symbol representation as one or many [locations](#Location)
2536 * or [location links](#LocationLink).
2537 */
2538 export type Declaration = Location | Location[] | LocationLink[];
2539
2540 /**
2541 * The declaration provider interface defines the contract between extensions and
2542 * the go to declaration feature.
2543 */
2544 export interface DeclarationProvider {
2545
2546 /**
2547 * Provide the declaration of the symbol at the given position and document.
2548 *
2549 * @param document The document in which the command was invoked.
2550 * @param position The position at which the command was invoked.
2551 * @param token A cancellation token.
2552 * @return A declaration or a thenable that resolves to such. The lack of a result can be
2553 * signaled by returning `undefined` or `null`.
2554 */
2555 provideDeclaration(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Declaration>;
2556 }
2557
2558 /**
2559 * The MarkdownString represents human-readable text that supports formatting via the
2560 * markdown syntax. Standard markdown is supported, also tables, but no embedded html.
2561 *
2562 * When created with `supportThemeIcons` then rendering of [theme icons](#ThemeIcon) via
2563 * the `$(<name>)`-syntax is supported.
2564 */
2565 export class MarkdownString {
2566
2567 /**
2568 * The markdown string.
2569 */
2570 value: string;
2571
2572 /**
2573 * Indicates that this markdown string is from a trusted source. Only *trusted*
2574 * markdown supports links that execute commands, e.g. `[Run it](command:myCommandId)`.
2575 */
2576 isTrusted?: boolean;
2577
2578 /**
2579 * Indicates that this markdown string can contain [ThemeIcons](#ThemeIcon), e.g. `$(zap)`.
2580 */
2581 readonly supportThemeIcons?: boolean;
2582
2583 /**
2584 * Creates a new markdown string with the given value.
2585 *
2586 * @param value Optional, initial value.
2587 * @param supportThemeIcons Optional, Specifies whether [ThemeIcons](#ThemeIcon) are supported within the [`MarkdownString`](#MarkdownString).
2588 */
2589 constructor(value?: string, supportThemeIcons?: boolean);
2590
2591 /**
2592 * Appends and escapes the given string to this markdown string.
2593 * @param value Plain text.
2594 */
2595 appendText(value: string): MarkdownString;
2596
2597 /**
2598 * Appends the given string 'as is' to this markdown string. When [`supportThemeIcons`](#MarkdownString.supportThemeIcons) is `true`, [ThemeIcons](#ThemeIcon) in the `value` will be iconified.
2599 * @param value Markdown string.
2600 */
2601 appendMarkdown(value: string): MarkdownString;
2602
2603 /**
2604 * Appends the given string as codeblock using the provided language.
2605 * @param value A code snippet.
2606 * @param language An optional [language identifier](#languages.getLanguages).
2607 */
2608 appendCodeblock(value: string, language?: string): MarkdownString;
2609 }
2610
2611 /**
2612 * MarkedString can be used to render human-readable text. It is either a markdown string
2613 * or a code-block that provides a language and a code snippet. Note that
2614 * markdown strings will be sanitized - that means html will be escaped.
2615 *
2616 * @deprecated This type is deprecated, please use [`MarkdownString`](#MarkdownString) instead.
2617 */
2618 export type MarkedString = MarkdownString | string | { language: string; value: string };
2619
2620 /**
2621 * A hover represents additional information for a symbol or word. Hovers are
2622 * rendered in a tooltip-like widget.
2623 */
2624 export class Hover {
2625
2626 /**
2627 * The contents of this hover.
2628 */
2629 contents: MarkedString[];
2630
2631 /**
2632 * The range to which this hover applies. When missing, the
2633 * editor will use the range at the current position or the
2634 * current position itself.
2635 */
2636 range?: Range;
2637
2638 /**
2639 * Creates a new hover object.
2640 *
2641 * @param contents The contents of the hover.
2642 * @param range The range to which the hover applies.
2643 */
2644 constructor(contents: MarkedString | MarkedString[], range?: Range);
2645 }
2646
2647 /**
2648 * The hover provider interface defines the contract between extensions and
2649 * the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature.
2650 */
2651 export interface HoverProvider {
2652
2653 /**
2654 * Provide a hover for the given position and document. Multiple hovers at the same
2655 * position will be merged by the editor. A hover can have a range which defaults
2656 * to the word range at the position when omitted.
2657 *
2658 * @param document The document in which the command was invoked.
2659 * @param position The position at which the command was invoked.
2660 * @param token A cancellation token.
2661 * @return A hover or a thenable that resolves to such. The lack of a result can be
2662 * signaled by returning `undefined` or `null`.
2663 */
2664 provideHover(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Hover>;
2665 }
2666
2667 /**
2668 * An EvaluatableExpression represents an expression in a document that can be evaluated by an active debugger or runtime.
2669 * The result of this evaluation is shown in a tooltip-like widget.
2670 * If only a range is specified, the expression will be extracted from the underlying document.
2671 * An optional expression can be used to override the extracted expression.
2672 * In this case the range is still used to highlight the range in the document.
2673 */
2674 export class EvaluatableExpression {
2675
2676 /*
2677 * The range is used to extract the evaluatable expression from the underlying document and to highlight it.
2678 */
2679 readonly range: Range;
2680
2681 /*
2682 * If specified the expression overrides the extracted expression.
2683 */
2684 readonly expression?: string;
2685
2686 /**
2687 * Creates a new evaluatable expression object.
2688 *
2689 * @param range The range in the underlying document from which the evaluatable expression is extracted.
2690 * @param expression If specified overrides the extracted expression.
2691 */
2692 constructor(range: Range, expression?: string);
2693 }
2694
2695 /**
2696 * The evaluatable expression provider interface defines the contract between extensions and
2697 * the debug hover. In this contract the provider returns an evaluatable expression for a given position
2698 * in a document and VS Code evaluates this expression in the active debug session and shows the result in a debug hover.
2699 */
2700 export interface EvaluatableExpressionProvider {
2701
2702 /**
2703 * Provide an evaluatable expression for the given document and position.
2704 * VS Code will evaluate this expression in the active debug session and will show the result in the debug hover.
2705 * The expression can be implicitly specified by the range in the underlying document or by explicitly returning an expression.
2706 *
2707 * @param document The document for which the debug hover is about to appear.
2708 * @param position The line and character position in the document where the debug hover is about to appear.
2709 * @param token A cancellation token.
2710 * @return An EvaluatableExpression or a thenable that resolves to such. The lack of a result can be
2711 * signaled by returning `undefined` or `null`.
2712 */
2713 provideEvaluatableExpression(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<EvaluatableExpression>;
2714 }
2715
2716 /**
2717 * Provide inline value as text.
2718 */
2719 export class InlineValueText {
2720 /**
2721 * The document range for which the inline value applies.
2722 */
2723 readonly range: Range;
2724 /**
2725 * The text of the inline value.
2726 */
2727 readonly text: string;
2728 /**
2729 * Creates a new InlineValueText object.
2730 *
2731 * @param range The document line where to show the inline value.
2732 * @param text The value to be shown for the line.
2733 */
2734 constructor(range: Range, text: string);
2735 }
2736
2737 /**
2738 * Provide inline value through a variable lookup.
2739 * If only a range is specified, the variable name will be extracted from the underlying document.
2740 * An optional variable name can be used to override the extracted name.
2741 */
2742 export class InlineValueVariableLookup {
2743 /**
2744 * The document range for which the inline value applies.
2745 * The range is used to extract the variable name from the underlying document.
2746 */
2747 readonly range: Range;
2748 /**
2749 * If specified the name of the variable to look up.
2750 */
2751 readonly variableName?: string;
2752 /**
2753 * How to perform the lookup.
2754 */
2755 readonly caseSensitiveLookup: boolean;
2756 /**
2757 * Creates a new InlineValueVariableLookup object.
2758 *
2759 * @param range The document line where to show the inline value.
2760 * @param variableName The name of the variable to look up.
2761 * @param caseSensitiveLookup How to perform the lookup. If missing lookup is case sensitive.
2762 */
2763 constructor(range: Range, variableName?: string, caseSensitiveLookup?: boolean);
2764 }
2765
2766 /**
2767 * Provide an inline value through an expression evaluation.
2768 * If only a range is specified, the expression will be extracted from the underlying document.
2769 * An optional expression can be used to override the extracted expression.
2770 */
2771 export class InlineValueEvaluatableExpression {
2772 /**
2773 * The document range for which the inline value applies.
2774 * The range is used to extract the evaluatable expression from the underlying document.
2775 */
2776 readonly range: Range;
2777 /**
2778 * If specified the expression overrides the extracted expression.
2779 */
2780 readonly expression?: string;
2781 /**
2782 * Creates a new InlineValueEvaluatableExpression object.
2783 *
2784 * @param range The range in the underlying document from which the evaluatable expression is extracted.
2785 * @param expression If specified overrides the extracted expression.
2786 */
2787 constructor(range: Range, expression?: string);
2788 }
2789
2790 /**
2791 * Inline value information can be provided by different means:
2792 * - directly as a text value (class InlineValueText).
2793 * - as a name to use for a variable lookup (class InlineValueVariableLookup)
2794 * - as an evaluatable expression (class InlineValueEvaluatableExpression)
2795 * The InlineValue types combines all inline value types into one type.
2796 */
2797 export type InlineValue = InlineValueText | InlineValueVariableLookup | InlineValueEvaluatableExpression;
2798
2799 /**
2800 * A value-object that contains contextual information when requesting inline values from a InlineValuesProvider.
2801 */
2802 export interface InlineValueContext {
2803
2804 /**
2805 * The stack frame (as a DAP Id) where the execution has stopped.
2806 */
2807 readonly frameId: number;
2808
2809 /**
2810 * The document range where execution has stopped.
2811 * Typically the end position of the range denotes the line where the inline values are shown.
2812 */
2813 readonly stoppedLocation: Range;
2814 }
2815
2816 /**
2817 * The inline values provider interface defines the contract between extensions and the VS Code debugger inline values feature.
2818 * In this contract the provider returns inline value information for a given document range
2819 * and VS Code shows this information in the editor at the end of lines.
2820 */
2821 export interface InlineValuesProvider {
2822
2823 /**
2824 * An optional event to signal that inline values have changed.
2825 * @see [EventEmitter](#EventEmitter)
2826 */
2827 onDidChangeInlineValues?: Event<void> | undefined;
2828
2829 /**
2830 * Provide "inline value" information for a given document and range.
2831 * VS Code calls this method whenever debugging stops in the given document.
2832 * The returned inline values information is rendered in the editor at the end of lines.
2833 *
2834 * @param document The document for which the inline values information is needed.
2835 * @param viewPort The visible document range for which inline values should be computed.
2836 * @param context A bag containing contextual information like the current location.
2837 * @param token A cancellation token.
2838 * @return An array of InlineValueDescriptors or a thenable that resolves to such. The lack of a result can be
2839 * signaled by returning `undefined` or `null`.
2840 */
2841 provideInlineValues(document: TextDocument, viewPort: Range, context: InlineValueContext, token: CancellationToken): ProviderResult<InlineValue[]>;
2842 }
2843
2844 /**
2845 * A document highlight kind.
2846 */
2847 export enum DocumentHighlightKind {
2848
2849 /**
2850 * A textual occurrence.
2851 */
2852 Text = 0,
2853
2854 /**
2855 * Read-access of a symbol, like reading a variable.
2856 */
2857 Read = 1,
2858
2859 /**
2860 * Write-access of a symbol, like writing to a variable.
2861 */
2862 Write = 2
2863 }
2864
2865 /**
2866 * A document highlight is a range inside a text document which deserves
2867 * special attention. Usually a document highlight is visualized by changing
2868 * the background color of its range.
2869 */
2870 export class DocumentHighlight {
2871
2872 /**
2873 * The range this highlight applies to.
2874 */
2875 range: Range;
2876
2877 /**
2878 * The highlight kind, default is [text](#DocumentHighlightKind.Text).
2879 */
2880 kind?: DocumentHighlightKind;
2881
2882 /**
2883 * Creates a new document highlight object.
2884 *
2885 * @param range The range the highlight applies to.
2886 * @param kind The highlight kind, default is [text](#DocumentHighlightKind.Text).
2887 */
2888 constructor(range: Range, kind?: DocumentHighlightKind);
2889 }
2890
2891 /**
2892 * The document highlight provider interface defines the contract between extensions and
2893 * the word-highlight-feature.
2894 */
2895 export interface DocumentHighlightProvider {
2896
2897 /**
2898 * Provide a set of document highlights, like all occurrences of a variable or
2899 * all exit-points of a function.
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 * @return An array of document highlights or a thenable that resolves to such. The lack of a result can be
2905 * signaled by returning `undefined`, `null`, or an empty array.
2906 */
2907 provideDocumentHighlights(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<DocumentHighlight[]>;
2908 }
2909
2910 /**
2911 * A symbol kind.
2912 */
2913 export enum SymbolKind {
2914 File = 0,
2915 Module = 1,
2916 Namespace = 2,
2917 Package = 3,
2918 Class = 4,
2919 Method = 5,
2920 Property = 6,
2921 Field = 7,
2922 Constructor = 8,
2923 Enum = 9,
2924 Interface = 10,
2925 Function = 11,
2926 Variable = 12,
2927 Constant = 13,
2928 String = 14,
2929 Number = 15,
2930 Boolean = 16,
2931 Array = 17,
2932 Object = 18,
2933 Key = 19,
2934 Null = 20,
2935 EnumMember = 21,
2936 Struct = 22,
2937 Event = 23,
2938 Operator = 24,
2939 TypeParameter = 25
2940 }
2941
2942 /**
2943 * Symbol tags are extra annotations that tweak the rendering of a symbol.
2944 */
2945 export enum SymbolTag {
2946
2947 /**
2948 * Render a symbol as obsolete, usually using a strike-out.
2949 */
2950 Deprecated = 1
2951 }
2952
2953 /**
2954 * Represents information about programming constructs like variables, classes,
2955 * interfaces etc.
2956 */
2957 export class SymbolInformation {
2958
2959 /**
2960 * The name of this symbol.
2961 */
2962 name: string;
2963
2964 /**
2965 * The name of the symbol containing this symbol.
2966 */
2967 containerName: string;
2968
2969 /**
2970 * The kind of this symbol.
2971 */
2972 kind: SymbolKind;
2973
2974 /**
2975 * Tags for this symbol.
2976 */
2977 tags?: ReadonlyArray<SymbolTag>;
2978
2979 /**
2980 * The location of this symbol.
2981 */
2982 location: Location;
2983
2984 /**
2985 * Creates a new symbol information object.
2986 *
2987 * @param name The name of the symbol.
2988 * @param kind The kind of the symbol.
2989 * @param containerName The name of the symbol containing the symbol.
2990 * @param location The location of the symbol.
2991 */
2992 constructor(name: string, kind: SymbolKind, containerName: string, location: Location);
2993
2994 /**
2995 * Creates a new symbol information object.
2996 *
2997 * @deprecated Please use the constructor taking a [location](#Location) object.
2998 *
2999 * @param name The name of the symbol.
3000 * @param kind The kind of the symbol.
3001 * @param range The range of the location of the symbol.
3002 * @param uri The resource of the location of symbol, defaults to the current document.
3003 * @param containerName The name of the symbol containing the symbol.
3004 */
3005 constructor(name: string, kind: SymbolKind, range: Range, uri?: Uri, containerName?: string);
3006 }
3007
3008 /**
3009 * Represents programming constructs like variables, classes, interfaces etc. that appear in a document. Document
3010 * symbols can be hierarchical and they have two ranges: one that encloses its definition and one that points to
3011 * its most interesting range, e.g. the range of an identifier.
3012 */
3013 export class DocumentSymbol {
3014
3015 /**
3016 * The name of this symbol.
3017 */
3018 name: string;
3019
3020 /**
3021 * More detail for this symbol, e.g. the signature of a function.
3022 */
3023 detail: string;
3024
3025 /**
3026 * The kind of this symbol.
3027 */
3028 kind: SymbolKind;
3029
3030 /**
3031 * Tags for this symbol.
3032 */
3033 tags?: ReadonlyArray<SymbolTag>;
3034
3035 /**
3036 * The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code.
3037 */
3038 range: Range;
3039
3040 /**
3041 * The range that should be selected and reveal when this symbol is being picked, e.g. the name of a function.
3042 * Must be contained by the [`range`](#DocumentSymbol.range).
3043 */
3044 selectionRange: Range;
3045
3046 /**
3047 * Children of this symbol, e.g. properties of a class.
3048 */
3049 children: DocumentSymbol[];
3050
3051 /**
3052 * Creates a new document symbol.
3053 *
3054 * @param name The name of the symbol.
3055 * @param detail Details for the symbol.
3056 * @param kind The kind of the symbol.
3057 * @param range The full range of the symbol.
3058 * @param selectionRange The range that should be reveal.
3059 */
3060 constructor(name: string, detail: string, kind: SymbolKind, range: Range, selectionRange: Range);
3061 }
3062
3063 /**
3064 * The document symbol provider interface defines the contract between extensions and
3065 * the [go to symbol](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-symbol)-feature.
3066 */
3067 export interface DocumentSymbolProvider {
3068
3069 /**
3070 * Provide symbol information for the given document.
3071 *
3072 * @param document The document in which the command was invoked.
3073 * @param token A cancellation token.
3074 * @return An array of document highlights or a thenable that resolves to such. The lack of a result can be
3075 * signaled by returning `undefined`, `null`, or an empty array.
3076 */
3077 provideDocumentSymbols(document: TextDocument, token: CancellationToken): ProviderResult<SymbolInformation[] | DocumentSymbol[]>;
3078 }
3079
3080 /**
3081 * Metadata about a document symbol provider.
3082 */
3083 export interface DocumentSymbolProviderMetadata {
3084 /**
3085 * A human-readable string that is shown when multiple outlines trees show for one document.
3086 */
3087 label?: string;
3088 }
3089
3090 /**
3091 * The workspace symbol provider interface defines the contract between extensions and
3092 * the [symbol search](https://code.visualstudio.com/docs/editor/editingevolved#_open-symbol-by-name)-feature.
3093 */
3094 export interface WorkspaceSymbolProvider<T extends SymbolInformation = SymbolInformation> {
3095
3096 /**
3097 * Project-wide search for a symbol matching the given query string.
3098 *
3099 * The `query`-parameter should be interpreted in a *relaxed way* as the editor will apply its own highlighting
3100 * and scoring on the results. A good rule of thumb is to match case-insensitive and to simply check that the
3101 * characters of *query* appear in their order in a candidate symbol. Don't use prefix, substring, or similar
3102 * strict matching.
3103 *
3104 * To improve performance implementors can implement `resolveWorkspaceSymbol` and then provide symbols with partial
3105 * [location](#SymbolInformation.location)-objects, without a `range` defined. The editor will then call
3106 * `resolveWorkspaceSymbol` for selected symbols only, e.g. when opening a workspace symbol.
3107 *
3108 * @param query A query string, can be the empty string in which case all symbols should be returned.
3109 * @param token A cancellation token.
3110 * @return An array of document highlights or a thenable that resolves to such. The lack of a result can be
3111 * signaled by returning `undefined`, `null`, or an empty array.
3112 */
3113 provideWorkspaceSymbols(query: string, token: CancellationToken): ProviderResult<T[]>;
3114
3115 /**
3116 * Given a symbol fill in its [location](#SymbolInformation.location). This method is called whenever a symbol
3117 * is selected in the UI. Providers can implement this method and return incomplete symbols from
3118 * [`provideWorkspaceSymbols`](#WorkspaceSymbolProvider.provideWorkspaceSymbols) which often helps to improve
3119 * performance.
3120 *
3121 * @param symbol The symbol that is to be resolved. Guaranteed to be an instance of an object returned from an
3122 * earlier call to `provideWorkspaceSymbols`.
3123 * @param token A cancellation token.
3124 * @return The resolved symbol or a thenable that resolves to that. When no result is returned,
3125 * the given `symbol` is used.
3126 */
3127 resolveWorkspaceSymbol?(symbol: T, token: CancellationToken): ProviderResult<T>;
3128 }
3129
3130 /**
3131 * Value-object that contains additional information when
3132 * requesting references.
3133 */
3134 export interface ReferenceContext {
3135
3136 /**
3137 * Include the declaration of the current symbol.
3138 */
3139 includeDeclaration: boolean;
3140 }
3141
3142 /**
3143 * The reference provider interface defines the contract between extensions and
3144 * the [find references](https://code.visualstudio.com/docs/editor/editingevolved#_peek)-feature.
3145 */
3146 export interface ReferenceProvider {
3147
3148 /**
3149 * Provide a set of project-wide references for the given position and document.
3150 *
3151 * @param document The document in which the command was invoked.
3152 * @param position The position at which the command was invoked.
3153 * @param token A cancellation token.
3154 *
3155 * @return An array of locations or a thenable that resolves to such. The lack of a result can be
3156 * signaled by returning `undefined`, `null`, or an empty array.
3157 */
3158 provideReferences(document: TextDocument, position: Position, context: ReferenceContext, token: CancellationToken): ProviderResult<Location[]>;
3159 }
3160
3161 /**
3162 * A text edit represents edits that should be applied
3163 * to a document.
3164 */
3165 export class TextEdit {
3166
3167 /**
3168 * Utility to create a replace edit.
3169 *
3170 * @param range A range.
3171 * @param newText A string.
3172 * @return A new text edit object.
3173 */
3174 static replace(range: Range, newText: string): TextEdit;
3175
3176 /**
3177 * Utility to create an insert edit.
3178 *
3179 * @param position A position, will become an empty range.
3180 * @param newText A string.
3181 * @return A new text edit object.
3182 */
3183 static insert(position: Position, newText: string): TextEdit;
3184
3185 /**
3186 * Utility to create a delete edit.
3187 *
3188 * @param range A range.
3189 * @return A new text edit object.
3190 */
3191 static delete(range: Range): TextEdit;
3192
3193 /**
3194 * Utility to create an eol-edit.
3195 *
3196 * @param eol An eol-sequence
3197 * @return A new text edit object.
3198 */
3199 static setEndOfLine(eol: EndOfLine): TextEdit;
3200
3201 /**
3202 * The range this edit applies to.
3203 */
3204 range: Range;
3205
3206 /**
3207 * The string this edit will insert.
3208 */
3209 newText: string;
3210
3211 /**
3212 * The eol-sequence used in the document.
3213 *
3214 * *Note* that the eol-sequence will be applied to the
3215 * whole document.
3216 */
3217 newEol?: EndOfLine;
3218
3219 /**
3220 * Create a new TextEdit.
3221 *
3222 * @param range A range.
3223 * @param newText A string.
3224 */
3225 constructor(range: Range, newText: string);
3226 }
3227
3228 /**
3229 * Additional data for entries of a workspace edit. Supports to label entries and marks entries
3230 * as needing confirmation by the user. The editor groups edits with equal labels into tree nodes,
3231 * for instance all edits labelled with "Changes in Strings" would be a tree node.
3232 */
3233 export interface WorkspaceEditEntryMetadata {
3234
3235 /**
3236 * A flag which indicates that user confirmation is needed.
3237 */
3238 needsConfirmation: boolean;
3239
3240 /**
3241 * A human-readable string which is rendered prominent.
3242 */
3243 label: string;
3244
3245 /**
3246 * A human-readable string which is rendered less prominent on the same line.
3247 */
3248 description?: string;
3249
3250 /**
3251 * The icon path or [ThemeIcon](#ThemeIcon) for the edit.
3252 */
3253 iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
3254 }
3255
3256 /**
3257 * A workspace edit is a collection of textual and files changes for
3258 * multiple resources and documents.
3259 *
3260 * Use the [applyEdit](#workspace.applyEdit)-function to apply a workspace edit.
3261 */
3262 export class WorkspaceEdit {
3263
3264 /**
3265 * The number of affected resources of textual or resource changes.
3266 */
3267 readonly size: number;
3268
3269 /**
3270 * Replace the given range with given text for the given resource.
3271 *
3272 * @param uri A resource identifier.
3273 * @param range A range.
3274 * @param newText A string.
3275 * @param metadata Optional metadata for the entry.
3276 */
3277 replace(uri: Uri, range: Range, newText: string, metadata?: WorkspaceEditEntryMetadata): void;
3278
3279 /**
3280 * Insert the given text at the given position.
3281 *
3282 * @param uri A resource identifier.
3283 * @param position A position.
3284 * @param newText A string.
3285 * @param metadata Optional metadata for the entry.
3286 */
3287 insert(uri: Uri, position: Position, newText: string, metadata?: WorkspaceEditEntryMetadata): void;
3288
3289 /**
3290 * Delete the text at the given range.
3291 *
3292 * @param uri A resource identifier.
3293 * @param range A range.
3294 * @param metadata Optional metadata for the entry.
3295 */
3296 delete(uri: Uri, range: Range, metadata?: WorkspaceEditEntryMetadata): void;
3297
3298 /**
3299 * Check if a text edit for a resource exists.
3300 *
3301 * @param uri A resource identifier.
3302 * @return `true` if the given resource will be touched by this edit.
3303 */
3304 has(uri: Uri): boolean;
3305
3306 /**
3307 * Set (and replace) text edits for a resource.
3308 *
3309 * @param uri A resource identifier.
3310 * @param edits An array of text edits.
3311 */
3312 set(uri: Uri, edits: TextEdit[]): void;
3313
3314 /**
3315 * Get the text edits for a resource.
3316 *
3317 * @param uri A resource identifier.
3318 * @return An array of text edits.
3319 */
3320 get(uri: Uri): TextEdit[];
3321
3322 /**
3323 * Create a regular file.
3324 *
3325 * @param uri Uri of the new file..
3326 * @param options Defines if an existing file should be overwritten or be
3327 * ignored. When overwrite and ignoreIfExists are both set overwrite wins.
3328 * When both are unset and when the file already exists then the edit cannot
3329 * be applied successfully.
3330 * @param metadata Optional metadata for the entry.
3331 */
3332 createFile(uri: Uri, options?: { overwrite?: boolean, ignoreIfExists?: boolean }, metadata?: WorkspaceEditEntryMetadata): void;
3333
3334 /**
3335 * Delete a file or folder.
3336 *
3337 * @param uri The uri of the file that is to be deleted.
3338 * @param metadata Optional metadata for the entry.
3339 */
3340 deleteFile(uri: Uri, options?: { recursive?: boolean, ignoreIfNotExists?: boolean }, metadata?: WorkspaceEditEntryMetadata): void;
3341
3342 /**
3343 * Rename a file or folder.
3344 *
3345 * @param oldUri The existing file.
3346 * @param newUri The new location.
3347 * @param options Defines if existing files should be overwritten or be
3348 * ignored. When overwrite and ignoreIfExists are both set overwrite wins.
3349 * @param metadata Optional metadata for the entry.
3350 */
3351 renameFile(oldUri: Uri, newUri: Uri, options?: { overwrite?: boolean, ignoreIfExists?: boolean }, metadata?: WorkspaceEditEntryMetadata): void;
3352
3353 /**
3354 * Get all text edits grouped by resource.
3355 *
3356 * @return A shallow copy of `[Uri, TextEdit[]]`-tuples.
3357 */
3358 entries(): [Uri, TextEdit[]][];
3359 }
3360
3361 /**
3362 * A snippet string is a template which allows to insert text
3363 * and to control the editor cursor when insertion happens.
3364 *
3365 * A snippet can define tab stops and placeholders with `$1`, `$2`
3366 * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
3367 * the end of the snippet. Variables are defined with `$name` and
3368 * `${name:default value}`. The full snippet syntax is documented
3369 * [here](https://code.visualstudio.com/docs/editor/userdefinedsnippets#_creating-your-own-snippets).
3370 */
3371 export class SnippetString {
3372
3373 /**
3374 * The snippet string.
3375 */
3376 value: string;
3377
3378 constructor(value?: string);
3379
3380 /**
3381 * Builder-function that appends the given string to
3382 * the [`value`](#SnippetString.value) of this snippet string.
3383 *
3384 * @param string A value to append 'as given'. The string will be escaped.
3385 * @return This snippet string.
3386 */
3387 appendText(string: string): SnippetString;
3388
3389 /**
3390 * Builder-function that appends a tabstop (`$1`, `$2` etc) to
3391 * the [`value`](#SnippetString.value) of this snippet string.
3392 *
3393 * @param number The number of this tabstop, defaults to an auto-increment
3394 * value starting at 1.
3395 * @return This snippet string.
3396 */
3397 appendTabstop(number?: number): SnippetString;
3398
3399 /**
3400 * Builder-function that appends a placeholder (`${1:value}`) to
3401 * the [`value`](#SnippetString.value) of this snippet string.
3402 *
3403 * @param value The value of this placeholder - either a string or a function
3404 * with which a nested snippet can be created.
3405 * @param number The number of this tabstop, defaults to an auto-increment
3406 * value starting at 1.
3407 * @return This snippet string.
3408 */
3409 appendPlaceholder(value: string | ((snippet: SnippetString) => any), number?: number): SnippetString;
3410
3411 /**
3412 * Builder-function that appends a choice (`${1|a,b,c|}`) to
3413 * the [`value`](#SnippetString.value) of this snippet string.
3414 *
3415 * @param values The values for choices - the array of strings
3416 * @param number The number of this tabstop, defaults to an auto-increment
3417 * value starting at 1.
3418 * @return This snippet string.
3419 */
3420 appendChoice(values: string[], number?: number): SnippetString;
3421
3422 /**
3423 * Builder-function that appends a variable (`${VAR}`) to
3424 * the [`value`](#SnippetString.value) of this snippet string.
3425 *
3426 * @param name The name of the variable - excluding the `$`.
3427 * @param defaultValue The default value which is used when the variable name cannot
3428 * be resolved - either a string or a function with which a nested snippet can be created.
3429 * @return This snippet string.
3430 */
3431 appendVariable(name: string, defaultValue: string | ((snippet: SnippetString) => any)): SnippetString;
3432 }
3433
3434 /**
3435 * The rename provider interface defines the contract between extensions and
3436 * the [rename](https://code.visualstudio.com/docs/editor/editingevolved#_rename-symbol)-feature.
3437 */
3438 export interface RenameProvider {
3439
3440 /**
3441 * Provide an edit that describes changes that have to be made to one
3442 * or many resources to rename a symbol to a different name.
3443 *
3444 * @param document The document in which the command was invoked.
3445 * @param position The position at which the command was invoked.
3446 * @param newName The new name of the symbol. If the given name is not valid, the provider must return a rejected promise.
3447 * @param token A cancellation token.
3448 * @return A workspace edit or a thenable that resolves to such. The lack of a result can be
3449 * signaled by returning `undefined` or `null`.
3450 */
3451 provideRenameEdits(document: TextDocument, position: Position, newName: string, token: CancellationToken): ProviderResult<WorkspaceEdit>;
3452
3453 /**
3454 * Optional function for resolving and validating a position *before* running rename. The result can
3455 * be a range or a range and a placeholder text. The placeholder text should be the identifier of the symbol
3456 * which is being renamed - when omitted the text in the returned range is used.
3457 *
3458 * *Note: * This function should throw an error or return a rejected thenable when the provided location
3459 * doesn't allow for a rename.
3460 *
3461 * @param document The document in which rename will be invoked.
3462 * @param position The position at which rename will be invoked.
3463 * @param token A cancellation token.
3464 * @return 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`.
3465 */
3466 prepareRename?(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Range | { range: Range, placeholder: string }>;
3467 }
3468
3469 /**
3470 * A semantic tokens legend contains the needed information to decipher
3471 * the integer encoded representation of semantic tokens.
3472 */
3473 export class SemanticTokensLegend {
3474 /**
3475 * The possible token types.
3476 */
3477 readonly tokenTypes: string[];
3478 /**
3479 * The possible token modifiers.
3480 */
3481 readonly tokenModifiers: string[];
3482
3483 constructor(tokenTypes: string[], tokenModifiers?: string[]);
3484 }
3485
3486 /**
3487 * A semantic tokens builder can help with creating a `SemanticTokens` instance
3488 * which contains delta encoded semantic tokens.
3489 */
3490 export class SemanticTokensBuilder {
3491
3492 constructor(legend?: SemanticTokensLegend);
3493
3494 /**
3495 * Add another token.
3496 *
3497 * @param line The token start line number (absolute value).
3498 * @param char The token start character (absolute value).
3499 * @param length The token length in characters.
3500 * @param tokenType The encoded token type.
3501 * @param tokenModifiers The encoded token modifiers.
3502 */
3503 push(line: number, char: number, length: number, tokenType: number, tokenModifiers?: number): void;
3504
3505 /**
3506 * Add another token. Use only when providing a legend.
3507 *
3508 * @param range The range of the token. Must be single-line.
3509 * @param tokenType The token type.
3510 * @param tokenModifiers The token modifiers.
3511 */
3512 push(range: Range, tokenType: string, tokenModifiers?: string[]): void;
3513
3514 /**
3515 * Finish and create a `SemanticTokens` instance.
3516 */
3517 build(resultId?: string): SemanticTokens;
3518 }
3519
3520 /**
3521 * Represents semantic tokens, either in a range or in an entire document.
3522 * @see [provideDocumentSemanticTokens](#DocumentSemanticTokensProvider.provideDocumentSemanticTokens) for an explanation of the format.
3523 * @see [SemanticTokensBuilder](#SemanticTokensBuilder) for a helper to create an instance.
3524 */
3525 export class SemanticTokens {
3526 /**
3527 * The result id of the tokens.
3528 *
3529 * This is the id that will be passed to `DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits` (if implemented).
3530 */
3531 readonly resultId?: string;
3532 /**
3533 * The actual tokens data.
3534 * @see [provideDocumentSemanticTokens](#DocumentSemanticTokensProvider.provideDocumentSemanticTokens) for an explanation of the format.
3535 */
3536 readonly data: Uint32Array;
3537
3538 constructor(data: Uint32Array, resultId?: string);
3539 }
3540
3541 /**
3542 * Represents edits to semantic tokens.
3543 * @see [provideDocumentSemanticTokensEdits](#DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits) for an explanation of the format.
3544 */
3545 export class SemanticTokensEdits {
3546 /**
3547 * The result id of the tokens.
3548 *
3549 * This is the id that will be passed to `DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits` (if implemented).
3550 */
3551 readonly resultId?: string;
3552 /**
3553 * The edits to the tokens data.
3554 * All edits refer to the initial data state.
3555 */
3556 readonly edits: SemanticTokensEdit[];
3557
3558 constructor(edits: SemanticTokensEdit[], resultId?: string);
3559 }
3560
3561 /**
3562 * Represents an edit to semantic tokens.
3563 * @see [provideDocumentSemanticTokensEdits](#DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits) for an explanation of the format.
3564 */
3565 export class SemanticTokensEdit {
3566 /**
3567 * The start offset of the edit.
3568 */
3569 readonly start: number;
3570 /**
3571 * The count of elements to remove.
3572 */
3573 readonly deleteCount: number;
3574 /**
3575 * The elements to insert.
3576 */
3577 readonly data?: Uint32Array;
3578
3579 constructor(start: number, deleteCount: number, data?: Uint32Array);
3580 }
3581
3582 /**
3583 * The document semantic tokens provider interface defines the contract between extensions and
3584 * semantic tokens.
3585 */
3586 export interface DocumentSemanticTokensProvider {
3587 /**
3588 * An optional event to signal that the semantic tokens from this provider have changed.
3589 */
3590 onDidChangeSemanticTokens?: Event<void>;
3591
3592 /**
3593 * Tokens in a file are represented as an array of integers. The position of each token is expressed relative to
3594 * the token before it, because most tokens remain stable relative to each other when edits are made in a file.
3595 *
3596 * ---
3597 * In short, each token takes 5 integers to represent, so a specific token `i` in the file consists of the following array indices:
3598 * - at index `5*i` - `deltaLine`: token line number, relative to the previous token
3599 * - 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)
3600 * - at index `5*i+2` - `length`: the length of the token. A token cannot be multiline.
3601 * - at index `5*i+3` - `tokenType`: will be looked up in `SemanticTokensLegend.tokenTypes`. We currently ask that `tokenType` < 65536.
3602 * - at index `5*i+4` - `tokenModifiers`: each set bit will be looked up in `SemanticTokensLegend.tokenModifiers`
3603 *
3604 * ---
3605 * ### How to encode tokens
3606 *
3607 * Here is an example for encoding a file with 3 tokens in a uint32 array:
3608 * ```
3609 * { line: 2, startChar: 5, length: 3, tokenType: "property", tokenModifiers: ["private", "static"] },
3610 * { line: 2, startChar: 10, length: 4, tokenType: "type", tokenModifiers: [] },
3611 * { line: 5, startChar: 2, length: 7, tokenType: "class", tokenModifiers: [] }
3612 * ```
3613 *
3614 * 1. First of all, a legend must be devised. This legend must be provided up-front and capture all possible token types.
3615 * For this example, we will choose the following legend which must be passed in when registering the provider:
3616 * ```
3617 * tokenTypes: ['property', 'type', 'class'],
3618 * tokenModifiers: ['private', 'static']
3619 * ```
3620 *
3621 * 2. The first transformation step is to encode `tokenType` and `tokenModifiers` as integers using the legend. Token types are looked
3622 * up by index, so a `tokenType` value of `1` means `tokenTypes[1]`. Multiple token modifiers can be set by using bit flags,
3623 * so a `tokenModifier` value of `3` is first viewed as binary `0b00000011`, which means `[tokenModifiers[0], tokenModifiers[1]]` because
3624 * bits 0 and 1 are set. Using this legend, the tokens now are:
3625 * ```
3626 * { line: 2, startChar: 5, length: 3, tokenType: 0, tokenModifiers: 3 },
3627 * { line: 2, startChar: 10, length: 4, tokenType: 1, tokenModifiers: 0 },
3628 * { line: 5, startChar: 2, length: 7, tokenType: 2, tokenModifiers: 0 }
3629 * ```
3630 *
3631 * 3. The next step is to represent each token relative to the previous token in the file. In this case, the second token
3632 * is on the same line as the first token, so the `startChar` of the second token is made relative to the `startChar`
3633 * of the first token, so it will be `10 - 5`. The third token is on a different line than the second token, so the
3634 * `startChar` of the third token will not be altered:
3635 * ```
3636 * { deltaLine: 2, deltaStartChar: 5, length: 3, tokenType: 0, tokenModifiers: 3 },
3637 * { deltaLine: 0, deltaStartChar: 5, length: 4, tokenType: 1, tokenModifiers: 0 },
3638 * { deltaLine: 3, deltaStartChar: 2, length: 7, tokenType: 2, tokenModifiers: 0 }
3639 * ```
3640 *
3641 * 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:
3642 * ```
3643 * // 1st token, 2nd token, 3rd token
3644 * [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
3645 * ```
3646 *
3647 * @see [SemanticTokensBuilder](#SemanticTokensBuilder) for a helper to encode tokens as integers.
3648 * *NOTE*: When doing edits, it is possible that multiple edits occur until VS Code decides to invoke the semantic tokens provider.
3649 * *NOTE*: If the provider cannot temporarily compute semantic tokens, it can indicate this by throwing an error with the message 'Busy'.
3650 */
3651 provideDocumentSemanticTokens(document: TextDocument, token: CancellationToken): ProviderResult<SemanticTokens>;
3652
3653 /**
3654 * Instead of always returning all the tokens in a file, it is possible for a `DocumentSemanticTokensProvider` to implement
3655 * this method (`provideDocumentSemanticTokensEdits`) and then return incremental updates to the previously provided semantic tokens.
3656 *
3657 * ---
3658 * ### How tokens change when the document changes
3659 *
3660 * Suppose that `provideDocumentSemanticTokens` has previously returned the following semantic tokens:
3661 * ```
3662 * // 1st token, 2nd token, 3rd token
3663 * [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
3664 * ```
3665 *
3666 * Also suppose that after some edits, the new semantic tokens in a file are:
3667 * ```
3668 * // 1st token, 2nd token, 3rd token
3669 * [ 3,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
3670 * ```
3671 * It is possible to express these new tokens in terms of an edit applied to the previous tokens:
3672 * ```
3673 * [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ] // old tokens
3674 * [ 3,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ] // new tokens
3675 *
3676 * edit: { start: 0, deleteCount: 1, data: [3] } // replace integer at offset 0 with 3
3677 * ```
3678 *
3679 * *NOTE*: If the provider cannot compute `SemanticTokensEdits`, it can "give up" and return all the tokens in the document again.
3680 * *NOTE*: All edits in `SemanticTokensEdits` contain indices in the old integers array, so they all refer to the previous result state.
3681 */
3682 provideDocumentSemanticTokensEdits?(document: TextDocument, previousResultId: string, token: CancellationToken): ProviderResult<SemanticTokens | SemanticTokensEdits>;
3683 }
3684
3685 /**
3686 * The document range semantic tokens provider interface defines the contract between extensions and
3687 * semantic tokens.
3688 */
3689 export interface DocumentRangeSemanticTokensProvider {
3690 /**
3691 * @see [provideDocumentSemanticTokens](#DocumentSemanticTokensProvider.provideDocumentSemanticTokens).
3692 */
3693 provideDocumentRangeSemanticTokens(document: TextDocument, range: Range, token: CancellationToken): ProviderResult<SemanticTokens>;
3694 }
3695
3696 /**
3697 * Value-object describing what options formatting should use.
3698 */
3699 export interface FormattingOptions {
3700
3701 /**
3702 * Size of a tab in spaces.
3703 */
3704 tabSize: number;
3705
3706 /**
3707 * Prefer spaces over tabs.
3708 */
3709 insertSpaces: boolean;
3710
3711 /**
3712 * Signature for further properties.
3713 */
3714 [key: string]: boolean | number | string;
3715 }
3716
3717 /**
3718 * The document formatting provider interface defines the contract between extensions and
3719 * the formatting-feature.
3720 */
3721 export interface DocumentFormattingEditProvider {
3722
3723 /**
3724 * Provide formatting edits for a whole document.
3725 *
3726 * @param document The document in which the command was invoked.
3727 * @param options Options controlling formatting.
3728 * @param token A cancellation token.
3729 * @return A set of text edits or a thenable that resolves to such. The lack of a result can be
3730 * signaled by returning `undefined`, `null`, or an empty array.
3731 */
3732 provideDocumentFormattingEdits(document: TextDocument, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
3733 }
3734
3735 /**
3736 * The document formatting provider interface defines the contract between extensions and
3737 * the formatting-feature.
3738 */
3739 export interface DocumentRangeFormattingEditProvider {
3740
3741 /**
3742 * Provide formatting edits for a range in a document.
3743 *
3744 * The given range is a hint and providers can decide to format a smaller
3745 * or larger range. Often this is done by adjusting the start and end
3746 * of the range to full syntax nodes.
3747 *
3748 * @param document The document in which the command was invoked.
3749 * @param range The range which should be formatted.
3750 * @param options Options controlling formatting.
3751 * @param token A cancellation token.
3752 * @return A set of text edits or a thenable that resolves to such. The lack of a result can be
3753 * signaled by returning `undefined`, `null`, or an empty array.
3754 */
3755 provideDocumentRangeFormattingEdits(document: TextDocument, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
3756 }
3757
3758 /**
3759 * The document formatting provider interface defines the contract between extensions and
3760 * the formatting-feature.
3761 */
3762 export interface OnTypeFormattingEditProvider {
3763
3764 /**
3765 * Provide formatting edits after a character has been typed.
3766 *
3767 * The given position and character should hint to the provider
3768 * what range the position to expand to, like find the matching `{`
3769 * when `}` has been entered.
3770 *
3771 * @param document The document in which the command was invoked.
3772 * @param position The position at which the command was invoked.
3773 * @param ch The character that has been typed.
3774 * @param options Options controlling formatting.
3775 * @param token A cancellation token.
3776 * @return A set of text edits or a thenable that resolves to such. The lack of a result can be
3777 * signaled by returning `undefined`, `null`, or an empty array.
3778 */
3779 provideOnTypeFormattingEdits(document: TextDocument, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
3780 }
3781
3782 /**
3783 * Represents a parameter of a callable-signature. A parameter can
3784 * have a label and a doc-comment.
3785 */
3786 export class ParameterInformation {
3787
3788 /**
3789 * The label of this signature.
3790 *
3791 * Either a string or inclusive start and exclusive end offsets within its containing
3792 * [signature label](#SignatureInformation.label). *Note*: A label of type string must be
3793 * a substring of its containing signature information's [label](#SignatureInformation.label).
3794 */
3795 label: string | [number, number];
3796
3797 /**
3798 * The human-readable doc-comment of this signature. Will be shown
3799 * in the UI but can be omitted.
3800 */
3801 documentation?: string | MarkdownString;
3802
3803 /**
3804 * Creates a new parameter information object.
3805 *
3806 * @param label A label string or inclusive start and exclusive end offsets within its containing signature label.
3807 * @param documentation A doc string.
3808 */
3809 constructor(label: string | [number, number], documentation?: string | MarkdownString);
3810 }
3811
3812 /**
3813 * Represents the signature of something callable. A signature
3814 * can have a label, like a function-name, a doc-comment, and
3815 * a set of parameters.
3816 */
3817 export class SignatureInformation {
3818
3819 /**
3820 * The label of this signature. Will be shown in
3821 * the UI.
3822 */
3823 label: string;
3824
3825 /**
3826 * The human-readable doc-comment of this signature. Will be shown
3827 * in the UI but can be omitted.
3828 */
3829 documentation?: string | MarkdownString;
3830
3831 /**
3832 * The parameters of this signature.
3833 */
3834 parameters: ParameterInformation[];
3835
3836 /**
3837 * The index of the active parameter.
3838 *
3839 * If provided, this is used in place of [`SignatureHelp.activeSignature`](#SignatureHelp.activeSignature).
3840 */
3841 activeParameter?: number;
3842
3843 /**
3844 * Creates a new signature information object.
3845 *
3846 * @param label A label string.
3847 * @param documentation A doc string.
3848 */
3849 constructor(label: string, documentation?: string | MarkdownString);
3850 }
3851
3852 /**
3853 * Signature help represents the signature of something
3854 * callable. There can be multiple signatures but only one
3855 * active and only one active parameter.
3856 */
3857 export class SignatureHelp {
3858
3859 /**
3860 * One or more signatures.
3861 */
3862 signatures: SignatureInformation[];
3863
3864 /**
3865 * The active signature.
3866 */
3867 activeSignature: number;
3868
3869 /**
3870 * The active parameter of the active signature.
3871 */
3872 activeParameter: number;
3873 }
3874
3875 /**
3876 * How a [`SignatureHelpProvider`](#SignatureHelpProvider) was triggered.
3877 */
3878 export enum SignatureHelpTriggerKind {
3879 /**
3880 * Signature help was invoked manually by the user or by a command.
3881 */
3882 Invoke = 1,
3883
3884 /**
3885 * Signature help was triggered by a trigger character.
3886 */
3887 TriggerCharacter = 2,
3888
3889 /**
3890 * Signature help was triggered by the cursor moving or by the document content changing.
3891 */
3892 ContentChange = 3,
3893 }
3894
3895 /**
3896 * Additional information about the context in which a
3897 * [`SignatureHelpProvider`](#SignatureHelpProvider.provideSignatureHelp) was triggered.
3898 */
3899 export interface SignatureHelpContext {
3900 /**
3901 * Action that caused signature help to be triggered.
3902 */
3903 readonly triggerKind: SignatureHelpTriggerKind;
3904
3905 /**
3906 * Character that caused signature help to be triggered.
3907 *
3908 * This is `undefined` when signature help is not triggered by typing, such as when manually invoking
3909 * signature help or when moving the cursor.
3910 */
3911 readonly triggerCharacter?: string;
3912
3913 /**
3914 * `true` if signature help was already showing when it was triggered.
3915 *
3916 * Retriggers occur when the signature help is already active and can be caused by actions such as
3917 * typing a trigger character, a cursor move, or document content changes.
3918 */
3919 readonly isRetrigger: boolean;
3920
3921 /**
3922 * The currently active [`SignatureHelp`](#SignatureHelp).
3923 *
3924 * The `activeSignatureHelp` has its [`SignatureHelp.activeSignature`] field updated based on
3925 * the user arrowing through available signatures.
3926 */
3927 readonly activeSignatureHelp?: SignatureHelp;
3928 }
3929
3930 /**
3931 * The signature help provider interface defines the contract between extensions and
3932 * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature.
3933 */
3934 export interface SignatureHelpProvider {
3935
3936 /**
3937 * Provide help for the signature at the given position and document.
3938 *
3939 * @param document The document in which the command was invoked.
3940 * @param position The position at which the command was invoked.
3941 * @param token A cancellation token.
3942 * @param context Information about how signature help was triggered.
3943 *
3944 * @return Signature help or a thenable that resolves to such. The lack of a result can be
3945 * signaled by returning `undefined` or `null`.
3946 */
3947 provideSignatureHelp(document: TextDocument, position: Position, token: CancellationToken, context: SignatureHelpContext): ProviderResult<SignatureHelp>;
3948 }
3949
3950 /**
3951 * Metadata about a registered [`SignatureHelpProvider`](#SignatureHelpProvider).
3952 */
3953 export interface SignatureHelpProviderMetadata {
3954 /**
3955 * List of characters that trigger signature help.
3956 */
3957 readonly triggerCharacters: ReadonlyArray<string>;
3958
3959 /**
3960 * List of characters that re-trigger signature help.
3961 *
3962 * These trigger characters are only active when signature help is already showing. All trigger characters
3963 * are also counted as re-trigger characters.
3964 */
3965 readonly retriggerCharacters: ReadonlyArray<string>;
3966 }
3967
3968 /**
3969 * Completion item kinds.
3970 */
3971 export enum CompletionItemKind {
3972 Text = 0,
3973 Method = 1,
3974 Function = 2,
3975 Constructor = 3,
3976 Field = 4,
3977 Variable = 5,
3978 Class = 6,
3979 Interface = 7,
3980 Module = 8,
3981 Property = 9,
3982 Unit = 10,
3983 Value = 11,
3984 Enum = 12,
3985 Keyword = 13,
3986 Snippet = 14,
3987 Color = 15,
3988 Reference = 17,
3989 File = 16,
3990 Folder = 18,
3991 EnumMember = 19,
3992 Constant = 20,
3993 Struct = 21,
3994 Event = 22,
3995 Operator = 23,
3996 TypeParameter = 24,
3997 User = 25,
3998 Issue = 26,
3999 }
4000
4001 /**
4002 * Completion item tags are extra annotations that tweak the rendering of a completion
4003 * item.
4004 */
4005 export enum CompletionItemTag {
4006 /**
4007 * Render a completion as obsolete, usually using a strike-out.
4008 */
4009 Deprecated = 1
4010 }
4011
4012 /**
4013 * A completion item represents a text snippet that is proposed to complete text that is being typed.
4014 *
4015 * It is sufficient to create a completion item from just a [label](#CompletionItem.label). In that
4016 * case the completion item will replace the [word](#TextDocument.getWordRangeAtPosition)
4017 * until the cursor with the given label or [insertText](#CompletionItem.insertText). Otherwise the
4018 * given [edit](#CompletionItem.textEdit) is used.
4019 *
4020 * When selecting a completion item in the editor its defined or synthesized text edit will be applied
4021 * to *all* cursors/selections whereas [additionalTextEdits](#CompletionItem.additionalTextEdits) will be
4022 * applied as provided.
4023 *
4024 * @see [CompletionItemProvider.provideCompletionItems](#CompletionItemProvider.provideCompletionItems)
4025 * @see [CompletionItemProvider.resolveCompletionItem](#CompletionItemProvider.resolveCompletionItem)
4026 */
4027 export class CompletionItem {
4028
4029 /**
4030 * The label of this completion item. By default
4031 * this is also the text that is inserted when selecting
4032 * this completion.
4033 */
4034 label: string;
4035
4036 /**
4037 * The kind of this completion item. Based on the kind
4038 * an icon is chosen by the editor.
4039 */
4040 kind?: CompletionItemKind;
4041
4042 /**
4043 * Tags for this completion item.
4044 */
4045 tags?: ReadonlyArray<CompletionItemTag>;
4046
4047 /**
4048 * A human-readable string with additional information
4049 * about this item, like type or symbol information.
4050 */
4051 detail?: string;
4052
4053 /**
4054 * A human-readable string that represents a doc-comment.
4055 */
4056 documentation?: string | MarkdownString;
4057
4058 /**
4059 * A string that should be used when comparing this item
4060 * with other items. When `falsy` the [label](#CompletionItem.label)
4061 * is used.
4062 *
4063 * Note that `sortText` is only used for the initial ordering of completion
4064 * items. When having a leading word (prefix) ordering is based on how
4065 * well completions match that prefix and the initial ordering is only used
4066 * when completions match equally well. The prefix is defined by the
4067 * [`range`](#CompletionItem.range)-property and can therefore be different
4068 * for each completion.
4069 */
4070 sortText?: string;
4071
4072 /**
4073 * A string that should be used when filtering a set of
4074 * completion items. When `falsy` the [label](#CompletionItem.label)
4075 * is used.
4076 *
4077 * Note that the filter text is matched against the leading word (prefix) which is defined
4078 * by the [`range`](#CompletionItem.range)-property.
4079 */
4080 filterText?: string;
4081
4082 /**
4083 * Select this item when showing. *Note* that only one completion item can be selected and
4084 * that the editor decides which item that is. The rule is that the *first* item of those
4085 * that match best is selected.
4086 */
4087 preselect?: boolean;
4088
4089 /**
4090 * A string or snippet that should be inserted in a document when selecting
4091 * this completion. When `falsy` the [label](#CompletionItem.label)
4092 * is used.
4093 */
4094 insertText?: string | SnippetString;
4095
4096 /**
4097 * A range or a insert and replace range selecting the text that should be replaced by this completion item.
4098 *
4099 * When omitted, the range of the [current word](#TextDocument.getWordRangeAtPosition) is used as replace-range
4100 * and as insert-range the start of the [current word](#TextDocument.getWordRangeAtPosition) to the
4101 * current position is used.
4102 *
4103 * *Note 1:* A range must be a [single line](#Range.isSingleLine) and it must
4104 * [contain](#Range.contains) the position at which completion has been [requested](#CompletionItemProvider.provideCompletionItems).
4105 * *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.
4106 */
4107 range?: Range | { inserting: Range; replacing: Range; };
4108
4109 /**
4110 * An optional set of characters that when pressed while this completion is active will accept it first and
4111 * then type that character. *Note* that all commit characters should have `length=1` and that superfluous
4112 * characters will be ignored.
4113 */
4114 commitCharacters?: string[];
4115
4116 /**
4117 * Keep whitespace of the [insertText](#CompletionItem.insertText) as is. By default, the editor adjusts leading
4118 * whitespace of new lines so that they match the indentation of the line for which the item is accepted - setting
4119 * this to `true` will prevent that.
4120 */
4121 keepWhitespace?: boolean;
4122
4123 /**
4124 * @deprecated Use `CompletionItem.insertText` and `CompletionItem.range` instead.
4125 *
4126 * An [edit](#TextEdit) which is applied to a document when selecting
4127 * this completion. When an edit is provided the value of
4128 * [insertText](#CompletionItem.insertText) is ignored.
4129 *
4130 * The [range](#Range) of the edit must be single-line and on the same
4131 * line completions were [requested](#CompletionItemProvider.provideCompletionItems) at.
4132 */
4133 textEdit?: TextEdit;
4134
4135 /**
4136 * An optional array of additional [text edits](#TextEdit) that are applied when
4137 * selecting this completion. Edits must not overlap with the main [edit](#CompletionItem.textEdit)
4138 * nor with themselves.
4139 */
4140 additionalTextEdits?: TextEdit[];
4141
4142 /**
4143 * An optional [command](#Command) that is executed *after* inserting this completion. *Note* that
4144 * additional modifications to the current document should be described with the
4145 * [additionalTextEdits](#CompletionItem.additionalTextEdits)-property.
4146 */
4147 command?: Command;
4148
4149 /**
4150 * Creates a new completion item.
4151 *
4152 * Completion items must have at least a [label](#CompletionItem.label) which then
4153 * will be used as insert text as well as for sorting and filtering.
4154 *
4155 * @param label The label of the completion.
4156 * @param kind The [kind](#CompletionItemKind) of the completion.
4157 */
4158 constructor(label: string, kind?: CompletionItemKind);
4159 }
4160
4161 /**
4162 * Represents a collection of [completion items](#CompletionItem) to be presented
4163 * in the editor.
4164 */
4165 export class CompletionList<T extends CompletionItem = CompletionItem> {
4166
4167 /**
4168 * This list is not complete. Further typing should result in recomputing
4169 * this list.
4170 */
4171 isIncomplete?: boolean;
4172
4173 /**
4174 * The completion items.
4175 */
4176 items: T[];
4177
4178 /**
4179 * Creates a new completion list.
4180 *
4181 * @param items The completion items.
4182 * @param isIncomplete The list is not complete.
4183 */
4184 constructor(items?: T[], isIncomplete?: boolean);
4185 }
4186
4187 /**
4188 * How a [completion provider](#CompletionItemProvider) was triggered
4189 */
4190 export enum CompletionTriggerKind {
4191 /**
4192 * Completion was triggered normally.
4193 */
4194 Invoke = 0,
4195 /**
4196 * Completion was triggered by a trigger character.
4197 */
4198 TriggerCharacter = 1,
4199 /**
4200 * Completion was re-triggered as current completion list is incomplete
4201 */
4202 TriggerForIncompleteCompletions = 2
4203 }
4204
4205 /**
4206 * Contains additional information about the context in which
4207 * [completion provider](#CompletionItemProvider.provideCompletionItems) is triggered.
4208 */
4209 export interface CompletionContext {
4210 /**
4211 * How the completion was triggered.
4212 */
4213 readonly triggerKind: CompletionTriggerKind;
4214
4215 /**
4216 * Character that triggered the completion item provider.
4217 *
4218 * `undefined` if provider was not triggered by a character.
4219 *
4220 * The trigger character is already in the document when the completion provider is triggered.
4221 */
4222 readonly triggerCharacter?: string;
4223 }
4224
4225 /**
4226 * The completion item provider interface defines the contract between extensions and
4227 * [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense).
4228 *
4229 * Providers can delay the computation of the [`detail`](#CompletionItem.detail)
4230 * and [`documentation`](#CompletionItem.documentation) properties by implementing the
4231 * [`resolveCompletionItem`](#CompletionItemProvider.resolveCompletionItem)-function. However, properties that
4232 * are needed for the initial sorting and filtering, like `sortText`, `filterText`, `insertText`, and `range`, must
4233 * not be changed during resolve.
4234 *
4235 * Providers are asked for completions either explicitly by a user gesture or -depending on the configuration-
4236 * implicitly when typing words or trigger characters.
4237 */
4238 export interface CompletionItemProvider<T extends CompletionItem = CompletionItem> {
4239
4240 /**
4241 * Provide completion items for the given position and document.
4242 *
4243 * @param document The document in which the command was invoked.
4244 * @param position The position at which the command was invoked.
4245 * @param token A cancellation token.
4246 * @param context How the completion was triggered.
4247 *
4248 * @return An array of completions, a [completion list](#CompletionList), or a thenable that resolves to either.
4249 * The lack of a result can be signaled by returning `undefined`, `null`, or an empty array.
4250 */
4251 provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken, context: CompletionContext): ProviderResult<T[] | CompletionList<T>>;
4252
4253 /**
4254 * Given a completion item fill in more data, like [doc-comment](#CompletionItem.documentation)
4255 * or [details](#CompletionItem.detail).
4256 *
4257 * The editor will only resolve a completion item once.
4258 *
4259 * *Note* that this function is called when completion items are already showing in the UI or when an item has been
4260 * selected for insertion. Because of that, no property that changes the presentation (label, sorting, filtering etc)
4261 * or the (primary) insert behaviour ([insertText](#CompletionItem.insertText)) can be changed.
4262 *
4263 * This function may fill in [additionalTextEdits](#CompletionItem.additionalTextEdits). However, that means an item might be
4264 * inserted *before* resolving is done and in that case the editor will do a best effort to still apply those additional
4265 * text edits.
4266 *
4267 * @param item A completion item currently active in the UI.
4268 * @param token A cancellation token.
4269 * @return The resolved completion item or a thenable that resolves to of such. It is OK to return the given
4270 * `item`. When no result is returned, the given `item` will be used.
4271 */
4272 resolveCompletionItem?(item: T, token: CancellationToken): ProviderResult<T>;
4273 }
4274
4275 /**
4276 * A document link is a range in a text document that links to an internal or external resource, like another
4277 * text document or a web site.
4278 */
4279 export class DocumentLink {
4280
4281 /**
4282 * The range this link applies to.
4283 */
4284 range: Range;
4285
4286 /**
4287 * The uri this link points to.
4288 */
4289 target?: Uri;
4290
4291 /**
4292 * The tooltip text when you hover over this link.
4293 *
4294 * If a tooltip is provided, is will be displayed in a string that includes instructions on how to
4295 * trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary depending on OS,
4296 * user settings, and localization.
4297 */
4298 tooltip?: string;
4299
4300 /**
4301 * Creates a new document link.
4302 *
4303 * @param range The range the document link applies to. Must not be empty.
4304 * @param target The uri the document link points to.
4305 */
4306 constructor(range: Range, target?: Uri);
4307 }
4308
4309 /**
4310 * The document link provider defines the contract between extensions and feature of showing
4311 * links in the editor.
4312 */
4313 export interface DocumentLinkProvider<T extends DocumentLink = DocumentLink> {
4314
4315 /**
4316 * Provide links for the given document. Note that the editor ships with a default provider that detects
4317 * `http(s)` and `file` links.
4318 *
4319 * @param document The document in which the command was invoked.
4320 * @param token A cancellation token.
4321 * @return An array of [document links](#DocumentLink) or a thenable that resolves to such. The lack of a result
4322 * can be signaled by returning `undefined`, `null`, or an empty array.
4323 */
4324 provideDocumentLinks(document: TextDocument, token: CancellationToken): ProviderResult<T[]>;
4325
4326 /**
4327 * Given a link fill in its [target](#DocumentLink.target). This method is called when an incomplete
4328 * link is selected in the UI. Providers can implement this method and return incomplete links
4329 * (without target) from the [`provideDocumentLinks`](#DocumentLinkProvider.provideDocumentLinks) method which
4330 * often helps to improve performance.
4331 *
4332 * @param link The link that is to be resolved.
4333 * @param token A cancellation token.
4334 */
4335 resolveDocumentLink?(link: T, token: CancellationToken): ProviderResult<T>;
4336 }
4337
4338 /**
4339 * Represents a color in RGBA space.
4340 */
4341 export class Color {
4342
4343 /**
4344 * The red component of this color in the range [0-1].
4345 */
4346 readonly red: number;
4347
4348 /**
4349 * The green component of this color in the range [0-1].
4350 */
4351 readonly green: number;
4352
4353 /**
4354 * The blue component of this color in the range [0-1].
4355 */
4356 readonly blue: number;
4357
4358 /**
4359 * The alpha component of this color in the range [0-1].
4360 */
4361 readonly alpha: number;
4362
4363 /**
4364 * Creates a new color instance.
4365 *
4366 * @param red The red component.
4367 * @param green The green component.
4368 * @param blue The blue component.
4369 * @param alpha The alpha component.
4370 */
4371 constructor(red: number, green: number, blue: number, alpha: number);
4372 }
4373
4374 /**
4375 * Represents a color range from a document.
4376 */
4377 export class ColorInformation {
4378
4379 /**
4380 * The range in the document where this color appears.
4381 */
4382 range: Range;
4383
4384 /**
4385 * The actual color value for this color range.
4386 */
4387 color: Color;
4388
4389 /**
4390 * Creates a new color range.
4391 *
4392 * @param range The range the color appears in. Must not be empty.
4393 * @param color The value of the color.
4394 * @param format The format in which this color is currently formatted.
4395 */
4396 constructor(range: Range, color: Color);
4397 }
4398
4399 /**
4400 * A color presentation object describes how a [`color`](#Color) should be represented as text and what
4401 * edits are required to refer to it from source code.
4402 *
4403 * For some languages one color can have multiple presentations, e.g. css can represent the color red with
4404 * the constant `Red`, the hex-value `#ff0000`, or in rgba and hsla forms. In csharp other representations
4405 * apply, e.g. `System.Drawing.Color.Red`.
4406 */
4407 export class ColorPresentation {
4408
4409 /**
4410 * The label of this color presentation. It will be shown on the color
4411 * picker header. By default this is also the text that is inserted when selecting
4412 * this color presentation.
4413 */
4414 label: string;
4415
4416 /**
4417 * An [edit](#TextEdit) which is applied to a document when selecting
4418 * this presentation for the color. When `falsy` the [label](#ColorPresentation.label)
4419 * is used.
4420 */
4421 textEdit?: TextEdit;
4422
4423 /**
4424 * An optional array of additional [text edits](#TextEdit) that are applied when
4425 * selecting this color presentation. Edits must not overlap with the main [edit](#ColorPresentation.textEdit) nor with themselves.
4426 */
4427 additionalTextEdits?: TextEdit[];
4428
4429 /**
4430 * Creates a new color presentation.
4431 *
4432 * @param label The label of this color presentation.
4433 */
4434 constructor(label: string);
4435 }
4436
4437 /**
4438 * The document color provider defines the contract between extensions and feature of
4439 * picking and modifying colors in the editor.
4440 */
4441 export interface DocumentColorProvider {
4442
4443 /**
4444 * Provide colors for the given document.
4445 *
4446 * @param document The document in which the command was invoked.
4447 * @param token A cancellation token.
4448 * @return An array of [color information](#ColorInformation) or a thenable that resolves to such. The lack of a result
4449 * can be signaled by returning `undefined`, `null`, or an empty array.
4450 */
4451 provideDocumentColors(document: TextDocument, token: CancellationToken): ProviderResult<ColorInformation[]>;
4452
4453 /**
4454 * Provide [representations](#ColorPresentation) for a color.
4455 *
4456 * @param color The color to show and insert.
4457 * @param context A context object with additional information
4458 * @param token A cancellation token.
4459 * @return An array of color presentations or a thenable that resolves to such. The lack of a result
4460 * can be signaled by returning `undefined`, `null`, or an empty array.
4461 */
4462 provideColorPresentations(color: Color, context: { document: TextDocument, range: Range }, token: CancellationToken): ProviderResult<ColorPresentation[]>;
4463 }
4464
4465 /**
4466 * 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.
4467 * Invalid ranges will be ignored.
4468 */
4469 export class FoldingRange {
4470
4471 /**
4472 * The zero-based start line of the range to fold. The folded area starts after the line's last character.
4473 * To be valid, the end must be zero or larger and smaller than the number of lines in the document.
4474 */
4475 start: number;
4476
4477 /**
4478 * The zero-based end line of the range to fold. The folded area ends with the line's last character.
4479 * To be valid, the end must be zero or larger and smaller than the number of lines in the document.
4480 */
4481 end: number;
4482
4483 /**
4484 * Describes the [Kind](#FoldingRangeKind) of the folding range such as [Comment](#FoldingRangeKind.Comment) or
4485 * [Region](#FoldingRangeKind.Region). The kind is used to categorize folding ranges and used by commands
4486 * like 'Fold all comments'. See
4487 * [FoldingRangeKind](#FoldingRangeKind) for an enumeration of all kinds.
4488 * If not set, the range is originated from a syntax element.
4489 */
4490 kind?: FoldingRangeKind;
4491
4492 /**
4493 * Creates a new folding range.
4494 *
4495 * @param start The start line of the folded range.
4496 * @param end The end line of the folded range.
4497 * @param kind The kind of the folding range.
4498 */
4499 constructor(start: number, end: number, kind?: FoldingRangeKind);
4500 }
4501
4502 /**
4503 * An enumeration of specific folding range kinds. The kind is an optional field of a [FoldingRange](#FoldingRange)
4504 * and is used to distinguish specific folding ranges such as ranges originated from comments. The kind is used by commands like
4505 * `Fold all comments` or `Fold all regions`.
4506 * If the kind is not set on the range, the range originated from a syntax element other than comments, imports or region markers.
4507 */
4508 export enum FoldingRangeKind {
4509 /**
4510 * Kind for folding range representing a comment.
4511 */
4512 Comment = 1,
4513 /**
4514 * Kind for folding range representing a import.
4515 */
4516 Imports = 2,
4517 /**
4518 * Kind for folding range representing regions originating from folding markers like `#region` and `#endregion`.
4519 */
4520 Region = 3
4521 }
4522
4523 /**
4524 * Folding context (for future use)
4525 */
4526 export interface FoldingContext {
4527 }
4528
4529 /**
4530 * The folding range provider interface defines the contract between extensions and
4531 * [Folding](https://code.visualstudio.com/docs/editor/codebasics#_folding) in the editor.
4532 */
4533 export interface FoldingRangeProvider {
4534
4535 /**
4536 * An optional event to signal that the folding ranges from this provider have changed.
4537 */
4538 onDidChangeFoldingRanges?: Event<void>;
4539
4540 /**
4541 * Returns a list of folding ranges or null and undefined if the provider
4542 * does not want to participate or was cancelled.
4543 * @param document The document in which the command was invoked.
4544 * @param context Additional context information (for future use)
4545 * @param token A cancellation token.
4546 */
4547 provideFoldingRanges(document: TextDocument, context: FoldingContext, token: CancellationToken): ProviderResult<FoldingRange[]>;
4548 }
4549
4550 /**
4551 * A selection range represents a part of a selection hierarchy. A selection range
4552 * may have a parent selection range that contains it.
4553 */
4554 export class SelectionRange {
4555
4556 /**
4557 * The [range](#Range) of this selection range.
4558 */
4559 range: Range;
4560
4561 /**
4562 * The parent selection range containing this range.
4563 */
4564 parent?: SelectionRange;
4565
4566 /**
4567 * Creates a new selection range.
4568 *
4569 * @param range The range of the selection range.
4570 * @param parent The parent of the selection range.
4571 */
4572 constructor(range: Range, parent?: SelectionRange);
4573 }
4574
4575 export interface SelectionRangeProvider {
4576 /**
4577 * Provide selection ranges for the given positions.
4578 *
4579 * Selection ranges should be computed individually and independent for each position. The editor will merge
4580 * and deduplicate ranges but providers must return hierarchies of selection ranges so that a range
4581 * is [contained](#Range.contains) by its parent.
4582 *
4583 * @param document The document in which the command was invoked.
4584 * @param positions The positions at which the command was invoked.
4585 * @param token A cancellation token.
4586 * @return Selection ranges or a thenable that resolves to such. The lack of a result can be
4587 * signaled by returning `undefined` or `null`.
4588 */
4589 provideSelectionRanges(document: TextDocument, positions: Position[], token: CancellationToken): ProviderResult<SelectionRange[]>;
4590 }
4591
4592 /**
4593 * Represents programming constructs like functions or constructors in the context
4594 * of call hierarchy.
4595 */
4596 export class CallHierarchyItem {
4597 /**
4598 * The name of this item.
4599 */
4600 name: string;
4601
4602 /**
4603 * The kind of this item.
4604 */
4605 kind: SymbolKind;
4606
4607 /**
4608 * Tags for this item.
4609 */
4610 tags?: ReadonlyArray<SymbolTag>;
4611
4612 /**
4613 * More detail for this item, e.g. the signature of a function.
4614 */
4615 detail?: string;
4616
4617 /**
4618 * The resource identifier of this item.
4619 */
4620 uri: Uri;
4621
4622 /**
4623 * The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code.
4624 */
4625 range: Range;
4626
4627 /**
4628 * The range that should be selected and revealed when this symbol is being picked, e.g. the name of a function.
4629 * Must be contained by the [`range`](#CallHierarchyItem.range).
4630 */
4631 selectionRange: Range;
4632
4633 /**
4634 * Creates a new call hierarchy item.
4635 */
4636 constructor(kind: SymbolKind, name: string, detail: string, uri: Uri, range: Range, selectionRange: Range);
4637 }
4638
4639 /**
4640 * Represents an incoming call, e.g. a caller of a method or constructor.
4641 */
4642 export class CallHierarchyIncomingCall {
4643
4644 /**
4645 * The item that makes the call.
4646 */
4647 from: CallHierarchyItem;
4648
4649 /**
4650 * The range at which at which the calls appears. This is relative to the caller
4651 * denoted by [`this.from`](#CallHierarchyIncomingCall.from).
4652 */
4653 fromRanges: Range[];
4654
4655 /**
4656 * Create a new call object.
4657 *
4658 * @param item The item making the call.
4659 * @param fromRanges The ranges at which the calls appear.
4660 */
4661 constructor(item: CallHierarchyItem, fromRanges: Range[]);
4662 }
4663
4664 /**
4665 * Represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc.
4666 */
4667 export class CallHierarchyOutgoingCall {
4668
4669 /**
4670 * The item that is called.
4671 */
4672 to: CallHierarchyItem;
4673
4674 /**
4675 * The range at which this item is called. This is the range relative to the caller, e.g the item
4676 * passed to [`provideCallHierarchyOutgoingCalls`](#CallHierarchyProvider.provideCallHierarchyOutgoingCalls)
4677 * and not [`this.to`](#CallHierarchyOutgoingCall.to).
4678 */
4679 fromRanges: Range[];
4680
4681 /**
4682 * Create a new call object.
4683 *
4684 * @param item The item being called
4685 * @param fromRanges The ranges at which the calls appear.
4686 */
4687 constructor(item: CallHierarchyItem, fromRanges: Range[]);
4688 }
4689
4690 /**
4691 * The call hierarchy provider interface describes the contract between extensions
4692 * and the call hierarchy feature which allows to browse calls and caller of function,
4693 * methods, constructor etc.
4694 */
4695 export interface CallHierarchyProvider {
4696
4697 /**
4698 * Bootstraps call hierarchy by returning the item that is denoted by the given document
4699 * and position. This item will be used as entry into the call graph. Providers should
4700 * return `undefined` or `null` when there is no item at the given location.
4701 *
4702 * @param document The document in which the command was invoked.
4703 * @param position The position at which the command was invoked.
4704 * @param token A cancellation token.
4705 * @returns A call hierarchy item or a thenable that resolves to such. The lack of a result can be
4706 * signaled by returning `undefined` or `null`.
4707 */
4708 prepareCallHierarchy(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<CallHierarchyItem | CallHierarchyItem[]>;
4709
4710 /**
4711 * Provide all incoming calls for an item, e.g all callers for a method. In graph terms this describes directed
4712 * and annotated edges inside the call graph, e.g the given item is the starting node and the result is the nodes
4713 * that can be reached.
4714 *
4715 * @param item The hierarchy item for which incoming calls should be computed.
4716 * @param token A cancellation token.
4717 * @returns A set of incoming calls or a thenable that resolves to such. The lack of a result can be
4718 * signaled by returning `undefined` or `null`.
4719 */
4720 provideCallHierarchyIncomingCalls(item: CallHierarchyItem, token: CancellationToken): ProviderResult<CallHierarchyIncomingCall[]>;
4721
4722 /**
4723 * Provide all outgoing calls for an item, e.g call calls to functions, methods, or constructors from the given item. In
4724 * graph terms this describes directed and annotated edges inside the call graph, e.g the given item is the starting
4725 * node and the result is the nodes that can be reached.
4726 *
4727 * @param item The hierarchy item for which outgoing calls should be computed.
4728 * @param token A cancellation token.
4729 * @returns A set of outgoing calls or a thenable that resolves to such. The lack of a result can be
4730 * signaled by returning `undefined` or `null`.
4731 */
4732 provideCallHierarchyOutgoingCalls(item: CallHierarchyItem, token: CancellationToken): ProviderResult<CallHierarchyOutgoingCall[]>;
4733 }
4734
4735 /**
4736 * Represents a list of ranges that can be edited together along with a word pattern to describe valid range contents.
4737 */
4738 export class LinkedEditingRanges {
4739 /**
4740 * Create a new linked editing ranges object.
4741 *
4742 * @param ranges A list of ranges that can be edited together
4743 * @param wordPattern An optional word pattern that describes valid contents for the given ranges
4744 */
4745 constructor(ranges: Range[], wordPattern?: RegExp);
4746
4747 /**
4748 * A list of ranges that can be edited together. The ranges must have
4749 * identical length and text content. The ranges cannot overlap.
4750 */
4751 readonly ranges: Range[];
4752
4753 /**
4754 * An optional word pattern that describes valid contents for the given ranges.
4755 * If no pattern is provided, the language configuration's word pattern will be used.
4756 */
4757 readonly wordPattern?: RegExp;
4758 }
4759
4760 /**
4761 * The linked editing range provider interface defines the contract between extensions and
4762 * the linked editing feature.
4763 */
4764 export interface LinkedEditingRangeProvider {
4765 /**
4766 * For a given position in a document, returns the range of the symbol at the position and all ranges
4767 * that have the same content. A change to one of the ranges can be applied to all other ranges if the new content
4768 * is valid. An optional word pattern can be returned with the result to describe valid contents.
4769 * If no result-specific word pattern is provided, the word pattern from the language configuration is used.
4770 *
4771 * @param document The document in which the provider was invoked.
4772 * @param position The position at which the provider was invoked.
4773 * @param token A cancellation token.
4774 * @return A list of ranges that can be edited together
4775 */
4776 provideLinkedEditingRanges(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<LinkedEditingRanges>;
4777 }
4778
4779 /**
4780 * A tuple of two characters, like a pair of
4781 * opening and closing brackets.
4782 */
4783 export type CharacterPair = [string, string];
4784
4785 /**
4786 * Describes how comments for a language work.
4787 */
4788 export interface CommentRule {
4789
4790 /**
4791 * The line comment token, like `// this is a comment`
4792 */
4793 lineComment?: string;
4794
4795 /**
4796 * The block comment character pair, like `/* block comment *&#47;`
4797 */
4798 blockComment?: CharacterPair;
4799 }
4800
4801 /**
4802 * Describes indentation rules for a language.
4803 */
4804 export interface IndentationRule {
4805 /**
4806 * If a line matches this pattern, then all the lines after it should be unindented once (until another rule matches).
4807 */
4808 decreaseIndentPattern: RegExp;
4809 /**
4810 * If a line matches this pattern, then all the lines after it should be indented once (until another rule matches).
4811 */
4812 increaseIndentPattern: RegExp;
4813 /**
4814 * If a line matches this pattern, then **only the next line** after it should be indented once.
4815 */
4816 indentNextLinePattern?: RegExp;
4817 /**
4818 * If a line matches this pattern, then its indentation should not be changed and it should not be evaluated against the other rules.
4819 */
4820 unIndentedLinePattern?: RegExp;
4821 }
4822
4823 /**
4824 * Describes what to do with the indentation when pressing Enter.
4825 */
4826 export enum IndentAction {
4827 /**
4828 * Insert new line and copy the previous line's indentation.
4829 */
4830 None = 0,
4831 /**
4832 * Insert new line and indent once (relative to the previous line's indentation).
4833 */
4834 Indent = 1,
4835 /**
4836 * Insert two new lines:
4837 * - the first one indented which will hold the cursor
4838 * - the second one at the same indentation level
4839 */
4840 IndentOutdent = 2,
4841 /**
4842 * Insert new line and outdent once (relative to the previous line's indentation).
4843 */
4844 Outdent = 3
4845 }
4846
4847 /**
4848 * Describes what to do when pressing Enter.
4849 */
4850 export interface EnterAction {
4851 /**
4852 * Describe what to do with the indentation.
4853 */
4854 indentAction: IndentAction;
4855 /**
4856 * Describes text to be appended after the new line and after the indentation.
4857 */
4858 appendText?: string;
4859 /**
4860 * Describes the number of characters to remove from the new line's indentation.
4861 */
4862 removeText?: number;
4863 }
4864
4865 /**
4866 * Describes a rule to be evaluated when pressing Enter.
4867 */
4868 export interface OnEnterRule {
4869 /**
4870 * This rule will only execute if the text before the cursor matches this regular expression.
4871 */
4872 beforeText: RegExp;
4873 /**
4874 * This rule will only execute if the text after the cursor matches this regular expression.
4875 */
4876 afterText?: RegExp;
4877 /**
4878 * This rule will only execute if the text above the current line matches this regular expression.
4879 */
4880 previousLineText?: RegExp;
4881 /**
4882 * The action to execute.
4883 */
4884 action: EnterAction;
4885 }
4886
4887 /**
4888 * The language configuration interfaces defines the contract between extensions
4889 * and various editor features, like automatic bracket insertion, automatic indentation etc.
4890 */
4891 export interface LanguageConfiguration {
4892 /**
4893 * The language's comment settings.
4894 */
4895 comments?: CommentRule;
4896 /**
4897 * The language's brackets.
4898 * This configuration implicitly affects pressing Enter around these brackets.
4899 */
4900 brackets?: CharacterPair[];
4901 /**
4902 * The language's word definition.
4903 * If the language supports Unicode identifiers (e.g. JavaScript), it is preferable
4904 * to provide a word definition that uses exclusion of known separators.
4905 * e.g.: A regex that matches anything except known separators (and dot is allowed to occur in a floating point number):
4906 * /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g
4907 */
4908 wordPattern?: RegExp;
4909 /**
4910 * The language's indentation settings.
4911 */
4912 indentationRules?: IndentationRule;
4913 /**
4914 * The language's rules to be evaluated when pressing Enter.
4915 */
4916 onEnterRules?: OnEnterRule[];
4917
4918 /**
4919 * **Deprecated** Do not use.
4920 *
4921 * @deprecated Will be replaced by a better API soon.
4922 */
4923 __electricCharacterSupport?: {
4924 /**
4925 * This property is deprecated and will be **ignored** from
4926 * the editor.
4927 * @deprecated
4928 */
4929 brackets?: any;
4930 /**
4931 * This property is deprecated and not fully supported anymore by
4932 * the editor (scope and lineStart are ignored).
4933 * Use the autoClosingPairs property in the language configuration file instead.
4934 * @deprecated
4935 */
4936 docComment?: {
4937 scope: string;
4938 open: string;
4939 lineStart: string;
4940 close?: string;
4941 };
4942 };
4943
4944 /**
4945 * **Deprecated** Do not use.
4946 *
4947 * @deprecated * Use the autoClosingPairs property in the language configuration file instead.
4948 */
4949 __characterPairSupport?: {
4950 autoClosingPairs: {
4951 open: string;
4952 close: string;
4953 notIn?: string[];
4954 }[];
4955 };
4956 }
4957
4958 /**
4959 * The configuration target
4960 */
4961 export enum ConfigurationTarget {
4962 /**
4963 * Global configuration
4964 */
4965 Global = 1,
4966
4967 /**
4968 * Workspace configuration
4969 */
4970 Workspace = 2,
4971
4972 /**
4973 * Workspace folder configuration
4974 */
4975 WorkspaceFolder = 3
4976 }
4977
4978 /**
4979 * Represents the configuration. It is a merged view of
4980 *
4981 * - *Default Settings*
4982 * - *Global (User) Settings*
4983 * - *Workspace settings*
4984 * - *Workspace Folder settings* - From one of the [Workspace Folders](#workspace.workspaceFolders) under which requested resource belongs to.
4985 * - *Language settings* - Settings defined under requested language.
4986 *
4987 * The *effective* value (returned by [`get`](#WorkspaceConfiguration.get)) is computed by overriding or merging the values in the following order.
4988 *
4989 * ```
4990 * `defaultValue` (if defined in `package.json` otherwise derived from the value's type)
4991 * `globalValue` (if defined)
4992 * `workspaceValue` (if defined)
4993 * `workspaceFolderValue` (if defined)
4994 * `defaultLanguageValue` (if defined)
4995 * `globalLanguageValue` (if defined)
4996 * `workspaceLanguageValue` (if defined)
4997 * `workspaceFolderLanguageValue` (if defined)
4998 * ```
4999 * **Note:** Only `object` value types are merged and all other value types are overridden.
5000 *
5001 * Example 1: Overriding
5002 *
5003 * ```ts
5004 * defaultValue = 'on';
5005 * globalValue = 'relative'
5006 * workspaceFolderValue = 'off'
5007 * value = 'off'
5008 * ```
5009 *
5010 * Example 2: Language Values
5011 *
5012 * ```ts
5013 * defaultValue = 'on';
5014 * globalValue = 'relative'
5015 * workspaceFolderValue = 'off'
5016 * globalLanguageValue = 'on'
5017 * value = 'on'
5018 * ```
5019 *
5020 * Example 3: Object Values
5021 *
5022 * ```ts
5023 * defaultValue = { "a": 1, "b": 2 };
5024 * globalValue = { "b": 3, "c": 4 };
5025 * value = { "a": 1, "b": 3, "c": 4 };
5026 * ```
5027 *
5028 * *Note:* Workspace and Workspace Folder configurations contains `launch` and `tasks` settings. Their basename will be
5029 * part of the section identifier. The following snippets shows how to retrieve all configurations
5030 * from `launch.json`:
5031 *
5032 * ```ts
5033 * // launch.json configuration
5034 * const config = workspace.getConfiguration('launch', vscode.workspace.workspaceFolders[0].uri);
5035 *
5036 * // retrieve values
5037 * const values = config.get('configurations');
5038 * ```
5039 *
5040 * Refer to [Settings](https://code.visualstudio.com/docs/getstarted/settings) for more information.
5041 */
5042 export interface WorkspaceConfiguration {
5043
5044 /**
5045 * Return a value from this configuration.
5046 *
5047 * @param section Configuration name, supports _dotted_ names.
5048 * @return The value `section` denotes or `undefined`.
5049 */
5050 get<T>(section: string): T | undefined;
5051
5052 /**
5053 * Return a value from this configuration.
5054 *
5055 * @param section Configuration name, supports _dotted_ names.
5056 * @param defaultValue A value should be returned when no value could be found, is `undefined`.
5057 * @return The value `section` denotes or the default.
5058 */
5059 get<T>(section: string, defaultValue: T): T;
5060
5061 /**
5062 * Check if this configuration has a certain value.
5063 *
5064 * @param section Configuration name, supports _dotted_ names.
5065 * @return `true` if the section doesn't resolve to `undefined`.
5066 */
5067 has(section: string): boolean;
5068
5069 /**
5070 * Retrieve all information about a configuration setting. A configuration value
5071 * often consists of a *default* value, a global or installation-wide value,
5072 * a workspace-specific value, folder-specific value
5073 * and language-specific values (if [WorkspaceConfiguration](#WorkspaceConfiguration) is scoped to a language).
5074 *
5075 * Also provides all language ids under which the given configuration setting is defined.
5076 *
5077 * *Note:* The configuration name must denote a leaf in the configuration tree
5078 * (`editor.fontSize` vs `editor`) otherwise no result is returned.
5079 *
5080 * @param section Configuration name, supports _dotted_ names.
5081 * @return Information about a configuration setting or `undefined`.
5082 */
5083 inspect<T>(section: string): {
5084 key: string;
5085
5086 defaultValue?: T;
5087 globalValue?: T;
5088 workspaceValue?: T,
5089 workspaceFolderValue?: T,
5090
5091 defaultLanguageValue?: T;
5092 globalLanguageValue?: T;
5093 workspaceLanguageValue?: T;
5094 workspaceFolderLanguageValue?: T;
5095
5096 languageIds?: string[];
5097
5098 } | undefined;
5099
5100 /**
5101 * Update a configuration value. The updated configuration values are persisted.
5102 *
5103 * A value can be changed in
5104 *
5105 * - [Global settings](#ConfigurationTarget.Global): Changes the value for all instances of the editor.
5106 * - [Workspace settings](#ConfigurationTarget.Workspace): Changes the value for current workspace, if available.
5107 * - [Workspace folder settings](#ConfigurationTarget.WorkspaceFolder): Changes the value for settings from one of the [Workspace Folders](#workspace.workspaceFolders) under which the requested resource belongs to.
5108 * - Language settings: Changes the value for the requested languageId.
5109 *
5110 * *Note:* To remove a configuration value use `undefined`, like so: `config.update('somekey', undefined)`
5111 *
5112 * @param section Configuration name, supports _dotted_ names.
5113 * @param value The new value.
5114 * @param configurationTarget The [configuration target](#ConfigurationTarget) or a boolean value.
5115 * - If `true` updates [Global settings](#ConfigurationTarget.Global).
5116 * - If `false` updates [Workspace settings](#ConfigurationTarget.Workspace).
5117 * - If `undefined` or `null` updates to [Workspace folder settings](#ConfigurationTarget.WorkspaceFolder) if configuration is resource specific,
5118 * otherwise to [Workspace settings](#ConfigurationTarget.Workspace).
5119 * @param overrideInLanguage Whether to update the value in the scope of requested languageId or not.
5120 * - If `true` updates the value under the requested languageId.
5121 * - If `undefined` updates the value under the requested languageId only if the configuration is defined for the language.
5122 * @throws error while updating
5123 * - configuration which is not registered.
5124 * - window configuration to workspace folder
5125 * - configuration to workspace or workspace folder when no workspace is opened.
5126 * - configuration to workspace folder when there is no workspace folder settings.
5127 * - configuration to workspace folder when [WorkspaceConfiguration](#WorkspaceConfiguration) is not scoped to a resource.
5128 */
5129 update(section: string, value: any, configurationTarget?: ConfigurationTarget | boolean, overrideInLanguage?: boolean): Thenable<void>;
5130
5131 /**
5132 * Readable dictionary that backs this configuration.
5133 */
5134 readonly [key: string]: any;
5135 }
5136
5137 /**
5138 * Represents a location inside a resource, such as a line
5139 * inside a text file.
5140 */
5141 export class Location {
5142
5143 /**
5144 * The resource identifier of this location.
5145 */
5146 uri: Uri;
5147
5148 /**
5149 * The document range of this location.
5150 */
5151 range: Range;
5152
5153 /**
5154 * Creates a new location object.
5155 *
5156 * @param uri The resource identifier.
5157 * @param rangeOrPosition The range or position. Positions will be converted to an empty range.
5158 */
5159 constructor(uri: Uri, rangeOrPosition: Range | Position);
5160 }
5161
5162 /**
5163 * Represents the connection of two locations. Provides additional metadata over normal [locations](#Location),
5164 * including an origin range.
5165 */
5166 export interface LocationLink {
5167 /**
5168 * Span of the origin of this link.
5169 *
5170 * Used as the underlined span for mouse definition hover. Defaults to the word range at
5171 * the definition position.
5172 */
5173 originSelectionRange?: Range;
5174
5175 /**
5176 * The target resource identifier of this link.
5177 */
5178 targetUri: Uri;
5179
5180 /**
5181 * The full target range of this link.
5182 */
5183 targetRange: Range;
5184
5185 /**
5186 * The span of this link.
5187 */
5188 targetSelectionRange?: Range;
5189 }
5190
5191 /**
5192 * The event that is fired when diagnostics change.
5193 */
5194 export interface DiagnosticChangeEvent {
5195
5196 /**
5197 * An array of resources for which diagnostics have changed.
5198 */
5199 readonly uris: ReadonlyArray<Uri>;
5200 }
5201
5202 /**
5203 * Represents the severity of diagnostics.
5204 */
5205 export enum DiagnosticSeverity {
5206
5207 /**
5208 * Something not allowed by the rules of a language or other means.
5209 */
5210 Error = 0,
5211
5212 /**
5213 * Something suspicious but allowed.
5214 */
5215 Warning = 1,
5216
5217 /**
5218 * Something to inform about but not a problem.
5219 */
5220 Information = 2,
5221
5222 /**
5223 * Something to hint to a better way of doing it, like proposing
5224 * a refactoring.
5225 */
5226 Hint = 3
5227 }
5228
5229 /**
5230 * Represents a related message and source code location for a diagnostic. This should be
5231 * used to point to code locations that cause or related to a diagnostics, e.g. when duplicating
5232 * a symbol in a scope.
5233 */
5234 export class DiagnosticRelatedInformation {
5235
5236 /**
5237 * The location of this related diagnostic information.
5238 */
5239 location: Location;
5240
5241 /**
5242 * The message of this related diagnostic information.
5243 */
5244 message: string;
5245
5246 /**
5247 * Creates a new related diagnostic information object.
5248 *
5249 * @param location The location.
5250 * @param message The message.
5251 */
5252 constructor(location: Location, message: string);
5253 }
5254
5255 /**
5256 * Additional metadata about the type of a diagnostic.
5257 */
5258 export enum DiagnosticTag {
5259 /**
5260 * Unused or unnecessary code.
5261 *
5262 * Diagnostics with this tag are rendered faded out. The amount of fading
5263 * is controlled by the `"editorUnnecessaryCode.opacity"` theme color. For
5264 * example, `"editorUnnecessaryCode.opacity": "#000000c0"` will render the
5265 * code with 75% opacity. For high contrast themes, use the
5266 * `"editorUnnecessaryCode.border"` theme color to underline unnecessary code
5267 * instead of fading it out.
5268 */
5269 Unnecessary = 1,
5270
5271 /**
5272 * Deprecated or obsolete code.
5273 *
5274 * Diagnostics with this tag are rendered with a strike through.
5275 */
5276 Deprecated = 2,
5277 }
5278
5279 /**
5280 * Represents a diagnostic, such as a compiler error or warning. Diagnostic objects
5281 * are only valid in the scope of a file.
5282 */
5283 export class Diagnostic {
5284
5285 /**
5286 * The range to which this diagnostic applies.
5287 */
5288 range: Range;
5289
5290 /**
5291 * The human-readable message.
5292 */
5293 message: string;
5294
5295 /**
5296 * The severity, default is [error](#DiagnosticSeverity.Error).
5297 */
5298 severity: DiagnosticSeverity;
5299
5300 /**
5301 * A human-readable string describing the source of this
5302 * diagnostic, e.g. 'typescript' or 'super lint'.
5303 */
5304 source?: string;
5305
5306 /**
5307 * A code or identifier for this diagnostic.
5308 * Should be used for later processing, e.g. when providing [code actions](#CodeActionContext).
5309 */
5310 code?: string | number | {
5311 /**
5312 * A code or identifier for this diagnostic.
5313 * Should be used for later processing, e.g. when providing [code actions](#CodeActionContext).
5314 */
5315 value: string | number;
5316
5317 /**
5318 * A target URI to open with more information about the diagnostic error.
5319 */
5320 target: Uri;
5321 };
5322
5323 /**
5324 * An array of related diagnostic information, e.g. when symbol-names within
5325 * a scope collide all definitions can be marked via this property.
5326 */
5327 relatedInformation?: DiagnosticRelatedInformation[];
5328
5329 /**
5330 * Additional metadata about the diagnostic.
5331 */
5332 tags?: DiagnosticTag[];
5333
5334 /**
5335 * Creates a new diagnostic object.
5336 *
5337 * @param range The range to which this diagnostic applies.
5338 * @param message The human-readable message.
5339 * @param severity The severity, default is [error](#DiagnosticSeverity.Error).
5340 */
5341 constructor(range: Range, message: string, severity?: DiagnosticSeverity);
5342 }
5343
5344 /**
5345 * A diagnostics collection is a container that manages a set of
5346 * [diagnostics](#Diagnostic). Diagnostics are always scopes to a
5347 * diagnostics collection and a resource.
5348 *
5349 * To get an instance of a `DiagnosticCollection` use
5350 * [createDiagnosticCollection](#languages.createDiagnosticCollection).
5351 */
5352 export interface DiagnosticCollection {
5353
5354 /**
5355 * The name of this diagnostic collection, for instance `typescript`. Every diagnostic
5356 * from this collection will be associated with this name. Also, the task framework uses this
5357 * name when defining [problem matchers](https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher).
5358 */
5359 readonly name: string;
5360
5361 /**
5362 * Assign diagnostics for given resource. Will replace
5363 * existing diagnostics for that resource.
5364 *
5365 * @param uri A resource identifier.
5366 * @param diagnostics Array of diagnostics or `undefined`
5367 */
5368 set(uri: Uri, diagnostics: ReadonlyArray<Diagnostic> | undefined): void;
5369
5370 /**
5371 * Replace diagnostics for multiple resources in this collection.
5372 *
5373 * _Note_ that multiple tuples of the same uri will be merged, e.g
5374 * `[[file1, [d1]], [file1, [d2]]]` is equivalent to `[[file1, [d1, d2]]]`.
5375 * If a diagnostics item is `undefined` as in `[file1, undefined]`
5376 * all previous but not subsequent diagnostics are removed.
5377 *
5378 * @param entries An array of tuples, like `[[file1, [d1, d2]], [file2, [d3, d4, d5]]]`, or `undefined`.
5379 */
5380 set(entries: ReadonlyArray<[Uri, ReadonlyArray<Diagnostic> | undefined]>): void;
5381
5382 /**
5383 * Remove all diagnostics from this collection that belong
5384 * to the provided `uri`. The same as `#set(uri, undefined)`.
5385 *
5386 * @param uri A resource identifier.
5387 */
5388 delete(uri: Uri): void;
5389
5390 /**
5391 * Remove all diagnostics from this collection. The same
5392 * as calling `#set(undefined)`;
5393 */
5394 clear(): void;
5395
5396 /**
5397 * Iterate over each entry in this collection.
5398 *
5399 * @param callback Function to execute for each entry.
5400 * @param thisArg The `this` context used when invoking the handler function.
5401 */
5402 forEach(callback: (uri: Uri, diagnostics: ReadonlyArray<Diagnostic>, collection: DiagnosticCollection) => any, thisArg?: any): void;
5403
5404 /**
5405 * Get the diagnostics for a given resource. *Note* that you cannot
5406 * modify the diagnostics-array returned from this call.
5407 *
5408 * @param uri A resource identifier.
5409 * @returns An immutable array of [diagnostics](#Diagnostic) or `undefined`.
5410 */
5411 get(uri: Uri): ReadonlyArray<Diagnostic> | undefined;
5412
5413 /**
5414 * Check if this collection contains diagnostics for a
5415 * given resource.
5416 *
5417 * @param uri A resource identifier.
5418 * @returns `true` if this collection has diagnostic for the given resource.
5419 */
5420 has(uri: Uri): boolean;
5421
5422 /**
5423 * Dispose and free associated resources. Calls
5424 * [clear](#DiagnosticCollection.clear).
5425 */
5426 dispose(): void;
5427 }
5428
5429 /**
5430 * Denotes a location of an editor in the window. Editors can be arranged in a grid
5431 * and each column represents one editor location in that grid by counting the editors
5432 * in order of their appearance.
5433 */
5434 export enum ViewColumn {
5435 /**
5436 * A *symbolic* editor column representing the currently active column. This value
5437 * can be used when opening editors, but the *resolved* [viewColumn](#TextEditor.viewColumn)-value
5438 * of editors will always be `One`, `Two`, `Three`,... or `undefined` but never `Active`.
5439 */
5440 Active = -1,
5441 /**
5442 * A *symbolic* editor column representing the column to the side of the active one. This value
5443 * can be used when opening editors, but the *resolved* [viewColumn](#TextEditor.viewColumn)-value
5444 * of editors will always be `One`, `Two`, `Three`,... or `undefined` but never `Beside`.
5445 */
5446 Beside = -2,
5447 /**
5448 * The first editor column.
5449 */
5450 One = 1,
5451 /**
5452 * The second editor column.
5453 */
5454 Two = 2,
5455 /**
5456 * The third editor column.
5457 */
5458 Three = 3,
5459 /**
5460 * The fourth editor column.
5461 */
5462 Four = 4,
5463 /**
5464 * The fifth editor column.
5465 */
5466 Five = 5,
5467 /**
5468 * The sixth editor column.
5469 */
5470 Six = 6,
5471 /**
5472 * The seventh editor column.
5473 */
5474 Seven = 7,
5475 /**
5476 * The eighth editor column.
5477 */
5478 Eight = 8,
5479 /**
5480 * The ninth editor column.
5481 */
5482 Nine = 9
5483 }
5484
5485 /**
5486 * An output channel is a container for readonly textual information.
5487 *
5488 * To get an instance of an `OutputChannel` use
5489 * [createOutputChannel](#window.createOutputChannel).
5490 */
5491 export interface OutputChannel {
5492
5493 /**
5494 * The human-readable name of this output channel.
5495 */
5496 readonly name: string;
5497
5498 /**
5499 * Append the given value to the channel.
5500 *
5501 * @param value A string, falsy values will not be printed.
5502 */
5503 append(value: string): void;
5504
5505 /**
5506 * Append the given value and a line feed character
5507 * to the channel.
5508 *
5509 * @param value A string, falsy values will be printed.
5510 */
5511 appendLine(value: string): void;
5512
5513 /**
5514 * Removes all output from the channel.
5515 */
5516 clear(): void;
5517
5518 /**
5519 * Reveal this channel in the UI.
5520 *
5521 * @param preserveFocus When `true` the channel will not take focus.
5522 */
5523 show(preserveFocus?: boolean): void;
5524
5525 /**
5526 * Reveal this channel in the UI.
5527 *
5528 * @deprecated Use the overload with just one parameter (`show(preserveFocus?: boolean): void`).
5529 *
5530 * @param column This argument is **deprecated** and will be ignored.
5531 * @param preserveFocus When `true` the channel will not take focus.
5532 */
5533 show(column?: ViewColumn, preserveFocus?: boolean): void;
5534
5535 /**
5536 * Hide this channel from the UI.
5537 */
5538 hide(): void;
5539
5540 /**
5541 * Dispose and free associated resources.
5542 */
5543 dispose(): void;
5544 }
5545
5546 /**
5547 * Accessibility information which controls screen reader behavior.
5548 */
5549 export interface AccessibilityInformation {
5550 /**
5551 * Label to be read out by a screen reader once the item has focus.
5552 */
5553 label: string;
5554
5555 /**
5556 * Role of the widget which defines how a screen reader interacts with it.
5557 * The role should be set in special cases when for example a tree-like element behaves like a checkbox.
5558 * If role is not specified VS Code will pick the appropriate role automatically.
5559 * More about aria roles can be found here https://w3c.github.io/aria/#widget_roles
5560 */
5561 role?: string;
5562 }
5563
5564 /**
5565 * Represents the alignment of status bar items.
5566 */
5567 export enum StatusBarAlignment {
5568
5569 /**
5570 * Aligned to the left side.
5571 */
5572 Left = 1,
5573
5574 /**
5575 * Aligned to the right side.
5576 */
5577 Right = 2
5578 }
5579
5580 /**
5581 * A status bar item is a status bar contribution that can
5582 * show text and icons and run a command on click.
5583 */
5584 export interface StatusBarItem {
5585
5586 /**
5587 * The alignment of this item.
5588 */
5589 readonly alignment: StatusBarAlignment;
5590
5591 /**
5592 * The priority of this item. Higher value means the item should
5593 * be shown more to the left.
5594 */
5595 readonly priority?: number;
5596
5597 /**
5598 * The text to show for the entry. You can embed icons in the text by leveraging the syntax:
5599 *
5600 * `My text $(icon-name) contains icons like $(icon-name) this one.`
5601 *
5602 * Where the icon-name is taken from the ThemeIcon [icon set](https://code.visualstudio.com/api/references/icons-in-labels#icon-listing), e.g.
5603 * `light-bulb`, `thumbsup`, `zap` etc.
5604 */
5605 text: string;
5606
5607 /**
5608 * The tooltip text when you hover over this entry.
5609 */
5610 tooltip: string | undefined;
5611
5612 /**
5613 * The foreground color for this entry.
5614 */
5615 color: string | ThemeColor | undefined;
5616
5617 /**
5618 * The background color for this entry.
5619 *
5620 * *Note*: only `new ThemeColor('statusBarItem.errorBackground')` is
5621 * supported for now. More background colors may be supported in the
5622 * future.
5623 *
5624 * *Note*: when a background color is set, the statusbar may override
5625 * the `color` choice to ensure the entry is readable in all themes.
5626 */
5627 backgroundColor: ThemeColor | undefined;
5628
5629 /**
5630 * [`Command`](#Command) or identifier of a command to run on click.
5631 *
5632 * The command must be [known](#commands.getCommands).
5633 *
5634 * Note that if this is a [`Command`](#Command) object, only the [`command`](#Command.command) and [`arguments`](#Command.arguments)
5635 * are used by VS Code.
5636 */
5637 command: string | Command | undefined;
5638
5639 /**
5640 * Accessibility information used when screen reader interacts with this StatusBar item
5641 */
5642 accessibilityInformation?: AccessibilityInformation;
5643
5644 /**
5645 * Shows the entry in the status bar.
5646 */
5647 show(): void;
5648
5649 /**
5650 * Hide the entry in the status bar.
5651 */
5652 hide(): void;
5653
5654 /**
5655 * Dispose and free associated resources. Call
5656 * [hide](#StatusBarItem.hide).
5657 */
5658 dispose(): void;
5659 }
5660
5661 /**
5662 * Defines a generalized way of reporting progress updates.
5663 */
5664 export interface Progress<T> {
5665
5666 /**
5667 * Report a progress update.
5668 * @param value A progress item, like a message and/or an
5669 * report on how much work finished
5670 */
5671 report(value: T): void;
5672 }
5673
5674 /**
5675 * An individual terminal instance within the integrated terminal.
5676 */
5677 export interface Terminal {
5678
5679 /**
5680 * The name of the terminal.
5681 */
5682 readonly name: string;
5683
5684 /**
5685 * The process ID of the shell process.
5686 */
5687 readonly processId: Thenable<number | undefined>;
5688
5689 /**
5690 * The object used to initialize the terminal, this is useful for example to detecting the
5691 * shell type of when the terminal was not launched by this extension or for detecting what
5692 * folder the shell was launched in.
5693 */
5694 readonly creationOptions: Readonly<TerminalOptions | ExtensionTerminalOptions>;
5695
5696 /**
5697 * The exit status of the terminal, this will be undefined while the terminal is active.
5698 *
5699 * **Example:** Show a notification with the exit code when the terminal exits with a
5700 * non-zero exit code.
5701 * ```typescript
5702 * window.onDidCloseTerminal(t => {
5703 * if (t.exitStatus && t.exitStatus.code) {
5704 * vscode.window.showInformationMessage(`Exit code: ${t.exitStatus.code}`);
5705 * }
5706 * });
5707 * ```
5708 */
5709 readonly exitStatus: TerminalExitStatus | undefined;
5710
5711 /**
5712 * Send text to the terminal. The text is written to the stdin of the underlying pty process
5713 * (shell) of the terminal.
5714 *
5715 * @param text The text to send.
5716 * @param addNewLine Whether to add a new line to the text being sent, this is normally
5717 * required to run a command in the terminal. The character(s) added are \n or \r\n
5718 * depending on the platform. This defaults to `true`.
5719 */
5720 sendText(text: string, addNewLine?: boolean): void;
5721
5722 /**
5723 * Show the terminal panel and reveal this terminal in the UI.
5724 *
5725 * @param preserveFocus When `true` the terminal will not take focus.
5726 */
5727 show(preserveFocus?: boolean): void;
5728
5729 /**
5730 * Hide the terminal panel if this terminal is currently showing.
5731 */
5732 hide(): void;
5733
5734 /**
5735 * Dispose and free associated resources.
5736 */
5737 dispose(): void;
5738 }
5739
5740 /**
5741 * Provides information on a line in a terminal in order to provide links for it.
5742 */
5743 export interface TerminalLinkContext {
5744 /**
5745 * This is the text from the unwrapped line in the terminal.
5746 */
5747 line: string;
5748
5749 /**
5750 * The terminal the link belongs to.
5751 */
5752 terminal: Terminal;
5753 }
5754
5755 /**
5756 * A provider that enables detection and handling of links within terminals.
5757 */
5758 export interface TerminalLinkProvider<T extends TerminalLink = TerminalLink> {
5759 /**
5760 * Provide terminal links for the given context. Note that this can be called multiple times
5761 * even before previous calls resolve, make sure to not share global objects (eg. `RegExp`)
5762 * that could have problems when asynchronous usage may overlap.
5763 * @param context Information about what links are being provided for.
5764 * @param token A cancellation token.
5765 * @return A list of terminal links for the given line.
5766 */
5767 provideTerminalLinks(context: TerminalLinkContext, token: CancellationToken): ProviderResult<T[]>;
5768
5769 /**
5770 * Handle an activated terminal link.
5771 * @param link The link to handle.
5772 */
5773 handleTerminalLink(link: T): ProviderResult<void>;
5774 }
5775
5776 /**
5777 * A link on a terminal line.
5778 */
5779 export interface TerminalLink {
5780 /**
5781 * The start index of the link on [TerminalLinkContext.line](#TerminalLinkContext.line].
5782 */
5783 startIndex: number;
5784
5785 /**
5786 * The length of the link on [TerminalLinkContext.line](#TerminalLinkContext.line]
5787 */
5788 length: number;
5789
5790 /**
5791 * The tooltip text when you hover over this link.
5792 *
5793 * If a tooltip is provided, is will be displayed in a string that includes instructions on
5794 * how to trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary
5795 * depending on OS, user settings, and localization.
5796 */
5797 tooltip?: string;
5798 }
5799
5800 /**
5801 * A file decoration represents metadata that can be rendered with a file.
5802 */
5803 export class FileDecoration {
5804
5805 /**
5806 * A very short string that represents this decoration.
5807 */
5808 badge?: string;
5809
5810 /**
5811 * A human-readable tooltip for this decoration.
5812 */
5813 tooltip?: string;
5814
5815 /**
5816 * The color of this decoration.
5817 */
5818 color?: ThemeColor;
5819
5820 /**
5821 * A flag expressing that this decoration should be
5822 * propagated to its parents.
5823 */
5824 propagate?: boolean;
5825
5826 /**
5827 * Creates a new decoration.
5828 *
5829 * @param badge A letter that represents the decoration.
5830 * @param tooltip The tooltip of the decoration.
5831 * @param color The color of the decoration.
5832 */
5833 constructor(badge?: string, tooltip?: string, color?: ThemeColor);
5834 }
5835
5836 /**
5837 * The decoration provider interfaces defines the contract between extensions and
5838 * file decorations.
5839 */
5840 export interface FileDecorationProvider {
5841
5842 /**
5843 * An optional event to signal that decorations for one or many files have changed.
5844 *
5845 * *Note* that this event should be used to propagate information about children.
5846 *
5847 * @see [EventEmitter](#EventEmitter)
5848 */
5849 onDidChangeFileDecorations?: Event<undefined | Uri | Uri[]>;
5850
5851 /**
5852 * Provide decorations for a given uri.
5853 *
5854 * *Note* that this function is only called when a file gets rendered in the UI.
5855 * This means a decoration from a descendent that propagates upwards must be signaled
5856 * to the editor via the [onDidChangeFileDecorations](#FileDecorationProvider.onDidChangeFileDecorations)-event.
5857 *
5858 * @param uri The uri of the file to provide a decoration for.
5859 * @param token A cancellation token.
5860 * @returns A decoration or a thenable that resolves to such.
5861 */
5862 provideFileDecoration(uri: Uri, token: CancellationToken): ProviderResult<FileDecoration>;
5863 }
5864
5865
5866 /**
5867 * In a remote window the extension kind describes if an extension
5868 * runs where the UI (window) runs or if an extension runs remotely.
5869 */
5870 export enum ExtensionKind {
5871
5872 /**
5873 * Extension runs where the UI runs.
5874 */
5875 UI = 1,
5876
5877 /**
5878 * Extension runs where the remote extension host runs.
5879 */
5880 Workspace = 2
5881 }
5882
5883 /**
5884 * Represents an extension.
5885 *
5886 * To get an instance of an `Extension` use [getExtension](#extensions.getExtension).
5887 */
5888 export interface Extension<T> {
5889
5890 /**
5891 * The canonical extension identifier in the form of: `publisher.name`.
5892 */
5893 readonly id: string;
5894
5895 /**
5896 * The uri of the directory containing the extension.
5897 */
5898 readonly extensionUri: Uri;
5899
5900 /**
5901 * The absolute file path of the directory containing this extension. Shorthand
5902 * notation for [Extension.extensionUri.fsPath](#Extension.extensionUri) (independent of the uri scheme).
5903 */
5904 readonly extensionPath: string;
5905
5906 /**
5907 * `true` if the extension has been activated.
5908 */
5909 readonly isActive: boolean;
5910
5911 /**
5912 * The parsed contents of the extension's package.json.
5913 */
5914 readonly packageJSON: any;
5915
5916 /**
5917 * The extension kind describes if an extension runs where the UI runs
5918 * or if an extension runs where the remote extension host runs. The extension kind
5919 * is defined in the `package.json`-file of extensions but can also be refined
5920 * via the `remote.extensionKind`-setting. When no remote extension host exists,
5921 * the value is [`ExtensionKind.UI`](#ExtensionKind.UI).
5922 */
5923 extensionKind: ExtensionKind;
5924
5925 /**
5926 * The public API exported by this extension. It is an invalid action
5927 * to access this field before this extension has been activated.
5928 */
5929 readonly exports: T;
5930
5931 /**
5932 * Activates this extension and returns its public API.
5933 *
5934 * @return A promise that will resolve when this extension has been activated.
5935 */
5936 activate(): Thenable<T>;
5937 }
5938
5939 /**
5940 * The ExtensionMode is provided on the `ExtensionContext` and indicates the
5941 * mode the specific extension is running in.
5942 */
5943 export enum ExtensionMode {
5944 /**
5945 * The extension is installed normally (for example, from the marketplace
5946 * or VSIX) in VS Code.
5947 */
5948 Production = 1,
5949
5950 /**
5951 * The extension is running from an `--extensionDevelopmentPath` provided
5952 * when launching VS Code.
5953 */
5954 Development = 2,
5955
5956 /**
5957 * The extension is running from an `--extensionTestsPath` and
5958 * the extension host is running unit tests.
5959 */
5960 Test = 3,
5961 }
5962
5963 /**
5964 * An extension context is a collection of utilities private to an
5965 * extension.
5966 *
5967 * An instance of an `ExtensionContext` is provided as the first
5968 * parameter to the `activate`-call of an extension.
5969 */
5970 export interface ExtensionContext {
5971
5972 /**
5973 * An array to which disposables can be added. When this
5974 * extension is deactivated the disposables will be disposed.
5975 */
5976 readonly subscriptions: { dispose(): any }[];
5977
5978 /**
5979 * A memento object that stores state in the context
5980 * of the currently opened [workspace](#workspace.workspaceFolders).
5981 */
5982 readonly workspaceState: Memento;
5983
5984 /**
5985 * A memento object that stores state independent
5986 * of the current opened [workspace](#workspace.workspaceFolders).
5987 */
5988 readonly globalState: Memento & {
5989 /**
5990 * Set the keys whose values should be synchronized across devices when synchronizing user-data
5991 * like configuration, extensions, and mementos.
5992 *
5993 * Note that this function defines the whole set of keys whose values are synchronized:
5994 * - calling it with an empty array stops synchronization for this memento
5995 * - calling it with a non-empty array replaces all keys whose values are synchronized
5996 *
5997 * For any given set of keys this function needs to be called only once but there is no harm in
5998 * repeatedly calling it.
5999 *
6000 * @param keys The set of keys whose values are synced.
6001 */
6002 setKeysForSync(keys: string[]): void;
6003 };
6004
6005 /**
6006 * A storage utility for secrets.
6007 */
6008 readonly secrets: SecretStorage;
6009
6010 /**
6011 * The uri of the directory containing the extension.
6012 */
6013 readonly extensionUri: Uri;
6014
6015 /**
6016 * The absolute file path of the directory containing the extension. Shorthand
6017 * notation for [ExtensionContext.extensionUri.fsPath](#TextDocument.uri) (independent of the uri scheme).
6018 */
6019 readonly extensionPath: string;
6020
6021 /**
6022 * Gets the extension's environment variable collection for this workspace, enabling changes
6023 * to be applied to terminal environment variables.
6024 */
6025 readonly environmentVariableCollection: EnvironmentVariableCollection;
6026
6027 /**
6028 * Get the absolute path of a resource contained in the extension.
6029 *
6030 * *Note* that an absolute uri can be constructed via [`Uri.joinPath`](#Uri.joinPath) and
6031 * [`extensionUri`](#ExtensionContext.extensionUri), e.g. `vscode.Uri.joinPath(context.extensionUri, relativePath);`
6032 *
6033 * @param relativePath A relative path to a resource contained in the extension.
6034 * @return The absolute path of the resource.
6035 */
6036 asAbsolutePath(relativePath: string): string;
6037
6038 /**
6039 * The uri of a workspace specific directory in which the extension
6040 * can store private state. The directory might not exist and creation is
6041 * up to the extension. However, the parent directory is guaranteed to be existent.
6042 * The value is `undefined` when no workspace nor folder has been opened.
6043 *
6044 * Use [`workspaceState`](#ExtensionContext.workspaceState) or
6045 * [`globalState`](#ExtensionContext.globalState) to store key value data.
6046 *
6047 * @see [`workspace.fs`](#FileSystem) for how to read and write files and folders from
6048 * an uri.
6049 */
6050 readonly storageUri: Uri | undefined;
6051
6052 /**
6053 * An absolute file path of a workspace specific directory in which the extension
6054 * can store private state. The directory might not exist on disk and creation is
6055 * up to the extension. However, the parent directory is guaranteed to be existent.
6056 *
6057 * Use [`workspaceState`](#ExtensionContext.workspaceState) or
6058 * [`globalState`](#ExtensionContext.globalState) to store key value data.
6059 *
6060 * @deprecated Use [storageUri](#ExtensionContext.storageUri) instead.
6061 */
6062 readonly storagePath: string | undefined;
6063
6064 /**
6065 * The uri of a directory in which the extension can store global state.
6066 * The directory might not exist on disk and creation is
6067 * up to the extension. However, the parent directory is guaranteed to be existent.
6068 *
6069 * Use [`globalState`](#ExtensionContext.globalState) to store key value data.
6070 *
6071 * @see [`workspace.fs`](#FileSystem) for how to read and write files and folders from
6072 * an uri.
6073 */
6074 readonly globalStorageUri: Uri;
6075
6076 /**
6077 * An absolute file path in which the extension can store global state.
6078 * The directory might not exist on disk and creation is
6079 * up to the extension. However, the parent directory is guaranteed to be existent.
6080 *
6081 * Use [`globalState`](#ExtensionContext.globalState) to store key value data.
6082 *
6083 * @deprecated Use [globalStorageUri](#ExtensionContext.globalStorageUri) instead.
6084 */
6085 readonly globalStoragePath: string;
6086
6087 /**
6088 * The uri of a directory in which the extension can create log files.
6089 * The directory might not exist on disk and creation is up to the extension. However,
6090 * the parent directory is guaranteed to be existent.
6091 *
6092 * @see [`workspace.fs`](#FileSystem) for how to read and write files and folders from
6093 * an uri.
6094 */
6095 readonly logUri: Uri;
6096
6097 /**
6098 * An absolute file path of a directory in which the extension can create log files.
6099 * The directory might not exist on disk and creation is up to the extension. However,
6100 * the parent directory is guaranteed to be existent.
6101 *
6102 * @deprecated Use [logUri](#ExtensionContext.logUri) instead.
6103 */
6104 readonly logPath: string;
6105
6106 /**
6107 * The mode the extension is running in. This is specific to the current
6108 * extension. One extension may be in `ExtensionMode.Development` while
6109 * other extensions in the host run in `ExtensionMode.Release`.
6110 */
6111 readonly extensionMode: ExtensionMode;
6112
6113 /**
6114 * The current `Extension` instance.
6115 */
6116 readonly extension: Extension<any>;
6117 }
6118
6119 /**
6120 * A memento represents a storage utility. It can store and retrieve
6121 * values.
6122 */
6123 export interface Memento {
6124
6125 /**
6126 * Return a value.
6127 *
6128 * @param key A string.
6129 * @return The stored value or `undefined`.
6130 */
6131 get<T>(key: string): T | undefined;
6132
6133 /**
6134 * Return a value.
6135 *
6136 * @param key A string.
6137 * @param defaultValue A value that should be returned when there is no
6138 * value (`undefined`) with the given key.
6139 * @return The stored value or the defaultValue.
6140 */
6141 get<T>(key: string, defaultValue: T): T;
6142
6143 /**
6144 * Store a value. The value must be JSON-stringifyable.
6145 *
6146 * @param key A string.
6147 * @param value A value. MUST not contain cyclic references.
6148 */
6149 update(key: string, value: any): Thenable<void>;
6150 }
6151
6152 /**
6153 * The event data that is fired when a secret is added or removed.
6154 */
6155 export interface SecretStorageChangeEvent {
6156 /**
6157 * The key of the secret that has changed.
6158 */
6159 readonly key: string;
6160 }
6161
6162 /**
6163 * Represents a storage utility for secrets, information that is
6164 * sensitive.
6165 */
6166 export interface SecretStorage {
6167 /**
6168 * Retrieve a secret that was stored with key. Returns undefined if there
6169 * is no password matching that key.
6170 * @param key The key the secret was stored under.
6171 * @returns The stored value or `undefined`.
6172 */
6173 get(key: string): Thenable<string | undefined>;
6174
6175 /**
6176 * Store a secret under a given key.
6177 * @param key The key to store the secret under.
6178 * @param value The secret.
6179 */
6180 store(key: string, value: string): Thenable<void>;
6181
6182 /**
6183 * Remove a secret from storage.
6184 * @param key The key the secret was stored under.
6185 */
6186 delete(key: string): Thenable<void>;
6187
6188 /**
6189 * Fires when a secret is stored or deleted.
6190 */
6191 onDidChange: Event<SecretStorageChangeEvent>;
6192 }
6193
6194 /**
6195 * Represents a color theme kind.
6196 */
6197 export enum ColorThemeKind {
6198 Light = 1,
6199 Dark = 2,
6200 HighContrast = 3
6201 }
6202
6203 /**
6204 * Represents a color theme.
6205 */
6206 export interface ColorTheme {
6207
6208 /**
6209 * The kind of this color theme: light, dark or high contrast.
6210 */
6211 readonly kind: ColorThemeKind;
6212 }
6213
6214 /**
6215 * Controls the behaviour of the terminal's visibility.
6216 */
6217 export enum TaskRevealKind {
6218 /**
6219 * Always brings the terminal to front if the task is executed.
6220 */
6221 Always = 1,
6222
6223 /**
6224 * Only brings the terminal to front if a problem is detected executing the task
6225 * (e.g. the task couldn't be started because).
6226 */
6227 Silent = 2,
6228
6229 /**
6230 * The terminal never comes to front when the task is executed.
6231 */
6232 Never = 3
6233 }
6234
6235 /**
6236 * Controls how the task channel is used between tasks
6237 */
6238 export enum TaskPanelKind {
6239
6240 /**
6241 * Shares a panel with other tasks. This is the default.
6242 */
6243 Shared = 1,
6244
6245 /**
6246 * Uses a dedicated panel for this tasks. The panel is not
6247 * shared with other tasks.
6248 */
6249 Dedicated = 2,
6250
6251 /**
6252 * Creates a new panel whenever this task is executed.
6253 */
6254 New = 3
6255 }
6256
6257 /**
6258 * Controls how the task is presented in the UI.
6259 */
6260 export interface TaskPresentationOptions {
6261 /**
6262 * Controls whether the task output is reveal in the user interface.
6263 * Defaults to `RevealKind.Always`.
6264 */
6265 reveal?: TaskRevealKind;
6266
6267 /**
6268 * Controls whether the command associated with the task is echoed
6269 * in the user interface.
6270 */
6271 echo?: boolean;
6272
6273 /**
6274 * Controls whether the panel showing the task output is taking focus.
6275 */
6276 focus?: boolean;
6277
6278 /**
6279 * Controls if the task panel is used for this task only (dedicated),
6280 * shared between tasks (shared) or if a new panel is created on
6281 * every task execution (new). Defaults to `TaskInstanceKind.Shared`
6282 */
6283 panel?: TaskPanelKind;
6284
6285 /**
6286 * Controls whether to show the "Terminal will be reused by tasks, press any key to close it" message.
6287 */
6288 showReuseMessage?: boolean;
6289
6290 /**
6291 * Controls whether the terminal is cleared before executing the task.
6292 */
6293 clear?: boolean;
6294 }
6295
6296 /**
6297 * A grouping for tasks. The editor by default supports the
6298 * 'Clean', 'Build', 'RebuildAll' and 'Test' group.
6299 */
6300 export class TaskGroup {
6301
6302 /**
6303 * The clean task group;
6304 */
6305 static Clean: TaskGroup;
6306
6307 /**
6308 * The build task group;
6309 */
6310 static Build: TaskGroup;
6311
6312 /**
6313 * The rebuild all task group;
6314 */
6315 static Rebuild: TaskGroup;
6316
6317 /**
6318 * The test all task group;
6319 */
6320 static Test: TaskGroup;
6321
6322 private constructor(id: string, label: string);
6323 }
6324
6325 /**
6326 * A structure that defines a task kind in the system.
6327 * The value must be JSON-stringifyable.
6328 */
6329 export interface TaskDefinition {
6330 /**
6331 * The task definition describing the task provided by an extension.
6332 * Usually a task provider defines more properties to identify
6333 * a task. They need to be defined in the package.json of the
6334 * extension under the 'taskDefinitions' extension point. The npm
6335 * task definition for example looks like this
6336 * ```typescript
6337 * interface NpmTaskDefinition extends TaskDefinition {
6338 * script: string;
6339 * }
6340 * ```
6341 *
6342 * Note that type identifier starting with a '$' are reserved for internal
6343 * usages and shouldn't be used by extensions.
6344 */
6345 readonly type: string;
6346
6347 /**
6348 * Additional attributes of a concrete task definition.
6349 */
6350 [name: string]: any;
6351 }
6352
6353 /**
6354 * Options for a process execution
6355 */
6356 export interface ProcessExecutionOptions {
6357 /**
6358 * The current working directory of the executed program or shell.
6359 * If omitted the tools current workspace root is used.
6360 */
6361 cwd?: string;
6362
6363 /**
6364 * The additional environment of the executed program or shell. If omitted
6365 * the parent process' environment is used. If provided it is merged with
6366 * the parent process' environment.
6367 */
6368 env?: { [key: string]: string };
6369 }
6370
6371 /**
6372 * The execution of a task happens as an external process
6373 * without shell interaction.
6374 */
6375 export class ProcessExecution {
6376
6377 /**
6378 * Creates a process execution.
6379 *
6380 * @param process The process to start.
6381 * @param options Optional options for the started process.
6382 */
6383 constructor(process: string, options?: ProcessExecutionOptions);
6384
6385 /**
6386 * Creates a process execution.
6387 *
6388 * @param process The process to start.
6389 * @param args Arguments to be passed to the process.
6390 * @param options Optional options for the started process.
6391 */
6392 constructor(process: string, args: string[], options?: ProcessExecutionOptions);
6393
6394 /**
6395 * The process to be executed.
6396 */
6397 process: string;
6398
6399 /**
6400 * The arguments passed to the process. Defaults to an empty array.
6401 */
6402 args: string[];
6403
6404 /**
6405 * The process options used when the process is executed.
6406 * Defaults to undefined.
6407 */
6408 options?: ProcessExecutionOptions;
6409 }
6410
6411 /**
6412 * The shell quoting options.
6413 */
6414 export interface ShellQuotingOptions {
6415
6416 /**
6417 * The character used to do character escaping. If a string is provided only spaces
6418 * are escaped. If a `{ escapeChar, charsToEscape }` literal is provide all characters
6419 * in `charsToEscape` are escaped using the `escapeChar`.
6420 */
6421 escape?: string | {
6422 /**
6423 * The escape character.
6424 */
6425 escapeChar: string;
6426 /**
6427 * The characters to escape.
6428 */
6429 charsToEscape: string;
6430 };
6431
6432 /**
6433 * The character used for strong quoting. The string's length must be 1.
6434 */
6435 strong?: string;
6436
6437 /**
6438 * The character used for weak quoting. The string's length must be 1.
6439 */
6440 weak?: string;
6441 }
6442
6443 /**
6444 * Options for a shell execution
6445 */
6446 export interface ShellExecutionOptions {
6447 /**
6448 * The shell executable.
6449 */
6450 executable?: string;
6451
6452 /**
6453 * The arguments to be passed to the shell executable used to run the task. Most shells
6454 * require special arguments to execute a command. For example `bash` requires the `-c`
6455 * argument to execute a command, `PowerShell` requires `-Command` and `cmd` requires both
6456 * `/d` and `/c`.
6457 */
6458 shellArgs?: string[];
6459
6460 /**
6461 * The shell quotes supported by this shell.
6462 */
6463 shellQuoting?: ShellQuotingOptions;
6464
6465 /**
6466 * The current working directory of the executed shell.
6467 * If omitted the tools current workspace root is used.
6468 */
6469 cwd?: string;
6470
6471 /**
6472 * The additional environment of the executed shell. If omitted
6473 * the parent process' environment is used. If provided it is merged with
6474 * the parent process' environment.
6475 */
6476 env?: { [key: string]: string };
6477 }
6478
6479 /**
6480 * Defines how an argument should be quoted if it contains
6481 * spaces or unsupported characters.
6482 */
6483 export enum ShellQuoting {
6484
6485 /**
6486 * Character escaping should be used. This for example
6487 * uses \ on bash and ` on PowerShell.
6488 */
6489 Escape = 1,
6490
6491 /**
6492 * Strong string quoting should be used. This for example
6493 * uses " for Windows cmd and ' for bash and PowerShell.
6494 * Strong quoting treats arguments as literal strings.
6495 * Under PowerShell echo 'The value is $(2 * 3)' will
6496 * print `The value is $(2 * 3)`
6497 */
6498 Strong = 2,
6499
6500 /**
6501 * Weak string quoting should be used. This for example
6502 * uses " for Windows cmd, bash and PowerShell. Weak quoting
6503 * still performs some kind of evaluation inside the quoted
6504 * string. Under PowerShell echo "The value is $(2 * 3)"
6505 * will print `The value is 6`
6506 */
6507 Weak = 3
6508 }
6509
6510 /**
6511 * A string that will be quoted depending on the used shell.
6512 */
6513 export interface ShellQuotedString {
6514 /**
6515 * The actual string value.
6516 */
6517 value: string;
6518
6519 /**
6520 * The quoting style to use.
6521 */
6522 quoting: ShellQuoting;
6523 }
6524
6525 export class ShellExecution {
6526 /**
6527 * Creates a shell execution with a full command line.
6528 *
6529 * @param commandLine The command line to execute.
6530 * @param options Optional options for the started the shell.
6531 */
6532 constructor(commandLine: string, options?: ShellExecutionOptions);
6533
6534 /**
6535 * Creates a shell execution with a command and arguments. For the real execution VS Code will
6536 * construct a command line from the command and the arguments. This is subject to interpretation
6537 * especially when it comes to quoting. If full control over the command line is needed please
6538 * use the constructor that creates a `ShellExecution` with the full command line.
6539 *
6540 * @param command The command to execute.
6541 * @param args The command arguments.
6542 * @param options Optional options for the started the shell.
6543 */
6544 constructor(command: string | ShellQuotedString, args: (string | ShellQuotedString)[], options?: ShellExecutionOptions);
6545
6546 /**
6547 * The shell command line. Is `undefined` if created with a command and arguments.
6548 */
6549 commandLine: string | undefined;
6550
6551 /**
6552 * The shell command. Is `undefined` if created with a full command line.
6553 */
6554 command: string | ShellQuotedString;
6555
6556 /**
6557 * The shell args. Is `undefined` if created with a full command line.
6558 */
6559 args: (string | ShellQuotedString)[];
6560
6561 /**
6562 * The shell options used when the command line is executed in a shell.
6563 * Defaults to undefined.
6564 */
6565 options?: ShellExecutionOptions;
6566 }
6567
6568 /**
6569 * Class used to execute an extension callback as a task.
6570 */
6571 export class CustomExecution {
6572 /**
6573 * Constructs a CustomExecution task object. The callback will be executed when the task is run, at which point the
6574 * extension should return the Pseudoterminal it will "run in". The task should wait to do further execution until
6575 * [Pseudoterminal.open](#Pseudoterminal.open) is called. Task cancellation should be handled using
6576 * [Pseudoterminal.close](#Pseudoterminal.close). When the task is complete fire
6577 * [Pseudoterminal.onDidClose](#Pseudoterminal.onDidClose).
6578 * @param callback The callback that will be called when the task is started by a user. Any ${} style variables that
6579 * were in the task definition will be resolved and passed into the callback as `resolvedDefinition`.
6580 */
6581 constructor(callback: (resolvedDefinition: TaskDefinition) => Thenable<Pseudoterminal>);
6582 }
6583
6584 /**
6585 * The scope of a task.
6586 */
6587 export enum TaskScope {
6588 /**
6589 * The task is a global task. Global tasks are currently not supported.
6590 */
6591 Global = 1,
6592
6593 /**
6594 * The task is a workspace task
6595 */
6596 Workspace = 2
6597 }
6598
6599 /**
6600 * Run options for a task.
6601 */
6602 export interface RunOptions {
6603 /**
6604 * Controls whether task variables are re-evaluated on rerun.
6605 */
6606 reevaluateOnRerun?: boolean;
6607 }
6608
6609 /**
6610 * A task to execute
6611 */
6612 export class Task {
6613
6614 /**
6615 * Creates a new task.
6616 *
6617 * @param definition The task definition as defined in the taskDefinitions extension point.
6618 * @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.
6619 * @param name The task's name. Is presented in the user interface.
6620 * @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
6621 * @param execution The process or shell execution.
6622 * @param problemMatchers the names of problem matchers to use, like '$tsc'
6623 * or '$eslint'. Problem matchers can be contributed by an extension using
6624 * the `problemMatchers` extension point.
6625 */
6626 constructor(taskDefinition: TaskDefinition, scope: WorkspaceFolder | TaskScope.Global | TaskScope.Workspace, name: string, source: string, execution?: ProcessExecution | ShellExecution | CustomExecution, problemMatchers?: string | string[]);
6627
6628 /**
6629 * Creates a new task.
6630 *
6631 * @deprecated Use the new constructors that allow specifying a scope for the task.
6632 *
6633 * @param definition The task definition as defined in the taskDefinitions extension point.
6634 * @param name The task's name. Is presented in the user interface.
6635 * @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
6636 * @param execution The process or shell execution.
6637 * @param problemMatchers the names of problem matchers to use, like '$tsc'
6638 * or '$eslint'. Problem matchers can be contributed by an extension using
6639 * the `problemMatchers` extension point.
6640 */
6641 constructor(taskDefinition: TaskDefinition, name: string, source: string, execution?: ProcessExecution | ShellExecution, problemMatchers?: string | string[]);
6642
6643 /**
6644 * The task's definition.
6645 */
6646 definition: TaskDefinition;
6647
6648 /**
6649 * The task's scope.
6650 */
6651 readonly scope?: TaskScope.Global | TaskScope.Workspace | WorkspaceFolder;
6652
6653 /**
6654 * The task's name
6655 */
6656 name: string;
6657
6658 /**
6659 * A human-readable string which is rendered less prominently on a separate line in places
6660 * where the task's name is displayed. Supports rendering of [theme icons](#ThemeIcon)
6661 * via the `$(<name>)`-syntax.
6662 */
6663 detail?: string;
6664
6665 /**
6666 * The task's execution engine
6667 */
6668 execution?: ProcessExecution | ShellExecution | CustomExecution;
6669
6670 /**
6671 * Whether the task is a background task or not.
6672 */
6673 isBackground: boolean;
6674
6675 /**
6676 * A human-readable string describing the source of this shell task, e.g. 'gulp'
6677 * or 'npm'. Supports rendering of [theme icons](#ThemeIcon) via the `$(<name>)`-syntax.
6678 */
6679 source: string;
6680
6681 /**
6682 * The task group this tasks belongs to. See TaskGroup
6683 * for a predefined set of available groups.
6684 * Defaults to undefined meaning that the task doesn't
6685 * belong to any special group.
6686 */
6687 group?: TaskGroup;
6688
6689 /**
6690 * The presentation options. Defaults to an empty literal.
6691 */
6692 presentationOptions: TaskPresentationOptions;
6693
6694 /**
6695 * The problem matchers attached to the task. Defaults to an empty
6696 * array.
6697 */
6698 problemMatchers: string[];
6699
6700 /**
6701 * Run options for the task
6702 */
6703 runOptions: RunOptions;
6704 }
6705
6706 /**
6707 * A task provider allows to add tasks to the task service.
6708 * A task provider is registered via #tasks.registerTaskProvider.
6709 */
6710 export interface TaskProvider<T extends Task = Task> {
6711 /**
6712 * Provides tasks.
6713 * @param token A cancellation token.
6714 * @return an array of tasks
6715 */
6716 provideTasks(token: CancellationToken): ProviderResult<T[]>;
6717
6718 /**
6719 * Resolves a task that has no [`execution`](#Task.execution) set. Tasks are
6720 * often created from information found in the `tasks.json`-file. Such tasks miss
6721 * the information on how to execute them and a task provider must fill in
6722 * the missing information in the `resolveTask`-method. This method will not be
6723 * called for tasks returned from the above `provideTasks` method since those
6724 * tasks are always fully resolved. A valid default implementation for the
6725 * `resolveTask` method is to return `undefined`.
6726 *
6727 * Note that when filling in the properties of `task`, you _must_ be sure to
6728 * use the exact same `TaskDefinition` and not create a new one. Other properties
6729 * may be changed.
6730 *
6731 * @param task The task to resolve.
6732 * @param token A cancellation token.
6733 * @return The resolved task
6734 */
6735 resolveTask(task: T, token: CancellationToken): ProviderResult<T>;
6736 }
6737
6738 /**
6739 * An object representing an executed Task. It can be used
6740 * to terminate a task.
6741 *
6742 * This interface is not intended to be implemented.
6743 */
6744 export interface TaskExecution {
6745 /**
6746 * The task that got started.
6747 */
6748 task: Task;
6749
6750 /**
6751 * Terminates the task execution.
6752 */
6753 terminate(): void;
6754 }
6755
6756 /**
6757 * An event signaling the start of a task execution.
6758 *
6759 * This interface is not intended to be implemented.
6760 */
6761 interface TaskStartEvent {
6762 /**
6763 * The task item representing the task that got started.
6764 */
6765 readonly execution: TaskExecution;
6766 }
6767
6768 /**
6769 * An event signaling the end of an executed task.
6770 *
6771 * This interface is not intended to be implemented.
6772 */
6773 interface TaskEndEvent {
6774 /**
6775 * The task item representing the task that finished.
6776 */
6777 readonly execution: TaskExecution;
6778 }
6779
6780 /**
6781 * An event signaling the start of a process execution
6782 * triggered through a task
6783 */
6784 export interface TaskProcessStartEvent {
6785
6786 /**
6787 * The task execution for which the process got started.
6788 */
6789 readonly execution: TaskExecution;
6790
6791 /**
6792 * The underlying process id.
6793 */
6794 readonly processId: number;
6795 }
6796
6797 /**
6798 * An event signaling the end of a process execution
6799 * triggered through a task
6800 */
6801 export interface TaskProcessEndEvent {
6802
6803 /**
6804 * The task execution for which the process got started.
6805 */
6806 readonly execution: TaskExecution;
6807
6808 /**
6809 * The process's exit code. Will be `undefined` when the task is terminated.
6810 */
6811 readonly exitCode: number | undefined;
6812 }
6813
6814 export interface TaskFilter {
6815 /**
6816 * The task version as used in the tasks.json file.
6817 * The string support the package.json semver notation.
6818 */
6819 version?: string;
6820
6821 /**
6822 * The task type to return;
6823 */
6824 type?: string;
6825 }
6826
6827 /**
6828 * Namespace for tasks functionality.
6829 */
6830 export namespace tasks {
6831
6832 /**
6833 * Register a task provider.
6834 *
6835 * @param type The task kind type this provider is registered for.
6836 * @param provider A task provider.
6837 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
6838 */
6839 export function registerTaskProvider(type: string, provider: TaskProvider): Disposable;
6840
6841 /**
6842 * Fetches all tasks available in the systems. This includes tasks
6843 * from `tasks.json` files as well as tasks from task providers
6844 * contributed through extensions.
6845 *
6846 * @param filter Optional filter to select tasks of a certain type or version.
6847 */
6848 export function fetchTasks(filter?: TaskFilter): Thenable<Task[]>;
6849
6850 /**
6851 * Executes a task that is managed by VS Code. The returned
6852 * task execution can be used to terminate the task.
6853 *
6854 * @throws When running a ShellExecution or a ProcessExecution
6855 * task in an environment where a new process cannot be started.
6856 * In such an environment, only CustomExecution tasks can be run.
6857 *
6858 * @param task the task to execute
6859 */
6860 export function executeTask(task: Task): Thenable<TaskExecution>;
6861
6862 /**
6863 * The currently active task executions or an empty array.
6864 */
6865 export const taskExecutions: ReadonlyArray<TaskExecution>;
6866
6867 /**
6868 * Fires when a task starts.
6869 */
6870 export const onDidStartTask: Event<TaskStartEvent>;
6871
6872 /**
6873 * Fires when a task ends.
6874 */
6875 export const onDidEndTask: Event<TaskEndEvent>;
6876
6877 /**
6878 * Fires when the underlying process has been started.
6879 * This event will not fire for tasks that don't
6880 * execute an underlying process.
6881 */
6882 export const onDidStartTaskProcess: Event<TaskProcessStartEvent>;
6883
6884 /**
6885 * Fires when the underlying process has ended.
6886 * This event will not fire for tasks that don't
6887 * execute an underlying process.
6888 */
6889 export const onDidEndTaskProcess: Event<TaskProcessEndEvent>;
6890 }
6891
6892 /**
6893 * Enumeration of file types. The types `File` and `Directory` can also be
6894 * a symbolic links, in that case use `FileType.File | FileType.SymbolicLink` and
6895 * `FileType.Directory | FileType.SymbolicLink`.
6896 */
6897 export enum FileType {
6898 /**
6899 * The file type is unknown.
6900 */
6901 Unknown = 0,
6902 /**
6903 * A regular file.
6904 */
6905 File = 1,
6906 /**
6907 * A directory.
6908 */
6909 Directory = 2,
6910 /**
6911 * A symbolic link to a file.
6912 */
6913 SymbolicLink = 64
6914 }
6915
6916 /**
6917 * The `FileStat`-type represents metadata about a file
6918 */
6919 export interface FileStat {
6920 /**
6921 * The type of the file, e.g. is a regular file, a directory, or symbolic link
6922 * to a file.
6923 *
6924 * *Note:* This value might be a bitmask, e.g. `FileType.File | FileType.SymbolicLink`.
6925 */
6926 type: FileType;
6927 /**
6928 * The creation timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
6929 */
6930 ctime: number;
6931 /**
6932 * The modification timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
6933 *
6934 * *Note:* If the file changed, it is important to provide an updated `mtime` that advanced
6935 * from the previous value. Otherwise there may be optimizations in place that will not show
6936 * the updated file contents in an editor for example.
6937 */
6938 mtime: number;
6939 /**
6940 * The size in bytes.
6941 *
6942 * *Note:* If the file changed, it is important to provide an updated `size`. Otherwise there
6943 * may be optimizations in place that will not show the updated file contents in an editor for
6944 * example.
6945 */
6946 size: number;
6947 }
6948
6949 /**
6950 * A type that filesystem providers should use to signal errors.
6951 *
6952 * This class has factory methods for common error-cases, like `FileNotFound` when
6953 * a file or folder doesn't exist, use them like so: `throw vscode.FileSystemError.FileNotFound(someUri);`
6954 */
6955 export class FileSystemError extends Error {
6956
6957 /**
6958 * Create an error to signal that a file or folder wasn't found.
6959 * @param messageOrUri Message or uri.
6960 */
6961 static FileNotFound(messageOrUri?: string | Uri): FileSystemError;
6962
6963 /**
6964 * Create an error to signal that a file or folder already exists, e.g. when
6965 * creating but not overwriting a file.
6966 * @param messageOrUri Message or uri.
6967 */
6968 static FileExists(messageOrUri?: string | Uri): FileSystemError;
6969
6970 /**
6971 * Create an error to signal that a file is not a folder.
6972 * @param messageOrUri Message or uri.
6973 */
6974 static FileNotADirectory(messageOrUri?: string | Uri): FileSystemError;
6975
6976 /**
6977 * Create an error to signal that a file is a folder.
6978 * @param messageOrUri Message or uri.
6979 */
6980 static FileIsADirectory(messageOrUri?: string | Uri): FileSystemError;
6981
6982 /**
6983 * Create an error to signal that an operation lacks required permissions.
6984 * @param messageOrUri Message or uri.
6985 */
6986 static NoPermissions(messageOrUri?: string | Uri): FileSystemError;
6987
6988 /**
6989 * Create an error to signal that the file system is unavailable or too busy to
6990 * complete a request.
6991 * @param messageOrUri Message or uri.
6992 */
6993 static Unavailable(messageOrUri?: string | Uri): FileSystemError;
6994
6995 /**
6996 * Creates a new filesystem error.
6997 *
6998 * @param messageOrUri Message or uri.
6999 */
7000 constructor(messageOrUri?: string | Uri);
7001
7002 /**
7003 * A code that identifies this error.
7004 *
7005 * Possible values are names of errors, like [`FileNotFound`](#FileSystemError.FileNotFound),
7006 * or `Unknown` for unspecified errors.
7007 */
7008 readonly code: string;
7009 }
7010
7011 /**
7012 * Enumeration of file change types.
7013 */
7014 export enum FileChangeType {
7015
7016 /**
7017 * The contents or metadata of a file have changed.
7018 */
7019 Changed = 1,
7020
7021 /**
7022 * A file has been created.
7023 */
7024 Created = 2,
7025
7026 /**
7027 * A file has been deleted.
7028 */
7029 Deleted = 3,
7030 }
7031
7032 /**
7033 * The event filesystem providers must use to signal a file change.
7034 */
7035 export interface FileChangeEvent {
7036
7037 /**
7038 * The type of change.
7039 */
7040 readonly type: FileChangeType;
7041
7042 /**
7043 * The uri of the file that has changed.
7044 */
7045 readonly uri: Uri;
7046 }
7047
7048 /**
7049 * The filesystem provider defines what the editor needs to read, write, discover,
7050 * and to manage files and folders. It allows extensions to serve files from remote places,
7051 * like ftp-servers, and to seamlessly integrate those into the editor.
7052 *
7053 * * *Note 1:* The filesystem provider API works with [uris](#Uri) and assumes hierarchical
7054 * paths, e.g. `foo:/my/path` is a child of `foo:/my/` and a parent of `foo:/my/path/deeper`.
7055 * * *Note 2:* There is an activation event `onFileSystem:<scheme>` that fires when a file
7056 * or folder is being accessed.
7057 * * *Note 3:* The word 'file' is often used to denote all [kinds](#FileType) of files, e.g.
7058 * folders, symbolic links, and regular files.
7059 */
7060 export interface FileSystemProvider {
7061
7062 /**
7063 * An event to signal that a resource has been created, changed, or deleted. This
7064 * event should fire for resources that are being [watched](#FileSystemProvider.watch)
7065 * by clients of this provider.
7066 *
7067 * *Note:* It is important that the metadata of the file that changed provides an
7068 * updated `mtime` that advanced from the previous value in the [stat](#FileStat) and a
7069 * correct `size` value. Otherwise there may be optimizations in place that will not show
7070 * the change in an editor for example.
7071 */
7072 readonly onDidChangeFile: Event<FileChangeEvent[]>;
7073
7074 /**
7075 * Subscribe to events in the file or folder denoted by `uri`.
7076 *
7077 * The editor will call this function for files and folders. In the latter case, the
7078 * options differ from defaults, e.g. what files/folders to exclude from watching
7079 * and if subfolders, sub-subfolder, etc. should be watched (`recursive`).
7080 *
7081 * @param uri The uri of the file to be watched.
7082 * @param options Configures the watch.
7083 * @returns A disposable that tells the provider to stop watching the `uri`.
7084 */
7085 watch(uri: Uri, options: { recursive: boolean; excludes: string[] }): Disposable;
7086
7087 /**
7088 * Retrieve metadata about a file.
7089 *
7090 * Note that the metadata for symbolic links should be the metadata of the file they refer to.
7091 * Still, the [SymbolicLink](#FileType.SymbolicLink)-type must be used in addition to the actual type, e.g.
7092 * `FileType.SymbolicLink | FileType.Directory`.
7093 *
7094 * @param uri The uri of the file to retrieve metadata about.
7095 * @return The file metadata about the file.
7096 * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `uri` doesn't exist.
7097 */
7098 stat(uri: Uri): FileStat | Thenable<FileStat>;
7099
7100 /**
7101 * Retrieve all entries of a [directory](#FileType.Directory).
7102 *
7103 * @param uri The uri of the folder.
7104 * @return An array of name/type-tuples or a thenable that resolves to such.
7105 * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `uri` doesn't exist.
7106 */
7107 readDirectory(uri: Uri): [string, FileType][] | Thenable<[string, FileType][]>;
7108
7109 /**
7110 * Create a new directory (Note, that new files are created via `write`-calls).
7111 *
7112 * @param uri The uri of the new folder.
7113 * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when the parent of `uri` doesn't exist, e.g. no mkdirp-logic required.
7114 * @throws [`FileExists`](#FileSystemError.FileExists) when `uri` already exists.
7115 * @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient.
7116 */
7117 createDirectory(uri: Uri): void | Thenable<void>;
7118
7119 /**
7120 * Read the entire contents of a file.
7121 *
7122 * @param uri The uri of the file.
7123 * @return An array of bytes or a thenable that resolves to such.
7124 * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `uri` doesn't exist.
7125 */
7126 readFile(uri: Uri): Uint8Array | Thenable<Uint8Array>;
7127
7128 /**
7129 * Write data to a file, replacing its entire contents.
7130 *
7131 * @param uri The uri of the file.
7132 * @param content The new content of the file.
7133 * @param options Defines if missing files should or must be created.
7134 * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `uri` doesn't exist and `create` is not set.
7135 * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when the parent of `uri` doesn't exist and `create` is set, e.g. no mkdirp-logic required.
7136 * @throws [`FileExists`](#FileSystemError.FileExists) when `uri` already exists, `create` is set but `overwrite` is not set.
7137 * @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient.
7138 */
7139 writeFile(uri: Uri, content: Uint8Array, options: { create: boolean, overwrite: boolean }): void | Thenable<void>;
7140
7141 /**
7142 * Delete a file.
7143 *
7144 * @param uri The resource that is to be deleted.
7145 * @param options Defines if deletion of folders is recursive.
7146 * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `uri` doesn't exist.
7147 * @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient.
7148 */
7149 delete(uri: Uri, options: { recursive: boolean }): void | Thenable<void>;
7150
7151 /**
7152 * Rename a file or folder.
7153 *
7154 * @param oldUri The existing file.
7155 * @param newUri The new location.
7156 * @param options Defines if existing files should be overwritten.
7157 * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `oldUri` doesn't exist.
7158 * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when parent of `newUri` doesn't exist, e.g. no mkdirp-logic required.
7159 * @throws [`FileExists`](#FileSystemError.FileExists) when `newUri` exists and when the `overwrite` option is not `true`.
7160 * @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient.
7161 */
7162 rename(oldUri: Uri, newUri: Uri, options: { overwrite: boolean }): void | Thenable<void>;
7163
7164 /**
7165 * Copy files or folders. Implementing this function is optional but it will speedup
7166 * the copy operation.
7167 *
7168 * @param source The existing file.
7169 * @param destination The destination location.
7170 * @param options Defines if existing files should be overwritten.
7171 * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when `source` doesn't exist.
7172 * @throws [`FileNotFound`](#FileSystemError.FileNotFound) when parent of `destination` doesn't exist, e.g. no mkdirp-logic required.
7173 * @throws [`FileExists`](#FileSystemError.FileExists) when `destination` exists and when the `overwrite` option is not `true`.
7174 * @throws [`NoPermissions`](#FileSystemError.NoPermissions) when permissions aren't sufficient.
7175 */
7176 copy?(source: Uri, destination: Uri, options: { overwrite: boolean }): void | Thenable<void>;
7177 }
7178
7179 /**
7180 * The file system interface exposes the editor's built-in and contributed
7181 * [file system providers](#FileSystemProvider). It allows extensions to work
7182 * with files from the local disk as well as files from remote places, like the
7183 * remote extension host or ftp-servers.
7184 *
7185 * *Note* that an instance of this interface is available as [`workspace.fs`](#workspace.fs).
7186 */
7187 export interface FileSystem {
7188
7189 /**
7190 * Retrieve metadata about a file.
7191 *
7192 * @param uri The uri of the file to retrieve metadata about.
7193 * @return The file metadata about the file.
7194 */
7195 stat(uri: Uri): Thenable<FileStat>;
7196
7197 /**
7198 * Retrieve all entries of a [directory](#FileType.Directory).
7199 *
7200 * @param uri The uri of the folder.
7201 * @return An array of name/type-tuples or a thenable that resolves to such.
7202 */
7203 readDirectory(uri: Uri): Thenable<[string, FileType][]>;
7204
7205 /**
7206 * Create a new directory (Note, that new files are created via `write`-calls).
7207 *
7208 * *Note* that missing directories are created automatically, e.g this call has
7209 * `mkdirp` semantics.
7210 *
7211 * @param uri The uri of the new folder.
7212 */
7213 createDirectory(uri: Uri): Thenable<void>;
7214
7215 /**
7216 * Read the entire contents of a file.
7217 *
7218 * @param uri The uri of the file.
7219 * @return An array of bytes or a thenable that resolves to such.
7220 */
7221 readFile(uri: Uri): Thenable<Uint8Array>;
7222
7223 /**
7224 * Write data to a file, replacing its entire contents.
7225 *
7226 * @param uri The uri of the file.
7227 * @param content The new content of the file.
7228 */
7229 writeFile(uri: Uri, content: Uint8Array): Thenable<void>;
7230
7231 /**
7232 * Delete a file.
7233 *
7234 * @param uri The resource that is to be deleted.
7235 * @param options Defines if trash can should be used and if deletion of folders is recursive
7236 */
7237 delete(uri: Uri, options?: { recursive?: boolean, useTrash?: boolean }): Thenable<void>;
7238
7239 /**
7240 * Rename a file or folder.
7241 *
7242 * @param oldUri The existing file.
7243 * @param newUri The new location.
7244 * @param options Defines if existing files should be overwritten.
7245 */
7246 rename(source: Uri, target: Uri, options?: { overwrite?: boolean }): Thenable<void>;
7247
7248 /**
7249 * Copy files or folders.
7250 *
7251 * @param source The existing file.
7252 * @param destination The destination location.
7253 * @param options Defines if existing files should be overwritten.
7254 */
7255 copy(source: Uri, target: Uri, options?: { overwrite?: boolean }): Thenable<void>;
7256
7257 /**
7258 * Check if a given file system supports writing files.
7259 *
7260 * Keep in mind that just because a file system supports writing, that does
7261 * not mean that writes will always succeed. There may be permissions issues
7262 * or other errors that prevent writing a file.
7263 *
7264 * @param scheme The scheme of the filesystem, for example `file` or `git`.
7265 *
7266 * @return `true` if the file system supports writing, `false` if it does not
7267 * support writing (i.e. it is readonly), and `undefined` if VS Code does not
7268 * know about the filesystem.
7269 */
7270 isWritableFileSystem(scheme: string): boolean | undefined;
7271 }
7272
7273 /**
7274 * Defines a port mapping used for localhost inside the webview.
7275 */
7276 export interface WebviewPortMapping {
7277 /**
7278 * Localhost port to remap inside the webview.
7279 */
7280 readonly webviewPort: number;
7281
7282 /**
7283 * Destination port. The `webviewPort` is resolved to this port.
7284 */
7285 readonly extensionHostPort: number;
7286 }
7287
7288 /**
7289 * Content settings for a webview.
7290 */
7291 export interface WebviewOptions {
7292 /**
7293 * Controls whether scripts are enabled in the webview content or not.
7294 *
7295 * Defaults to false (scripts-disabled).
7296 */
7297 readonly enableScripts?: boolean;
7298
7299 /**
7300 * Controls whether command uris are enabled in webview content or not.
7301 *
7302 * Defaults to false.
7303 */
7304 readonly enableCommandUris?: boolean;
7305
7306 /**
7307 * Root paths from which the webview can load local (filesystem) resources using uris from `asWebviewUri`
7308 *
7309 * Default to the root folders of the current workspace plus the extension's install directory.
7310 *
7311 * Pass in an empty array to disallow access to any local resources.
7312 */
7313 readonly localResourceRoots?: ReadonlyArray<Uri>;
7314
7315 /**
7316 * Mappings of localhost ports used inside the webview.
7317 *
7318 * Port mapping allow webviews to transparently define how localhost ports are resolved. This can be used
7319 * to allow using a static localhost port inside the webview that is resolved to random port that a service is
7320 * running on.
7321 *
7322 * If a webview accesses localhost content, we recommend that you specify port mappings even if
7323 * the `webviewPort` and `extensionHostPort` ports are the same.
7324 *
7325 * *Note* that port mappings only work for `http` or `https` urls. Websocket urls (e.g. `ws://localhost:3000`)
7326 * cannot be mapped to another port.
7327 */
7328 readonly portMapping?: ReadonlyArray<WebviewPortMapping>;
7329 }
7330
7331 /**
7332 * Displays html content, similarly to an iframe.
7333 */
7334 export interface Webview {
7335 /**
7336 * Content settings for the webview.
7337 */
7338 options: WebviewOptions;
7339
7340 /**
7341 * HTML contents of the webview.
7342 *
7343 * This should be a complete, valid html document. Changing this property causes the webview to be reloaded.
7344 *
7345 * Webviews are sandboxed from normal extension process, so all communication with the webview must use
7346 * message passing. To send a message from the extension to the webview, use [`postMessage`](#Webview.postMessage).
7347 * To send message from the webview back to an extension, use the `acquireVsCodeApi` function inside the webview
7348 * to get a handle to VS Code's api and then call `.postMessage()`:
7349 *
7350 * ```html
7351 * <script>
7352 * const vscode = acquireVsCodeApi(); // acquireVsCodeApi can only be invoked once
7353 * vscode.postMessage({ message: 'hello!' });
7354 * </script>
7355 * ```
7356 *
7357 * To load a resources from the workspace inside a webview, use the `[asWebviewUri](#Webview.asWebviewUri)` method
7358 * and ensure the resource's directory is listed in [`WebviewOptions.localResourceRoots`](#WebviewOptions.localResourceRoots).
7359 *
7360 * Keep in mind that even though webviews are sandboxed, they still allow running scripts and loading arbitrary content,
7361 * so extensions must follow all standard web security best practices when working with webviews. This includes
7362 * properly sanitizing all untrusted input (including content from the workspace) and
7363 * setting a [content security policy](https://aka.ms/vscode-api-webview-csp).
7364 */
7365 html: string;
7366
7367 /**
7368 * Fired when the webview content posts a message.
7369 *
7370 * Webview content can post strings or json serializable objects back to a VS Code extension. They cannot
7371 * post `Blob`, `File`, `ImageData` and other DOM specific objects since the extension that receives the
7372 * message does not run in a browser environment.
7373 */
7374 readonly onDidReceiveMessage: Event<any>;
7375
7376 /**
7377 * Post a message to the webview content.
7378 *
7379 * Messages are only delivered if the webview is live (either visible or in the
7380 * background with `retainContextWhenHidden`).
7381 *
7382 * @param message Body of the message. This must be a string or other json serializable object.
7383 */
7384 postMessage(message: any): Thenable<boolean>;
7385
7386 /**
7387 * Convert a uri for the local file system to one that can be used inside webviews.
7388 *
7389 * Webviews cannot directly load resources from the workspace or local file system using `file:` uris. The
7390 * `asWebviewUri` function takes a local `file:` uri and converts it into a uri that can be used inside of
7391 * a webview to load the same resource:
7392 *
7393 * ```ts
7394 * webview.html = `<img src="${webview.asWebviewUri(vscode.Uri.file('/Users/codey/workspace/cat.gif'))}">`
7395 * ```
7396 */
7397 asWebviewUri(localResource: Uri): Uri;
7398
7399 /**
7400 * Content security policy source for webview resources.
7401 *
7402 * This is the origin that should be used in a content security policy rule:
7403 *
7404 * ```
7405 * img-src https: ${webview.cspSource} ...;
7406 * ```
7407 */
7408 readonly cspSource: string;
7409 }
7410
7411 /**
7412 * Content settings for a webview panel.
7413 */
7414 export interface WebviewPanelOptions {
7415 /**
7416 * Controls if the find widget is enabled in the panel.
7417 *
7418 * Defaults to false.
7419 */
7420 readonly enableFindWidget?: boolean;
7421
7422 /**
7423 * Controls if the webview panel's content (iframe) is kept around even when the panel
7424 * is no longer visible.
7425 *
7426 * Normally the webview panel's html context is created when the panel becomes visible
7427 * and destroyed when it is hidden. Extensions that have complex state
7428 * or UI can set the `retainContextWhenHidden` to make VS Code keep the webview
7429 * context around, even when the webview moves to a background tab. When a webview using
7430 * `retainContextWhenHidden` becomes hidden, its scripts and other dynamic content are suspended.
7431 * When the panel becomes visible again, the context is automatically restored
7432 * in the exact same state it was in originally. You cannot send messages to a
7433 * hidden webview, even with `retainContextWhenHidden` enabled.
7434 *
7435 * `retainContextWhenHidden` has a high memory overhead and should only be used if
7436 * your panel's context cannot be quickly saved and restored.
7437 */
7438 readonly retainContextWhenHidden?: boolean;
7439 }
7440
7441 /**
7442 * A panel that contains a webview.
7443 */
7444 interface WebviewPanel {
7445 /**
7446 * Identifies the type of the webview panel, such as `'markdown.preview'`.
7447 */
7448 readonly viewType: string;
7449
7450 /**
7451 * Title of the panel shown in UI.
7452 */
7453 title: string;
7454
7455 /**
7456 * Icon for the panel shown in UI.
7457 */
7458 iconPath?: Uri | { light: Uri; dark: Uri };
7459
7460 /**
7461 * [`Webview`](#Webview) belonging to the panel.
7462 */
7463 readonly webview: Webview;
7464
7465 /**
7466 * Content settings for the webview panel.
7467 */
7468 readonly options: WebviewPanelOptions;
7469
7470 /**
7471 * Editor position of the panel. This property is only set if the webview is in
7472 * one of the editor view columns.
7473 */
7474 readonly viewColumn?: ViewColumn;
7475
7476 /**
7477 * Whether the panel is active (focused by the user).
7478 */
7479 readonly active: boolean;
7480
7481 /**
7482 * Whether the panel is visible.
7483 */
7484 readonly visible: boolean;
7485
7486 /**
7487 * Fired when the panel's view state changes.
7488 */
7489 readonly onDidChangeViewState: Event<WebviewPanelOnDidChangeViewStateEvent>;
7490
7491 /**
7492 * Fired when the panel is disposed.
7493 *
7494 * This may be because the user closed the panel or because `.dispose()` was
7495 * called on it.
7496 *
7497 * Trying to use the panel after it has been disposed throws an exception.
7498 */
7499 readonly onDidDispose: Event<void>;
7500
7501 /**
7502 * Show the webview panel in a given column.
7503 *
7504 * A webview panel may only show in a single column at a time. If it is already showing, this
7505 * method moves it to a new column.
7506 *
7507 * @param viewColumn View column to show the panel in. Shows in the current `viewColumn` if undefined.
7508 * @param preserveFocus When `true`, the webview will not take focus.
7509 */
7510 reveal(viewColumn?: ViewColumn, preserveFocus?: boolean): void;
7511
7512 /**
7513 * Dispose of the webview panel.
7514 *
7515 * This closes the panel if it showing and disposes of the resources owned by the webview.
7516 * Webview panels are also disposed when the user closes the webview panel. Both cases
7517 * fire the `onDispose` event.
7518 */
7519 dispose(): any;
7520 }
7521
7522 /**
7523 * Event fired when a webview panel's view state changes.
7524 */
7525 export interface WebviewPanelOnDidChangeViewStateEvent {
7526 /**
7527 * Webview panel whose view state changed.
7528 */
7529 readonly webviewPanel: WebviewPanel;
7530 }
7531
7532 /**
7533 * Restore webview panels that have been persisted when vscode shuts down.
7534 *
7535 * There are two types of webview persistence:
7536 *
7537 * - Persistence within a session.
7538 * - Persistence across sessions (across restarts of VS Code).
7539 *
7540 * A `WebviewPanelSerializer` is only required for the second case: persisting a webview across sessions.
7541 *
7542 * Persistence within a session allows a webview to save its state when it becomes hidden
7543 * and restore its content from this state when it becomes visible again. It is powered entirely
7544 * by the webview content itself. To save off a persisted state, call `acquireVsCodeApi().setState()` with
7545 * any json serializable object. To restore the state again, call `getState()`
7546 *
7547 * ```js
7548 * // Within the webview
7549 * const vscode = acquireVsCodeApi();
7550 *
7551 * // Get existing state
7552 * const oldState = vscode.getState() || { value: 0 };
7553 *
7554 * // Update state
7555 * setState({ value: oldState.value + 1 })
7556 * ```
7557 *
7558 * A `WebviewPanelSerializer` extends this persistence across restarts of VS Code. When the editor is shutdown,
7559 * VS Code will save off the state from `setState` of all webviews that have a serializer. When the
7560 * webview first becomes visible after the restart, this state is passed to `deserializeWebviewPanel`.
7561 * The extension can then restore the old `WebviewPanel` from this state.
7562 *
7563 * @param T Type of the webview's state.
7564 */
7565 interface WebviewPanelSerializer<T = unknown> {
7566 /**
7567 * Restore a webview panel from its serialized `state`.
7568 *
7569 * Called when a serialized webview first becomes visible.
7570 *
7571 * @param webviewPanel Webview panel to restore. The serializer should take ownership of this panel. The
7572 * serializer must restore the webview's `.html` and hook up all webview events.
7573 * @param state Persisted state from the webview content.
7574 *
7575 * @return Thenable indicating that the webview has been fully restored.
7576 */
7577 deserializeWebviewPanel(webviewPanel: WebviewPanel, state: T): Thenable<void>;
7578 }
7579
7580 /**
7581 * A webview based view.
7582 */
7583 export interface WebviewView {
7584 /**
7585 * Identifies the type of the webview view, such as `'hexEditor.dataView'`.
7586 */
7587 readonly viewType: string;
7588
7589 /**
7590 * The underlying webview for the view.
7591 */
7592 readonly webview: Webview;
7593
7594 /**
7595 * View title displayed in the UI.
7596 *
7597 * The view title is initially taken from the extension `package.json` contribution.
7598 */
7599 title?: string;
7600
7601 /**
7602 * Human-readable string which is rendered less prominently in the title.
7603 */
7604 description?: string;
7605
7606 /**
7607 * Event fired when the view is disposed.
7608 *
7609 * Views are disposed when they are explicitly hidden by a user (this happens when a user
7610 * right clicks in a view and unchecks the webview view).
7611 *
7612 * Trying to use the view after it has been disposed throws an exception.
7613 */
7614 readonly onDidDispose: Event<void>;
7615
7616 /**
7617 * Tracks if the webview is currently visible.
7618 *
7619 * Views are visible when they are on the screen and expanded.
7620 */
7621 readonly visible: boolean;
7622
7623 /**
7624 * Event fired when the visibility of the view changes.
7625 *
7626 * Actions that trigger a visibility change:
7627 *
7628 * - The view is collapsed or expanded.
7629 * - The user switches to a different view group in the sidebar or panel.
7630 *
7631 * Note that hiding a view using the context menu instead disposes of the view and fires `onDidDispose`.
7632 */
7633 readonly onDidChangeVisibility: Event<void>;
7634
7635 /**
7636 * Reveal the view in the UI.
7637 *
7638 * If the view is collapsed, this will expand it.
7639 *
7640 * @param preserveFocus When `true` the view will not take focus.
7641 */
7642 show(preserveFocus?: boolean): void;
7643 }
7644
7645 /**
7646 * Additional information the webview view being resolved.
7647 *
7648 * @param T Type of the webview's state.
7649 */
7650 interface WebviewViewResolveContext<T = unknown> {
7651 /**
7652 * Persisted state from the webview content.
7653 *
7654 * To save resources, VS Code normally deallocates webview documents (the iframe content) that are not visible.
7655 * For example, when the user collapse a view or switches to another top level activity in the sidebar, the
7656 * `WebviewView` itself is kept alive but the webview's underlying document is deallocated. It is recreated when
7657 * the view becomes visible again.
7658 *
7659 * You can prevent this behavior by setting `retainContextWhenHidden` in the `WebviewOptions`. However this
7660 * increases resource usage and should be avoided wherever possible. Instead, you can use persisted state to
7661 * save off a webview's state so that it can be quickly recreated as needed.
7662 *
7663 * To save off a persisted state, inside the webview call `acquireVsCodeApi().setState()` with
7664 * any json serializable object. To restore the state again, call `getState()`. For example:
7665 *
7666 * ```js
7667 * // Within the webview
7668 * const vscode = acquireVsCodeApi();
7669 *
7670 * // Get existing state
7671 * const oldState = vscode.getState() || { value: 0 };
7672 *
7673 * // Update state
7674 * setState({ value: oldState.value + 1 })
7675 * ```
7676 *
7677 * VS Code ensures that the persisted state is saved correctly when a webview is hidden and across
7678 * editor restarts.
7679 */
7680 readonly state: T | undefined;
7681 }
7682
7683 /**
7684 * Provider for creating `WebviewView` elements.
7685 */
7686 export interface WebviewViewProvider {
7687 /**
7688 * Revolves a webview view.
7689 *
7690 * `resolveWebviewView` is called when a view first becomes visible. This may happen when the view is
7691 * first loaded or when the user hides and then shows a view again.
7692 *
7693 * @param webviewView Webview view to restore. The provider should take ownership of this view. The
7694 * provider must set the webview's `.html` and hook up all webview events it is interested in.
7695 * @param context Additional metadata about the view being resolved.
7696 * @param token Cancellation token indicating that the view being provided is no longer needed.
7697 *
7698 * @return Optional thenable indicating that the view has been fully resolved.
7699 */
7700 resolveWebviewView(webviewView: WebviewView, context: WebviewViewResolveContext, token: CancellationToken): Thenable<void> | void;
7701 }
7702
7703 /**
7704 * Provider for text based custom editors.
7705 *
7706 * Text based custom editors use a [`TextDocument`](#TextDocument) as their data model. This considerably simplifies
7707 * implementing a custom editor as it allows VS Code to handle many common operations such as
7708 * undo and backup. The provider is responsible for synchronizing text changes between the webview and the `TextDocument`.
7709 */
7710 export interface CustomTextEditorProvider {
7711
7712 /**
7713 * Resolve a custom editor for a given text resource.
7714 *
7715 * This is called when a user first opens a resource for a `CustomTextEditorProvider`, or if they reopen an
7716 * existing editor using this `CustomTextEditorProvider`.
7717 *
7718 *
7719 * @param document Document for the resource to resolve.
7720 *
7721 * @param webviewPanel The webview panel used to display the editor UI for this resource.
7722 *
7723 * During resolve, the provider must fill in the initial html for the content webview panel and hook up all
7724 * the event listeners on it that it is interested in. The provider can also hold onto the `WebviewPanel` to
7725 * use later for example in a command. See [`WebviewPanel`](#WebviewPanel) for additional details.
7726 *
7727 * @param token A cancellation token that indicates the result is no longer needed.
7728 *
7729 * @return Thenable indicating that the custom editor has been resolved.
7730 */
7731 resolveCustomTextEditor(document: TextDocument, webviewPanel: WebviewPanel, token: CancellationToken): Thenable<void> | void;
7732 }
7733
7734 /**
7735 * Represents a custom document used by a [`CustomEditorProvider`](#CustomEditorProvider).
7736 *
7737 * Custom documents are only used within a given `CustomEditorProvider`. The lifecycle of a `CustomDocument` is
7738 * managed by VS Code. When no more references remain to a `CustomDocument`, it is disposed of.
7739 */
7740 interface CustomDocument {
7741 /**
7742 * The associated uri for this document.
7743 */
7744 readonly uri: Uri;
7745
7746 /**
7747 * Dispose of the custom document.
7748 *
7749 * This is invoked by VS Code when there are no more references to a given `CustomDocument` (for example when
7750 * all editors associated with the document have been closed.)
7751 */
7752 dispose(): void;
7753 }
7754
7755 /**
7756 * Event triggered by extensions to signal to VS Code that an edit has occurred on an [`CustomDocument`](#CustomDocument).
7757 *
7758 * @see [`CustomDocumentProvider.onDidChangeCustomDocument`](#CustomDocumentProvider.onDidChangeCustomDocument).
7759 */
7760 interface CustomDocumentEditEvent<T extends CustomDocument = CustomDocument> {
7761
7762 /**
7763 * The document that the edit is for.
7764 */
7765 readonly document: T;
7766
7767 /**
7768 * Undo the edit operation.
7769 *
7770 * This is invoked by VS Code when the user undoes this edit. To implement `undo`, your
7771 * extension should restore the document and editor to the state they were in just before this
7772 * edit was added to VS Code's internal edit stack by `onDidChangeCustomDocument`.
7773 */
7774 undo(): Thenable<void> | void;
7775
7776 /**
7777 * Redo the edit operation.
7778 *
7779 * This is invoked by VS Code when the user redoes this edit. To implement `redo`, your
7780 * extension should restore the document and editor to the state they were in just after this
7781 * edit was added to VS Code's internal edit stack by `onDidChangeCustomDocument`.
7782 */
7783 redo(): Thenable<void> | void;
7784
7785 /**
7786 * Display name describing the edit.
7787 *
7788 * This will be shown to users in the UI for undo/redo operations.
7789 */
7790 readonly label?: string;
7791 }
7792
7793 /**
7794 * Event triggered by extensions to signal to VS Code that the content of a [`CustomDocument`](#CustomDocument)
7795 * has changed.
7796 *
7797 * @see [`CustomDocumentProvider.onDidChangeCustomDocument`](#CustomDocumentProvider.onDidChangeCustomDocument).
7798 */
7799 interface CustomDocumentContentChangeEvent<T extends CustomDocument = CustomDocument> {
7800 /**
7801 * The document that the change is for.
7802 */
7803 readonly document: T;
7804 }
7805
7806 /**
7807 * A backup for an [`CustomDocument`](#CustomDocument).
7808 */
7809 interface CustomDocumentBackup {
7810 /**
7811 * Unique identifier for the backup.
7812 *
7813 * This id is passed back to your extension in `openCustomDocument` when opening a custom editor from a backup.
7814 */
7815 readonly id: string;
7816
7817 /**
7818 * Delete the current backup.
7819 *
7820 * This is called by VS Code when it is clear the current backup is no longer needed, such as when a new backup
7821 * is made or when the file is saved.
7822 */
7823 delete(): void;
7824 }
7825
7826 /**
7827 * Additional information used to implement [`CustomEditableDocument.backup`](#CustomEditableDocument.backup).
7828 */
7829 interface CustomDocumentBackupContext {
7830 /**
7831 * Suggested file location to write the new backup.
7832 *
7833 * Note that your extension is free to ignore this and use its own strategy for backup.
7834 *
7835 * If the editor is for a resource from the current workspace, `destination` will point to a file inside
7836 * `ExtensionContext.storagePath`. The parent folder of `destination` may not exist, so make sure to created it
7837 * before writing the backup to this location.
7838 */
7839 readonly destination: Uri;
7840 }
7841
7842 /**
7843 * Additional information about the opening custom document.
7844 */
7845 interface CustomDocumentOpenContext {
7846 /**
7847 * The id of the backup to restore the document from or `undefined` if there is no backup.
7848 *
7849 * If this is provided, your extension should restore the editor from the backup instead of reading the file
7850 * from the user's workspace.
7851 */
7852 readonly backupId?: string;
7853
7854 /**
7855 * If the URI is an untitled file, this will be populated with the byte data of that file
7856 *
7857 * If this is provided, your extension should utilize this byte data rather than executing fs APIs on the URI passed in
7858 */
7859 readonly untitledDocumentData?: Uint8Array;
7860 }
7861
7862 /**
7863 * Provider for readonly custom editors that use a custom document model.
7864 *
7865 * Custom editors use [`CustomDocument`](#CustomDocument) as their document model instead of a [`TextDocument`](#TextDocument).
7866 *
7867 * You should use this type of custom editor when dealing with binary files or more complex scenarios. For simple
7868 * text based documents, use [`CustomTextEditorProvider`](#CustomTextEditorProvider) instead.
7869 *
7870 * @param T Type of the custom document returned by this provider.
7871 */
7872 export interface CustomReadonlyEditorProvider<T extends CustomDocument = CustomDocument> {
7873
7874 /**
7875 * Create a new document for a given resource.
7876 *
7877 * `openCustomDocument` is called when the first time an editor for a given resource is opened. The opened
7878 * document is then passed to `resolveCustomEditor` so that the editor can be shown to the user.
7879 *
7880 * Already opened `CustomDocument` are re-used if the user opened additional editors. When all editors for a
7881 * given resource are closed, the `CustomDocument` is disposed of. Opening an editor at this point will
7882 * trigger another call to `openCustomDocument`.
7883 *
7884 * @param uri Uri of the document to open.
7885 * @param openContext Additional information about the opening custom document.
7886 * @param token A cancellation token that indicates the result is no longer needed.
7887 *
7888 * @return The custom document.
7889 */
7890 openCustomDocument(uri: Uri, openContext: CustomDocumentOpenContext, token: CancellationToken): Thenable<T> | T;
7891
7892 /**
7893 * Resolve a custom editor for a given resource.
7894 *
7895 * This is called whenever the user opens a new editor for this `CustomEditorProvider`.
7896 *
7897 * @param document Document for the resource being resolved.
7898 *
7899 * @param webviewPanel The webview panel used to display the editor UI for this resource.
7900 *
7901 * During resolve, the provider must fill in the initial html for the content webview panel and hook up all
7902 * the event listeners on it that it is interested in. The provider can also hold onto the `WebviewPanel` to
7903 * use later for example in a command. See [`WebviewPanel`](#WebviewPanel) for additional details.
7904 *
7905 * @param token A cancellation token that indicates the result is no longer needed.
7906 *
7907 * @return Optional thenable indicating that the custom editor has been resolved.
7908 */
7909 resolveCustomEditor(document: T, webviewPanel: WebviewPanel, token: CancellationToken): Thenable<void> | void;
7910 }
7911
7912 /**
7913 * Provider for editable custom editors that use a custom document model.
7914 *
7915 * Custom editors use [`CustomDocument`](#CustomDocument) as their document model instead of a [`TextDocument`](#TextDocument).
7916 * This gives extensions full control over actions such as edit, save, and backup.
7917 *
7918 * You should use this type of custom editor when dealing with binary files or more complex scenarios. For simple
7919 * text based documents, use [`CustomTextEditorProvider`](#CustomTextEditorProvider) instead.
7920 *
7921 * @param T Type of the custom document returned by this provider.
7922 */
7923 export interface CustomEditorProvider<T extends CustomDocument = CustomDocument> extends CustomReadonlyEditorProvider<T> {
7924 /**
7925 * Signal that an edit has occurred inside a custom editor.
7926 *
7927 * This event must be fired by your extension whenever an edit happens in a custom editor. An edit can be
7928 * anything from changing some text, to cropping an image, to reordering a list. Your extension is free to
7929 * define what an edit is and what data is stored on each edit.
7930 *
7931 * Firing `onDidChange` causes VS Code to mark the editors as being dirty. This is cleared when the user either
7932 * saves or reverts the file.
7933 *
7934 * Editors that support undo/redo must fire a `CustomDocumentEditEvent` whenever an edit happens. This allows
7935 * users to undo and redo the edit using VS Code's standard VS Code keyboard shortcuts. VS Code will also mark
7936 * the editor as no longer being dirty if the user undoes all edits to the last saved state.
7937 *
7938 * Editors that support editing but cannot use VS Code's standard undo/redo mechanism must fire a `CustomDocumentContentChangeEvent`.
7939 * The only way for a user to clear the dirty state of an editor that does not support undo/redo is to either
7940 * `save` or `revert` the file.
7941 *
7942 * An editor should only ever fire `CustomDocumentEditEvent` events, or only ever fire `CustomDocumentContentChangeEvent` events.
7943 */
7944 readonly onDidChangeCustomDocument: Event<CustomDocumentEditEvent<T>> | Event<CustomDocumentContentChangeEvent<T>>;
7945
7946 /**
7947 * Save a custom document.
7948 *
7949 * This method is invoked by VS Code when the user saves a custom editor. This can happen when the user
7950 * triggers save while the custom editor is active, by commands such as `save all`, or by auto save if enabled.
7951 *
7952 * To implement `save`, the implementer must persist the custom editor. This usually means writing the
7953 * file data for the custom document to disk. After `save` completes, any associated editor instances will
7954 * no longer be marked as dirty.
7955 *
7956 * @param document Document to save.
7957 * @param cancellation Token that signals the save is no longer required (for example, if another save was triggered).
7958 *
7959 * @return Thenable signaling that saving has completed.
7960 */
7961 saveCustomDocument(document: T, cancellation: CancellationToken): Thenable<void>;
7962
7963 /**
7964 * Save a custom document to a different location.
7965 *
7966 * This method is invoked by VS Code when the user triggers 'save as' on a custom editor. The implementer must
7967 * persist the custom editor to `destination`.
7968 *
7969 * When the user accepts save as, the current editor is be replaced by an non-dirty editor for the newly saved file.
7970 *
7971 * @param document Document to save.
7972 * @param destination Location to save to.
7973 * @param cancellation Token that signals the save is no longer required.
7974 *
7975 * @return Thenable signaling that saving has completed.
7976 */
7977 saveCustomDocumentAs(document: T, destination: Uri, cancellation: CancellationToken): Thenable<void>;
7978
7979 /**
7980 * Revert a custom document to its last saved state.
7981 *
7982 * This method is invoked by VS Code when the user triggers `File: Revert File` in a custom editor. (Note that
7983 * this is only used using VS Code's `File: Revert File` command and not on a `git revert` of the file).
7984 *
7985 * To implement `revert`, the implementer must make sure all editor instances (webviews) for `document`
7986 * are displaying the document in the same state is saved in. This usually means reloading the file from the
7987 * workspace.
7988 *
7989 * @param document Document to revert.
7990 * @param cancellation Token that signals the revert is no longer required.
7991 *
7992 * @return Thenable signaling that the change has completed.
7993 */
7994 revertCustomDocument(document: T, cancellation: CancellationToken): Thenable<void>;
7995
7996 /**
7997 * Back up a dirty custom document.
7998 *
7999 * Backups are used for hot exit and to prevent data loss. Your `backup` method should persist the resource in
8000 * its current state, i.e. with the edits applied. Most commonly this means saving the resource to disk in
8001 * the `ExtensionContext.storagePath`. When VS Code reloads and your custom editor is opened for a resource,
8002 * your extension should first check to see if any backups exist for the resource. If there is a backup, your
8003 * extension should load the file contents from there instead of from the resource in the workspace.
8004 *
8005 * `backup` is triggered approximately one second after the user stops editing the document. If the user
8006 * rapidly edits the document, `backup` will not be invoked until the editing stops.
8007 *
8008 * `backup` is not invoked when `auto save` is enabled (since auto save already persists the resource).
8009 *
8010 * @param document Document to backup.
8011 * @param context Information that can be used to backup the document.
8012 * @param cancellation Token that signals the current backup since a new backup is coming in. It is up to your
8013 * extension to decided how to respond to cancellation. If for example your extension is backing up a large file
8014 * in an operation that takes time to complete, your extension may decide to finish the ongoing backup rather
8015 * than cancelling it to ensure that VS Code has some valid backup.
8016 */
8017 backupCustomDocument(document: T, context: CustomDocumentBackupContext, cancellation: CancellationToken): Thenable<CustomDocumentBackup>;
8018 }
8019
8020 /**
8021 * The clipboard provides read and write access to the system's clipboard.
8022 */
8023 export interface Clipboard {
8024
8025 /**
8026 * Read the current clipboard contents as text.
8027 * @returns A thenable that resolves to a string.
8028 */
8029 readText(): Thenable<string>;
8030
8031 /**
8032 * Writes text into the clipboard.
8033 * @returns A thenable that resolves when writing happened.
8034 */
8035 writeText(value: string): Thenable<void>;
8036 }
8037
8038 /**
8039 * Possible kinds of UI that can use extensions.
8040 */
8041 export enum UIKind {
8042
8043 /**
8044 * Extensions are accessed from a desktop application.
8045 */
8046 Desktop = 1,
8047
8048 /**
8049 * Extensions are accessed from a web browser.
8050 */
8051 Web = 2
8052 }
8053
8054 /**
8055 * Namespace describing the environment the editor runs in.
8056 */
8057 export namespace env {
8058
8059 /**
8060 * The application name of the editor, like 'VS Code'.
8061 */
8062 export const appName: string;
8063
8064 /**
8065 * The application root folder from which the editor is running.
8066 *
8067 * *Note* that the value is the empty string when running in an
8068 * environment that has no representation of an application root folder.
8069 */
8070 export const appRoot: string;
8071
8072 /**
8073 * The custom uri scheme the editor registers to in the operating system.
8074 */
8075 export const uriScheme: string;
8076
8077 /**
8078 * Represents the preferred user-language, like `de-CH`, `fr`, or `en-US`.
8079 */
8080 export const language: string;
8081
8082 /**
8083 * The system clipboard.
8084 */
8085 export const clipboard: Clipboard;
8086
8087 /**
8088 * A unique identifier for the computer.
8089 */
8090 export const machineId: string;
8091
8092 /**
8093 * A unique identifier for the current session.
8094 * Changes each time the editor is started.
8095 */
8096 export const sessionId: string;
8097
8098 /**
8099 * Indicates that this is a fresh install of the application.
8100 * `true` if within the first day of installation otherwise `false`.
8101 */
8102 export const isNewAppInstall: boolean;
8103
8104 /**
8105 * Indicates whether the users has telemetry enabled.
8106 * Can be observed to determine if the extension should send telemetry.
8107 */
8108 export const isTelemetryEnabled: boolean;
8109
8110 /**
8111 * An [event](#Event) which fires when the user enabled or disables telemetry.
8112 * `true` if the user has enabled telemetry or `false` if the user has disabled telemetry.
8113 */
8114 export const onDidChangeTelemetryEnabled: Event<boolean>;
8115
8116 /**
8117 * The name of a remote. Defined by extensions, popular samples are `wsl` for the Windows
8118 * Subsystem for Linux or `ssh-remote` for remotes using a secure shell.
8119 *
8120 * *Note* that the value is `undefined` when there is no remote extension host but that the
8121 * value is defined in all extension hosts (local and remote) in case a remote extension host
8122 * exists. Use [`Extension#extensionKind`](#Extension.extensionKind) to know if
8123 * a specific extension runs remote or not.
8124 */
8125 export const remoteName: string | undefined;
8126
8127 /**
8128 * The detected default shell for the extension host, this is overridden by the
8129 * `terminal.integrated.shell` setting for the extension host's platform. Note that in
8130 * environments that do not support a shell the value is the empty string.
8131 */
8132 export const shell: string;
8133
8134 /**
8135 * The UI kind property indicates from which UI extensions
8136 * are accessed from. For example, extensions could be accessed
8137 * from a desktop application or a web browser.
8138 */
8139 export const uiKind: UIKind;
8140
8141 /**
8142 * Opens a link externally using the default application. Depending on the
8143 * used scheme this can be:
8144 * * a browser (`http:`, `https:`)
8145 * * a mail client (`mailto:`)
8146 * * VSCode itself (`vscode:` from `vscode.env.uriScheme`)
8147 *
8148 * *Note* that [`showTextDocument`](#window.showTextDocument) is the right
8149 * way to open a text document inside the editor, not this function.
8150 *
8151 * @param target The uri that should be opened.
8152 * @returns A promise indicating if open was successful.
8153 */
8154 export function openExternal(target: Uri): Thenable<boolean>;
8155
8156 /**
8157 * Resolves a uri to form that is accessible externally. Currently only supports `https:`, `http:` and
8158 * `vscode.env.uriScheme` uris.
8159 *
8160 * #### `http:` or `https:` scheme
8161 *
8162 * Resolves an *external* uri, such as a `http:` or `https:` link, from where the extension is running to a
8163 * uri to the same resource on the client machine.
8164 *
8165 * This is a no-op if the extension is running on the client machine.
8166 *
8167 * If the extension is running remotely, this function automatically establishes a port forwarding tunnel
8168 * from the local machine to `target` on the remote and returns a local uri to the tunnel. The lifetime of
8169 * the port forwarding tunnel is managed by VS Code and the tunnel can be closed by the user.
8170 *
8171 * *Note* that uris passed through `openExternal` are automatically resolved and you should not call `asExternalUri` on them.
8172 *
8173 * #### `vscode.env.uriScheme`
8174 *
8175 * Creates a uri that - if opened in a browser (e.g. via `openExternal`) - will result in a registered [UriHandler](#UriHandler)
8176 * to trigger.
8177 *
8178 * Extensions should not make any assumptions about the resulting uri and should not alter it in anyway.
8179 * Rather, extensions can e.g. use this uri in an authentication flow, by adding the uri as callback query
8180 * argument to the server to authenticate to.
8181 *
8182 * *Note* that if the server decides to add additional query parameters to the uri (e.g. a token or secret), it
8183 * will appear in the uri that is passed to the [UriHandler](#UriHandler).
8184 *
8185 * **Example** of an authentication flow:
8186 * ```typescript
8187 * vscode.window.registerUriHandler({
8188 * handleUri(uri: vscode.Uri): vscode.ProviderResult<void> {
8189 * if (uri.path === '/did-authenticate') {
8190 * console.log(uri.toString());
8191 * }
8192 * }
8193 * });
8194 *
8195 * const callableUri = await vscode.env.asExternalUri(vscode.Uri.parse(`${vscode.env.uriScheme}://my.extension/did-authenticate`));
8196 * await vscode.env.openExternal(callableUri);
8197 * ```
8198 *
8199 * *Note* that extensions should not cache the result of `asExternalUri` as the resolved uri may become invalid due to
8200 * a system or user action — for example, in remote cases, a user may close a port forwarding tunnel that was opened by
8201 * `asExternalUri`.
8202 *
8203 * @return A uri that can be used on the client machine.
8204 */
8205 export function asExternalUri(target: Uri): Thenable<Uri>;
8206 }
8207
8208 /**
8209 * Namespace for dealing with commands. In short, a command is a function with a
8210 * unique identifier. The function is sometimes also called _command handler_.
8211 *
8212 * Commands can be added to the editor using the [registerCommand](#commands.registerCommand)
8213 * and [registerTextEditorCommand](#commands.registerTextEditorCommand) functions. Commands
8214 * can be executed [manually](#commands.executeCommand) or from a UI gesture. Those are:
8215 *
8216 * * palette - Use the `commands`-section in `package.json` to make a command show in
8217 * the [command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette).
8218 * * keybinding - Use the `keybindings`-section in `package.json` to enable
8219 * [keybindings](https://code.visualstudio.com/docs/getstarted/keybindings#_customizing-shortcuts)
8220 * for your extension.
8221 *
8222 * Commands from other extensions and from the editor itself are accessible to an extension. However,
8223 * when invoking an editor command not all argument types are supported.
8224 *
8225 * This is a sample that registers a command handler and adds an entry for that command to the palette. First
8226 * register a command handler with the identifier `extension.sayHello`.
8227 * ```javascript
8228 * commands.registerCommand('extension.sayHello', () => {
8229 * window.showInformationMessage('Hello World!');
8230 * });
8231 * ```
8232 * Second, bind the command identifier to a title under which it will show in the palette (`package.json`).
8233 * ```json
8234 * {
8235 * "contributes": {
8236 * "commands": [{
8237 * "command": "extension.sayHello",
8238 * "title": "Hello World"
8239 * }]
8240 * }
8241 * }
8242 * ```
8243 */
8244 export namespace commands {
8245
8246 /**
8247 * Registers a command that can be invoked via a keyboard shortcut,
8248 * a menu item, an action, or directly.
8249 *
8250 * Registering a command with an existing command identifier twice
8251 * will cause an error.
8252 *
8253 * @param command A unique identifier for the command.
8254 * @param callback A command handler function.
8255 * @param thisArg The `this` context used when invoking the handler function.
8256 * @return Disposable which unregisters this command on disposal.
8257 */
8258 export function registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable;
8259
8260 /**
8261 * Registers a text editor command that can be invoked via a keyboard shortcut,
8262 * a menu item, an action, or directly.
8263 *
8264 * Text editor commands are different from ordinary [commands](#commands.registerCommand) as
8265 * they only execute when there is an active editor when the command is called. Also, the
8266 * command handler of an editor command has access to the active editor and to an
8267 * [edit](#TextEditorEdit)-builder. Note that the edit-builder is only valid while the
8268 * callback executes.
8269 *
8270 * @param command A unique identifier for the command.
8271 * @param callback A command handler function with access to an [editor](#TextEditor) and an [edit](#TextEditorEdit).
8272 * @param thisArg The `this` context used when invoking the handler function.
8273 * @return Disposable which unregisters this command on disposal.
8274 */
8275 export function registerTextEditorCommand(command: string, callback: (textEditor: TextEditor, edit: TextEditorEdit, ...args: any[]) => void, thisArg?: any): Disposable;
8276
8277 /**
8278 * Executes the command denoted by the given command identifier.
8279 *
8280 * * *Note 1:* When executing an editor command not all types are allowed to
8281 * be passed as arguments. Allowed are the primitive types `string`, `boolean`,
8282 * `number`, `undefined`, and `null`, as well as [`Position`](#Position), [`Range`](#Range), [`Uri`](#Uri) and [`Location`](#Location).
8283 * * *Note 2:* There are no restrictions when executing commands that have been contributed
8284 * by extensions.
8285 *
8286 * @param command Identifier of the command to execute.
8287 * @param rest Parameters passed to the command function.
8288 * @return A thenable that resolves to the returned value of the given command. `undefined` when
8289 * the command handler function doesn't return anything.
8290 */
8291 export function executeCommand<T>(command: string, ...rest: any[]): Thenable<T | undefined>;
8292
8293 /**
8294 * Retrieve the list of all available commands. Commands starting with an underscore are
8295 * treated as internal commands.
8296 *
8297 * @param filterInternal Set `true` to not see internal commands (starting with an underscore)
8298 * @return Thenable that resolves to a list of command ids.
8299 */
8300 export function getCommands(filterInternal?: boolean): Thenable<string[]>;
8301 }
8302
8303 /**
8304 * Represents the state of a window.
8305 */
8306 export interface WindowState {
8307
8308 /**
8309 * Whether the current window is focused.
8310 */
8311 readonly focused: boolean;
8312 }
8313
8314 /**
8315 * A uri handler is responsible for handling system-wide [uris](#Uri).
8316 *
8317 * @see [window.registerUriHandler](#window.registerUriHandler).
8318 */
8319 export interface UriHandler {
8320
8321 /**
8322 * Handle the provided system-wide [uri](#Uri).
8323 *
8324 * @see [window.registerUriHandler](#window.registerUriHandler).
8325 */
8326 handleUri(uri: Uri): ProviderResult<void>;
8327 }
8328
8329 /**
8330 * Namespace for dealing with the current window of the editor. That is visible
8331 * and active editors, as well as, UI elements to show messages, selections, and
8332 * asking for user input.
8333 */
8334 export namespace window {
8335
8336 /**
8337 * The currently active editor or `undefined`. The active editor is the one
8338 * that currently has focus or, when none has focus, the one that has changed
8339 * input most recently.
8340 */
8341 export let activeTextEditor: TextEditor | undefined;
8342
8343 /**
8344 * The currently visible editors or an empty array.
8345 */
8346 export let visibleTextEditors: TextEditor[];
8347
8348 /**
8349 * An [event](#Event) which fires when the [active editor](#window.activeTextEditor)
8350 * has changed. *Note* that the event also fires when the active editor changes
8351 * to `undefined`.
8352 */
8353 export const onDidChangeActiveTextEditor: Event<TextEditor | undefined>;
8354
8355 /**
8356 * An [event](#Event) which fires when the array of [visible editors](#window.visibleTextEditors)
8357 * has changed.
8358 */
8359 export const onDidChangeVisibleTextEditors: Event<TextEditor[]>;
8360
8361 /**
8362 * An [event](#Event) which fires when the selection in an editor has changed.
8363 */
8364 export const onDidChangeTextEditorSelection: Event<TextEditorSelectionChangeEvent>;
8365
8366 /**
8367 * An [event](#Event) which fires when the visible ranges of an editor has changed.
8368 */
8369 export const onDidChangeTextEditorVisibleRanges: Event<TextEditorVisibleRangesChangeEvent>;
8370
8371 /**
8372 * An [event](#Event) which fires when the options of an editor have changed.
8373 */
8374 export const onDidChangeTextEditorOptions: Event<TextEditorOptionsChangeEvent>;
8375
8376 /**
8377 * An [event](#Event) which fires when the view column of an editor has changed.
8378 */
8379 export const onDidChangeTextEditorViewColumn: Event<TextEditorViewColumnChangeEvent>;
8380
8381 /**
8382 * The currently opened terminals or an empty array.
8383 */
8384 export const terminals: ReadonlyArray<Terminal>;
8385
8386 /**
8387 * The currently active terminal or `undefined`. The active terminal is the one that
8388 * currently has focus or most recently had focus.
8389 */
8390 export const activeTerminal: Terminal | undefined;
8391
8392 /**
8393 * An [event](#Event) which fires when the [active terminal](#window.activeTerminal)
8394 * has changed. *Note* that the event also fires when the active terminal changes
8395 * to `undefined`.
8396 */
8397 export const onDidChangeActiveTerminal: Event<Terminal | undefined>;
8398
8399 /**
8400 * An [event](#Event) which fires when a terminal has been created, either through the
8401 * [createTerminal](#window.createTerminal) API or commands.
8402 */
8403 export const onDidOpenTerminal: Event<Terminal>;
8404
8405 /**
8406 * An [event](#Event) which fires when a terminal is disposed.
8407 */
8408 export const onDidCloseTerminal: Event<Terminal>;
8409
8410 /**
8411 * Represents the current window's state.
8412 */
8413 export const state: WindowState;
8414
8415 /**
8416 * An [event](#Event) which fires when the focus state of the current window
8417 * changes. The value of the event represents whether the window is focused.
8418 */
8419 export const onDidChangeWindowState: Event<WindowState>;
8420
8421 /**
8422 * Show the given document in a text editor. A [column](#ViewColumn) can be provided
8423 * to control where the editor is being shown. Might change the [active editor](#window.activeTextEditor).
8424 *
8425 * @param document A text document to be shown.
8426 * @param column A view column in which the [editor](#TextEditor) should be shown. The default is the [active](#ViewColumn.Active), other values
8427 * are adjusted to be `Min(column, columnCount + 1)`, the [active](#ViewColumn.Active)-column is not adjusted. Use [`ViewColumn.Beside`](#ViewColumn.Beside)
8428 * to open the editor to the side of the currently active one.
8429 * @param preserveFocus When `true` the editor will not take focus.
8430 * @return A promise that resolves to an [editor](#TextEditor).
8431 */
8432 export function showTextDocument(document: TextDocument, column?: ViewColumn, preserveFocus?: boolean): Thenable<TextEditor>;
8433
8434 /**
8435 * Show the given document in a text editor. [Options](#TextDocumentShowOptions) can be provided
8436 * to control options of the editor is being shown. Might change the [active editor](#window.activeTextEditor).
8437 *
8438 * @param document A text document to be shown.
8439 * @param options [Editor options](#TextDocumentShowOptions) to configure the behavior of showing the [editor](#TextEditor).
8440 * @return A promise that resolves to an [editor](#TextEditor).
8441 */
8442 export function showTextDocument(document: TextDocument, options?: TextDocumentShowOptions): Thenable<TextEditor>;
8443
8444 /**
8445 * A short-hand for `openTextDocument(uri).then(document => showTextDocument(document, options))`.
8446 *
8447 * @see [openTextDocument](#openTextDocument)
8448 *
8449 * @param uri A resource identifier.
8450 * @param options [Editor options](#TextDocumentShowOptions) to configure the behavior of showing the [editor](#TextEditor).
8451 * @return A promise that resolves to an [editor](#TextEditor).
8452 */
8453 export function showTextDocument(uri: Uri, options?: TextDocumentShowOptions): Thenable<TextEditor>;
8454
8455 /**
8456 * Create a TextEditorDecorationType that can be used to add decorations to text editors.
8457 *
8458 * @param options Rendering options for the decoration type.
8459 * @return A new decoration type instance.
8460 */
8461 export function createTextEditorDecorationType(options: DecorationRenderOptions): TextEditorDecorationType;
8462
8463 /**
8464 * Show an information message to users. Optionally provide an array of items which will be presented as
8465 * clickable buttons.
8466 *
8467 * @param message The message to show.
8468 * @param items A set of items that will be rendered as actions in the message.
8469 * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
8470 */
8471 export function showInformationMessage(message: string, ...items: string[]): Thenable<string | undefined>;
8472
8473 /**
8474 * Show an information message to users. Optionally provide an array of items which will be presented as
8475 * clickable buttons.
8476 *
8477 * @param message The message to show.
8478 * @param options Configures the behaviour of the message.
8479 * @param items A set of items that will be rendered as actions in the message.
8480 * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
8481 */
8482 export function showInformationMessage(message: string, options: MessageOptions, ...items: string[]): Thenable<string | undefined>;
8483
8484 /**
8485 * Show an information message.
8486 *
8487 * @see [showInformationMessage](#window.showInformationMessage)
8488 *
8489 * @param message The message to show.
8490 * @param items A set of items that will be rendered as actions in the message.
8491 * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
8492 */
8493 export function showInformationMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T | undefined>;
8494
8495 /**
8496 * Show an information message.
8497 *
8498 * @see [showInformationMessage](#window.showInformationMessage)
8499 *
8500 * @param message The message to show.
8501 * @param options Configures the behaviour of the message.
8502 * @param items A set of items that will be rendered as actions in the message.
8503 * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
8504 */
8505 export function showInformationMessage<T extends MessageItem>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
8506
8507 /**
8508 * Show a warning message.
8509 *
8510 * @see [showInformationMessage](#window.showInformationMessage)
8511 *
8512 * @param message The message to show.
8513 * @param items A set of items that will be rendered as actions in the message.
8514 * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
8515 */
8516 export function showWarningMessage(message: string, ...items: string[]): Thenable<string | undefined>;
8517
8518 /**
8519 * Show a warning message.
8520 *
8521 * @see [showInformationMessage](#window.showInformationMessage)
8522 *
8523 * @param message The message to show.
8524 * @param options Configures the behaviour of the message.
8525 * @param items A set of items that will be rendered as actions in the message.
8526 * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
8527 */
8528 export function showWarningMessage(message: string, options: MessageOptions, ...items: string[]): Thenable<string | undefined>;
8529
8530 /**
8531 * Show a warning message.
8532 *
8533 * @see [showInformationMessage](#window.showInformationMessage)
8534 *
8535 * @param message The message to show.
8536 * @param items A set of items that will be rendered as actions in the message.
8537 * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
8538 */
8539 export function showWarningMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T | undefined>;
8540
8541 /**
8542 * Show a warning message.
8543 *
8544 * @see [showInformationMessage](#window.showInformationMessage)
8545 *
8546 * @param message The message to show.
8547 * @param options Configures the behaviour of the message.
8548 * @param items A set of items that will be rendered as actions in the message.
8549 * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
8550 */
8551 export function showWarningMessage<T extends MessageItem>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
8552
8553 /**
8554 * Show an error message.
8555 *
8556 * @see [showInformationMessage](#window.showInformationMessage)
8557 *
8558 * @param message The message to show.
8559 * @param items A set of items that will be rendered as actions in the message.
8560 * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
8561 */
8562 export function showErrorMessage(message: string, ...items: string[]): Thenable<string | undefined>;
8563
8564 /**
8565 * Show an error message.
8566 *
8567 * @see [showInformationMessage](#window.showInformationMessage)
8568 *
8569 * @param message The message to show.
8570 * @param options Configures the behaviour of the message.
8571 * @param items A set of items that will be rendered as actions in the message.
8572 * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
8573 */
8574 export function showErrorMessage(message: string, options: MessageOptions, ...items: string[]): Thenable<string | undefined>;
8575
8576 /**
8577 * Show an error message.
8578 *
8579 * @see [showInformationMessage](#window.showInformationMessage)
8580 *
8581 * @param message The message to show.
8582 * @param items A set of items that will be rendered as actions in the message.
8583 * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
8584 */
8585 export function showErrorMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T | undefined>;
8586
8587 /**
8588 * Show an error message.
8589 *
8590 * @see [showInformationMessage](#window.showInformationMessage)
8591 *
8592 * @param message The message to show.
8593 * @param options Configures the behaviour of the message.
8594 * @param items A set of items that will be rendered as actions in the message.
8595 * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
8596 */
8597 export function showErrorMessage<T extends MessageItem>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
8598
8599 /**
8600 * Shows a selection list allowing multiple selections.
8601 *
8602 * @param items An array of strings, or a promise that resolves to an array of strings.
8603 * @param options Configures the behavior of the selection list.
8604 * @param token A token that can be used to signal cancellation.
8605 * @return A promise that resolves to the selected items or `undefined`.
8606 */
8607 export function showQuickPick(items: string[] | Thenable<string[]>, options: QuickPickOptions & { canPickMany: true; }, token?: CancellationToken): Thenable<string[] | undefined>;
8608
8609 /**
8610 * Shows a selection list.
8611 *
8612 * @param items An array of strings, or a promise that resolves to an array of strings.
8613 * @param options Configures the behavior of the selection list.
8614 * @param token A token that can be used to signal cancellation.
8615 * @return A promise that resolves to the selection or `undefined`.
8616 */
8617 export function showQuickPick(items: string[] | Thenable<string[]>, options?: QuickPickOptions, token?: CancellationToken): Thenable<string | undefined>;
8618
8619 /**
8620 * Shows a selection list allowing multiple selections.
8621 *
8622 * @param items An array of items, or a promise that resolves to an array of items.
8623 * @param options Configures the behavior of the selection list.
8624 * @param token A token that can be used to signal cancellation.
8625 * @return A promise that resolves to the selected items or `undefined`.
8626 */
8627 export function showQuickPick<T extends QuickPickItem>(items: T[] | Thenable<T[]>, options: QuickPickOptions & { canPickMany: true; }, token?: CancellationToken): Thenable<T[] | undefined>;
8628
8629 /**
8630 * Shows a selection list.
8631 *
8632 * @param items An array of items, or a promise that resolves to an array of items.
8633 * @param options Configures the behavior of the selection list.
8634 * @param token A token that can be used to signal cancellation.
8635 * @return A promise that resolves to the selected item or `undefined`.
8636 */
8637 export function showQuickPick<T extends QuickPickItem>(items: T[] | Thenable<T[]>, options?: QuickPickOptions, token?: CancellationToken): Thenable<T | undefined>;
8638
8639 /**
8640 * Shows a selection list of [workspace folders](#workspace.workspaceFolders) to pick from.
8641 * Returns `undefined` if no folder is open.
8642 *
8643 * @param options Configures the behavior of the workspace folder list.
8644 * @return A promise that resolves to the workspace folder or `undefined`.
8645 */
8646 export function showWorkspaceFolderPick(options?: WorkspaceFolderPickOptions): Thenable<WorkspaceFolder | undefined>;
8647
8648 /**
8649 * Shows a file open dialog to the user which allows to select a file
8650 * for opening-purposes.
8651 *
8652 * @param options Options that control the dialog.
8653 * @returns A promise that resolves to the selected resources or `undefined`.
8654 */
8655 export function showOpenDialog(options?: OpenDialogOptions): Thenable<Uri[] | undefined>;
8656
8657 /**
8658 * Shows a file save dialog to the user which allows to select a file
8659 * for saving-purposes.
8660 *
8661 * @param options Options that control the dialog.
8662 * @returns A promise that resolves to the selected resource or `undefined`.
8663 */
8664 export function showSaveDialog(options?: SaveDialogOptions): Thenable<Uri | undefined>;
8665
8666 /**
8667 * Opens an input box to ask the user for input.
8668 *
8669 * The returned value will be `undefined` if the input box was canceled (e.g. pressing ESC). Otherwise the
8670 * returned value will be the string typed by the user or an empty string if the user did not type
8671 * anything but dismissed the input box with OK.
8672 *
8673 * @param options Configures the behavior of the input box.
8674 * @param token A token that can be used to signal cancellation.
8675 * @return A promise that resolves to a string the user provided or to `undefined` in case of dismissal.
8676 */
8677 export function showInputBox(options?: InputBoxOptions, token?: CancellationToken): Thenable<string | undefined>;
8678
8679 /**
8680 * Creates a [QuickPick](#QuickPick) to let the user pick an item from a list
8681 * of items of type T.
8682 *
8683 * Note that in many cases the more convenient [window.showQuickPick](#window.showQuickPick)
8684 * is easier to use. [window.createQuickPick](#window.createQuickPick) should be used
8685 * when [window.showQuickPick](#window.showQuickPick) does not offer the required flexibility.
8686 *
8687 * @return A new [QuickPick](#QuickPick).
8688 */
8689 export function createQuickPick<T extends QuickPickItem>(): QuickPick<T>;
8690
8691 /**
8692 * Creates a [InputBox](#InputBox) to let the user enter some text input.
8693 *
8694 * Note that in many cases the more convenient [window.showInputBox](#window.showInputBox)
8695 * is easier to use. [window.createInputBox](#window.createInputBox) should be used
8696 * when [window.showInputBox](#window.showInputBox) does not offer the required flexibility.
8697 *
8698 * @return A new [InputBox](#InputBox).
8699 */
8700 export function createInputBox(): InputBox;
8701
8702 /**
8703 * Creates a new [output channel](#OutputChannel) with the given name.
8704 *
8705 * @param name Human-readable string which will be used to represent the channel in the UI.
8706 */
8707 export function createOutputChannel(name: string): OutputChannel;
8708
8709 /**
8710 * Create and show a new webview panel.
8711 *
8712 * @param viewType Identifies the type of the webview panel.
8713 * @param title Title of the panel.
8714 * @param showOptions Where to show the webview in the editor. If preserveFocus is set, the new webview will not take focus.
8715 * @param options Settings for the new panel.
8716 *
8717 * @return New webview panel.
8718 */
8719 export function createWebviewPanel(viewType: string, title: string, showOptions: ViewColumn | { viewColumn: ViewColumn, preserveFocus?: boolean }, options?: WebviewPanelOptions & WebviewOptions): WebviewPanel;
8720
8721 /**
8722 * Set a message to the status bar. This is a short hand for the more powerful
8723 * status bar [items](#window.createStatusBarItem).
8724 *
8725 * @param text The message to show, supports icon substitution as in status bar [items](#StatusBarItem.text).
8726 * @param hideAfterTimeout Timeout in milliseconds after which the message will be disposed.
8727 * @return A disposable which hides the status bar message.
8728 */
8729 export function setStatusBarMessage(text: string, hideAfterTimeout: number): Disposable;
8730
8731 /**
8732 * Set a message to the status bar. This is a short hand for the more powerful
8733 * status bar [items](#window.createStatusBarItem).
8734 *
8735 * @param text The message to show, supports icon substitution as in status bar [items](#StatusBarItem.text).
8736 * @param hideWhenDone Thenable on which completion (resolve or reject) the message will be disposed.
8737 * @return A disposable which hides the status bar message.
8738 */
8739 export function setStatusBarMessage(text: string, hideWhenDone: Thenable<any>): Disposable;
8740
8741 /**
8742 * Set a message to the status bar. This is a short hand for the more powerful
8743 * status bar [items](#window.createStatusBarItem).
8744 *
8745 * *Note* that status bar messages stack and that they must be disposed when no
8746 * longer used.
8747 *
8748 * @param text The message to show, supports icon substitution as in status bar [items](#StatusBarItem.text).
8749 * @return A disposable which hides the status bar message.
8750 */
8751 export function setStatusBarMessage(text: string): Disposable;
8752
8753 /**
8754 * Show progress in the Source Control viewlet while running the given callback and while
8755 * its returned promise isn't resolve or rejected.
8756 *
8757 * @deprecated Use `withProgress` instead.
8758 *
8759 * @param task A callback returning a promise. Progress increments can be reported with
8760 * the provided [progress](#Progress)-object.
8761 * @return The thenable the task did return.
8762 */
8763 export function withScmProgress<R>(task: (progress: Progress<number>) => Thenable<R>): Thenable<R>;
8764
8765 /**
8766 * Show progress in the editor. Progress is shown while running the given callback
8767 * and while the promise it returned isn't resolved nor rejected. The location at which
8768 * progress should show (and other details) is defined via the passed [`ProgressOptions`](#ProgressOptions).
8769 *
8770 * @param task A callback returning a promise. Progress state can be reported with
8771 * the provided [progress](#Progress)-object.
8772 *
8773 * To report discrete progress, use `increment` to indicate how much work has been completed. Each call with
8774 * a `increment` value will be summed up and reflected as overall progress until 100% is reached (a value of
8775 * e.g. `10` accounts for `10%` of work done).
8776 * Note that currently only `ProgressLocation.Notification` is capable of showing discrete progress.
8777 *
8778 * To monitor if the operation has been cancelled by the user, use the provided [`CancellationToken`](#CancellationToken).
8779 * Note that currently only `ProgressLocation.Notification` is supporting to show a cancel button to cancel the
8780 * long running operation.
8781 *
8782 * @return The thenable the task-callback returned.
8783 */
8784 export function withProgress<R>(options: ProgressOptions, task: (progress: Progress<{ message?: string; increment?: number }>, token: CancellationToken) => Thenable<R>): Thenable<R>;
8785
8786 /**
8787 * Creates a status bar [item](#StatusBarItem).
8788 *
8789 * @param alignment The alignment of the item.
8790 * @param priority The priority of the item. Higher values mean the item should be shown more to the left.
8791 * @return A new status bar item.
8792 */
8793 export function createStatusBarItem(alignment?: StatusBarAlignment, priority?: number): StatusBarItem;
8794
8795 /**
8796 * Creates a [Terminal](#Terminal) with a backing shell process. The cwd of the terminal will be the workspace
8797 * directory if it exists.
8798 *
8799 * @param name Optional human-readable string which will be used to represent the terminal in the UI.
8800 * @param shellPath Optional path to a custom shell executable to be used in the terminal.
8801 * @param shellArgs Optional args for the custom shell executable. A string can be used on Windows only which
8802 * allows specifying shell args in
8803 * [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6).
8804 * @return A new Terminal.
8805 * @throws When running in an environment where a new process cannot be started.
8806 */
8807 export function createTerminal(name?: string, shellPath?: string, shellArgs?: string[] | string): Terminal;
8808
8809 /**
8810 * Creates a [Terminal](#Terminal) with a backing shell process.
8811 *
8812 * @param options A TerminalOptions object describing the characteristics of the new terminal.
8813 * @return A new Terminal.
8814 * @throws When running in an environment where a new process cannot be started.
8815 */
8816 export function createTerminal(options: TerminalOptions): Terminal;
8817
8818 /**
8819 * Creates a [Terminal](#Terminal) where an extension controls its input and output.
8820 *
8821 * @param options An [ExtensionTerminalOptions](#ExtensionTerminalOptions) object describing
8822 * the characteristics of the new terminal.
8823 * @return A new Terminal.
8824 */
8825 export function createTerminal(options: ExtensionTerminalOptions): Terminal;
8826
8827 /**
8828 * Register a [TreeDataProvider](#TreeDataProvider) for the view contributed using the extension point `views`.
8829 * This will allow you to contribute data to the [TreeView](#TreeView) and update if the data changes.
8830 *
8831 * **Note:** To get access to the [TreeView](#TreeView) and perform operations on it, use [createTreeView](#window.createTreeView).
8832 *
8833 * @param viewId Id of the view contributed using the extension point `views`.
8834 * @param treeDataProvider A [TreeDataProvider](#TreeDataProvider) that provides tree data for the view
8835 */
8836 export function registerTreeDataProvider<T>(viewId: string, treeDataProvider: TreeDataProvider<T>): Disposable;
8837
8838 /**
8839 * Create a [TreeView](#TreeView) for the view contributed using the extension point `views`.
8840 * @param viewId Id of the view contributed using the extension point `views`.
8841 * @param options Options for creating the [TreeView](#TreeView)
8842 * @returns a [TreeView](#TreeView).
8843 */
8844 export function createTreeView<T>(viewId: string, options: TreeViewOptions<T>): TreeView<T>;
8845
8846 /**
8847 * Registers a [uri handler](#UriHandler) capable of handling system-wide [uris](#Uri).
8848 * In case there are multiple windows open, the topmost window will handle the uri.
8849 * A uri handler is scoped to the extension it is contributed from; it will only
8850 * be able to handle uris which are directed to the extension itself. A uri must respect
8851 * the following rules:
8852 *
8853 * - The uri-scheme must be `vscode.env.uriScheme`;
8854 * - The uri-authority must be the extension id (e.g. `my.extension`);
8855 * - The uri-path, -query and -fragment parts are arbitrary.
8856 *
8857 * For example, if the `my.extension` extension registers a uri handler, it will only
8858 * be allowed to handle uris with the prefix `product-name://my.extension`.
8859 *
8860 * An extension can only register a single uri handler in its entire activation lifetime.
8861 *
8862 * * *Note:* There is an activation event `onUri` that fires when a uri directed for
8863 * the current extension is about to be handled.
8864 *
8865 * @param handler The uri handler to register for this extension.
8866 */
8867 export function registerUriHandler(handler: UriHandler): Disposable;
8868
8869 /**
8870 * Registers a webview panel serializer.
8871 *
8872 * Extensions that support reviving should have an `"onWebviewPanel:viewType"` activation event and
8873 * make sure that [registerWebviewPanelSerializer](#registerWebviewPanelSerializer) is called during activation.
8874 *
8875 * Only a single serializer may be registered at a time for a given `viewType`.
8876 *
8877 * @param viewType Type of the webview panel that can be serialized.
8878 * @param serializer Webview serializer.
8879 */
8880 export function registerWebviewPanelSerializer(viewType: string, serializer: WebviewPanelSerializer): Disposable;
8881
8882 /**
8883 * Register a new provider for webview views.
8884 *
8885 * @param viewId Unique id of the view. This should match the `id` from the
8886 * `views` contribution in the package.json.
8887 * @param provider Provider for the webview views.
8888 *
8889 * @return Disposable that unregisters the provider.
8890 */
8891 export function registerWebviewViewProvider(viewId: string, provider: WebviewViewProvider, options?: {
8892 /**
8893 * Content settings for the webview created for this view.
8894 */
8895 readonly webviewOptions?: {
8896 /**
8897 * Controls if the webview element itself (iframe) is kept around even when the view
8898 * is no longer visible.
8899 *
8900 * Normally the webview's html context is created when the view becomes visible
8901 * and destroyed when it is hidden. Extensions that have complex state
8902 * or UI can set the `retainContextWhenHidden` to make VS Code keep the webview
8903 * context around, even when the webview moves to a background tab. When a webview using
8904 * `retainContextWhenHidden` becomes hidden, its scripts and other dynamic content are suspended.
8905 * When the view becomes visible again, the context is automatically restored
8906 * in the exact same state it was in originally. You cannot send messages to a
8907 * hidden webview, even with `retainContextWhenHidden` enabled.
8908 *
8909 * `retainContextWhenHidden` has a high memory overhead and should only be used if
8910 * your view's context cannot be quickly saved and restored.
8911 */
8912 readonly retainContextWhenHidden?: boolean;
8913 };
8914 }): Disposable;
8915
8916 /**
8917 * Register a provider for custom editors for the `viewType` contributed by the `customEditors` extension point.
8918 *
8919 * When a custom editor is opened, VS Code fires an `onCustomEditor:viewType` activation event. Your extension
8920 * must register a [`CustomTextEditorProvider`](#CustomTextEditorProvider), [`CustomReadonlyEditorProvider`](#CustomReadonlyEditorProvider),
8921 * [`CustomEditorProvider`](#CustomEditorProvider)for `viewType` as part of activation.
8922 *
8923 * @param viewType Unique identifier for the custom editor provider. This should match the `viewType` from the
8924 * `customEditors` contribution point.
8925 * @param provider Provider that resolves custom editors.
8926 * @param options Options for the provider.
8927 *
8928 * @return Disposable that unregisters the provider.
8929 */
8930 export function registerCustomEditorProvider(viewType: string, provider: CustomTextEditorProvider | CustomReadonlyEditorProvider | CustomEditorProvider, options?: {
8931 /**
8932 * Content settings for the webview panels created for this custom editor.
8933 */
8934 readonly webviewOptions?: WebviewPanelOptions;
8935
8936 /**
8937 * Only applies to `CustomReadonlyEditorProvider | CustomEditorProvider`.
8938 *
8939 * Indicates that the provider allows multiple editor instances to be open at the same time for
8940 * the same resource.
8941 *
8942 * By default, VS Code only allows one editor instance to be open at a time for each resource. If the
8943 * user tries to open a second editor instance for the resource, the first one is instead moved to where
8944 * the second one was to be opened.
8945 *
8946 * When `supportsMultipleEditorsPerDocument` is enabled, users can split and create copies of the custom
8947 * editor. In this case, the custom editor must make sure it can properly synchronize the states of all
8948 * editor instances for a resource so that they are consistent.
8949 */
8950 readonly supportsMultipleEditorsPerDocument?: boolean;
8951 }): Disposable;
8952
8953 /**
8954 * Register provider that enables the detection and handling of links within the terminal.
8955 * @param provider The provider that provides the terminal links.
8956 * @return Disposable that unregisters the provider.
8957 */
8958 export function registerTerminalLinkProvider(provider: TerminalLinkProvider): Disposable;
8959
8960 /**
8961 * Register a file decoration provider.
8962 *
8963 * @param provider A [FileDecorationProvider](#FileDecorationProvider).
8964 * @return A [disposable](#Disposable) that unregisters the provider.
8965 */
8966 export function registerFileDecorationProvider(provider: FileDecorationProvider): Disposable;
8967
8968 /**
8969 * The currently active color theme as configured in the settings. The active
8970 * theme can be changed via the `workbench.colorTheme` setting.
8971 */
8972 export let activeColorTheme: ColorTheme;
8973
8974 /**
8975 * An [event](#Event) which fires when the active color theme is changed or has changes.
8976 */
8977 export const onDidChangeActiveColorTheme: Event<ColorTheme>;
8978 }
8979
8980 /**
8981 * Options for creating a [TreeView](#TreeView)
8982 */
8983 export interface TreeViewOptions<T> {
8984
8985 /**
8986 * A data provider that provides tree data.
8987 */
8988 treeDataProvider: TreeDataProvider<T>;
8989
8990 /**
8991 * Whether to show collapse all action or not.
8992 */
8993 showCollapseAll?: boolean;
8994
8995 /**
8996 * Whether the tree supports multi-select. When the tree supports multi-select and a command is executed from the tree,
8997 * the first argument to the command is the tree item that the command was executed on and the second argument is an
8998 * array containing all selected tree items.
8999 */
9000 canSelectMany?: boolean;
9001 }
9002
9003 /**
9004 * The event that is fired when an element in the [TreeView](#TreeView) is expanded or collapsed
9005 */
9006 export interface TreeViewExpansionEvent<T> {
9007
9008 /**
9009 * Element that is expanded or collapsed.
9010 */
9011 readonly element: T;
9012
9013 }
9014
9015 /**
9016 * The event that is fired when there is a change in [tree view's selection](#TreeView.selection)
9017 */
9018 export interface TreeViewSelectionChangeEvent<T> {
9019
9020 /**
9021 * Selected elements.
9022 */
9023 readonly selection: T[];
9024
9025 }
9026
9027 /**
9028 * The event that is fired when there is a change in [tree view's visibility](#TreeView.visible)
9029 */
9030 export interface TreeViewVisibilityChangeEvent {
9031
9032 /**
9033 * `true` if the [tree view](#TreeView) is visible otherwise `false`.
9034 */
9035 readonly visible: boolean;
9036
9037 }
9038
9039 /**
9040 * Represents a Tree view
9041 */
9042 export interface TreeView<T> extends Disposable {
9043
9044 /**
9045 * Event that is fired when an element is expanded
9046 */
9047 readonly onDidExpandElement: Event<TreeViewExpansionEvent<T>>;
9048
9049 /**
9050 * Event that is fired when an element is collapsed
9051 */
9052 readonly onDidCollapseElement: Event<TreeViewExpansionEvent<T>>;
9053
9054 /**
9055 * Currently selected elements.
9056 */
9057 readonly selection: T[];
9058
9059 /**
9060 * Event that is fired when the [selection](#TreeView.selection) has changed
9061 */
9062 readonly onDidChangeSelection: Event<TreeViewSelectionChangeEvent<T>>;
9063
9064 /**
9065 * `true` if the [tree view](#TreeView) is visible otherwise `false`.
9066 */
9067 readonly visible: boolean;
9068
9069 /**
9070 * Event that is fired when [visibility](#TreeView.visible) has changed
9071 */
9072 readonly onDidChangeVisibility: Event<TreeViewVisibilityChangeEvent>;
9073
9074 /**
9075 * An optional human-readable message that will be rendered in the view.
9076 * Setting the message to null, undefined, or empty string will remove the message from the view.
9077 */
9078 message?: string;
9079
9080 /**
9081 * The tree view title is initially taken from the extension package.json
9082 * Changes to the title property will be properly reflected in the UI in the title of the view.
9083 */
9084 title?: string;
9085
9086 /**
9087 * An optional human-readable description which is rendered less prominently in the title of the view.
9088 * Setting the title description to null, undefined, or empty string will remove the description from the view.
9089 */
9090 description?: string;
9091
9092 /**
9093 * Reveals the given element in the tree view.
9094 * If the tree view is not visible then the tree view is shown and element is revealed.
9095 *
9096 * By default revealed element is selected.
9097 * In order to not to select, set the option `select` to `false`.
9098 * In order to focus, set the option `focus` to `true`.
9099 * 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.
9100 * **NOTE:** You can expand only to 3 levels maximum.
9101 *
9102 * **NOTE:** The [TreeDataProvider](#TreeDataProvider) that the `TreeView` [is registered with](#window.createTreeView) with must implement [getParent](#TreeDataProvider.getParent) method to access this API.
9103 */
9104 reveal(element: T, options?: { select?: boolean, focus?: boolean, expand?: boolean | number }): Thenable<void>;
9105 }
9106
9107 /**
9108 * A data provider that provides tree data
9109 */
9110 export interface TreeDataProvider<T> {
9111 /**
9112 * An optional event to signal that an element or root has changed.
9113 * This will trigger the view to update the changed element/root and its children recursively (if shown).
9114 * To signal that root has changed, do not pass any argument or pass `undefined` or `null`.
9115 */
9116 onDidChangeTreeData?: Event<T | undefined | null | void>;
9117
9118 /**
9119 * Get [TreeItem](#TreeItem) representation of the `element`
9120 *
9121 * @param element The element for which [TreeItem](#TreeItem) representation is asked for.
9122 * @return [TreeItem](#TreeItem) representation of the element
9123 */
9124 getTreeItem(element: T): TreeItem | Thenable<TreeItem>;
9125
9126 /**
9127 * Get the children of `element` or root if no element is passed.
9128 *
9129 * @param element The element from which the provider gets children. Can be `undefined`.
9130 * @return Children of `element` or root if no element is passed.
9131 */
9132 getChildren(element?: T): ProviderResult<T[]>;
9133
9134 /**
9135 * Optional method to return the parent of `element`.
9136 * Return `null` or `undefined` if `element` is a child of root.
9137 *
9138 * **NOTE:** This method should be implemented in order to access [reveal](#TreeView.reveal) API.
9139 *
9140 * @param element The element for which the parent has to be returned.
9141 * @return Parent of `element`.
9142 */
9143 getParent?(element: T): ProviderResult<T>;
9144
9145 /**
9146 * Called on hover to resolve the [TreeItem](#TreeItem.tooltip) property if it is undefined.
9147 * Called on tree item click/open to resolve the [TreeItem](#TreeItem.command) property if it is undefined.
9148 * Only properties that were undefined can be resolved in `resolveTreeItem`.
9149 * Functionality may be expanded later to include being called to resolve other missing
9150 * properties on selection and/or on open.
9151 *
9152 * Will only ever be called once per TreeItem.
9153 *
9154 * onDidChangeTreeData should not be triggered from within resolveTreeItem.
9155 *
9156 * *Note* that this function is called when tree items are already showing in the UI.
9157 * Because of that, no property that changes the presentation (label, description, etc.)
9158 * can be changed.
9159 *
9160 * @param item Undefined properties of `item` should be set then `item` should be returned.
9161 * @param element The object associated with the TreeItem.
9162 * @param token A cancellation token.
9163 * @return The resolved tree item or a thenable that resolves to such. It is OK to return the given
9164 * `item`. When no result is returned, the given `item` will be used.
9165 */
9166 resolveTreeItem?(item: TreeItem, element: T, token: CancellationToken): ProviderResult<TreeItem>;
9167 }
9168
9169 export class TreeItem {
9170 /**
9171 * A human-readable string describing this item. When `falsy`, it is derived from [resourceUri](#TreeItem.resourceUri).
9172 */
9173 label?: string | TreeItemLabel;
9174
9175 /**
9176 * 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.
9177 *
9178 * 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.
9179 */
9180 id?: string;
9181
9182 /**
9183 * The icon path or [ThemeIcon](#ThemeIcon) for the tree item.
9184 * When `falsy`, [Folder Theme Icon](#ThemeIcon.Folder) is assigned, if item is collapsible otherwise [File Theme Icon](#ThemeIcon.File).
9185 * When a file or folder [ThemeIcon](#ThemeIcon) is specified, icon is derived from the current file icon theme for the specified theme icon using [resourceUri](#TreeItem.resourceUri) (if provided).
9186 */
9187 iconPath?: string | Uri | { light: string | Uri; dark: string | Uri } | ThemeIcon;
9188
9189 /**
9190 * A human-readable string which is rendered less prominent.
9191 * When `true`, it is derived from [resourceUri](#TreeItem.resourceUri) and when `falsy`, it is not shown.
9192 */
9193 description?: string | boolean;
9194
9195 /**
9196 * The [uri](#Uri) of the resource representing this item.
9197 *
9198 * Will be used to derive the [label](#TreeItem.label), when it is not provided.
9199 * Will be used to derive the icon from current file icon theme, when [iconPath](#TreeItem.iconPath) has [ThemeIcon](#ThemeIcon) value.
9200 */
9201 resourceUri?: Uri;
9202
9203 /**
9204 * The tooltip text when you hover over this item.
9205 */
9206 tooltip?: string | MarkdownString | undefined;
9207
9208 /**
9209 * The [command](#Command) that should be executed when the tree item is selected.
9210 *
9211 * Please use `vscode.open` or `vscode.diff` as command IDs when the tree item is opening
9212 * something in the editor. Using these commands ensures that the resulting editor will
9213 * appear consistent with how other built-in trees open editors.
9214 */
9215 command?: Command;
9216
9217 /**
9218 * [TreeItemCollapsibleState](#TreeItemCollapsibleState) of the tree item.
9219 */
9220 collapsibleState?: TreeItemCollapsibleState;
9221
9222 /**
9223 * Context value of the tree item. This can be used to contribute item specific actions in the tree.
9224 * For example, a tree item is given a context value as `folder`. When contributing actions to `view/item/context`
9225 * using `menus` extension point, you can specify context value for key `viewItem` in `when` expression like `viewItem == folder`.
9226 * ```
9227 * "contributes": {
9228 * "menus": {
9229 * "view/item/context": [
9230 * {
9231 * "command": "extension.deleteFolder",
9232 * "when": "viewItem == folder"
9233 * }
9234 * ]
9235 * }
9236 * }
9237 * ```
9238 * This will show action `extension.deleteFolder` only for items with `contextValue` is `folder`.
9239 */
9240 contextValue?: string;
9241
9242 /**
9243 * Accessibility information used when screen reader interacts with this tree item.
9244 * Generally, a TreeItem has no need to set the `role` of the accessibilityInformation;
9245 * however, there are cases where a TreeItem is not displayed in a tree-like way where setting the `role` may make sense.
9246 */
9247 accessibilityInformation?: AccessibilityInformation;
9248
9249 /**
9250 * @param label A human-readable string describing this item
9251 * @param collapsibleState [TreeItemCollapsibleState](#TreeItemCollapsibleState) of the tree item. Default is [TreeItemCollapsibleState.None](#TreeItemCollapsibleState.None)
9252 */
9253 constructor(label: string | TreeItemLabel, collapsibleState?: TreeItemCollapsibleState);
9254
9255 /**
9256 * @param resourceUri The [uri](#Uri) of the resource representing this item.
9257 * @param collapsibleState [TreeItemCollapsibleState](#TreeItemCollapsibleState) of the tree item. Default is [TreeItemCollapsibleState.None](#TreeItemCollapsibleState.None)
9258 */
9259 constructor(resourceUri: Uri, collapsibleState?: TreeItemCollapsibleState);
9260 }
9261
9262 /**
9263 * Collapsible state of the tree item
9264 */
9265 export enum TreeItemCollapsibleState {
9266 /**
9267 * Determines an item can be neither collapsed nor expanded. Implies it has no children.
9268 */
9269 None = 0,
9270 /**
9271 * Determines an item is collapsed
9272 */
9273 Collapsed = 1,
9274 /**
9275 * Determines an item is expanded
9276 */
9277 Expanded = 2
9278 }
9279
9280 /**
9281 * Label describing the [Tree item](#TreeItem)
9282 */
9283 export interface TreeItemLabel {
9284
9285 /**
9286 * A human-readable string describing the [Tree item](#TreeItem).
9287 */
9288 label: string;
9289
9290 /**
9291 * Ranges in the label to highlight. A range is defined as a tuple of two number where the
9292 * first is the inclusive start index and the second the exclusive end index
9293 */
9294 highlights?: [number, number][];
9295 }
9296
9297 /**
9298 * Value-object describing what options a terminal should use.
9299 */
9300 export interface TerminalOptions {
9301 /**
9302 * A human-readable string which will be used to represent the terminal in the UI.
9303 */
9304 name?: string;
9305
9306 /**
9307 * A path to a custom shell executable to be used in the terminal.
9308 */
9309 shellPath?: string;
9310
9311 /**
9312 * Args for the custom shell executable. A string can be used on Windows only which allows
9313 * specifying shell args in [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6).
9314 */
9315 shellArgs?: string[] | string;
9316
9317 /**
9318 * A path or Uri for the current working directory to be used for the terminal.
9319 */
9320 cwd?: string | Uri;
9321
9322 /**
9323 * Object with environment variables that will be added to the VS Code process.
9324 */
9325 env?: { [key: string]: string | null | undefined };
9326
9327 /**
9328 * Whether the terminal process environment should be exactly as provided in
9329 * `TerminalOptions.env`. When this is false (default), the environment will be based on the
9330 * window's environment and also apply configured platform settings like
9331 * `terminal.integrated.windows.env` on top. When this is true, the complete environment
9332 * must be provided as nothing will be inherited from the process or any configuration.
9333 */
9334 strictEnv?: boolean;
9335
9336 /**
9337 * When enabled the terminal will run the process as normal but not be surfaced to the user
9338 * until `Terminal.show` is called. The typical usage for this is when you need to run
9339 * something that may need interactivity but only want to tell the user about it when
9340 * interaction is needed. Note that the terminals will still be exposed to all extensions
9341 * as normal.
9342 */
9343 hideFromUser?: boolean;
9344 }
9345
9346 /**
9347 * Value-object describing what options a virtual process terminal should use.
9348 */
9349 export interface ExtensionTerminalOptions {
9350 /**
9351 * A human-readable string which will be used to represent the terminal in the UI.
9352 */
9353 name: string;
9354
9355 /**
9356 * An implementation of [Pseudoterminal](#Pseudoterminal) that allows an extension to
9357 * control a terminal.
9358 */
9359 pty: Pseudoterminal;
9360 }
9361
9362 /**
9363 * Defines the interface of a terminal pty, enabling extensions to control a terminal.
9364 */
9365 interface Pseudoterminal {
9366 /**
9367 * An event that when fired will write data to the terminal. Unlike
9368 * [Terminal.sendText](#Terminal.sendText) which sends text to the underlying child
9369 * pseudo-device (the child), this will write the text to parent pseudo-device (the
9370 * _terminal_ itself).
9371 *
9372 * Note writing `\n` will just move the cursor down 1 row, you need to write `\r` as well
9373 * to move the cursor to the left-most cell.
9374 *
9375 * **Example:** Write red text to the terminal
9376 * ```typescript
9377 * const writeEmitter = new vscode.EventEmitter<string>();
9378 * const pty: vscode.Pseudoterminal = {
9379 * onDidWrite: writeEmitter.event,
9380 * open: () => writeEmitter.fire('\x1b[31mHello world\x1b[0m'),
9381 * close: () => {}
9382 * };
9383 * vscode.window.createTerminal({ name: 'My terminal', pty });
9384 * ```
9385 *
9386 * **Example:** Move the cursor to the 10th row and 20th column and write an asterisk
9387 * ```typescript
9388 * writeEmitter.fire('\x1b[10;20H*');
9389 * ```
9390 */
9391 onDidWrite: Event<string>;
9392
9393 /**
9394 * An event that when fired allows overriding the [dimensions](#Pseudoterminal.setDimensions) of the
9395 * terminal. Note that when set, the overridden dimensions will only take effect when they
9396 * are lower than the actual dimensions of the terminal (ie. there will never be a scroll
9397 * bar). Set to `undefined` for the terminal to go back to the regular dimensions (fit to
9398 * the size of the panel).
9399 *
9400 * **Example:** Override the dimensions of a terminal to 20 columns and 10 rows
9401 * ```typescript
9402 * const dimensionsEmitter = new vscode.EventEmitter<vscode.TerminalDimensions>();
9403 * const pty: vscode.Pseudoterminal = {
9404 * onDidWrite: writeEmitter.event,
9405 * onDidOverrideDimensions: dimensionsEmitter.event,
9406 * open: () => {
9407 * dimensionsEmitter.fire({
9408 * columns: 20,
9409 * rows: 10
9410 * });
9411 * },
9412 * close: () => {}
9413 * };
9414 * vscode.window.createTerminal({ name: 'My terminal', pty });
9415 * ```
9416 */
9417 onDidOverrideDimensions?: Event<TerminalDimensions | undefined>;
9418
9419 /**
9420 * An event that when fired will signal that the pty is closed and dispose of the terminal.
9421 *
9422 * A number can be used to provide an exit code for the terminal. Exit codes must be
9423 * positive and a non-zero exit codes signals failure which shows a notification for a
9424 * regular terminal and allows dependent tasks to proceed when used with the
9425 * `CustomExecution` API.
9426 *
9427 * **Example:** Exit the terminal when "y" is pressed, otherwise show a notification.
9428 * ```typescript
9429 * const writeEmitter = new vscode.EventEmitter<string>();
9430 * const closeEmitter = new vscode.EventEmitter<vscode.TerminalDimensions>();
9431 * const pty: vscode.Pseudoterminal = {
9432 * onDidWrite: writeEmitter.event,
9433 * onDidClose: closeEmitter.event,
9434 * open: () => writeEmitter.fire('Press y to exit successfully'),
9435 * close: () => {},
9436 * handleInput: data => {
9437 * if (data !== 'y') {
9438 * vscode.window.showInformationMessage('Something went wrong');
9439 * }
9440 * closeEmitter.fire();
9441 * }
9442 * };
9443 * vscode.window.createTerminal({ name: 'Exit example', pty });
9444 * ```
9445 */
9446 onDidClose?: Event<void | number>;
9447
9448 /**
9449 * Implement to handle when the pty is open and ready to start firing events.
9450 *
9451 * @param initialDimensions The dimensions of the terminal, this will be undefined if the
9452 * terminal panel has not been opened before this is called.
9453 */
9454 open(initialDimensions: TerminalDimensions | undefined): void;
9455
9456 /**
9457 * Implement to handle when the terminal is closed by an act of the user.
9458 */
9459 close(): void;
9460
9461 /**
9462 * Implement to handle incoming keystrokes in the terminal or when an extension calls
9463 * [Terminal.sendText](#Terminal.sendText). `data` contains the keystrokes/text serialized into
9464 * their corresponding VT sequence representation.
9465 *
9466 * @param data The incoming data.
9467 *
9468 * **Example:** Echo input in the terminal. The sequence for enter (`\r`) is translated to
9469 * CRLF to go to a new line and move the cursor to the start of the line.
9470 * ```typescript
9471 * const writeEmitter = new vscode.EventEmitter<string>();
9472 * const pty: vscode.Pseudoterminal = {
9473 * onDidWrite: writeEmitter.event,
9474 * open: () => {},
9475 * close: () => {},
9476 * handleInput: data => writeEmitter.fire(data === '\r' ? '\r\n' : data)
9477 * };
9478 * vscode.window.createTerminal({ name: 'Local echo', pty });
9479 * ```
9480 */
9481 handleInput?(data: string): void;
9482
9483 /**
9484 * Implement to handle when the number of rows and columns that fit into the terminal panel
9485 * changes, for example when font size changes or when the panel is resized. The initial
9486 * state of a terminal's dimensions should be treated as `undefined` until this is triggered
9487 * as the size of a terminal isn't known until it shows up in the user interface.
9488 *
9489 * When dimensions are overridden by
9490 * [onDidOverrideDimensions](#Pseudoterminal.onDidOverrideDimensions), `setDimensions` will
9491 * continue to be called with the regular panel dimensions, allowing the extension continue
9492 * to react dimension changes.
9493 *
9494 * @param dimensions The new dimensions.
9495 */
9496 setDimensions?(dimensions: TerminalDimensions): void;
9497 }
9498
9499 /**
9500 * Represents the dimensions of a terminal.
9501 */
9502 export interface TerminalDimensions {
9503 /**
9504 * The number of columns in the terminal.
9505 */
9506 readonly columns: number;
9507
9508 /**
9509 * The number of rows in the terminal.
9510 */
9511 readonly rows: number;
9512 }
9513
9514 /**
9515 * Represents how a terminal exited.
9516 */
9517 export interface TerminalExitStatus {
9518 /**
9519 * The exit code that a terminal exited with, it can have the following values:
9520 * - Zero: the terminal process or custom execution succeeded.
9521 * - Non-zero: the terminal process or custom execution failed.
9522 * - `undefined`: the user forcibly closed the terminal or a custom execution exited
9523 * without providing an exit code.
9524 */
9525 readonly code: number | undefined;
9526 }
9527
9528 /**
9529 * A type of mutation that can be applied to an environment variable.
9530 */
9531 export enum EnvironmentVariableMutatorType {
9532 /**
9533 * Replace the variable's existing value.
9534 */
9535 Replace = 1,
9536 /**
9537 * Append to the end of the variable's existing value.
9538 */
9539 Append = 2,
9540 /**
9541 * Prepend to the start of the variable's existing value.
9542 */
9543 Prepend = 3
9544 }
9545
9546 /**
9547 * A type of mutation and its value to be applied to an environment variable.
9548 */
9549 export interface EnvironmentVariableMutator {
9550 /**
9551 * The type of mutation that will occur to the variable.
9552 */
9553 readonly type: EnvironmentVariableMutatorType;
9554
9555 /**
9556 * The value to use for the variable.
9557 */
9558 readonly value: string;
9559 }
9560
9561 /**
9562 * A collection of mutations that an extension can apply to a process environment.
9563 */
9564 export interface EnvironmentVariableCollection {
9565 /**
9566 * Whether the collection should be cached for the workspace and applied to the terminal
9567 * across window reloads. When true the collection will be active immediately such when the
9568 * window reloads. Additionally, this API will return the cached version if it exists. The
9569 * collection will be invalidated when the extension is uninstalled or when the collection
9570 * is cleared. Defaults to true.
9571 */
9572 persistent: boolean;
9573
9574 /**
9575 * Replace an environment variable with a value.
9576 *
9577 * Note that an extension can only make a single change to any one variable, so this will
9578 * overwrite any previous calls to replace, append or prepend.
9579 *
9580 * @param variable The variable to replace.
9581 * @param value The value to replace the variable with.
9582 */
9583 replace(variable: string, value: string): void;
9584
9585 /**
9586 * Append a value to an environment variable.
9587 *
9588 * Note that an extension can only make a single change to any one variable, so this will
9589 * overwrite any previous calls to replace, append or prepend.
9590 *
9591 * @param variable The variable to append to.
9592 * @param value The value to append to the variable.
9593 */
9594 append(variable: string, value: string): void;
9595
9596 /**
9597 * Prepend a value to an environment variable.
9598 *
9599 * Note that an extension can only make a single change to any one variable, so this will
9600 * overwrite any previous calls to replace, append or prepend.
9601 *
9602 * @param variable The variable to prepend.
9603 * @param value The value to prepend to the variable.
9604 */
9605 prepend(variable: string, value: string): void;
9606
9607 /**
9608 * Gets the mutator that this collection applies to a variable, if any.
9609 *
9610 * @param variable The variable to get the mutator for.
9611 */
9612 get(variable: string): EnvironmentVariableMutator | undefined;
9613
9614 /**
9615 * Iterate over each mutator in this collection.
9616 *
9617 * @param callback Function to execute for each entry.
9618 * @param thisArg The `this` context used when invoking the handler function.
9619 */
9620 forEach(callback: (variable: string, mutator: EnvironmentVariableMutator, collection: EnvironmentVariableCollection) => any, thisArg?: any): void;
9621
9622 /**
9623 * Deletes this collection's mutator for a variable.
9624 *
9625 * @param variable The variable to delete the mutator for.
9626 */
9627 delete(variable: string): void;
9628
9629 /**
9630 * Clears all mutators from this collection.
9631 */
9632 clear(): void;
9633 }
9634
9635 /**
9636 * A location in the editor at which progress information can be shown. It depends on the
9637 * location how progress is visually represented.
9638 */
9639 export enum ProgressLocation {
9640
9641 /**
9642 * Show progress for the source control viewlet, as overlay for the icon and as progress bar
9643 * inside the viewlet (when visible). Neither supports cancellation nor discrete progress.
9644 */
9645 SourceControl = 1,
9646
9647 /**
9648 * Show progress in the status bar of the editor. Neither supports cancellation nor discrete progress.
9649 */
9650 Window = 10,
9651
9652 /**
9653 * Show progress as notification with an optional cancel button. Supports to show infinite and discrete progress.
9654 */
9655 Notification = 15
9656 }
9657
9658 /**
9659 * Value-object describing where and how progress should show.
9660 */
9661 export interface ProgressOptions {
9662
9663 /**
9664 * The location at which progress should show.
9665 */
9666 location: ProgressLocation | { viewId: string };
9667
9668 /**
9669 * A human-readable string which will be used to describe the
9670 * operation.
9671 */
9672 title?: string;
9673
9674 /**
9675 * Controls if a cancel button should show to allow the user to
9676 * cancel the long running operation. Note that currently only
9677 * `ProgressLocation.Notification` is supporting to show a cancel
9678 * button.
9679 */
9680 cancellable?: boolean;
9681 }
9682
9683 /**
9684 * A light-weight user input UI that is initially not visible. After
9685 * configuring it through its properties the extension can make it
9686 * visible by calling [QuickInput.show](#QuickInput.show).
9687 *
9688 * There are several reasons why this UI might have to be hidden and
9689 * the extension will be notified through [QuickInput.onDidHide](#QuickInput.onDidHide).
9690 * (Examples include: an explicit call to [QuickInput.hide](#QuickInput.hide),
9691 * the user pressing Esc, some other input UI opening, etc.)
9692 *
9693 * A user pressing Enter or some other gesture implying acceptance
9694 * of the current state does not automatically hide this UI component.
9695 * It is up to the extension to decide whether to accept the user's input
9696 * and if the UI should indeed be hidden through a call to [QuickInput.hide](#QuickInput.hide).
9697 *
9698 * When the extension no longer needs this input UI, it should
9699 * [QuickInput.dispose](#QuickInput.dispose) it to allow for freeing up
9700 * any resources associated with it.
9701 *
9702 * See [QuickPick](#QuickPick) and [InputBox](#InputBox) for concrete UIs.
9703 */
9704 export interface QuickInput {
9705
9706 /**
9707 * An optional title.
9708 */
9709 title: string | undefined;
9710
9711 /**
9712 * An optional current step count.
9713 */
9714 step: number | undefined;
9715
9716 /**
9717 * An optional total step count.
9718 */
9719 totalSteps: number | undefined;
9720
9721 /**
9722 * If the UI should allow for user input. Defaults to true.
9723 *
9724 * Change this to false, e.g., while validating user input or
9725 * loading data for the next step in user input.
9726 */
9727 enabled: boolean;
9728
9729 /**
9730 * If the UI should show a progress indicator. Defaults to false.
9731 *
9732 * Change this to true, e.g., while loading more data or validating
9733 * user input.
9734 */
9735 busy: boolean;
9736
9737 /**
9738 * If the UI should stay open even when loosing UI focus. Defaults to false.
9739 */
9740 ignoreFocusOut: boolean;
9741
9742 /**
9743 * Makes the input UI visible in its current configuration. Any other input
9744 * UI will first fire an [QuickInput.onDidHide](#QuickInput.onDidHide) event.
9745 */
9746 show(): void;
9747
9748 /**
9749 * Hides this input UI. This will also fire an [QuickInput.onDidHide](#QuickInput.onDidHide)
9750 * event.
9751 */
9752 hide(): void;
9753
9754 /**
9755 * An event signaling when this input UI is hidden.
9756 *
9757 * There are several reasons why this UI might have to be hidden and
9758 * the extension will be notified through [QuickInput.onDidHide](#QuickInput.onDidHide).
9759 * (Examples include: an explicit call to [QuickInput.hide](#QuickInput.hide),
9760 * the user pressing Esc, some other input UI opening, etc.)
9761 */
9762 onDidHide: Event<void>;
9763
9764 /**
9765 * Dispose of this input UI and any associated resources. If it is still
9766 * visible, it is first hidden. After this call the input UI is no longer
9767 * functional and no additional methods or properties on it should be
9768 * accessed. Instead a new input UI should be created.
9769 */
9770 dispose(): void;
9771 }
9772
9773 /**
9774 * A concrete [QuickInput](#QuickInput) to let the user pick an item from a
9775 * list of items of type T. The items can be filtered through a filter text field and
9776 * there is an option [canSelectMany](#QuickPick.canSelectMany) to allow for
9777 * selecting multiple items.
9778 *
9779 * Note that in many cases the more convenient [window.showQuickPick](#window.showQuickPick)
9780 * is easier to use. [window.createQuickPick](#window.createQuickPick) should be used
9781 * when [window.showQuickPick](#window.showQuickPick) does not offer the required flexibility.
9782 */
9783 export interface QuickPick<T extends QuickPickItem> extends QuickInput {
9784
9785 /**
9786 * Current value of the filter text.
9787 */
9788 value: string;
9789
9790 /**
9791 * Optional placeholder in the filter text.
9792 */
9793 placeholder: string | undefined;
9794
9795 /**
9796 * An event signaling when the value of the filter text has changed.
9797 */
9798 readonly onDidChangeValue: Event<string>;
9799
9800 /**
9801 * An event signaling when the user indicated acceptance of the selected item(s).
9802 */
9803 readonly onDidAccept: Event<void>;
9804
9805 /**
9806 * Buttons for actions in the UI.
9807 */
9808 buttons: ReadonlyArray<QuickInputButton>;
9809
9810 /**
9811 * An event signaling when a button was triggered.
9812 */
9813 readonly onDidTriggerButton: Event<QuickInputButton>;
9814
9815 /**
9816 * Items to pick from.
9817 */
9818 items: ReadonlyArray<T>;
9819
9820 /**
9821 * If multiple items can be selected at the same time. Defaults to false.
9822 */
9823 canSelectMany: boolean;
9824
9825 /**
9826 * If the filter text should also be matched against the description of the items. Defaults to false.
9827 */
9828 matchOnDescription: boolean;
9829
9830 /**
9831 * If the filter text should also be matched against the detail of the items. Defaults to false.
9832 */
9833 matchOnDetail: boolean;
9834
9835 /**
9836 * Active items. This can be read and updated by the extension.
9837 */
9838 activeItems: ReadonlyArray<T>;
9839
9840 /**
9841 * An event signaling when the active items have changed.
9842 */
9843 readonly onDidChangeActive: Event<T[]>;
9844
9845 /**
9846 * Selected items. This can be read and updated by the extension.
9847 */
9848 selectedItems: ReadonlyArray<T>;
9849
9850 /**
9851 * An event signaling when the selected items have changed.
9852 */
9853 readonly onDidChangeSelection: Event<T[]>;
9854 }
9855
9856 /**
9857 * A concrete [QuickInput](#QuickInput) to let the user input a text value.
9858 *
9859 * Note that in many cases the more convenient [window.showInputBox](#window.showInputBox)
9860 * is easier to use. [window.createInputBox](#window.createInputBox) should be used
9861 * when [window.showInputBox](#window.showInputBox) does not offer the required flexibility.
9862 */
9863 export interface InputBox extends QuickInput {
9864
9865 /**
9866 * Current input value.
9867 */
9868 value: string;
9869
9870 /**
9871 * Optional placeholder in the filter text.
9872 */
9873 placeholder: string | undefined;
9874
9875 /**
9876 * If the input value should be hidden. Defaults to false.
9877 */
9878 password: boolean;
9879
9880 /**
9881 * An event signaling when the value has changed.
9882 */
9883 readonly onDidChangeValue: Event<string>;
9884
9885 /**
9886 * An event signaling when the user indicated acceptance of the input value.
9887 */
9888 readonly onDidAccept: Event<void>;
9889
9890 /**
9891 * Buttons for actions in the UI.
9892 */
9893 buttons: ReadonlyArray<QuickInputButton>;
9894
9895 /**
9896 * An event signaling when a button was triggered.
9897 */
9898 readonly onDidTriggerButton: Event<QuickInputButton>;
9899
9900 /**
9901 * An optional prompt text providing some ask or explanation to the user.
9902 */
9903 prompt: string | undefined;
9904
9905 /**
9906 * An optional validation message indicating a problem with the current input value.
9907 */
9908 validationMessage: string | undefined;
9909 }
9910
9911 /**
9912 * Button for an action in a [QuickPick](#QuickPick) or [InputBox](#InputBox).
9913 */
9914 export interface QuickInputButton {
9915
9916 /**
9917 * Icon for the button.
9918 */
9919 readonly iconPath: Uri | { light: Uri; dark: Uri } | ThemeIcon;
9920
9921 /**
9922 * An optional tooltip.
9923 */
9924 readonly tooltip?: string | undefined;
9925 }
9926
9927 /**
9928 * Predefined buttons for [QuickPick](#QuickPick) and [InputBox](#InputBox).
9929 */
9930 export class QuickInputButtons {
9931
9932 /**
9933 * A back button for [QuickPick](#QuickPick) and [InputBox](#InputBox).
9934 *
9935 * When a navigation 'back' button is needed this one should be used for consistency.
9936 * It comes with a predefined icon, tooltip and location.
9937 */
9938 static readonly Back: QuickInputButton;
9939
9940 /**
9941 * @hidden
9942 */
9943 private constructor();
9944 }
9945
9946 /**
9947 * An event describing an individual change in the text of a [document](#TextDocument).
9948 */
9949 export interface TextDocumentContentChangeEvent {
9950 /**
9951 * The range that got replaced.
9952 */
9953 readonly range: Range;
9954 /**
9955 * The offset of the range that got replaced.
9956 */
9957 readonly rangeOffset: number;
9958 /**
9959 * The length of the range that got replaced.
9960 */
9961 readonly rangeLength: number;
9962 /**
9963 * The new text for the range.
9964 */
9965 readonly text: string;
9966 }
9967
9968 /**
9969 * An event describing a transactional [document](#TextDocument) change.
9970 */
9971 export interface TextDocumentChangeEvent {
9972
9973 /**
9974 * The affected document.
9975 */
9976 readonly document: TextDocument;
9977
9978 /**
9979 * An array of content changes.
9980 */
9981 readonly contentChanges: ReadonlyArray<TextDocumentContentChangeEvent>;
9982 }
9983
9984 /**
9985 * Represents reasons why a text document is saved.
9986 */
9987 export enum TextDocumentSaveReason {
9988
9989 /**
9990 * Manually triggered, e.g. by the user pressing save, by starting debugging,
9991 * or by an API call.
9992 */
9993 Manual = 1,
9994
9995 /**
9996 * Automatic after a delay.
9997 */
9998 AfterDelay = 2,
9999
10000 /**
10001 * When the editor lost focus.
10002 */
10003 FocusOut = 3
10004 }
10005
10006 /**
10007 * An event that is fired when a [document](#TextDocument) will be saved.
10008 *
10009 * To make modifications to the document before it is being saved, call the
10010 * [`waitUntil`](#TextDocumentWillSaveEvent.waitUntil)-function with a thenable
10011 * that resolves to an array of [text edits](#TextEdit).
10012 */
10013 export interface TextDocumentWillSaveEvent {
10014
10015 /**
10016 * The document that will be saved.
10017 */
10018 readonly document: TextDocument;
10019
10020 /**
10021 * The reason why save was triggered.
10022 */
10023 readonly reason: TextDocumentSaveReason;
10024
10025 /**
10026 * Allows to pause the event loop and to apply [pre-save-edits](#TextEdit).
10027 * Edits of subsequent calls to this function will be applied in order. The
10028 * edits will be *ignored* if concurrent modifications of the document happened.
10029 *
10030 * *Note:* This function can only be called during event dispatch and not
10031 * in an asynchronous manner:
10032 *
10033 * ```ts
10034 * workspace.onWillSaveTextDocument(event => {
10035 * // async, will *throw* an error
10036 * setTimeout(() => event.waitUntil(promise));
10037 *
10038 * // sync, OK
10039 * event.waitUntil(promise);
10040 * })
10041 * ```
10042 *
10043 * @param thenable A thenable that resolves to [pre-save-edits](#TextEdit).
10044 */
10045 waitUntil(thenable: Thenable<TextEdit[]>): void;
10046
10047 /**
10048 * Allows to pause the event loop until the provided thenable resolved.
10049 *
10050 * *Note:* This function can only be called during event dispatch.
10051 *
10052 * @param thenable A thenable that delays saving.
10053 */
10054 waitUntil(thenable: Thenable<any>): void;
10055 }
10056
10057 /**
10058 * An event that is fired when files are going to be created.
10059 *
10060 * To make modifications to the workspace before the files are created,
10061 * call the [`waitUntil](#FileWillCreateEvent.waitUntil)-function with a
10062 * thenable that resolves to a [workspace edit](#WorkspaceEdit).
10063 */
10064 export interface FileWillCreateEvent {
10065
10066 /**
10067 * The files that are going to be created.
10068 */
10069 readonly files: ReadonlyArray<Uri>;
10070
10071 /**
10072 * Allows to pause the event and to apply a [workspace edit](#WorkspaceEdit).
10073 *
10074 * *Note:* This function can only be called during event dispatch and not
10075 * in an asynchronous manner:
10076 *
10077 * ```ts
10078 * workspace.onWillCreateFiles(event => {
10079 * // async, will *throw* an error
10080 * setTimeout(() => event.waitUntil(promise));
10081 *
10082 * // sync, OK
10083 * event.waitUntil(promise);
10084 * })
10085 * ```
10086 *
10087 * @param thenable A thenable that delays saving.
10088 */
10089 waitUntil(thenable: Thenable<WorkspaceEdit>): void;
10090
10091 /**
10092 * Allows to pause the event until the provided thenable resolves.
10093 *
10094 * *Note:* This function can only be called during event dispatch.
10095 *
10096 * @param thenable A thenable that delays saving.
10097 */
10098 waitUntil(thenable: Thenable<any>): void;
10099 }
10100
10101 /**
10102 * An event that is fired after files are created.
10103 */
10104 export interface FileCreateEvent {
10105
10106 /**
10107 * The files that got created.
10108 */
10109 readonly files: ReadonlyArray<Uri>;
10110 }
10111
10112 /**
10113 * An event that is fired when files are going to be deleted.
10114 *
10115 * To make modifications to the workspace before the files are deleted,
10116 * call the [`waitUntil](#FileWillCreateEvent.waitUntil)-function with a
10117 * thenable that resolves to a [workspace edit](#WorkspaceEdit).
10118 */
10119 export interface FileWillDeleteEvent {
10120
10121 /**
10122 * The files that are going to be deleted.
10123 */
10124 readonly files: ReadonlyArray<Uri>;
10125
10126 /**
10127 * Allows to pause the event and to apply a [workspace edit](#WorkspaceEdit).
10128 *
10129 * *Note:* This function can only be called during event dispatch and not
10130 * in an asynchronous manner:
10131 *
10132 * ```ts
10133 * workspace.onWillCreateFiles(event => {
10134 * // async, will *throw* an error
10135 * setTimeout(() => event.waitUntil(promise));
10136 *
10137 * // sync, OK
10138 * event.waitUntil(promise);
10139 * })
10140 * ```
10141 *
10142 * @param thenable A thenable that delays saving.
10143 */
10144 waitUntil(thenable: Thenable<WorkspaceEdit>): void;
10145
10146 /**
10147 * Allows to pause the event until the provided thenable resolves.
10148 *
10149 * *Note:* This function can only be called during event dispatch.
10150 *
10151 * @param thenable A thenable that delays saving.
10152 */
10153 waitUntil(thenable: Thenable<any>): void;
10154 }
10155
10156 /**
10157 * An event that is fired after files are deleted.
10158 */
10159 export interface FileDeleteEvent {
10160
10161 /**
10162 * The files that got deleted.
10163 */
10164 readonly files: ReadonlyArray<Uri>;
10165 }
10166
10167 /**
10168 * An event that is fired when files are going to be renamed.
10169 *
10170 * To make modifications to the workspace before the files are renamed,
10171 * call the [`waitUntil](#FileWillCreateEvent.waitUntil)-function with a
10172 * thenable that resolves to a [workspace edit](#WorkspaceEdit).
10173 */
10174 export interface FileWillRenameEvent {
10175
10176 /**
10177 * The files that are going to be renamed.
10178 */
10179 readonly files: ReadonlyArray<{ oldUri: Uri, newUri: Uri }>;
10180
10181 /**
10182 * Allows to pause the event and to apply a [workspace edit](#WorkspaceEdit).
10183 *
10184 * *Note:* This function can only be called during event dispatch and not
10185 * in an asynchronous manner:
10186 *
10187 * ```ts
10188 * workspace.onWillCreateFiles(event => {
10189 * // async, will *throw* an error
10190 * setTimeout(() => event.waitUntil(promise));
10191 *
10192 * // sync, OK
10193 * event.waitUntil(promise);
10194 * })
10195 * ```
10196 *
10197 * @param thenable A thenable that delays saving.
10198 */
10199 waitUntil(thenable: Thenable<WorkspaceEdit>): void;
10200
10201 /**
10202 * Allows to pause the event until the provided thenable resolves.
10203 *
10204 * *Note:* This function can only be called during event dispatch.
10205 *
10206 * @param thenable A thenable that delays saving.
10207 */
10208 waitUntil(thenable: Thenable<any>): void;
10209 }
10210
10211 /**
10212 * An event that is fired after files are renamed.
10213 */
10214 export interface FileRenameEvent {
10215
10216 /**
10217 * The files that got renamed.
10218 */
10219 readonly files: ReadonlyArray<{ oldUri: Uri, newUri: Uri }>;
10220 }
10221
10222 /**
10223 * An event describing a change to the set of [workspace folders](#workspace.workspaceFolders).
10224 */
10225 export interface WorkspaceFoldersChangeEvent {
10226 /**
10227 * Added workspace folders.
10228 */
10229 readonly added: ReadonlyArray<WorkspaceFolder>;
10230
10231 /**
10232 * Removed workspace folders.
10233 */
10234 readonly removed: ReadonlyArray<WorkspaceFolder>;
10235 }
10236
10237 /**
10238 * A workspace folder is one of potentially many roots opened by the editor. All workspace folders
10239 * are equal which means there is no notion of an active or primary workspace folder.
10240 */
10241 export interface WorkspaceFolder {
10242
10243 /**
10244 * The associated uri for this workspace folder.
10245 *
10246 * *Note:* The [Uri](#Uri)-type was intentionally chosen such that future releases of the editor can support
10247 * workspace folders that are not stored on the local disk, e.g. `ftp://server/workspaces/foo`.
10248 */
10249 readonly uri: Uri;
10250
10251 /**
10252 * The name of this workspace folder. Defaults to
10253 * the basename of its [uri-path](#Uri.path)
10254 */
10255 readonly name: string;
10256
10257 /**
10258 * The ordinal number of this workspace folder.
10259 */
10260 readonly index: number;
10261 }
10262
10263 /**
10264 * Namespace for dealing with the current workspace. A workspace is the collection of one
10265 * or more folders that are opened in a VS Code window (instance).
10266 *
10267 * It is also possible to open VS Code without a workspace. For example, when you open a
10268 * new VS Code window by selecting a file from your platform's File menu, you will not be
10269 * inside a workspace. In this mode, some of VS Code's capabilities are reduced but you can
10270 * still open text files and edit them.
10271 *
10272 * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information on
10273 * the concept of workspaces in VS Code.
10274 *
10275 * The workspace offers support for [listening](#workspace.createFileSystemWatcher) to fs
10276 * events and for [finding](#workspace.findFiles) files. Both perform well and run _outside_
10277 * the editor-process so that they should be always used instead of nodejs-equivalents.
10278 */
10279 export namespace workspace {
10280
10281 /**
10282 * A [file system](#FileSystem) instance that allows to interact with local and remote
10283 * files, e.g. `vscode.workspace.fs.readDirectory(someUri)` allows to retrieve all entries
10284 * of a directory or `vscode.workspace.fs.stat(anotherUri)` returns the meta data for a
10285 * file.
10286 */
10287 export const fs: FileSystem;
10288
10289 /**
10290 * The workspace folder that is open in VS Code. `undefined` when no workspace
10291 * has been opened.
10292 *
10293 * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information
10294 * on workspaces in VS Code.
10295 *
10296 * @deprecated Use [`workspaceFolders`](#workspace.workspaceFolders) instead.
10297 */
10298 export const rootPath: string | undefined;
10299
10300 /**
10301 * List of workspace folders that are open in VS Code. `undefined when no workspace
10302 * has been opened.
10303 *
10304 * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information
10305 * on workspaces in VS Code.
10306 *
10307 * *Note* that the first entry corresponds to the value of `rootPath`.
10308 */
10309 export const workspaceFolders: ReadonlyArray<WorkspaceFolder> | undefined;
10310
10311 /**
10312 * The name of the workspace. `undefined` when no workspace
10313 * has been opened.
10314 *
10315 * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information on
10316 * the concept of workspaces in VS Code.
10317 */
10318 export const name: string | undefined;
10319
10320 /**
10321 * The location of the workspace file, for example:
10322 *
10323 * `file:///Users/name/Development/myProject.code-workspace`
10324 *
10325 * or
10326 *
10327 * `untitled:1555503116870`
10328 *
10329 * for a workspace that is untitled and not yet saved.
10330 *
10331 * Depending on the workspace that is opened, the value will be:
10332 * * `undefined` when no workspace is opened
10333 * * the path of the workspace file as `Uri` otherwise. if the workspace
10334 * is untitled, the returned URI will use the `untitled:` scheme
10335 *
10336 * The location can e.g. be used with the `vscode.openFolder` command to
10337 * open the workspace again after it has been closed.
10338 *
10339 * **Example:**
10340 * ```typescript
10341 * vscode.commands.executeCommand('vscode.openFolder', uriOfWorkspace);
10342 * ```
10343 *
10344 * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information on
10345 * the concept of workspaces in VS Code.
10346 *
10347 * **Note:** it is not advised to use `workspace.workspaceFile` to write
10348 * configuration data into the file. You can use `workspace.getConfiguration().update()`
10349 * for that purpose which will work both when a single folder is opened as
10350 * well as an untitled or saved workspace.
10351 */
10352 export const workspaceFile: Uri | undefined;
10353
10354 /**
10355 * An event that is emitted when a workspace folder is added or removed.
10356 */
10357 export const onDidChangeWorkspaceFolders: Event<WorkspaceFoldersChangeEvent>;
10358
10359 /**
10360 * Returns the [workspace folder](#WorkspaceFolder) that contains a given uri.
10361 * * returns `undefined` when the given uri doesn't match any workspace folder
10362 * * returns the *input* when the given uri is a workspace folder itself
10363 *
10364 * @param uri An uri.
10365 * @return A workspace folder or `undefined`
10366 */
10367 export function getWorkspaceFolder(uri: Uri): WorkspaceFolder | undefined;
10368
10369 /**
10370 * Returns a path that is relative to the workspace folder or folders.
10371 *
10372 * When there are no [workspace folders](#workspace.workspaceFolders) or when the path
10373 * is not contained in them, the input is returned.
10374 *
10375 * @param pathOrUri A path or uri. When a uri is given its [fsPath](#Uri.fsPath) is used.
10376 * @param includeWorkspaceFolder When `true` and when the given path is contained inside a
10377 * workspace folder the name of the workspace is prepended. Defaults to `true` when there are
10378 * multiple workspace folders and `false` otherwise.
10379 * @return A path relative to the root or the input.
10380 */
10381 export function asRelativePath(pathOrUri: string | Uri, includeWorkspaceFolder?: boolean): string;
10382
10383 /**
10384 * This method replaces `deleteCount` [workspace folders](#workspace.workspaceFolders) starting at index `start`
10385 * by an optional set of `workspaceFoldersToAdd` on the `vscode.workspace.workspaceFolders` array. This "splice"
10386 * behavior can be used to add, remove and change workspace folders in a single operation.
10387 *
10388 * If the first workspace folder is added, removed or changed, the currently executing extensions (including the
10389 * one that called this method) will be terminated and restarted so that the (deprecated) `rootPath` property is
10390 * updated to point to the first workspace folder.
10391 *
10392 * Use the [`onDidChangeWorkspaceFolders()`](#onDidChangeWorkspaceFolders) event to get notified when the
10393 * workspace folders have been updated.
10394 *
10395 * **Example:** adding a new workspace folder at the end of workspace folders
10396 * ```typescript
10397 * workspace.updateWorkspaceFolders(workspace.workspaceFolders ? workspace.workspaceFolders.length : 0, null, { uri: ...});
10398 * ```
10399 *
10400 * **Example:** removing the first workspace folder
10401 * ```typescript
10402 * workspace.updateWorkspaceFolders(0, 1);
10403 * ```
10404 *
10405 * **Example:** replacing an existing workspace folder with a new one
10406 * ```typescript
10407 * workspace.updateWorkspaceFolders(0, 1, { uri: ...});
10408 * ```
10409 *
10410 * It is valid to remove an existing workspace folder and add it again with a different name
10411 * to rename that folder.
10412 *
10413 * **Note:** it is not valid to call [updateWorkspaceFolders()](#updateWorkspaceFolders) multiple times
10414 * without waiting for the [`onDidChangeWorkspaceFolders()`](#onDidChangeWorkspaceFolders) to fire.
10415 *
10416 * @param start the zero-based location in the list of currently opened [workspace folders](#WorkspaceFolder)
10417 * from which to start deleting workspace folders.
10418 * @param deleteCount the optional number of workspace folders to remove.
10419 * @param workspaceFoldersToAdd the optional variable set of workspace folders to add in place of the deleted ones.
10420 * Each workspace is identified with a mandatory URI and an optional name.
10421 * @return true if the operation was successfully started and false otherwise if arguments were used that would result
10422 * in invalid workspace folder state (e.g. 2 folders with the same URI).
10423 */
10424 export function updateWorkspaceFolders(start: number, deleteCount: number | undefined | null, ...workspaceFoldersToAdd: { uri: Uri, name?: string }[]): boolean;
10425
10426 /**
10427 * Creates a file system watcher.
10428 *
10429 * A glob pattern that filters the file events on their absolute path must be provided. Optionally,
10430 * flags to ignore certain kinds of events can be provided. To stop listening to events the watcher must be disposed.
10431 *
10432 * *Note* that only files within the current [workspace folders](#workspace.workspaceFolders) can be watched.
10433 * *Note* that when watching for file changes such as '**​/*.js', notifications will not be sent when a parent folder is
10434 * moved or deleted (this is a known limitation of the current implementation and may change in the future).
10435 *
10436 * @param globPattern A [glob pattern](#GlobPattern) that is applied to the absolute paths of created, changed,
10437 * and deleted files. Use a [relative pattern](#RelativePattern) to limit events to a certain [workspace folder](#WorkspaceFolder).
10438 * @param ignoreCreateEvents Ignore when files have been created.
10439 * @param ignoreChangeEvents Ignore when files have been changed.
10440 * @param ignoreDeleteEvents Ignore when files have been deleted.
10441 * @return A new file system watcher instance.
10442 */
10443 export function createFileSystemWatcher(globPattern: GlobPattern, ignoreCreateEvents?: boolean, ignoreChangeEvents?: boolean, ignoreDeleteEvents?: boolean): FileSystemWatcher;
10444
10445 /**
10446 * Find files across all [workspace folders](#workspace.workspaceFolders) in the workspace.
10447 *
10448 * @example
10449 * findFiles('**​/*.js', '**​/node_modules/**', 10)
10450 *
10451 * @param include A [glob pattern](#GlobPattern) that defines the files to search for. The glob pattern
10452 * will be matched against the file paths of resulting matches relative to their workspace. Use a [relative pattern](#RelativePattern)
10453 * to restrict the search results to a [workspace folder](#WorkspaceFolder).
10454 * @param exclude A [glob pattern](#GlobPattern) that defines files and folders to exclude. The glob pattern
10455 * will be matched against the file paths of resulting matches relative to their workspace. When `undefined` only default excludes will
10456 * apply, when `null` no excludes will apply.
10457 * @param maxResults An upper-bound for the result.
10458 * @param token A token that can be used to signal cancellation to the underlying search engine.
10459 * @return A thenable that resolves to an array of resource identifiers. Will return no results if no
10460 * [workspace folders](#workspace.workspaceFolders) are opened.
10461 */
10462 export function findFiles(include: GlobPattern, exclude?: GlobPattern | null, maxResults?: number, token?: CancellationToken): Thenable<Uri[]>;
10463
10464 /**
10465 * Save all dirty files.
10466 *
10467 * @param includeUntitled Also save files that have been created during this session.
10468 * @return A thenable that resolves when the files have been saved.
10469 */
10470 export function saveAll(includeUntitled?: boolean): Thenable<boolean>;
10471
10472 /**
10473 * Make changes to one or many resources or create, delete, and rename resources as defined by the given
10474 * [workspace edit](#WorkspaceEdit).
10475 *
10476 * All changes of a workspace edit are applied in the same order in which they have been added. If
10477 * multiple textual inserts are made at the same position, these strings appear in the resulting text
10478 * in the order the 'inserts' were made, unless that are interleaved with resource edits. Invalid sequences
10479 * like 'delete file a' -> 'insert text in file a' cause failure of the operation.
10480 *
10481 * When applying a workspace edit that consists only of text edits an 'all-or-nothing'-strategy is used.
10482 * A workspace edit with resource creations or deletions aborts the operation, e.g. consecutive edits will
10483 * not be attempted, when a single edit fails.
10484 *
10485 * @param edit A workspace edit.
10486 * @return A thenable that resolves when the edit could be applied.
10487 */
10488 export function applyEdit(edit: WorkspaceEdit): Thenable<boolean>;
10489
10490 /**
10491 * All text documents currently known to the system.
10492 */
10493 export const textDocuments: ReadonlyArray<TextDocument>;
10494
10495 /**
10496 * Opens a document. Will return early if this document is already open. Otherwise
10497 * the document is loaded and the [didOpen](#workspace.onDidOpenTextDocument)-event fires.
10498 *
10499 * The document is denoted by an [uri](#Uri). Depending on the [scheme](#Uri.scheme) the
10500 * following rules apply:
10501 * * `file`-scheme: Open a file on disk, will be rejected if the file does not exist or cannot be loaded.
10502 * * `untitled`-scheme: A new file that should be saved on disk, e.g. `untitled:c:\frodo\new.js`. The language
10503 * will be derived from the file name.
10504 * * For all other schemes contributed [text document content providers](#TextDocumentContentProvider) and
10505 * [file system providers](#FileSystemProvider) are consulted.
10506 *
10507 * *Note* that the lifecycle of the returned document is owned by the editor and not by the extension. That means an
10508 * [`onDidClose`](#workspace.onDidCloseTextDocument)-event can occur at any time after opening it.
10509 *
10510 * @param uri Identifies the resource to open.
10511 * @return A promise that resolves to a [document](#TextDocument).
10512 */
10513 export function openTextDocument(uri: Uri): Thenable<TextDocument>;
10514
10515 /**
10516 * A short-hand for `openTextDocument(Uri.file(fileName))`.
10517 *
10518 * @see [openTextDocument](#openTextDocument)
10519 * @param fileName A name of a file on disk.
10520 * @return A promise that resolves to a [document](#TextDocument).
10521 */
10522 export function openTextDocument(fileName: string): Thenable<TextDocument>;
10523
10524 /**
10525 * Opens an untitled text document. The editor will prompt the user for a file
10526 * path when the document is to be saved. The `options` parameter allows to
10527 * specify the *language* and/or the *content* of the document.
10528 *
10529 * @param options Options to control how the document will be created.
10530 * @return A promise that resolves to a [document](#TextDocument).
10531 */
10532 export function openTextDocument(options?: { language?: string; content?: string; }): Thenable<TextDocument>;
10533
10534 /**
10535 * Register a text document content provider.
10536 *
10537 * Only one provider can be registered per scheme.
10538 *
10539 * @param scheme The uri-scheme to register for.
10540 * @param provider A content provider.
10541 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
10542 */
10543 export function registerTextDocumentContentProvider(scheme: string, provider: TextDocumentContentProvider): Disposable;
10544
10545 /**
10546 * An event that is emitted when a [text document](#TextDocument) is opened or when the language id
10547 * of a text document [has been changed](#languages.setTextDocumentLanguage).
10548 *
10549 * To add an event listener when a visible text document is opened, use the [TextEditor](#TextEditor) events in the
10550 * [window](#window) namespace. Note that:
10551 *
10552 * - The event is emitted before the [document](#TextDocument) is updated in the
10553 * [active text editor](#window.activeTextEditor)
10554 * - When a [text document](#TextDocument) is already open (e.g.: open in another [visible text editor](#window.visibleTextEditors)) this event is not emitted
10555 *
10556 */
10557 export const onDidOpenTextDocument: Event<TextDocument>;
10558
10559 /**
10560 * An event that is emitted when a [text document](#TextDocument) is disposed or when the language id
10561 * of a text document [has been changed](#languages.setTextDocumentLanguage).
10562 *
10563 * *Note 1:* There is no guarantee that this event fires when an editor tab is closed, use the
10564 * [`onDidChangeVisibleTextEditors`](#window.onDidChangeVisibleTextEditors)-event to know when editors change.
10565 *
10566 * *Note 2:* A document can be open but not shown in an editor which means this event can fire
10567 * for a document that has not been shown in an editor.
10568 */
10569 export const onDidCloseTextDocument: Event<TextDocument>;
10570
10571 /**
10572 * An event that is emitted when a [text document](#TextDocument) is changed. This usually happens
10573 * when the [contents](#TextDocument.getText) changes but also when other things like the
10574 * [dirty](#TextDocument.isDirty)-state changes.
10575 */
10576 export const onDidChangeTextDocument: Event<TextDocumentChangeEvent>;
10577
10578 /**
10579 * An event that is emitted when a [text document](#TextDocument) will be saved to disk.
10580 *
10581 * *Note 1:* Subscribers can delay saving by registering asynchronous work. For the sake of data integrity the editor
10582 * might save without firing this event. For instance when shutting down with dirty files.
10583 *
10584 * *Note 2:* Subscribers are called sequentially and they can [delay](#TextDocumentWillSaveEvent.waitUntil) saving
10585 * by registering asynchronous work. Protection against misbehaving listeners is implemented as such:
10586 * * there is an overall time budget that all listeners share and if that is exhausted no further listener is called
10587 * * listeners that take a long time or produce errors frequently will not be called anymore
10588 *
10589 * The current thresholds are 1.5 seconds as overall time budget and a listener can misbehave 3 times before being ignored.
10590 */
10591 export const onWillSaveTextDocument: Event<TextDocumentWillSaveEvent>;
10592
10593 /**
10594 * An event that is emitted when a [text document](#TextDocument) is saved to disk.
10595 */
10596 export const onDidSaveTextDocument: Event<TextDocument>;
10597
10598 /**
10599 * An event that is emitted when files are being created.
10600 *
10601 * *Note 1:* This event is triggered by user gestures, like creating a file from the
10602 * explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api. This event is *not* fired when
10603 * files change on disk, e.g triggered by another application, or when using the
10604 * [`workspace.fs`](#FileSystem)-api.
10605 *
10606 * *Note 2:* When this event is fired, edits to files that are are being created cannot be applied.
10607 */
10608 export const onWillCreateFiles: Event<FileWillCreateEvent>;
10609
10610 /**
10611 * An event that is emitted when files have been created.
10612 *
10613 * *Note:* This event is triggered by user gestures, like creating a file from the
10614 * explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
10615 * files change on disk, e.g triggered by another application, or when using the
10616 * [`workspace.fs`](#FileSystem)-api.
10617 */
10618 export const onDidCreateFiles: Event<FileCreateEvent>;
10619
10620 /**
10621 * An event that is emitted when files are being deleted.
10622 *
10623 * *Note 1:* This event is triggered by user gestures, like deleting a file from the
10624 * explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
10625 * files change on disk, e.g triggered by another application, or when using the
10626 * [`workspace.fs`](#FileSystem)-api.
10627 *
10628 * *Note 2:* When deleting a folder with children only one event is fired.
10629 */
10630 export const onWillDeleteFiles: Event<FileWillDeleteEvent>;
10631
10632 /**
10633 * An event that is emitted when files have been deleted.
10634 *
10635 * *Note 1:* This event is triggered by user gestures, like deleting a file from the
10636 * explorer, or from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
10637 * files change on disk, e.g triggered by another application, or when using the
10638 * [`workspace.fs`](#FileSystem)-api.
10639 *
10640 * *Note 2:* When deleting a folder with children only one event is fired.
10641 */
10642 export const onDidDeleteFiles: Event<FileDeleteEvent>;
10643
10644 /**
10645 * An event that is emitted when files are being renamed.
10646 *
10647 * *Note 1:* This event is triggered by user gestures, like renaming a file from the
10648 * explorer, and from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
10649 * files change on disk, e.g triggered by another application, or when using the
10650 * [`workspace.fs`](#FileSystem)-api.
10651 *
10652 * *Note 2:* When renaming a folder with children only one event is fired.
10653 */
10654 export const onWillRenameFiles: Event<FileWillRenameEvent>;
10655
10656 /**
10657 * An event that is emitted when files have been renamed.
10658 *
10659 * *Note 1:* This event is triggered by user gestures, like renaming a file from the
10660 * explorer, and from the [`workspace.applyEdit`](#workspace.applyEdit)-api, but this event is *not* fired when
10661 * files change on disk, e.g triggered by another application, or when using the
10662 * [`workspace.fs`](#FileSystem)-api.
10663 *
10664 * *Note 2:* When renaming a folder with children only one event is fired.
10665 */
10666 export const onDidRenameFiles: Event<FileRenameEvent>;
10667
10668 /**
10669 * Get a workspace configuration object.
10670 *
10671 * When a section-identifier is provided only that part of the configuration
10672 * is returned. Dots in the section-identifier are interpreted as child-access,
10673 * like `{ myExt: { setting: { doIt: true }}}` and `getConfiguration('myExt.setting').get('doIt') === true`.
10674 *
10675 * When a scope is provided configuration confined to that scope is returned. Scope can be a resource or a language identifier or both.
10676 *
10677 * @param section A dot-separated identifier.
10678 * @param scope A scope for which the configuration is asked for.
10679 * @return The full configuration or a subset.
10680 */
10681 export function getConfiguration(section?: string | undefined, scope?: ConfigurationScope | null): WorkspaceConfiguration;
10682
10683 /**
10684 * An event that is emitted when the [configuration](#WorkspaceConfiguration) changed.
10685 */
10686 export const onDidChangeConfiguration: Event<ConfigurationChangeEvent>;
10687
10688 /**
10689 * Register a task provider.
10690 *
10691 * @deprecated Use the corresponding function on the `tasks` namespace instead
10692 *
10693 * @param type The task kind type this provider is registered for.
10694 * @param provider A task provider.
10695 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
10696 */
10697 export function registerTaskProvider(type: string, provider: TaskProvider): Disposable;
10698
10699 /**
10700 * Register a filesystem provider for a given scheme, e.g. `ftp`.
10701 *
10702 * There can only be one provider per scheme and an error is being thrown when a scheme
10703 * has been claimed by another provider or when it is reserved.
10704 *
10705 * @param scheme The uri-[scheme](#Uri.scheme) the provider registers for.
10706 * @param provider The filesystem provider.
10707 * @param options Immutable metadata about the provider.
10708 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
10709 */
10710 export function registerFileSystemProvider(scheme: string, provider: FileSystemProvider, options?: { readonly isCaseSensitive?: boolean, readonly isReadonly?: boolean }): Disposable;
10711
10712 /**
10713 * When true, the user has explicitly trusted the contents of the workspace.
10714 */
10715 export const isTrusted: boolean;
10716
10717 /**
10718 * Event that fires when the current workspace has been trusted.
10719 */
10720 export const onDidGrantWorkspaceTrust: Event<void>;
10721 }
10722
10723 /**
10724 * The configuration scope which can be a
10725 * a 'resource' or a languageId or both or
10726 * a '[TextDocument](#TextDocument)' or
10727 * a '[WorkspaceFolder](#WorkspaceFolder)'
10728 */
10729 export type ConfigurationScope = Uri | TextDocument | WorkspaceFolder | { uri?: Uri, languageId: string };
10730
10731 /**
10732 * An event describing the change in Configuration
10733 */
10734 export interface ConfigurationChangeEvent {
10735
10736 /**
10737 * Checks if the given section has changed.
10738 * If scope is provided, checks if the section has changed for resources under the given scope.
10739 *
10740 * @param section Configuration name, supports _dotted_ names.
10741 * @param scope A scope in which to check.
10742 * @return `true` if the given section has changed.
10743 */
10744 affectsConfiguration(section: string, scope?: ConfigurationScope): boolean;
10745 }
10746
10747 /**
10748 * Namespace for participating in language-specific editor [features](https://code.visualstudio.com/docs/editor/editingevolved),
10749 * like IntelliSense, code actions, diagnostics etc.
10750 *
10751 * Many programming languages exist and there is huge variety in syntaxes, semantics, and paradigms. Despite that, features
10752 * like automatic word-completion, code navigation, or code checking have become popular across different tools for different
10753 * programming languages.
10754 *
10755 * The editor provides an API that makes it simple to provide such common features by having all UI and actions already in place and
10756 * by allowing you to participate by providing data only. For instance, to contribute a hover all you have to do is provide a function
10757 * that can be called with a [TextDocument](#TextDocument) and a [Position](#Position) returning hover info. The rest, like tracking the
10758 * mouse, positioning the hover, keeping the hover stable etc. is taken care of by the editor.
10759 *
10760 * ```javascript
10761 * languages.registerHoverProvider('javascript', {
10762 * provideHover(document, position, token) {
10763 * return new Hover('I am a hover!');
10764 * }
10765 * });
10766 * ```
10767 *
10768 * Registration is done using a [document selector](#DocumentSelector) which is either a language id, like `javascript` or
10769 * a more complex [filter](#DocumentFilter) like `{ language: 'typescript', scheme: 'file' }`. Matching a document against such
10770 * a selector will result in a [score](#languages.match) that is used to determine if and how a provider shall be used. When
10771 * scores are equal the provider that came last wins. For features that allow full arity, like [hover](#languages.registerHoverProvider),
10772 * the score is only checked to be `>0`, for other features, like [IntelliSense](#languages.registerCompletionItemProvider) the
10773 * score is used for determining the order in which providers are asked to participate.
10774 */
10775 export namespace languages {
10776
10777 /**
10778 * Return the identifiers of all known languages.
10779 * @return Promise resolving to an array of identifier strings.
10780 */
10781 export function getLanguages(): Thenable<string[]>;
10782
10783 /**
10784 * Set (and change) the [language](#TextDocument.languageId) that is associated
10785 * with the given document.
10786 *
10787 * *Note* that calling this function will trigger the [`onDidCloseTextDocument`](#workspace.onDidCloseTextDocument) event
10788 * followed by the [`onDidOpenTextDocument`](#workspace.onDidOpenTextDocument) event.
10789 *
10790 * @param document The document which language is to be changed
10791 * @param languageId The new language identifier.
10792 * @returns A thenable that resolves with the updated document.
10793 */
10794 export function setTextDocumentLanguage(document: TextDocument, languageId: string): Thenable<TextDocument>;
10795
10796 /**
10797 * Compute the match between a document [selector](#DocumentSelector) and a document. Values
10798 * greater than zero mean the selector matches the document.
10799 *
10800 * A match is computed according to these rules:
10801 * 1. When [`DocumentSelector`](#DocumentSelector) is an array, compute the match for each contained `DocumentFilter` or language identifier and take the maximum value.
10802 * 2. A string will be desugared to become the `language`-part of a [`DocumentFilter`](#DocumentFilter), so `"fooLang"` is like `{ language: "fooLang" }`.
10803 * 3. A [`DocumentFilter`](#DocumentFilter) will be matched against the document by comparing its parts with the document. The following rules apply:
10804 * 1. When the `DocumentFilter` is empty (`{}`) the result is `0`
10805 * 2. When `scheme`, `language`, or `pattern` are defined but one doesn’t match, the result is `0`
10806 * 3. Matching against `*` gives a score of `5`, matching via equality or via a glob-pattern gives a score of `10`
10807 * 4. The result is the maximum value of each match
10808 *
10809 * Samples:
10810 * ```js
10811 * // default document from disk (file-scheme)
10812 * doc.uri; //'file:///my/file.js'
10813 * doc.languageId; // 'javascript'
10814 * match('javascript', doc); // 10;
10815 * match({language: 'javascript'}, doc); // 10;
10816 * match({language: 'javascript', scheme: 'file'}, doc); // 10;
10817 * match('*', doc); // 5
10818 * match('fooLang', doc); // 0
10819 * match(['fooLang', '*'], doc); // 5
10820 *
10821 * // virtual document, e.g. from git-index
10822 * doc.uri; // 'git:/my/file.js'
10823 * doc.languageId; // 'javascript'
10824 * match('javascript', doc); // 10;
10825 * match({language: 'javascript', scheme: 'git'}, doc); // 10;
10826 * match('*', doc); // 5
10827 * ```
10828 *
10829 * @param selector A document selector.
10830 * @param document A text document.
10831 * @return A number `>0` when the selector matches and `0` when the selector does not match.
10832 */
10833 export function match(selector: DocumentSelector, document: TextDocument): number;
10834
10835 /**
10836 * An [event](#Event) which fires when the global set of diagnostics changes. This is
10837 * newly added and removed diagnostics.
10838 */
10839 export const onDidChangeDiagnostics: Event<DiagnosticChangeEvent>;
10840
10841 /**
10842 * Get all diagnostics for a given resource.
10843 *
10844 * @param resource A resource
10845 * @returns An array of [diagnostics](#Diagnostic) objects or an empty array.
10846 */
10847 export function getDiagnostics(resource: Uri): Diagnostic[];
10848
10849 /**
10850 * Get all diagnostics.
10851 *
10852 * @returns An array of uri-diagnostics tuples or an empty array.
10853 */
10854 export function getDiagnostics(): [Uri, Diagnostic[]][];
10855
10856 /**
10857 * Create a diagnostics collection.
10858 *
10859 * @param name The [name](#DiagnosticCollection.name) of the collection.
10860 * @return A new diagnostic collection.
10861 */
10862 export function createDiagnosticCollection(name?: string): DiagnosticCollection;
10863
10864 /**
10865 * Register a completion provider.
10866 *
10867 * Multiple providers can be registered for a language. In that case providers are sorted
10868 * by their [score](#languages.match) and groups of equal score are sequentially asked for
10869 * completion items. The process stops when one or many providers of a group return a
10870 * result. A failing provider (rejected promise or exception) will not fail the whole
10871 * operation.
10872 *
10873 * A completion item provider can be associated with a set of `triggerCharacters`. When trigger
10874 * characters are being typed, completions are requested but only from providers that registered
10875 * the typed character. Because of that trigger characters should be different than [word characters](#LanguageConfiguration.wordPattern),
10876 * a common trigger character is `.` to trigger member completions.
10877 *
10878 * @param selector A selector that defines the documents this provider is applicable to.
10879 * @param provider A completion provider.
10880 * @param triggerCharacters Trigger completion when the user types one of the characters.
10881 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
10882 */
10883 export function registerCompletionItemProvider(selector: DocumentSelector, provider: CompletionItemProvider, ...triggerCharacters: string[]): Disposable;
10884
10885 /**
10886 * Register a code action provider.
10887 *
10888 * Multiple providers can be registered for a language. In that case providers are asked in
10889 * parallel and the results are merged. A failing provider (rejected promise or exception) will
10890 * not cause a failure of the whole operation.
10891 *
10892 * @param selector A selector that defines the documents this provider is applicable to.
10893 * @param provider A code action provider.
10894 * @param metadata Metadata about the kind of code actions the provider provides.
10895 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
10896 */
10897 export function registerCodeActionsProvider(selector: DocumentSelector, provider: CodeActionProvider, metadata?: CodeActionProviderMetadata): Disposable;
10898
10899 /**
10900 * Register a code lens provider.
10901 *
10902 * Multiple providers can be registered for a language. In that case providers are asked in
10903 * parallel and the results are merged. A failing provider (rejected promise or exception) will
10904 * not cause a failure of the whole operation.
10905 *
10906 * @param selector A selector that defines the documents this provider is applicable to.
10907 * @param provider A code lens provider.
10908 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
10909 */
10910 export function registerCodeLensProvider(selector: DocumentSelector, provider: CodeLensProvider): Disposable;
10911
10912 /**
10913 * Register a definition provider.
10914 *
10915 * Multiple providers can be registered for a language. In that case providers are asked in
10916 * parallel and the results are merged. A failing provider (rejected promise or exception) will
10917 * not cause a failure of the whole operation.
10918 *
10919 * @param selector A selector that defines the documents this provider is applicable to.
10920 * @param provider A definition provider.
10921 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
10922 */
10923 export function registerDefinitionProvider(selector: DocumentSelector, provider: DefinitionProvider): Disposable;
10924
10925 /**
10926 * Register an implementation provider.
10927 *
10928 * Multiple providers can be registered for a language. In that case providers are asked in
10929 * parallel and the results are merged. A failing provider (rejected promise or exception) will
10930 * not cause a failure of the whole operation.
10931 *
10932 * @param selector A selector that defines the documents this provider is applicable to.
10933 * @param provider An implementation provider.
10934 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
10935 */
10936 export function registerImplementationProvider(selector: DocumentSelector, provider: ImplementationProvider): Disposable;
10937
10938 /**
10939 * Register a type definition provider.
10940 *
10941 * Multiple providers can be registered for a language. In that case providers are asked in
10942 * parallel and the results are merged. A failing provider (rejected promise or exception) will
10943 * not cause a failure of the whole operation.
10944 *
10945 * @param selector A selector that defines the documents this provider is applicable to.
10946 * @param provider A type definition provider.
10947 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
10948 */
10949 export function registerTypeDefinitionProvider(selector: DocumentSelector, provider: TypeDefinitionProvider): Disposable;
10950
10951 /**
10952 * Register a declaration provider.
10953 *
10954 * Multiple providers can be registered for a language. In that case providers are asked in
10955 * parallel and the results are merged. A failing provider (rejected promise or exception) will
10956 * not cause a failure of the whole operation.
10957 *
10958 * @param selector A selector that defines the documents this provider is applicable to.
10959 * @param provider A declaration provider.
10960 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
10961 */
10962 export function registerDeclarationProvider(selector: DocumentSelector, provider: DeclarationProvider): Disposable;
10963
10964 /**
10965 * Register a hover provider.
10966 *
10967 * Multiple providers can be registered for a language. In that case providers are asked in
10968 * parallel and the results are merged. A failing provider (rejected promise or exception) will
10969 * not cause a failure of the whole operation.
10970 *
10971 * @param selector A selector that defines the documents this provider is applicable to.
10972 * @param provider A hover provider.
10973 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
10974 */
10975 export function registerHoverProvider(selector: DocumentSelector, provider: HoverProvider): Disposable;
10976
10977 /**
10978 * Register a provider that locates evaluatable expressions in text documents.
10979 * VS Code will evaluate the expression in the active debug session and will show the result in the debug hover.
10980 *
10981 * If multiple providers are registered for a language an arbitrary provider will be used.
10982 *
10983 * @param selector A selector that defines the documents this provider is applicable to.
10984 * @param provider An evaluatable expression provider.
10985 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
10986 */
10987 export function registerEvaluatableExpressionProvider(selector: DocumentSelector, provider: EvaluatableExpressionProvider): Disposable;
10988
10989 /**
10990 * Register a provider that returns data for the debugger's 'inline value' feature.
10991 * Whenever the generic VS Code debugger has stopped in a source file, providers registered for the language of the file
10992 * are called to return textual data that will be shown in the editor at the end of lines.
10993 *
10994 * Multiple providers can be registered for a language. In that case providers are asked in
10995 * parallel and the results are merged. A failing provider (rejected promise or exception) will
10996 * not cause a failure of the whole operation.
10997 *
10998 * @param selector A selector that defines the documents this provider is applicable to.
10999 * @param provider An inline values provider.
11000 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11001 */
11002 export function registerInlineValuesProvider(selector: DocumentSelector, provider: InlineValuesProvider): Disposable;
11003
11004 /**
11005 * Register a document highlight provider.
11006 *
11007 * Multiple providers can be registered for a language. In that case providers are sorted
11008 * by their [score](#languages.match) and groups sequentially asked for document highlights.
11009 * The process stops when a provider returns a `non-falsy` or `non-failure` result.
11010 *
11011 * @param selector A selector that defines the documents this provider is applicable to.
11012 * @param provider A document highlight provider.
11013 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11014 */
11015 export function registerDocumentHighlightProvider(selector: DocumentSelector, provider: DocumentHighlightProvider): Disposable;
11016
11017 /**
11018 * Register a document symbol provider.
11019 *
11020 * Multiple providers can be registered for a language. In that case providers are asked in
11021 * parallel and the results are merged. A failing provider (rejected promise or exception) will
11022 * not cause a failure of the whole operation.
11023 *
11024 * @param selector A selector that defines the documents this provider is applicable to.
11025 * @param provider A document symbol provider.
11026 * @param metaData metadata about the provider
11027 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11028 */
11029 export function registerDocumentSymbolProvider(selector: DocumentSelector, provider: DocumentSymbolProvider, metaData?: DocumentSymbolProviderMetadata): Disposable;
11030
11031 /**
11032 * Register a workspace symbol provider.
11033 *
11034 * Multiple providers can be registered. In that case providers are asked in parallel and
11035 * the results are merged. A failing provider (rejected promise or exception) will not cause
11036 * a failure of the whole operation.
11037 *
11038 * @param provider A workspace symbol provider.
11039 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11040 */
11041 export function registerWorkspaceSymbolProvider(provider: WorkspaceSymbolProvider): Disposable;
11042
11043 /**
11044 * Register a reference provider.
11045 *
11046 * Multiple providers can be registered for a language. In that case providers are asked in
11047 * parallel and the results are merged. A failing provider (rejected promise or exception) will
11048 * not cause a failure of the whole operation.
11049 *
11050 * @param selector A selector that defines the documents this provider is applicable to.
11051 * @param provider A reference provider.
11052 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11053 */
11054 export function registerReferenceProvider(selector: DocumentSelector, provider: ReferenceProvider): Disposable;
11055
11056 /**
11057 * Register a rename provider.
11058 *
11059 * Multiple providers can be registered for a language. In that case providers are sorted
11060 * by their [score](#languages.match) and asked in sequence. The first provider producing a result
11061 * defines the result of the whole operation.
11062 *
11063 * @param selector A selector that defines the documents this provider is applicable to.
11064 * @param provider A rename provider.
11065 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11066 */
11067 export function registerRenameProvider(selector: DocumentSelector, provider: RenameProvider): Disposable;
11068
11069 /**
11070 * Register a semantic tokens provider for a whole document.
11071 *
11072 * Multiple providers can be registered for a language. In that case providers are sorted
11073 * by their [score](#languages.match) and the best-matching provider is used. Failure
11074 * of the selected provider will cause a failure of the whole operation.
11075 *
11076 * @param selector A selector that defines the documents this provider is applicable to.
11077 * @param provider A document semantic tokens provider.
11078 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11079 */
11080 export function registerDocumentSemanticTokensProvider(selector: DocumentSelector, provider: DocumentSemanticTokensProvider, legend: SemanticTokensLegend): Disposable;
11081
11082 /**
11083 * Register a semantic tokens provider for a document range.
11084 *
11085 * *Note:* If a document has both a `DocumentSemanticTokensProvider` and a `DocumentRangeSemanticTokensProvider`,
11086 * the range provider will be invoked only initially, for the time in which the full document provider takes
11087 * to resolve the first request. Once the full document provider resolves the first request, the semantic tokens
11088 * provided via the range provider will be discarded and from that point forward, only the document provider
11089 * will be used.
11090 *
11091 * Multiple providers can be registered for a language. In that case providers are sorted
11092 * by their [score](#languages.match) and the best-matching provider is used. Failure
11093 * of the selected provider will cause a failure of the whole operation.
11094 *
11095 * @param selector A selector that defines the documents this provider is applicable to.
11096 * @param provider A document range semantic tokens provider.
11097 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11098 */
11099 export function registerDocumentRangeSemanticTokensProvider(selector: DocumentSelector, provider: DocumentRangeSemanticTokensProvider, legend: SemanticTokensLegend): Disposable;
11100
11101 /**
11102 * Register a formatting provider for a document.
11103 *
11104 * Multiple providers can be registered for a language. In that case providers are sorted
11105 * by their [score](#languages.match) and the best-matching provider is used. Failure
11106 * of the selected provider will cause a failure of the whole operation.
11107 *
11108 * @param selector A selector that defines the documents this provider is applicable to.
11109 * @param provider A document formatting edit provider.
11110 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11111 */
11112 export function registerDocumentFormattingEditProvider(selector: DocumentSelector, provider: DocumentFormattingEditProvider): Disposable;
11113
11114 /**
11115 * Register a formatting provider for a document range.
11116 *
11117 * *Note:* A document range provider is also a [document formatter](#DocumentFormattingEditProvider)
11118 * which means there is no need to [register](#languages.registerDocumentFormattingEditProvider) a document
11119 * formatter when also registering a range provider.
11120 *
11121 * Multiple providers can be registered for a language. In that case providers are sorted
11122 * by their [score](#languages.match) and the best-matching provider is used. Failure
11123 * of the selected provider will cause a failure of the whole operation.
11124 *
11125 * @param selector A selector that defines the documents this provider is applicable to.
11126 * @param provider A document range formatting edit provider.
11127 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11128 */
11129 export function registerDocumentRangeFormattingEditProvider(selector: DocumentSelector, provider: DocumentRangeFormattingEditProvider): Disposable;
11130
11131 /**
11132 * Register a formatting provider that works on type. The provider is active when the user enables the setting `editor.formatOnType`.
11133 *
11134 * Multiple providers can be registered for a language. In that case providers are sorted
11135 * by their [score](#languages.match) and the best-matching provider is used. Failure
11136 * of the selected provider will cause a failure of the whole operation.
11137 *
11138 * @param selector A selector that defines the documents this provider is applicable to.
11139 * @param provider An on type formatting edit provider.
11140 * @param firstTriggerCharacter A character on which formatting should be triggered, like `}`.
11141 * @param moreTriggerCharacter More trigger characters.
11142 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11143 */
11144 export function registerOnTypeFormattingEditProvider(selector: DocumentSelector, provider: OnTypeFormattingEditProvider, firstTriggerCharacter: string, ...moreTriggerCharacter: string[]): Disposable;
11145
11146 /**
11147 * Register a signature help provider.
11148 *
11149 * Multiple providers can be registered for a language. In that case providers are sorted
11150 * by their [score](#languages.match) and called sequentially until a provider returns a
11151 * valid result.
11152 *
11153 * @param selector A selector that defines the documents this provider is applicable to.
11154 * @param provider A signature help provider.
11155 * @param triggerCharacters Trigger signature help when the user types one of the characters, like `,` or `(`.
11156 * @param metadata Information about the provider.
11157 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11158 */
11159 export function registerSignatureHelpProvider(selector: DocumentSelector, provider: SignatureHelpProvider, ...triggerCharacters: string[]): Disposable;
11160 export function registerSignatureHelpProvider(selector: DocumentSelector, provider: SignatureHelpProvider, metadata: SignatureHelpProviderMetadata): Disposable;
11161
11162 /**
11163 * Register a document link provider.
11164 *
11165 * Multiple providers can be registered for a language. In that case providers are asked in
11166 * parallel and the results are merged. A failing provider (rejected promise or exception) will
11167 * not cause a failure of the whole operation.
11168 *
11169 * @param selector A selector that defines the documents this provider is applicable to.
11170 * @param provider A document link provider.
11171 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11172 */
11173 export function registerDocumentLinkProvider(selector: DocumentSelector, provider: DocumentLinkProvider): Disposable;
11174
11175 /**
11176 * Register a color provider.
11177 *
11178 * Multiple providers can be registered for a language. In that case providers are asked in
11179 * parallel and the results are merged. A failing provider (rejected promise or exception) will
11180 * not cause a failure of the whole operation.
11181 *
11182 * @param selector A selector that defines the documents this provider is applicable to.
11183 * @param provider A color provider.
11184 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11185 */
11186 export function registerColorProvider(selector: DocumentSelector, provider: DocumentColorProvider): Disposable;
11187
11188 /**
11189 * Register a folding range provider.
11190 *
11191 * Multiple providers can be registered for a language. In that case providers are asked in
11192 * parallel and the results are merged.
11193 * If multiple folding ranges start at the same position, only the range of the first registered provider is used.
11194 * If a folding range overlaps with an other range that has a smaller position, it is also ignored.
11195 *
11196 * A failing provider (rejected promise or exception) will
11197 * not cause a failure of the whole operation.
11198 *
11199 * @param selector A selector that defines the documents this provider is applicable to.
11200 * @param provider A folding range provider.
11201 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11202 */
11203 export function registerFoldingRangeProvider(selector: DocumentSelector, provider: FoldingRangeProvider): Disposable;
11204
11205 /**
11206 * Register a selection range provider.
11207 *
11208 * Multiple providers can be registered for a language. In that case providers are asked in
11209 * parallel and the results are merged. A failing provider (rejected promise or exception) will
11210 * not cause a failure of the whole operation.
11211 *
11212 * @param selector A selector that defines the documents this provider is applicable to.
11213 * @param provider A selection range provider.
11214 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11215 */
11216 export function registerSelectionRangeProvider(selector: DocumentSelector, provider: SelectionRangeProvider): Disposable;
11217
11218 /**
11219 * Register a call hierarchy provider.
11220 *
11221 * @param selector A selector that defines the documents this provider is applicable to.
11222 * @param provider A call hierarchy provider.
11223 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11224 */
11225 export function registerCallHierarchyProvider(selector: DocumentSelector, provider: CallHierarchyProvider): Disposable;
11226
11227 /**
11228 * Register a linked editing range provider.
11229 *
11230 * Multiple providers can be registered for a language. In that case providers are sorted
11231 * by their [score](#languages.match) and the best-matching provider that has a result is used. Failure
11232 * of the selected provider will cause a failure of the whole operation.
11233 *
11234 * @param selector A selector that defines the documents this provider is applicable to.
11235 * @param provider A linked editing range provider.
11236 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
11237 */
11238 export function registerLinkedEditingRangeProvider(selector: DocumentSelector, provider: LinkedEditingRangeProvider): Disposable;
11239
11240 /**
11241 * Set a [language configuration](#LanguageConfiguration) for a language.
11242 *
11243 * @param language A language identifier like `typescript`.
11244 * @param configuration Language configuration.
11245 * @return A [disposable](#Disposable) that unsets this configuration.
11246 */
11247 export function setLanguageConfiguration(language: string, configuration: LanguageConfiguration): Disposable;
11248
11249 }
11250
11251 /**
11252 * Represents the input box in the Source Control viewlet.
11253 */
11254 export interface SourceControlInputBox {
11255
11256 /**
11257 * Setter and getter for the contents of the input box.
11258 */
11259 value: string;
11260
11261 /**
11262 * A string to show as placeholder in the input box to guide the user.
11263 */
11264 placeholder: string;
11265
11266 /**
11267 * Controls whether the input box is visible (default is `true`).
11268 */
11269 visible: boolean;
11270 }
11271
11272 interface QuickDiffProvider {
11273
11274 /**
11275 * Provide a [uri](#Uri) to the original resource of any given resource uri.
11276 *
11277 * @param uri The uri of the resource open in a text editor.
11278 * @param token A cancellation token.
11279 * @return A thenable that resolves to uri of the matching original resource.
11280 */
11281 provideOriginalResource?(uri: Uri, token: CancellationToken): ProviderResult<Uri>;
11282 }
11283
11284 /**
11285 * The theme-aware decorations for a
11286 * [source control resource state](#SourceControlResourceState).
11287 */
11288 export interface SourceControlResourceThemableDecorations {
11289
11290 /**
11291 * The icon path for a specific
11292 * [source control resource state](#SourceControlResourceState).
11293 */
11294 readonly iconPath?: string | Uri;
11295 }
11296
11297 /**
11298 * The decorations for a [source control resource state](#SourceControlResourceState).
11299 * Can be independently specified for light and dark themes.
11300 */
11301 export interface SourceControlResourceDecorations extends SourceControlResourceThemableDecorations {
11302
11303 /**
11304 * Whether the [source control resource state](#SourceControlResourceState) should
11305 * be striked-through in the UI.
11306 */
11307 readonly strikeThrough?: boolean;
11308
11309 /**
11310 * Whether the [source control resource state](#SourceControlResourceState) should
11311 * be faded in the UI.
11312 */
11313 readonly faded?: boolean;
11314
11315 /**
11316 * The title for a specific
11317 * [source control resource state](#SourceControlResourceState).
11318 */
11319 readonly tooltip?: string;
11320
11321 /**
11322 * The light theme decorations.
11323 */
11324 readonly light?: SourceControlResourceThemableDecorations;
11325
11326 /**
11327 * The dark theme decorations.
11328 */
11329 readonly dark?: SourceControlResourceThemableDecorations;
11330 }
11331
11332 /**
11333 * An source control resource state represents the state of an underlying workspace
11334 * resource within a certain [source control group](#SourceControlResourceGroup).
11335 */
11336 export interface SourceControlResourceState {
11337
11338 /**
11339 * The [uri](#Uri) of the underlying resource inside the workspace.
11340 */
11341 readonly resourceUri: Uri;
11342
11343 /**
11344 * The [command](#Command) which should be run when the resource
11345 * state is open in the Source Control viewlet.
11346 */
11347 readonly command?: Command;
11348
11349 /**
11350 * The [decorations](#SourceControlResourceDecorations) for this source control
11351 * resource state.
11352 */
11353 readonly decorations?: SourceControlResourceDecorations;
11354
11355 /**
11356 * Context value of the resource state. This can be used to contribute resource specific actions.
11357 * For example, if a resource is given a context value as `diffable`. When contributing actions to `scm/resourceState/context`
11358 * using `menus` extension point, you can specify context value for key `scmResourceState` in `when` expressions, like `scmResourceState == diffable`.
11359 * ```
11360 * "contributes": {
11361 * "menus": {
11362 * "scm/resourceState/context": [
11363 * {
11364 * "command": "extension.diff",
11365 * "when": "scmResourceState == diffable"
11366 * }
11367 * ]
11368 * }
11369 * }
11370 * ```
11371 * This will show action `extension.diff` only for resources with `contextValue` is `diffable`.
11372 */
11373 readonly contextValue?: string;
11374 }
11375
11376 /**
11377 * A source control resource group is a collection of
11378 * [source control resource states](#SourceControlResourceState).
11379 */
11380 export interface SourceControlResourceGroup {
11381
11382 /**
11383 * The id of this source control resource group.
11384 */
11385 readonly id: string;
11386
11387 /**
11388 * The label of this source control resource group.
11389 */
11390 label: string;
11391
11392 /**
11393 * Whether this source control resource group is hidden when it contains
11394 * no [source control resource states](#SourceControlResourceState).
11395 */
11396 hideWhenEmpty?: boolean;
11397
11398 /**
11399 * This group's collection of
11400 * [source control resource states](#SourceControlResourceState).
11401 */
11402 resourceStates: SourceControlResourceState[];
11403
11404 /**
11405 * Dispose this source control resource group.
11406 */
11407 dispose(): void;
11408 }
11409
11410 /**
11411 * An source control is able to provide [resource states](#SourceControlResourceState)
11412 * to the editor and interact with the editor in several source control related ways.
11413 */
11414 export interface SourceControl {
11415
11416 /**
11417 * The id of this source control.
11418 */
11419 readonly id: string;
11420
11421 /**
11422 * The human-readable label of this source control.
11423 */
11424 readonly label: string;
11425
11426 /**
11427 * The (optional) Uri of the root of this source control.
11428 */
11429 readonly rootUri: Uri | undefined;
11430
11431 /**
11432 * The [input box](#SourceControlInputBox) for this source control.
11433 */
11434 readonly inputBox: SourceControlInputBox;
11435
11436 /**
11437 * The UI-visible count of [resource states](#SourceControlResourceState) of
11438 * this source control.
11439 *
11440 * Equals to the total number of [resource state](#SourceControlResourceState)
11441 * of this source control, if undefined.
11442 */
11443 count?: number;
11444
11445 /**
11446 * An optional [quick diff provider](#QuickDiffProvider).
11447 */
11448 quickDiffProvider?: QuickDiffProvider;
11449
11450 /**
11451 * Optional commit template string.
11452 *
11453 * The Source Control viewlet will populate the Source Control
11454 * input with this value when appropriate.
11455 */
11456 commitTemplate?: string;
11457
11458 /**
11459 * Optional accept input command.
11460 *
11461 * This command will be invoked when the user accepts the value
11462 * in the Source Control input.
11463 */
11464 acceptInputCommand?: Command;
11465
11466 /**
11467 * Optional status bar commands.
11468 *
11469 * These commands will be displayed in the editor's status bar.
11470 */
11471 statusBarCommands?: Command[];
11472
11473 /**
11474 * Create a new [resource group](#SourceControlResourceGroup).
11475 */
11476 createResourceGroup(id: string, label: string): SourceControlResourceGroup;
11477
11478 /**
11479 * Dispose this source control.
11480 */
11481 dispose(): void;
11482 }
11483
11484 export namespace scm {
11485
11486 /**
11487 * The [input box](#SourceControlInputBox) for the last source control
11488 * created by the extension.
11489 *
11490 * @deprecated Use SourceControl.inputBox instead
11491 */
11492 export const inputBox: SourceControlInputBox;
11493
11494 /**
11495 * Creates a new [source control](#SourceControl) instance.
11496 *
11497 * @param id An `id` for the source control. Something short, e.g.: `git`.
11498 * @param label A human-readable string for the source control. E.g.: `Git`.
11499 * @param rootUri An optional Uri of the root of the source control. E.g.: `Uri.parse(workspaceRoot)`.
11500 * @return An instance of [source control](#SourceControl).
11501 */
11502 export function createSourceControl(id: string, label: string, rootUri?: Uri): SourceControl;
11503 }
11504
11505 /**
11506 * 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.
11507 */
11508 export interface DebugProtocolMessage {
11509 // Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Base_Protocol_ProtocolMessage).
11510 }
11511
11512 /**
11513 * 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.
11514 */
11515 export interface DebugProtocolSource {
11516 // Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Source).
11517 }
11518
11519 /**
11520 * 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.
11521 */
11522 export interface DebugProtocolBreakpoint {
11523 // Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Breakpoint).
11524 }
11525
11526 /**
11527 * Configuration for a debug session.
11528 */
11529 export interface DebugConfiguration {
11530 /**
11531 * The type of the debug session.
11532 */
11533 type: string;
11534
11535 /**
11536 * The name of the debug session.
11537 */
11538 name: string;
11539
11540 /**
11541 * The request type of the debug session.
11542 */
11543 request: string;
11544
11545 /**
11546 * Additional debug type specific properties.
11547 */
11548 [key: string]: any;
11549 }
11550
11551 /**
11552 * A debug session.
11553 */
11554 export interface DebugSession {
11555
11556 /**
11557 * The unique ID of this debug session.
11558 */
11559 readonly id: string;
11560
11561 /**
11562 * The debug session's type from the [debug configuration](#DebugConfiguration).
11563 */
11564 readonly type: string;
11565
11566 /**
11567 * The debug session's name is initially taken from the [debug configuration](#DebugConfiguration).
11568 * Any changes will be properly reflected in the UI.
11569 */
11570 name: string;
11571
11572 /**
11573 * The workspace folder of this session or `undefined` for a folderless setup.
11574 */
11575 readonly workspaceFolder: WorkspaceFolder | undefined;
11576
11577 /**
11578 * The "resolved" [debug configuration](#DebugConfiguration) of this session.
11579 * "Resolved" means that
11580 * - all variables have been substituted and
11581 * - platform specific attribute sections have been "flattened" for the matching platform and removed for non-matching platforms.
11582 */
11583 readonly configuration: DebugConfiguration;
11584
11585 /**
11586 * Send a custom request to the debug adapter.
11587 */
11588 customRequest(command: string, args?: any): Thenable<any>;
11589
11590 /**
11591 * Maps a VS Code breakpoint to the corresponding Debug Adapter Protocol (DAP) breakpoint that is managed by the debug adapter of the debug session.
11592 * If no DAP breakpoint exists (either because the VS Code breakpoint was not yet registered or because the debug adapter is not interested in the breakpoint), the value `undefined` is returned.
11593 *
11594 * @param breakpoint A VS Code [breakpoint](#Breakpoint).
11595 * @return A promise that resolves to the Debug Adapter Protocol breakpoint or `undefined`.
11596 */
11597 getDebugProtocolBreakpoint(breakpoint: Breakpoint): Thenable<DebugProtocolBreakpoint | undefined>;
11598 }
11599
11600 /**
11601 * A custom Debug Adapter Protocol event received from a [debug session](#DebugSession).
11602 */
11603 export interface DebugSessionCustomEvent {
11604 /**
11605 * The [debug session](#DebugSession) for which the custom event was received.
11606 */
11607 readonly session: DebugSession;
11608
11609 /**
11610 * Type of event.
11611 */
11612 readonly event: string;
11613
11614 /**
11615 * Event specific information.
11616 */
11617 readonly body?: any;
11618 }
11619
11620 /**
11621 * A debug configuration provider allows to add debug configurations to the debug service
11622 * and to resolve launch configurations before they are used to start a debug session.
11623 * A debug configuration provider is registered via #debug.registerDebugConfigurationProvider.
11624 */
11625 export interface DebugConfigurationProvider {
11626 /**
11627 * Provides [debug configuration](#DebugConfiguration) to the debug service. If more than one debug configuration provider is
11628 * registered for the same type, debug configurations are concatenated in arbitrary order.
11629 *
11630 * @param folder The workspace folder for which the configurations are used or `undefined` for a folderless setup.
11631 * @param token A cancellation token.
11632 * @return An array of [debug configurations](#DebugConfiguration).
11633 */
11634 provideDebugConfigurations?(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult<DebugConfiguration[]>;
11635
11636 /**
11637 * Resolves a [debug configuration](#DebugConfiguration) by filling in missing values or by adding/changing/removing attributes.
11638 * If more than one debug configuration provider is registered for the same type, the resolveDebugConfiguration calls are chained
11639 * in arbitrary order and the initial debug configuration is piped through the chain.
11640 * Returning the value 'undefined' prevents the debug session from starting.
11641 * Returning the value 'null' prevents the debug session from starting and opens the underlying debug configuration instead.
11642 *
11643 * @param folder The workspace folder from which the configuration originates from or `undefined` for a folderless setup.
11644 * @param debugConfiguration The [debug configuration](#DebugConfiguration) to resolve.
11645 * @param token A cancellation token.
11646 * @return The resolved debug configuration or undefined or null.
11647 */
11648 resolveDebugConfiguration?(folder: WorkspaceFolder | undefined, debugConfiguration: DebugConfiguration, token?: CancellationToken): ProviderResult<DebugConfiguration>;
11649
11650 /**
11651 * This hook is directly called after 'resolveDebugConfiguration' but with all variables substituted.
11652 * It can be used to resolve or verify a [debug configuration](#DebugConfiguration) by filling in missing values or by adding/changing/removing attributes.
11653 * If more than one debug configuration provider is registered for the same type, the 'resolveDebugConfigurationWithSubstitutedVariables' calls are chained
11654 * in arbitrary order and the initial debug configuration is piped through the chain.
11655 * Returning the value 'undefined' prevents the debug session from starting.
11656 * Returning the value 'null' prevents the debug session from starting and opens the underlying debug configuration instead.
11657 *
11658 * @param folder The workspace folder from which the configuration originates from or `undefined` for a folderless setup.
11659 * @param debugConfiguration The [debug configuration](#DebugConfiguration) to resolve.
11660 * @param token A cancellation token.
11661 * @return The resolved debug configuration or undefined or null.
11662 */
11663 resolveDebugConfigurationWithSubstitutedVariables?(folder: WorkspaceFolder | undefined, debugConfiguration: DebugConfiguration, token?: CancellationToken): ProviderResult<DebugConfiguration>;
11664 }
11665
11666 /**
11667 * Represents a debug adapter executable and optional arguments and runtime options passed to it.
11668 */
11669 export class DebugAdapterExecutable {
11670
11671 /**
11672 * Creates a description for a debug adapter based on an executable program.
11673 *
11674 * @param command The command or executable path that implements the debug adapter.
11675 * @param args Optional arguments to be passed to the command or executable.
11676 * @param options Optional options to be used when starting the command or executable.
11677 */
11678 constructor(command: string, args?: string[], options?: DebugAdapterExecutableOptions);
11679
11680 /**
11681 * The command or path of the debug adapter executable.
11682 * 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.
11683 * The special value 'node' will be mapped to VS Code's built-in Node.js runtime.
11684 */
11685 readonly command: string;
11686
11687 /**
11688 * The arguments passed to the debug adapter executable. Defaults to an empty array.
11689 */
11690 readonly args: string[];
11691
11692 /**
11693 * Optional options to be used when the debug adapter is started.
11694 * Defaults to undefined.
11695 */
11696 readonly options?: DebugAdapterExecutableOptions;
11697 }
11698
11699 /**
11700 * Options for a debug adapter executable.
11701 */
11702 export interface DebugAdapterExecutableOptions {
11703
11704 /**
11705 * The additional environment of the executed program or shell. If omitted
11706 * the parent process' environment is used. If provided it is merged with
11707 * the parent process' environment.
11708 */
11709 env?: { [key: string]: string };
11710
11711 /**
11712 * The current working directory for the executed debug adapter.
11713 */
11714 cwd?: string;
11715 }
11716
11717 /**
11718 * Represents a debug adapter running as a socket based server.
11719 */
11720 export class DebugAdapterServer {
11721
11722 /**
11723 * The port.
11724 */
11725 readonly port: number;
11726
11727 /**
11728 * The host.
11729 */
11730 readonly host?: string;
11731
11732 /**
11733 * Create a description for a debug adapter running as a socket based server.
11734 */
11735 constructor(port: number, host?: string);
11736 }
11737
11738 /**
11739 * Represents a debug adapter running as a Named Pipe (on Windows)/UNIX Domain Socket (on non-Windows) based server.
11740 */
11741 export class DebugAdapterNamedPipeServer {
11742 /**
11743 * The path to the NamedPipe/UNIX Domain Socket.
11744 */
11745 readonly path: string;
11746
11747 /**
11748 * Create a description for a debug adapter running as a Named Pipe (on Windows)/UNIX Domain Socket (on non-Windows) based server.
11749 */
11750 constructor(path: string);
11751 }
11752
11753 /**
11754 * A debug adapter that implements the Debug Adapter Protocol can be registered with VS Code if it implements the DebugAdapter interface.
11755 */
11756 export interface DebugAdapter extends Disposable {
11757
11758 /**
11759 * An event which fires after the debug adapter has sent a Debug Adapter Protocol message to VS Code.
11760 * Messages can be requests, responses, or events.
11761 */
11762 readonly onDidSendMessage: Event<DebugProtocolMessage>;
11763
11764 /**
11765 * Handle a Debug Adapter Protocol message.
11766 * Messages can be requests, responses, or events.
11767 * Results or errors are returned via onSendMessage events.
11768 * @param message A Debug Adapter Protocol message
11769 */
11770 handleMessage(message: DebugProtocolMessage): void;
11771 }
11772
11773 /**
11774 * A debug adapter descriptor for an inline implementation.
11775 */
11776 export class DebugAdapterInlineImplementation {
11777
11778 /**
11779 * Create a descriptor for an inline implementation of a debug adapter.
11780 */
11781 constructor(implementation: DebugAdapter);
11782 }
11783
11784 export type DebugAdapterDescriptor = DebugAdapterExecutable | DebugAdapterServer | DebugAdapterNamedPipeServer | DebugAdapterInlineImplementation;
11785
11786 export interface DebugAdapterDescriptorFactory {
11787 /**
11788 * 'createDebugAdapterDescriptor' is called at the start of a debug session to provide details about the debug adapter to use.
11789 * These details must be returned as objects of type [DebugAdapterDescriptor](#DebugAdapterDescriptor).
11790 * Currently two types of debug adapters are supported:
11791 * - a debug adapter executable is specified as a command path and arguments (see [DebugAdapterExecutable](#DebugAdapterExecutable)),
11792 * - a debug adapter server reachable via a communication port (see [DebugAdapterServer](#DebugAdapterServer)).
11793 * If the method is not implemented the default behavior is this:
11794 * createDebugAdapter(session: DebugSession, executable: DebugAdapterExecutable) {
11795 * if (typeof session.configuration.debugServer === 'number') {
11796 * return new DebugAdapterServer(session.configuration.debugServer);
11797 * }
11798 * return executable;
11799 * }
11800 * @param session The [debug session](#DebugSession) for which the debug adapter will be used.
11801 * @param executable The debug adapter's executable information as specified in the package.json (or undefined if no such information exists).
11802 * @return a [debug adapter descriptor](#DebugAdapterDescriptor) or undefined.
11803 */
11804 createDebugAdapterDescriptor(session: DebugSession, executable: DebugAdapterExecutable | undefined): ProviderResult<DebugAdapterDescriptor>;
11805 }
11806
11807 /**
11808 * A Debug Adapter Tracker is a means to track the communication between VS Code and a Debug Adapter.
11809 */
11810 export interface DebugAdapterTracker {
11811 /**
11812 * A session with the debug adapter is about to be started.
11813 */
11814 onWillStartSession?(): void;
11815 /**
11816 * The debug adapter is about to receive a Debug Adapter Protocol message from VS Code.
11817 */
11818 onWillReceiveMessage?(message: any): void;
11819 /**
11820 * The debug adapter has sent a Debug Adapter Protocol message to VS Code.
11821 */
11822 onDidSendMessage?(message: any): void;
11823 /**
11824 * The debug adapter session is about to be stopped.
11825 */
11826 onWillStopSession?(): void;
11827 /**
11828 * An error with the debug adapter has occurred.
11829 */
11830 onError?(error: Error): void;
11831 /**
11832 * The debug adapter has exited with the given exit code or signal.
11833 */
11834 onExit?(code: number | undefined, signal: string | undefined): void;
11835 }
11836
11837 export interface DebugAdapterTrackerFactory {
11838 /**
11839 * The method 'createDebugAdapterTracker' is called at the start of a debug session in order
11840 * to return a "tracker" object that provides read-access to the communication between VS Code and a debug adapter.
11841 *
11842 * @param session The [debug session](#DebugSession) for which the debug adapter tracker will be used.
11843 * @return A [debug adapter tracker](#DebugAdapterTracker) or undefined.
11844 */
11845 createDebugAdapterTracker(session: DebugSession): ProviderResult<DebugAdapterTracker>;
11846 }
11847
11848 /**
11849 * Represents the debug console.
11850 */
11851 export interface DebugConsole {
11852 /**
11853 * Append the given value to the debug console.
11854 *
11855 * @param value A string, falsy values will not be printed.
11856 */
11857 append(value: string): void;
11858
11859 /**
11860 * Append the given value and a line feed character
11861 * to the debug console.
11862 *
11863 * @param value A string, falsy values will be printed.
11864 */
11865 appendLine(value: string): void;
11866 }
11867
11868 /**
11869 * An event describing the changes to the set of [breakpoints](#Breakpoint).
11870 */
11871 export interface BreakpointsChangeEvent {
11872 /**
11873 * Added breakpoints.
11874 */
11875 readonly added: ReadonlyArray<Breakpoint>;
11876
11877 /**
11878 * Removed breakpoints.
11879 */
11880 readonly removed: ReadonlyArray<Breakpoint>;
11881
11882 /**
11883 * Changed breakpoints.
11884 */
11885 readonly changed: ReadonlyArray<Breakpoint>;
11886 }
11887
11888 /**
11889 * The base class of all breakpoint types.
11890 */
11891 export class Breakpoint {
11892 /**
11893 * The unique ID of the breakpoint.
11894 */
11895 readonly id: string;
11896 /**
11897 * Is breakpoint enabled.
11898 */
11899 readonly enabled: boolean;
11900 /**
11901 * An optional expression for conditional breakpoints.
11902 */
11903 readonly condition?: string;
11904 /**
11905 * An optional expression that controls how many hits of the breakpoint are ignored.
11906 */
11907 readonly hitCondition?: string;
11908 /**
11909 * An optional message that gets logged when this breakpoint is hit. Embedded expressions within {} are interpolated by the debug adapter.
11910 */
11911 readonly logMessage?: string;
11912
11913 protected constructor(enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string);
11914 }
11915
11916 /**
11917 * A breakpoint specified by a source location.
11918 */
11919 export class SourceBreakpoint extends Breakpoint {
11920 /**
11921 * The source and line position of this breakpoint.
11922 */
11923 readonly location: Location;
11924
11925 /**
11926 * Create a new breakpoint for a source location.
11927 */
11928 constructor(location: Location, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string);
11929 }
11930
11931 /**
11932 * A breakpoint specified by a function name.
11933 */
11934 export class FunctionBreakpoint extends Breakpoint {
11935 /**
11936 * The name of the function to which this breakpoint is attached.
11937 */
11938 readonly functionName: string;
11939
11940 /**
11941 * Create a new function breakpoint.
11942 */
11943 constructor(functionName: string, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string);
11944 }
11945
11946 /**
11947 * Debug console mode used by debug session, see [options](#DebugSessionOptions).
11948 */
11949 export enum DebugConsoleMode {
11950 /**
11951 * Debug session should have a separate debug console.
11952 */
11953 Separate = 0,
11954
11955 /**
11956 * Debug session should share debug console with its parent session.
11957 * This value has no effect for sessions which do not have a parent session.
11958 */
11959 MergeWithParent = 1
11960 }
11961
11962 /**
11963 * Options for [starting a debug session](#debug.startDebugging).
11964 */
11965 export interface DebugSessionOptions {
11966
11967 /**
11968 * When specified the newly created debug session is registered as a "child" session of this
11969 * "parent" debug session.
11970 */
11971 parentSession?: DebugSession;
11972
11973 /**
11974 * Controls whether this session should have a separate debug console or share it
11975 * with the parent session. Has no effect for sessions which do not have a parent session.
11976 * Defaults to Separate.
11977 */
11978 consoleMode?: DebugConsoleMode;
11979
11980 /**
11981 * Controls whether this session should run without debugging, thus ignoring breakpoints.
11982 * When this property is not specified, the value from the parent session (if there is one) is used.
11983 */
11984 noDebug?: boolean;
11985
11986 /**
11987 * Controls if the debug session's parent session is shown in the CALL STACK view even if it has only a single child.
11988 * By default, the debug session will never hide its parent.
11989 * If compact is true, debug sessions with a single child are hidden in the CALL STACK view to make the tree more compact.
11990 */
11991 compact?: boolean;
11992 }
11993
11994 /**
11995 * A DebugConfigurationProviderTriggerKind specifies when the `provideDebugConfigurations` method of a `DebugConfigurationProvider` is triggered.
11996 * Currently there are two situations: to provide the initial debug configurations for a newly created launch.json or
11997 * to provide dynamically generated debug configurations when the user asks for them through the UI (e.g. via the "Select and Start Debugging" command).
11998 * A trigger kind is used when registering a `DebugConfigurationProvider` with #debug.registerDebugConfigurationProvider.
11999 */
12000 export enum DebugConfigurationProviderTriggerKind {
12001 /**
12002 * `DebugConfigurationProvider.provideDebugConfigurations` is called to provide the initial debug configurations for a newly created launch.json.
12003 */
12004 Initial = 1,
12005 /**
12006 * `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).
12007 */
12008 Dynamic = 2
12009 }
12010
12011 /**
12012 * Namespace for debug functionality.
12013 */
12014 export namespace debug {
12015
12016 /**
12017 * The currently active [debug session](#DebugSession) or `undefined`. The active debug session is the one
12018 * represented by the debug action floating window or the one currently shown in the drop down menu of the debug action floating window.
12019 * If no debug session is active, the value is `undefined`.
12020 */
12021 export let activeDebugSession: DebugSession | undefined;
12022
12023 /**
12024 * The currently active [debug console](#DebugConsole).
12025 * If no debug session is active, output sent to the debug console is not shown.
12026 */
12027 export let activeDebugConsole: DebugConsole;
12028
12029 /**
12030 * List of breakpoints.
12031 */
12032 export let breakpoints: Breakpoint[];
12033
12034 /**
12035 * An [event](#Event) which fires when the [active debug session](#debug.activeDebugSession)
12036 * has changed. *Note* that the event also fires when the active debug session changes
12037 * to `undefined`.
12038 */
12039 export const onDidChangeActiveDebugSession: Event<DebugSession | undefined>;
12040
12041 /**
12042 * An [event](#Event) which fires when a new [debug session](#DebugSession) has been started.
12043 */
12044 export const onDidStartDebugSession: Event<DebugSession>;
12045
12046 /**
12047 * An [event](#Event) which fires when a custom DAP event is received from the [debug session](#DebugSession).
12048 */
12049 export const onDidReceiveDebugSessionCustomEvent: Event<DebugSessionCustomEvent>;
12050
12051 /**
12052 * An [event](#Event) which fires when a [debug session](#DebugSession) has terminated.
12053 */
12054 export const onDidTerminateDebugSession: Event<DebugSession>;
12055
12056 /**
12057 * An [event](#Event) that is emitted when the set of breakpoints is added, removed, or changed.
12058 */
12059 export const onDidChangeBreakpoints: Event<BreakpointsChangeEvent>;
12060
12061 /**
12062 * Register a [debug configuration provider](#DebugConfigurationProvider) for a specific debug type.
12063 * The optional [triggerKind](#DebugConfigurationProviderTriggerKind) can be used to specify when the `provideDebugConfigurations` method of the provider is triggered.
12064 * 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.
12065 * 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).
12066 * Please note that the `triggerKind` argument only applies to the `provideDebugConfigurations` method: so the `resolveDebugConfiguration` methods are not affected at all.
12067 * Registering a single provider with resolve methods for different trigger kinds, results in the same resolve methods called multiple times.
12068 * More than one provider can be registered for the same type.
12069 *
12070 * @param type The debug type for which the provider is registered.
12071 * @param provider The [debug configuration provider](#DebugConfigurationProvider) to register.
12072 * @param triggerKind The [trigger](#DebugConfigurationProviderTrigger) for which the 'provideDebugConfiguration' method of the provider is registered. If `triggerKind` is missing, the value `DebugConfigurationProviderTriggerKind.Initial` is assumed.
12073 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
12074 */
12075 export function registerDebugConfigurationProvider(debugType: string, provider: DebugConfigurationProvider, triggerKind?: DebugConfigurationProviderTriggerKind): Disposable;
12076
12077 /**
12078 * Register a [debug adapter descriptor factory](#DebugAdapterDescriptorFactory) for a specific debug type.
12079 * An extension is only allowed to register a DebugAdapterDescriptorFactory for the debug type(s) defined by the extension. Otherwise an error is thrown.
12080 * Registering more than one DebugAdapterDescriptorFactory for a debug type results in an error.
12081 *
12082 * @param debugType The debug type for which the factory is registered.
12083 * @param factory The [debug adapter descriptor factory](#DebugAdapterDescriptorFactory) to register.
12084 * @return A [disposable](#Disposable) that unregisters this factory when being disposed.
12085 */
12086 export function registerDebugAdapterDescriptorFactory(debugType: string, factory: DebugAdapterDescriptorFactory): Disposable;
12087
12088 /**
12089 * Register a debug adapter tracker factory for the given debug type.
12090 *
12091 * @param debugType The debug type for which the factory is registered or '*' for matching all debug types.
12092 * @param factory The [debug adapter tracker factory](#DebugAdapterTrackerFactory) to register.
12093 * @return A [disposable](#Disposable) that unregisters this factory when being disposed.
12094 */
12095 export function registerDebugAdapterTrackerFactory(debugType: string, factory: DebugAdapterTrackerFactory): Disposable;
12096
12097 /**
12098 * Start debugging by using either a named launch or named compound configuration,
12099 * or by directly passing a [DebugConfiguration](#DebugConfiguration).
12100 * The named configurations are looked up in '.vscode/launch.json' found in the given folder.
12101 * Before debugging starts, all unsaved files are saved and the launch configurations are brought up-to-date.
12102 * Folder specific variables used in the configuration (e.g. '${workspaceFolder}') are resolved against the given folder.
12103 * @param folder The [workspace folder](#WorkspaceFolder) for looking up named configurations and resolving variables or `undefined` for a non-folder setup.
12104 * @param nameOrConfiguration Either the name of a debug or compound configuration or a [DebugConfiguration](#DebugConfiguration) object.
12105 * @param parentSessionOrOptions Debug session options. When passed a parent [debug session](#DebugSession), assumes options with just this parent session.
12106 * @return A thenable that resolves when debugging could be successfully started.
12107 */
12108 export function startDebugging(folder: WorkspaceFolder | undefined, nameOrConfiguration: string | DebugConfiguration, parentSessionOrOptions?: DebugSession | DebugSessionOptions): Thenable<boolean>;
12109
12110 /**
12111 * Stop the given debug session or stop all debug sessions if session is omitted.
12112 * @param session The [debug session](#DebugSession) to stop; if omitted all sessions are stopped.
12113 */
12114 export function stopDebugging(session?: DebugSession): Thenable<void>;
12115
12116 /**
12117 * Add breakpoints.
12118 * @param breakpoints The breakpoints to add.
12119 */
12120 export function addBreakpoints(breakpoints: Breakpoint[]): void;
12121
12122 /**
12123 * Remove breakpoints.
12124 * @param breakpoints The breakpoints to remove.
12125 */
12126 export function removeBreakpoints(breakpoints: Breakpoint[]): void;
12127
12128 /**
12129 * Converts a "Source" descriptor object received via the Debug Adapter Protocol into a Uri that can be used to load its contents.
12130 * If the source descriptor is based on a path, a file Uri is returned.
12131 * If the source descriptor uses a reference number, a specific debug Uri (scheme 'debug') is constructed that requires a corresponding VS Code ContentProvider and a running debug session
12132 *
12133 * If the "Source" descriptor has insufficient information for creating the Uri, an error is thrown.
12134 *
12135 * @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.
12136 * @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.
12137 * @return A uri that can be used to load the contents of the source.
12138 */
12139 export function asDebugSourceUri(source: DebugProtocolSource, session?: DebugSession): Uri;
12140 }
12141
12142 /**
12143 * Namespace for dealing with installed extensions. Extensions are represented
12144 * by an [extension](#Extension)-interface which enables reflection on them.
12145 *
12146 * Extension writers can provide APIs to other extensions by returning their API public
12147 * surface from the `activate`-call.
12148 *
12149 * ```javascript
12150 * export function activate(context: vscode.ExtensionContext) {
12151 * let api = {
12152 * sum(a, b) {
12153 * return a + b;
12154 * },
12155 * mul(a, b) {
12156 * return a * b;
12157 * }
12158 * };
12159 * // 'export' public api-surface
12160 * return api;
12161 * }
12162 * ```
12163 * When depending on the API of another extension add an `extensionDependencies`-entry
12164 * to `package.json`, and use the [getExtension](#extensions.getExtension)-function
12165 * and the [exports](#Extension.exports)-property, like below:
12166 *
12167 * ```javascript
12168 * let mathExt = extensions.getExtension('genius.math');
12169 * let importedApi = mathExt.exports;
12170 *
12171 * console.log(importedApi.mul(42, 1));
12172 * ```
12173 */
12174 export namespace extensions {
12175
12176 /**
12177 * Get an extension by its full identifier in the form of: `publisher.name`.
12178 *
12179 * @param extensionId An extension identifier.
12180 * @return An extension or `undefined`.
12181 */
12182 export function getExtension(extensionId: string): Extension<any> | undefined;
12183
12184 /**
12185 * Get an extension by its full identifier in the form of: `publisher.name`.
12186 *
12187 * @param extensionId An extension identifier.
12188 * @return An extension or `undefined`.
12189 */
12190 export function getExtension<T>(extensionId: string): Extension<T> | undefined;
12191
12192 /**
12193 * All extensions currently known to the system.
12194 */
12195 export const all: ReadonlyArray<Extension<any>>;
12196
12197 /**
12198 * An event which fires when `extensions.all` changes. This can happen when extensions are
12199 * installed, uninstalled, enabled or disabled.
12200 */
12201 export const onDidChange: Event<void>;
12202 }
12203
12204 /**
12205 * Collapsible state of a [comment thread](#CommentThread)
12206 */
12207 export enum CommentThreadCollapsibleState {
12208 /**
12209 * Determines an item is collapsed
12210 */
12211 Collapsed = 0,
12212
12213 /**
12214 * Determines an item is expanded
12215 */
12216 Expanded = 1
12217 }
12218
12219 /**
12220 * Comment mode of a [comment](#Comment)
12221 */
12222 export enum CommentMode {
12223 /**
12224 * Displays the comment editor
12225 */
12226 Editing = 0,
12227
12228 /**
12229 * Displays the preview of the comment
12230 */
12231 Preview = 1
12232 }
12233
12234 /**
12235 * A collection of [comments](#Comment) representing a conversation at a particular range in a document.
12236 */
12237 export interface CommentThread {
12238 /**
12239 * The uri of the document the thread has been created on.
12240 */
12241 readonly uri: Uri;
12242
12243 /**
12244 * The range the comment thread is located within the document. The thread icon will be shown
12245 * at the first line of the range.
12246 */
12247 range: Range;
12248
12249 /**
12250 * The ordered comments of the thread.
12251 */
12252 comments: ReadonlyArray<Comment>;
12253
12254 /**
12255 * Whether the thread should be collapsed or expanded when opening the document.
12256 * Defaults to Collapsed.
12257 */
12258 collapsibleState: CommentThreadCollapsibleState;
12259
12260 /**
12261 * Whether the thread supports reply.
12262 * Defaults to true.
12263 */
12264 canReply: boolean;
12265
12266 /**
12267 * Context value of the comment thread. This can be used to contribute thread specific actions.
12268 * For example, a comment thread is given a context value as `editable`. When contributing actions to `comments/commentThread/title`
12269 * using `menus` extension point, you can specify context value for key `commentThread` in `when` expression like `commentThread == editable`.
12270 * ```
12271 * "contributes": {
12272 * "menus": {
12273 * "comments/commentThread/title": [
12274 * {
12275 * "command": "extension.deleteCommentThread",
12276 * "when": "commentThread == editable"
12277 * }
12278 * ]
12279 * }
12280 * }
12281 * ```
12282 * This will show action `extension.deleteCommentThread` only for comment threads with `contextValue` is `editable`.
12283 */
12284 contextValue?: string;
12285
12286 /**
12287 * The optional human-readable label describing the [Comment Thread](#CommentThread)
12288 */
12289 label?: string;
12290
12291 /**
12292 * Dispose this comment thread.
12293 *
12294 * Once disposed, this comment thread will be removed from visible editors and Comment Panel when appropriate.
12295 */
12296 dispose(): void;
12297 }
12298
12299 /**
12300 * Author information of a [comment](#Comment)
12301 */
12302 export interface CommentAuthorInformation {
12303 /**
12304 * The display name of the author of the comment
12305 */
12306 name: string;
12307
12308 /**
12309 * The optional icon path for the author
12310 */
12311 iconPath?: Uri;
12312 }
12313
12314 /**
12315 * Reactions of a [comment](#Comment)
12316 */
12317 export interface CommentReaction {
12318 /**
12319 * The human-readable label for the reaction
12320 */
12321 readonly label: string;
12322
12323 /**
12324 * Icon for the reaction shown in UI.
12325 */
12326 readonly iconPath: string | Uri;
12327
12328 /**
12329 * The number of users who have reacted to this reaction
12330 */
12331 readonly count: number;
12332
12333 /**
12334 * Whether the [author](CommentAuthorInformation) of the comment has reacted to this reaction
12335 */
12336 readonly authorHasReacted: boolean;
12337 }
12338
12339 /**
12340 * A comment is displayed within the editor or the Comments Panel, depending on how it is provided.
12341 */
12342 export interface Comment {
12343 /**
12344 * The human-readable comment body
12345 */
12346 body: string | MarkdownString;
12347
12348 /**
12349 * [Comment mode](#CommentMode) of the comment
12350 */
12351 mode: CommentMode;
12352
12353 /**
12354 * The [author information](#CommentAuthorInformation) of the comment
12355 */
12356 author: CommentAuthorInformation;
12357
12358 /**
12359 * Context value of the comment. This can be used to contribute comment specific actions.
12360 * For example, a comment is given a context value as `editable`. When contributing actions to `comments/comment/title`
12361 * using `menus` extension point, you can specify context value for key `comment` in `when` expression like `comment == editable`.
12362 * ```json
12363 * "contributes": {
12364 * "menus": {
12365 * "comments/comment/title": [
12366 * {
12367 * "command": "extension.deleteComment",
12368 * "when": "comment == editable"
12369 * }
12370 * ]
12371 * }
12372 * }
12373 * ```
12374 * This will show action `extension.deleteComment` only for comments with `contextValue` is `editable`.
12375 */
12376 contextValue?: string;
12377
12378 /**
12379 * Optional reactions of the [comment](#Comment)
12380 */
12381 reactions?: CommentReaction[];
12382
12383 /**
12384 * Optional label describing the [Comment](#Comment)
12385 * Label will be rendered next to authorName if exists.
12386 */
12387 label?: string;
12388 }
12389
12390 /**
12391 * Command argument for actions registered in `comments/commentThread/context`.
12392 */
12393 export interface CommentReply {
12394 /**
12395 * The active [comment thread](#CommentThread)
12396 */
12397 thread: CommentThread;
12398
12399 /**
12400 * The value in the comment editor
12401 */
12402 text: string;
12403 }
12404
12405 /**
12406 * Commenting range provider for a [comment controller](#CommentController).
12407 */
12408 export interface CommentingRangeProvider {
12409 /**
12410 * Provide a list of ranges which allow new comment threads creation or null for a given document
12411 */
12412 provideCommentingRanges(document: TextDocument, token: CancellationToken): ProviderResult<Range[]>;
12413 }
12414
12415 /**
12416 * Represents a [comment controller](#CommentController)'s [options](#CommentController.options).
12417 */
12418 export interface CommentOptions {
12419 /**
12420 * An optional string to show on the comment input box when it's collapsed.
12421 */
12422 prompt?: string;
12423
12424 /**
12425 * An optional string to show as placeholder in the comment input box when it's focused.
12426 */
12427 placeHolder?: string;
12428 }
12429
12430 /**
12431 * A comment controller is able to provide [comments](#CommentThread) support to the editor and
12432 * provide users various ways to interact with comments.
12433 */
12434 export interface CommentController {
12435 /**
12436 * The id of this comment controller.
12437 */
12438 readonly id: string;
12439
12440 /**
12441 * The human-readable label of this comment controller.
12442 */
12443 readonly label: string;
12444
12445 /**
12446 * Comment controller options
12447 */
12448 options?: CommentOptions;
12449
12450 /**
12451 * Optional commenting range provider. Provide a list [ranges](#Range) which support commenting to any given resource uri.
12452 *
12453 * If not provided, users can leave comments in any document opened in the editor.
12454 */
12455 commentingRangeProvider?: CommentingRangeProvider;
12456
12457 /**
12458 * Create a [comment thread](#CommentThread). The comment thread will be displayed in visible text editors (if the resource matches)
12459 * and Comments Panel once created.
12460 *
12461 * @param uri The uri of the document the thread has been created on.
12462 * @param range The range the comment thread is located within the document.
12463 * @param comments The ordered comments of the thread.
12464 */
12465 createCommentThread(uri: Uri, range: Range, comments: Comment[]): CommentThread;
12466
12467 /**
12468 * Optional reaction handler for creating and deleting reactions on a [comment](#Comment).
12469 */
12470 reactionHandler?: (comment: Comment, reaction: CommentReaction) => Thenable<void>;
12471
12472 /**
12473 * Dispose this comment controller.
12474 *
12475 * Once disposed, all [comment threads](#CommentThread) created by this comment controller will also be removed from the editor
12476 * and Comments Panel.
12477 */
12478 dispose(): void;
12479 }
12480
12481 namespace comments {
12482 /**
12483 * Creates a new [comment controller](#CommentController) instance.
12484 *
12485 * @param id An `id` for the comment controller.
12486 * @param label A human-readable string for the comment controller.
12487 * @return An instance of [comment controller](#CommentController).
12488 */
12489 export function createCommentController(id: string, label: string): CommentController;
12490 }
12491
12492 //#endregion
12493
12494 /**
12495 * Represents a session of a currently logged in user.
12496 */
12497 export interface AuthenticationSession {
12498 /**
12499 * The identifier of the authentication session.
12500 */
12501 readonly id: string;
12502
12503 /**
12504 * The access token.
12505 */
12506 readonly accessToken: string;
12507
12508 /**
12509 * The account associated with the session.
12510 */
12511 readonly account: AuthenticationSessionAccountInformation;
12512
12513 /**
12514 * The permissions granted by the session's access token. Available scopes
12515 * are defined by the [AuthenticationProvider](#AuthenticationProvider).
12516 */
12517 readonly scopes: ReadonlyArray<string>;
12518 }
12519
12520 /**
12521 * The information of an account associated with an [AuthenticationSession](#AuthenticationSession).
12522 */
12523 export interface AuthenticationSessionAccountInformation {
12524 /**
12525 * The unique identifier of the account.
12526 */
12527 readonly id: string;
12528
12529 /**
12530 * The human-readable name of the account.
12531 */
12532 readonly label: string;
12533 }
12534
12535
12536 /**
12537 * Options to be used when getting an [AuthenticationSession](#AuthenticationSession) from an [AuthenticationProvider](#AuthenticationProvider).
12538 */
12539 export interface AuthenticationGetSessionOptions {
12540 /**
12541 * Whether login should be performed if there is no matching session.
12542 *
12543 * If true, a modal dialog will be shown asking the user to sign in. If false, a numbered badge will be shown
12544 * on the accounts activity bar icon. An entry for the extension will be added under the menu to sign in. This
12545 * allows quietly prompting the user to sign in.
12546 *
12547 * If there is a matching session but the extension has not been granted access to it, setting this to true
12548 * will also result in an immediate modal dialog, and false will add a numbered badge to the accounts icon.
12549 *
12550 * Defaults to false.
12551 */
12552 createIfNone?: boolean;
12553
12554 /**
12555 * Whether the existing user session preference should be cleared.
12556 *
12557 * For authentication providers that support being signed into multiple accounts at once, the user will be
12558 * prompted to select an account to use when [getSession](#authentication.getSession) is called. This preference
12559 * is remembered until [getSession](#authentication.getSession) is called with this flag.
12560 *
12561 * Defaults to false.
12562 */
12563 clearSessionPreference?: boolean;
12564 }
12565
12566 /**
12567 * Basic information about an [authenticationProvider](#AuthenticationProvider)
12568 */
12569 export interface AuthenticationProviderInformation {
12570 /**
12571 * The unique identifier of the authentication provider.
12572 */
12573 readonly id: string;
12574
12575 /**
12576 * The human-readable name of the authentication provider.
12577 */
12578 readonly label: string;
12579 }
12580
12581 /**
12582 * An [event](#Event) which fires when an [AuthenticationSession](#AuthenticationSession) is added, removed, or changed.
12583 */
12584 export interface AuthenticationSessionsChangeEvent {
12585 /**
12586 * The [authenticationProvider](#AuthenticationProvider) that has had its sessions change.
12587 */
12588 readonly provider: AuthenticationProviderInformation;
12589 }
12590
12591 /**
12592 * Options for creating an [AuthenticationProvider](#AuthenticationProvider).
12593 */
12594 export interface AuthenticationProviderOptions {
12595 /**
12596 * Whether it is possible to be signed into multiple accounts at once with this provider.
12597 * If not specified, will default to false.
12598 */
12599 readonly supportsMultipleAccounts?: boolean;
12600 }
12601
12602 /**
12603 * An [event](#Event) which fires when an [AuthenticationSession](#AuthenticationSession) is added, removed, or changed.
12604 */
12605 export interface AuthenticationProviderAuthenticationSessionsChangeEvent {
12606 /**
12607 * The [AuthenticationSession](#AuthenticationSession)s of the [AuthenticationProvider](#AuthentiationProvider) that have been added.
12608 */
12609 readonly added?: ReadonlyArray<AuthenticationSession>;
12610
12611 /**
12612 * The [AuthenticationSession](#AuthenticationSession)s of the [AuthenticationProvider](#AuthentiationProvider) that have been removed.
12613 */
12614 readonly removed?: ReadonlyArray<AuthenticationSession>;
12615
12616 /**
12617 * The [AuthenticationSession](#AuthenticationSession)s of the [AuthenticationProvider](#AuthentiationProvider) that have been changed.
12618 * A session changes when its data excluding the id are updated. An example of this is a session refresh that results in a new
12619 * access token being set for the session.
12620 */
12621 readonly changed?: ReadonlyArray<AuthenticationSession>;
12622 }
12623
12624 /**
12625 * A provider for performing authentication to a service.
12626 */
12627 export interface AuthenticationProvider {
12628 /**
12629 * An [event](#Event) which fires when the array of sessions has changed, or data
12630 * within a session has changed.
12631 */
12632 readonly onDidChangeSessions: Event<AuthenticationProviderAuthenticationSessionsChangeEvent>;
12633
12634 /**
12635 * Get a list of sessions.
12636 * @param scopes An optional list of scopes. If provided, the sessions returned should match
12637 * these permissions, otherwise all sessions should be returned.
12638 * @returns A promise that resolves to an array of authentication sessions.
12639 */
12640 getSessions(scopes?: string[]): Thenable<ReadonlyArray<AuthenticationSession>>;
12641
12642 /**
12643 * Prompts a user to login.
12644 *
12645 * If login is successful, the onDidChangeSessions event should be fired.
12646 *
12647 * If login fails, a rejected promise should be returned.
12648 *
12649 * If the provider has specified that it does not support multiple accounts,
12650 * then this should never be called if there is already an existing session matching these
12651 * scopes.
12652 * @param scopes A list of scopes, permissions, that the new session should be created with.
12653 * @returns A promise that resolves to an authentication session.
12654 */
12655 createSession(scopes: string[]): Thenable<AuthenticationSession>;
12656
12657 /**
12658 * Removes the session corresponding to session id.
12659 *
12660 * If the removal is successful, the onDidChangeSessions event should be fired.
12661 *
12662 * If a session cannot be removed, the provider should reject with an error message.
12663 * @param sessionId The id of the session to remove.
12664 */
12665 removeSession(sessionId: string): Thenable<void>;
12666 }
12667
12668
12669 /**
12670 * Namespace for authentication.
12671 */
12672 export namespace authentication {
12673 /**
12674 * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
12675 * registered, or if the user does not consent to sharing authentication information with
12676 * the extension. If there are multiple sessions with the same scopes, the user will be shown a
12677 * quickpick to select which account they would like to use.
12678 *
12679 * Currently, there are only two authentication providers that are contributed from built in extensions
12680 * to VS Code that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
12681 * @param providerId The id of the provider to use
12682 * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
12683 * @param options The [getSessionOptions](#GetSessionOptions) to use
12684 * @returns A thenable that resolves to an authentication session
12685 */
12686 export function getSession(providerId: string, scopes: string[], options: AuthenticationGetSessionOptions & { createIfNone: true }): Thenable<AuthenticationSession>;
12687
12688 /**
12689 * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
12690 * registered, or if the user does not consent to sharing authentication information with
12691 * the extension. If there are multiple sessions with the same scopes, the user will be shown a
12692 * quickpick to select which account they would like to use.
12693 *
12694 * Currently, there are only two authentication providers that are contributed from built in extensions
12695 * to VS Code that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
12696 * @param providerId The id of the provider to use
12697 * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
12698 * @param options The [getSessionOptions](#GetSessionOptions) to use
12699 * @returns A thenable that resolves to an authentication session if available, or undefined if there are no sessions
12700 */
12701 export function getSession(providerId: string, scopes: string[], options?: AuthenticationGetSessionOptions): Thenable<AuthenticationSession | undefined>;
12702
12703 /**
12704 * An [event](#Event) which fires when the authentication sessions of an authentication provider have
12705 * been added, removed, or changed.
12706 */
12707 export const onDidChangeSessions: Event<AuthenticationSessionsChangeEvent>;
12708
12709 /**
12710 * Register an authentication provider.
12711 *
12712 * There can only be one provider per id and an error is being thrown when an id
12713 * has already been used by another provider. Ids are case-sensitive.
12714 *
12715 * @param id The unique identifier of the provider.
12716 * @param label The human-readable name of the provider.
12717 * @param provider The authentication provider provider.
12718 * @params options Additional options for the provider.
12719 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
12720 */
12721 export function registerAuthenticationProvider(id: string, label: string, provider: AuthenticationProvider, options?: AuthenticationProviderOptions): Disposable;
12722 }
12723}
12724
12725/**
12726 * Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise,
12727 * and others. This API makes no assumption about what promise library is being used which
12728 * enables reusing existing code without migrating to a specific promise implementation. Still,
12729 * we recommend the use of native promises which are available in this editor.
12730 */
12731interface Thenable<T> {
12732 /**
12733 * Attaches callbacks for the resolution and/or rejection of the Promise.
12734 * @param onfulfilled The callback to execute when the Promise is resolved.
12735 * @param onrejected The callback to execute when the Promise is rejected.
12736 * @returns A Promise for the completion of which ever callback is executed.
12737 */
12738 then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
12739 then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
12740}
12741
\No newline at end of file