1 | // Type definitions for Visual Studio Code 1.59
|
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.59 Extension API
|
14 | * See https://code.visualstudio.com/api for more information
|
15 | */
|
16 |
|
17 | declare 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 {@link 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 {@link TextDocument document} 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 {@link TextLine.firstNonWhitespaceCharacterIndex} === {@link TextLine.text TextLine.text.length}.
|
91 | */
|
92 | readonly isEmptyOrWhitespace: boolean;
|
93 | }
|
94 |
|
95 | /**
|
96 | * Represents a text document, such as a source file. Text documents have
|
97 | * {@link TextLine lines} 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 {@link FileSystemProvider}
|
108 | * @see {@link TextDocumentContentProvider}
|
109 | */
|
110 | readonly uri: Uri;
|
111 |
|
112 | /**
|
113 | * The file system path of the associated resource. Shorthand
|
114 | * notation for {@link TextDocument.uri TextDocument.uri.fsPath}. 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 {@link Uri.scheme `uri.scheme`}
|
121 | * to figure out where a document will be {@link FileSystemProvider saved}, 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 {@link EndOfLine end of line} 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 {@link TextLine line}.
|
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 {@link TextDocument.validatePosition adjusted}.
|
183 | *
|
184 | * @see {@link TextDocument.lineAt}
|
185 | *
|
186 | * @param position A position.
|
187 | * @return A {@link TextLine line}.
|
188 | */
|
189 | lineAt(position: Position): TextLine;
|
190 |
|
191 | /**
|
192 | * Converts the position to a zero-based offset.
|
193 | *
|
194 | * The position will be {@link TextDocument.validatePosition adjusted}.
|
195 | *
|
196 | * @param position A position.
|
197 | * @return A valid zero-based offset.
|
198 | */
|
199 | offsetAt(position: Position): number;
|
200 |
|
201 | /**
|
202 | * Converts a zero-based offset to a position.
|
203 | *
|
204 | * @param offset A zero-based offset.
|
205 | * @return A valid {@link Position}.
|
206 | */
|
207 | positionAt(offset: number): Position;
|
208 |
|
209 | /**
|
210 | * Get the text of this document. A substring can be retrieved by providing
|
211 | * a range. The range will be {@link TextDocument.validateRange adjusted}.
|
212 | *
|
213 | * @param range Include only the text included by the range.
|
214 | * @return The text inside the provided range or the entire text.
|
215 | */
|
216 | getText(range?: Range): string;
|
217 |
|
218 | /**
|
219 | * Get a word-range at the given position. By default words are defined by
|
220 | * common separators, like space, -, _, etc. In addition, per language custom
|
221 | * [word definitions} can be defined. It
|
222 | * is also possible to provide a custom regular expression.
|
223 | *
|
224 | * * *Note 1:* A custom regular expression must not match the empty string and
|
225 | * if it does, it will be ignored.
|
226 | * * *Note 2:* A custom regular expression will fail to match multiline strings
|
227 | * and in the name of speed regular expressions should not match words with
|
228 | * spaces. Use {@link TextLine.text `TextLine.text`} for more complex, non-wordy, scenarios.
|
229 | *
|
230 | * The position will be {@link TextDocument.validatePosition adjusted}.
|
231 | *
|
232 | * @param position A position.
|
233 | * @param regex Optional regular expression that describes what a word is.
|
234 | * @return A range spanning a word, or `undefined`.
|
235 | */
|
236 | getWordRangeAtPosition(position: Position, regex?: RegExp): Range | undefined;
|
237 |
|
238 | /**
|
239 | * Ensure a range is completely contained in this document.
|
240 | *
|
241 | * @param range A range.
|
242 | * @return The given range or a new, adjusted range.
|
243 | */
|
244 | validateRange(range: Range): Range;
|
245 |
|
246 | /**
|
247 | * Ensure a position is contained in the range of this document.
|
248 | *
|
249 | * @param position A position.
|
250 | * @return The given position or a new, adjusted position.
|
251 | */
|
252 | validatePosition(position: Position): Position;
|
253 | }
|
254 |
|
255 | /**
|
256 | * Represents a line and character position, such as
|
257 | * the position of the cursor.
|
258 | *
|
259 | * Position objects are __immutable__. Use the {@link Position.with with} or
|
260 | * {@link Position.translate translate} methods to derive new positions
|
261 | * from an existing position.
|
262 | */
|
263 | export class Position {
|
264 |
|
265 | /**
|
266 | * The zero-based line value.
|
267 | */
|
268 | readonly line: number;
|
269 |
|
270 | /**
|
271 | * The zero-based character value.
|
272 | */
|
273 | readonly character: number;
|
274 |
|
275 | /**
|
276 | * @param line A zero-based line value.
|
277 | * @param character A zero-based character value.
|
278 | */
|
279 | constructor(line: number, character: number);
|
280 |
|
281 | /**
|
282 | * Check if this position is before `other`.
|
283 | *
|
284 | * @param other A position.
|
285 | * @return `true` if position is on a smaller line
|
286 | * or on the same line on a smaller character.
|
287 | */
|
288 | isBefore(other: Position): boolean;
|
289 |
|
290 | /**
|
291 | * Check if this position is before or equal to `other`.
|
292 | *
|
293 | * @param other A position.
|
294 | * @return `true` if position is on a smaller line
|
295 | * or on the same line on a smaller or equal character.
|
296 | */
|
297 | isBeforeOrEqual(other: Position): boolean;
|
298 |
|
299 | /**
|
300 | * Check if this position is after `other`.
|
301 | *
|
302 | * @param other A position.
|
303 | * @return `true` if position is on a greater line
|
304 | * or on the same line on a greater character.
|
305 | */
|
306 | isAfter(other: Position): boolean;
|
307 |
|
308 | /**
|
309 | * Check if this position is after or equal to `other`.
|
310 | *
|
311 | * @param other A position.
|
312 | * @return `true` if position is on a greater line
|
313 | * or on the same line on a greater or equal character.
|
314 | */
|
315 | isAfterOrEqual(other: Position): boolean;
|
316 |
|
317 | /**
|
318 | * Check if this position is equal to `other`.
|
319 | *
|
320 | * @param other A position.
|
321 | * @return `true` if the line and character of the given position are equal to
|
322 | * the line and character of this position.
|
323 | */
|
324 | isEqual(other: Position): boolean;
|
325 |
|
326 | /**
|
327 | * Compare this to `other`.
|
328 | *
|
329 | * @param other A position.
|
330 | * @return A number smaller than zero if this position is before the given position,
|
331 | * a number greater than zero if this position is after the given position, or zero when
|
332 | * this and the given position are equal.
|
333 | */
|
334 | compareTo(other: Position): number;
|
335 |
|
336 | /**
|
337 | * Create a new position relative to this position.
|
338 | *
|
339 | * @param lineDelta Delta value for the line value, default is `0`.
|
340 | * @param characterDelta Delta value for the character value, default is `0`.
|
341 | * @return A position which line and character is the sum of the current line and
|
342 | * character and the corresponding deltas.
|
343 | */
|
344 | translate(lineDelta?: number, characterDelta?: number): Position;
|
345 |
|
346 | /**
|
347 | * Derived a new position relative to this position.
|
348 | *
|
349 | * @param change An object that describes a delta to this position.
|
350 | * @return A position that reflects the given delta. Will return `this` position if the change
|
351 | * is not changing anything.
|
352 | */
|
353 | translate(change: { lineDelta?: number; characterDelta?: number; }): Position;
|
354 |
|
355 | /**
|
356 | * Create a new position derived from this position.
|
357 | *
|
358 | * @param line Value that should be used as line value, default is the { Position.line existing value}
|
359 | * as character value, default is the { Position.character existing value}
character Value that should be used |
360 | * A position where line and character are replaced by the given values.
|
361 | */
|
362 | with(line?: number, character?: number): Position;
|
363 |
|
364 | /**
|
365 | * Derived a new position from this position.
|
366 | *
|
367 | * @param change An object that describes a change to this position.
|
368 | * @return A position that reflects the given change. Will return `this` position if the change
|
369 | * is not changing anything.
|
370 | */
|
371 | with(change: { line?: number; character?: number; }): Position;
|
372 | }
|
373 |
|
374 | /**
|
375 | * A range represents an ordered pair of two positions.
|
376 | * It is guaranteed that {@link Range.start start}.isBeforeOrEqual({@link Range.end end})
|
377 | *
|
378 | * Range objects are __immutable__. Use the {@link Range.with with},
|
379 | * {@link Range.intersection intersection}, or {@link Range.union union} methods
|
380 | * to derive new ranges from an existing range.
|
381 | */
|
382 | export class Range {
|
383 |
|
384 | /**
|
385 | * The start position. It is before or equal to {@link Range.end end}.
|
386 | */
|
387 | readonly start: Position;
|
388 |
|
389 | /**
|
390 | * The end position. It is after or equal to {@link Range.start start}.
|
391 | */
|
392 | readonly end: Position;
|
393 |
|
394 | /**
|
395 | * Create a new range from two positions. If `start` is not
|
396 | * before or equal to `end`, the values will be swapped.
|
397 | *
|
398 | * @param start A position.
|
399 | * @param end A position.
|
400 | */
|
401 | constructor(start: Position, end: Position);
|
402 |
|
403 | /**
|
404 | * Create a new range from number coordinates. It is a shorter equivalent of
|
405 | * using `new Range(new Position(startLine, startCharacter), new Position(endLine, endCharacter))`
|
406 | *
|
407 | * @param startLine A zero-based line value.
|
408 | * @param startCharacter A zero-based character value.
|
409 | * @param endLine A zero-based line value.
|
410 | * @param endCharacter A zero-based character value.
|
411 | */
|
412 | constructor(startLine: number, startCharacter: number, endLine: number, endCharacter: number);
|
413 |
|
414 | /**
|
415 | * `true` if `start` and `end` are equal.
|
416 | */
|
417 | isEmpty: boolean;
|
418 |
|
419 | /**
|
420 | * `true` if `start.line` and `end.line` are equal.
|
421 | */
|
422 | isSingleLine: boolean;
|
423 |
|
424 | /**
|
425 | * Check if a position or a range is contained in this range.
|
426 | *
|
427 | * @param positionOrRange A position or a range.
|
428 | * @return `true` if the position or range is inside or equal
|
429 | * to this range.
|
430 | */
|
431 | contains(positionOrRange: Position | Range): boolean;
|
432 |
|
433 | /**
|
434 | * Check if `other` equals this range.
|
435 | *
|
436 | * @param other A range.
|
437 | * @return `true` when start and end are {@link Position.isEqual equal} to
|
438 | * start and end of this range.
|
439 | */
|
440 | isEqual(other: Range): boolean;
|
441 |
|
442 | /**
|
443 | * Intersect `range` with this range and returns a new range or `undefined`
|
444 | * if the ranges have no overlap.
|
445 | *
|
446 | * @param range A range.
|
447 | * @return A range of the greater start and smaller end positions. Will
|
448 | * return undefined when there is no overlap.
|
449 | */
|
450 | intersection(range: Range): Range | undefined;
|
451 |
|
452 | /**
|
453 | * Compute the union of `other` with this range.
|
454 | *
|
455 | * @param other A range.
|
456 | * @return A range of smaller start position and the greater end position.
|
457 | */
|
458 | union(other: Range): Range;
|
459 |
|
460 | /**
|
461 | * Derived a new range from this range.
|
462 | *
|
463 | * @param start A position that should be used as start. The default value is the { Range.start current start}.
|
464 | * as end. The default value is the { Range.end current end}.
end A position that should be used |
465 | * from this range with the given start and end position.
A range derived |
466 | * If start and end are not different `this` range will be returned.
|
467 | */
|
468 | with(start?: Position, end?: Position): Range;
|
469 |
|
470 | /**
|
471 | * Derived a new range from this range.
|
472 | *
|
473 | * @param change An object that describes a change to this range.
|
474 | * @return A range that reflects the given change. Will return `this` range if the change
|
475 | * is not changing anything.
|
476 | */
|
477 | with(change: { start?: Position, end?: Position }): Range;
|
478 | }
|
479 |
|
480 | /**
|
481 | * Represents a text selection in an editor.
|
482 | */
|
483 | export class Selection extends Range {
|
484 |
|
485 | /**
|
486 | * The position at which the selection starts.
|
487 | * This position might be before or after {@link Selection.active active}.
|
488 | */
|
489 | anchor: Position;
|
490 |
|
491 | /**
|
492 | * The position of the cursor.
|
493 | * This position might be before or after {@link Selection.anchor anchor}.
|
494 | */
|
495 | active: Position;
|
496 |
|
497 | /**
|
498 | * Create a selection from two positions.
|
499 | *
|
500 | * @param anchor A position.
|
501 | * @param active A position.
|
502 | */
|
503 | constructor(anchor: Position, active: Position);
|
504 |
|
505 | /**
|
506 | * Create a selection from four coordinates.
|
507 | *
|
508 | * @param anchorLine A zero-based line value.
|
509 | * @param anchorCharacter A zero-based character value.
|
510 | * @param activeLine A zero-based line value.
|
511 | * @param activeCharacter A zero-based character value.
|
512 | */
|
513 | constructor(anchorLine: number, anchorCharacter: number, activeLine: number, activeCharacter: number);
|
514 |
|
515 | /**
|
516 | * A selection is reversed if {@link Selection.active active}.isBefore({).
Selection.anchor anchor} |
517 | */
|
518 | isReversed: boolean;
|
519 | }
|
520 |
|
521 | /**
|
522 | * Represents sources that can cause {window.onDidChangeTextEditorSelection selection change events}.
|
523 | */
|
524 | export enum TextEditorSelectionChangeKind {
|
525 | /**
|
526 | * Selection changed due to typing in the editor.
|
527 | */
|
528 | Keyboard = 1,
|
529 | /**
|
530 | * Selection change due to clicking in the editor.
|
531 | */
|
532 | Mouse = 2,
|
533 | /**
|
534 | * Selection changed because a command ran.
|
535 | */
|
536 | Command = 3
|
537 | }
|
538 |
|
539 | /**
|
540 | * Represents an event describing the change in a {@link TextEditor.selections text editor's selections}.
|
541 | */
|
542 | export interface TextEditorSelectionChangeEvent {
|
543 | /**
|
544 | * The {@link TextEditor text editor} for which the selections have changed.
|
545 | */
|
546 | readonly textEditor: TextEditor;
|
547 | /**
|
548 | * The new value for the {@link TextEditor.selections text editor's selections}.
|
549 | */
|
550 | readonly selections: readonly Selection[];
|
551 | /**
|
552 | * The {@link TextEditorSelectionChangeKind change kind} which has triggered this
|
553 | * event. Can be `undefined`.
|
554 | */
|
555 | readonly kind?: TextEditorSelectionChangeKind;
|
556 | }
|
557 |
|
558 | /**
|
559 | * Represents an event describing the change in a {@link TextEditor.visibleRanges text editor's visible ranges}.
|
560 | */
|
561 | export interface TextEditorVisibleRangesChangeEvent {
|
562 | /**
|
563 | * The {@link TextEditor text editor} for which the visible ranges have changed.
|
564 | */
|
565 | readonly textEditor: TextEditor;
|
566 | /**
|
567 | * The new value for the {@link TextEditor.visibleRanges text editor's visible ranges}.
|
568 | */
|
569 | readonly visibleRanges: readonly Range[];
|
570 | }
|
571 |
|
572 | /**
|
573 | * Represents an event describing the change in a {@link TextEditor.options text editor's options}.
|
574 | */
|
575 | export interface TextEditorOptionsChangeEvent {
|
576 | /**
|
577 | * The {@link TextEditor text editor} for which the options have changed.
|
578 | */
|
579 | readonly textEditor: TextEditor;
|
580 | /**
|
581 | * The new value for the {@link TextEditor.options text editor's options}.
|
582 | */
|
583 | readonly options: TextEditorOptions;
|
584 | }
|
585 |
|
586 | /**
|
587 | * Represents an event describing the change of a {@link TextEditor.viewColumn text editor's view column}.
|
588 | */
|
589 | export interface TextEditorViewColumnChangeEvent {
|
590 | /**
|
591 | * The {@link TextEditor text editor} for which the view column has changed.
|
592 | */
|
593 | readonly textEditor: TextEditor;
|
594 | /**
|
595 | * The new value for the {@link TextEditor.viewColumn text editor's view column}.
|
596 | */
|
597 | readonly viewColumn: ViewColumn;
|
598 | }
|
599 |
|
600 | /**
|
601 | * Rendering style of the cursor.
|
602 | */
|
603 | export enum TextEditorCursorStyle {
|
604 | /**
|
605 | * Render the cursor as a vertical thick line.
|
606 | */
|
607 | Line = 1,
|
608 | /**
|
609 | * Render the cursor as a block filled.
|
610 | */
|
611 | Block = 2,
|
612 | /**
|
613 | * Render the cursor as a thick horizontal line.
|
614 | */
|
615 | Underline = 3,
|
616 | /**
|
617 | * Render the cursor as a vertical thin line.
|
618 | */
|
619 | LineThin = 4,
|
620 | /**
|
621 | * Render the cursor as a block outlined.
|
622 | */
|
623 | BlockOutline = 5,
|
624 | /**
|
625 | * Render the cursor as a thin horizontal line.
|
626 | */
|
627 | UnderlineThin = 6
|
628 | }
|
629 |
|
630 | /**
|
631 | * Rendering style of the line numbers.
|
632 | */
|
633 | export enum TextEditorLineNumbersStyle {
|
634 | /**
|
635 | * Do not render the line numbers.
|
636 | */
|
637 | Off = 0,
|
638 | /**
|
639 | * Render the line numbers.
|
640 | */
|
641 | On = 1,
|
642 | /**
|
643 | * Render the line numbers with values relative to the primary cursor location.
|
644 | */
|
645 | Relative = 2
|
646 | }
|
647 |
|
648 | /**
|
649 | * Represents a {@link TextEditor text editor}'s {@link TextEditor.options options}.
|
650 | */
|
651 | export interface TextEditorOptions {
|
652 |
|
653 | /**
|
654 | * The size in spaces a tab takes. This is used for two purposes:
|
655 | * - the rendering width of a tab character;
|
656 | * - the number of spaces to insert when {@link TextEditorOptions.insertSpaces insertSpaces} is true.
|
657 | *
|
658 | * When getting a text editor's options, this property will always be a number (resolved).
|
659 | * When setting a text editor's options, this property is optional and it can be a number or `"auto"`.
|
660 | */
|
661 | tabSize?: number | string;
|
662 |
|
663 | /**
|
664 | * When pressing Tab insert {@link TextEditorOptions.tabSize n} spaces.
|
665 | * When getting a text editor's options, this property will always be a boolean (resolved).
|
666 | * When setting a text editor's options, this property is optional and it can be a boolean or `"auto"`.
|
667 | */
|
668 | insertSpaces?: boolean | string;
|
669 |
|
670 | /**
|
671 | * The rendering style of the cursor in this editor.
|
672 | * When getting a text editor's options, this property will always be present.
|
673 | * When setting a text editor's options, this property is optional.
|
674 | */
|
675 | cursorStyle?: TextEditorCursorStyle;
|
676 |
|
677 | /**
|
678 | * Render relative line numbers w.r.t. the current line number.
|
679 | * When getting a text editor's options, this property will always be present.
|
680 | * When setting a text editor's options, this property is optional.
|
681 | */
|
682 | lineNumbers?: TextEditorLineNumbersStyle;
|
683 | }
|
684 |
|
685 | /**
|
686 | * Represents a handle to a set of decorations
|
687 | * sharing the same {@link DecorationRenderOptions styling options} in a {@link TextEditor text editor}.
|
688 | *
|
689 | * To get an instance of a `TextEditorDecorationType` use
|
690 | * {@link window.createTextEditorDecorationType createTextEditorDecorationType}.
|
691 | */
|
692 | export interface TextEditorDecorationType {
|
693 |
|
694 | /**
|
695 | * Internal representation of the handle.
|
696 | */
|
697 | readonly key: string;
|
698 |
|
699 | /**
|
700 | * Remove this decoration type and all decorations on all text editors using it.
|
701 | */
|
702 | dispose(): void;
|
703 | }
|
704 |
|
705 | /**
|
706 | * Represents different {@link TextEditor.revealRange reveal} strategies in a text editor.
|
707 | */
|
708 | export enum TextEditorRevealType {
|
709 | /**
|
710 | * The range will be revealed with as little scrolling as possible.
|
711 | */
|
712 | Default = 0,
|
713 | /**
|
714 | * The range will always be revealed in the center of the viewport.
|
715 | */
|
716 | InCenter = 1,
|
717 | /**
|
718 | * If the range is outside the viewport, it will be revealed in the center of the viewport.
|
719 | * Otherwise, it will be revealed with as little scrolling as possible.
|
720 | */
|
721 | InCenterIfOutsideViewport = 2,
|
722 | /**
|
723 | * The range will always be revealed at the top of the viewport.
|
724 | */
|
725 | AtTop = 3
|
726 | }
|
727 |
|
728 | /**
|
729 | * Represents different positions for rendering a decoration in an {@link DecorationRenderOptions.overviewRulerLane overview ruler}.
|
730 | * The overview ruler supports three lanes.
|
731 | */
|
732 | export enum OverviewRulerLane {
|
733 | Left = 1,
|
734 | Center = 2,
|
735 | Right = 4,
|
736 | Full = 7
|
737 | }
|
738 |
|
739 | /**
|
740 | * Describes the behavior of decorations when typing/editing at their edges.
|
741 | */
|
742 | export enum DecorationRangeBehavior {
|
743 | /**
|
744 | * The decoration's range will widen when edits occur at the start or end.
|
745 | */
|
746 | OpenOpen = 0,
|
747 | /**
|
748 | * The decoration's range will not widen when edits occur at the start of end.
|
749 | */
|
750 | ClosedClosed = 1,
|
751 | /**
|
752 | * The decoration's range will widen when edits occur at the start, but not at the end.
|
753 | */
|
754 | OpenClosed = 2,
|
755 | /**
|
756 | * The decoration's range will widen when edits occur at the end, but not at the start.
|
757 | */
|
758 | ClosedOpen = 3
|
759 | }
|
760 |
|
761 | /**
|
762 | * Represents options to configure the behavior of showing a {@link TextDocument document} in an {@link TextEditor editor}.
|
763 | */
|
764 | export interface TextDocumentShowOptions {
|
765 | /**
|
766 | * An optional view column in which the {@link TextEditor editor} should be shown.
|
767 | * The default is the {@link ViewColumn.Active active}, other values are adjusted to
|
768 | * be `Min(column, columnCount + 1)`, the {@link ViewColumn.Active active}-column is
|
769 | * not adjusted. Use {@link ViewColumn.Beside `ViewColumn.Beside`} to open the
|
770 | * editor to the side of the currently active one.
|
771 | */
|
772 | viewColumn?: ViewColumn;
|
773 |
|
774 | /**
|
775 | * An optional flag that when `true` will stop the {@link TextEditor editor} from taking focus.
|
776 | */
|
777 | preserveFocus?: boolean;
|
778 |
|
779 | /**
|
780 | * An optional flag that controls if an {@link TextEditor editor}-tab will be replaced
|
781 | * with the next editor or if it will be kept.
|
782 | */
|
783 | preview?: boolean;
|
784 |
|
785 | /**
|
786 | * An optional selection to apply for the document in the {@link TextEditor editor}.
|
787 | */
|
788 | selection?: Range;
|
789 | }
|
790 |
|
791 | /**
|
792 | * A reference to one of the workbench colors as defined in https://code.visualstudio.com/docs/getstarted/theme-color-reference.
|
793 | * Using a theme color is preferred over a custom color as it gives theme authors and users the possibility to change the color.
|
794 | */
|
795 | export class ThemeColor {
|
796 |
|
797 | /**
|
798 | * Creates a reference to a theme color.
|
799 | * @param id of the color. The available colors are listed in https://code.visualstudio.com/docs/getstarted/theme-color-reference.
|
800 | */
|
801 | constructor(id: string);
|
802 | }
|
803 |
|
804 | /**
|
805 | * A reference to a named icon. Currently, { ThemeIcon.File File}, { ThemeIcon.Folder Folder},
|
806 | * and [ThemeIcon ids](https://code.visualstudio.com/api/references/icons-in-labels#icon-listing) are supported.
|
807 | * Using a theme icon is preferred over a custom icon as it gives product theme authors the possibility to change the icons.
|
808 | *
|
809 | * *Note* that theme icons can also be rendered inside labels and descriptions. Places that support theme icons spell this out
|
810 | * and they use the `$(<name>)`-syntax, for instance `quickPick.label = "Hello World $(globe)"`.
|
811 | */
|
812 | export class ThemeIcon {
|
813 | /**
|
814 | * Reference to an icon representing a file. The icon is taken from the current file icon theme or a placeholder icon is used.
|
815 | */
|
816 | static readonly File: ThemeIcon;
|
817 |
|
818 | /**
|
819 | * Reference to an icon representing a folder. The icon is taken from the current file icon theme or a placeholder icon is used.
|
820 | */
|
821 | static readonly Folder: ThemeIcon;
|
822 |
|
823 | /**
|
824 | * The id of the icon. The available icons are listed in https://code.visualstudio.com/api/references/icons-in-labels#icon-listing.
|
825 | */
|
826 | readonly id: string;
|
827 |
|
828 | /**
|
829 | * The optional ThemeColor of the icon. The color is currently only used in {@link TreeItem}.
|
830 | */
|
831 | readonly color?: ThemeColor;
|
832 |
|
833 | /**
|
834 | * Creates a reference to a theme icon.
|
835 | * @param id id of the icon. The available icons are listed in https://code.visualstudio.com/api/references/icons-in-labels#icon-listing.
|
836 | * @param color optional `ThemeColor` for the icon. The color is currently only used in {@link TreeItem}.
|
837 | */
|
838 | constructor(id: string, color?: ThemeColor);
|
839 | }
|
840 |
|
841 | /**
|
842 | * Represents theme specific rendering styles for a { TextEditorDecorationType text editor decoration}.
|
843 | */
|
844 | export interface ThemableDecorationRenderOptions {
|
845 | /**
|
846 | * Background color of the decoration. Use rgba() and define transparent background colors to play well with other decorations.
|
847 | * Alternatively a color from the color registry can be {@link ThemeColor referenced}.
|
848 | */
|
849 | backgroundColor?: string | ThemeColor;
|
850 |
|
851 | /**
|
852 | * CSS styling property that will be applied to text enclosed by a decoration.
|
853 | */
|
854 | outline?: string;
|
855 |
|
856 | /**
|
857 | * CSS styling property that will be applied to text enclosed by a decoration.
|
858 | * Better use 'outline' for setting one or more of the individual outline properties.
|
859 | */
|
860 | outlineColor?: string | ThemeColor;
|
861 |
|
862 | /**
|
863 | * CSS styling property that will be applied to text enclosed by a decoration.
|
864 | * Better use 'outline' for setting one or more of the individual outline properties.
|
865 | */
|
866 | outlineStyle?: string;
|
867 |
|
868 | /**
|
869 | * CSS styling property that will be applied to text enclosed by a decoration.
|
870 | * Better use 'outline' for setting one or more of the individual outline properties.
|
871 | */
|
872 | outlineWidth?: string;
|
873 |
|
874 | /**
|
875 | * CSS styling property that will be applied to text enclosed by a decoration.
|
876 | */
|
877 | border?: string;
|
878 |
|
879 | /**
|
880 | * CSS styling property that will be applied to text enclosed by a decoration.
|
881 | * Better use 'border' for setting one or more of the individual border properties.
|
882 | */
|
883 | borderColor?: string | ThemeColor;
|
884 |
|
885 | /**
|
886 | * CSS styling property that will be applied to text enclosed by a decoration.
|
887 | * Better use 'border' for setting one or more of the individual border properties.
|
888 | */
|
889 | borderRadius?: string;
|
890 |
|
891 | /**
|
892 | * CSS styling property that will be applied to text enclosed by a decoration.
|
893 | * Better use 'border' for setting one or more of the individual border properties.
|
894 | */
|
895 | borderSpacing?: string;
|
896 |
|
897 | /**
|
898 | * CSS styling property that will be applied to text enclosed by a decoration.
|
899 | * Better use 'border' for setting one or more of the individual border properties.
|
900 | */
|
901 | borderStyle?: string;
|
902 |
|
903 | /**
|
904 | * CSS styling property that will be applied to text enclosed by a decoration.
|
905 | * Better use 'border' for setting one or more of the individual border properties.
|
906 | */
|
907 | borderWidth?: string;
|
908 |
|
909 | /**
|
910 | * CSS styling property that will be applied to text enclosed by a decoration.
|
911 | */
|
912 | fontStyle?: string;
|
913 |
|
914 | /**
|
915 | * CSS styling property that will be applied to text enclosed by a decoration.
|
916 | */
|
917 | fontWeight?: string;
|
918 |
|
919 | /**
|
920 | * CSS styling property that will be applied to text enclosed by a decoration.
|
921 | */
|
922 | textDecoration?: string;
|
923 |
|
924 | /**
|
925 | * CSS styling property that will be applied to text enclosed by a decoration.
|
926 | */
|
927 | cursor?: string;
|
928 |
|
929 | /**
|
930 | * CSS styling property that will be applied to text enclosed by a decoration.
|
931 | */
|
932 | color?: string | ThemeColor;
|
933 |
|
934 | /**
|
935 | * CSS styling property that will be applied to text enclosed by a decoration.
|
936 | */
|
937 | opacity?: string;
|
938 |
|
939 | /**
|
940 | * CSS styling property that will be applied to text enclosed by a decoration.
|
941 | */
|
942 | letterSpacing?: string;
|
943 |
|
944 | /**
|
945 | * An **absolute path** or an URI to an image to be rendered in the gutter.
|
946 | */
|
947 | gutterIconPath?: string | Uri;
|
948 |
|
949 | /**
|
950 | * Specifies the size of the gutter icon.
|
951 | * Available values are 'auto', 'contain', 'cover' and any percentage value.
|
952 | * For further information: https://msdn.microsoft.com/en-us/library/jj127316(v=vs.85).aspx
|
953 | */
|
954 | gutterIconSize?: string;
|
955 |
|
956 | /**
|
957 | * The color of the decoration in the overview ruler. Use rgba() and define transparent colors to play well with other decorations.
|
958 | */
|
959 | overviewRulerColor?: string | ThemeColor;
|
960 |
|
961 | /**
|
962 | * Defines the rendering options of the attachment that is inserted before the decorated text.
|
963 | */
|
964 | before?: ThemableDecorationAttachmentRenderOptions;
|
965 |
|
966 | /**
|
967 | * Defines the rendering options of the attachment that is inserted after the decorated text.
|
968 | */
|
969 | after?: ThemableDecorationAttachmentRenderOptions;
|
970 | }
|
971 |
|
972 | export interface ThemableDecorationAttachmentRenderOptions {
|
973 | /**
|
974 | * Defines a text content that is shown in the attachment. Either an icon or a text can be shown, but not both.
|
975 | */
|
976 | contentText?: string;
|
977 | /**
|
978 | * An **absolute path** or an URI to an image to be rendered in the attachment. Either an icon
|
979 | * or a text can be shown, but not both.
|
980 | */
|
981 | contentIconPath?: string | Uri;
|
982 | /**
|
983 | * CSS styling property that will be applied to the decoration attachment.
|
984 | */
|
985 | border?: string;
|
986 | /**
|
987 | * CSS styling property that will be applied to text enclosed by a decoration.
|
988 | */
|
989 | borderColor?: string | ThemeColor;
|
990 | /**
|
991 | * CSS styling property that will be applied to the decoration attachment.
|
992 | */
|
993 | fontStyle?: string;
|
994 | /**
|
995 | * CSS styling property that will be applied to the decoration attachment.
|
996 | */
|
997 | fontWeight?: string;
|
998 | /**
|
999 | * CSS styling property that will be applied to the decoration attachment.
|
1000 | */
|
1001 | textDecoration?: string;
|
1002 | /**
|
1003 | * CSS styling property that will be applied to the decoration attachment.
|
1004 | */
|
1005 | color?: string | ThemeColor;
|
1006 | /**
|
1007 | * CSS styling property that will be applied to the decoration attachment.
|
1008 | */
|
1009 | backgroundColor?: string | ThemeColor;
|
1010 | /**
|
1011 | * CSS styling property that will be applied to the decoration attachment.
|
1012 | */
|
1013 | margin?: string;
|
1014 | /**
|
1015 | * CSS styling property that will be applied to the decoration attachment.
|
1016 | */
|
1017 | width?: string;
|
1018 | /**
|
1019 | * CSS styling property that will be applied to the decoration attachment.
|
1020 | */
|
1021 | height?: string;
|
1022 | }
|
1023 |
|
1024 | /**
|
1025 | * Represents rendering styles for a {@link TextEditorDecorationType text editor decoration}.
|
1026 | */
|
1027 | export interface DecorationRenderOptions extends ThemableDecorationRenderOptions {
|
1028 | /**
|
1029 | * Should the decoration be rendered also on the whitespace after the line text.
|
1030 | * Defaults to `false`.
|
1031 | */
|
1032 | isWholeLine?: boolean;
|
1033 |
|
1034 | /**
|
1035 | * Customize the growing behavior of the decoration when edits occur at the edges of the decoration's range.
|
1036 | * Defaults to `DecorationRangeBehavior.OpenOpen`.
|
1037 | */
|
1038 | rangeBehavior?: DecorationRangeBehavior;
|
1039 |
|
1040 | /**
|
1041 | * The position in the overview ruler where the decoration should be rendered.
|
1042 | */
|
1043 | overviewRulerLane?: OverviewRulerLane;
|
1044 |
|
1045 | /**
|
1046 | * Overwrite options for light themes.
|
1047 | */
|
1048 | light?: ThemableDecorationRenderOptions;
|
1049 |
|
1050 | /**
|
1051 | * Overwrite options for dark themes.
|
1052 | */
|
1053 | dark?: ThemableDecorationRenderOptions;
|
1054 | }
|
1055 |
|
1056 | /**
|
1057 | * Represents options for a specific decoration in a {@link TextEditorDecorationType decoration set}.
|
1058 | */
|
1059 | export interface DecorationOptions {
|
1060 |
|
1061 | /**
|
1062 | * Range to which this decoration is applied. The range must not be empty.
|
1063 | */
|
1064 | range: Range;
|
1065 |
|
1066 | /**
|
1067 | * A message that should be rendered when hovering over the decoration.
|
1068 | */
|
1069 | hoverMessage?: MarkdownString | MarkedString | Array<MarkdownString | MarkedString>;
|
1070 |
|
1071 | /**
|
1072 | * Render options applied to the current decoration. For performance reasons, keep the
|
1073 | * number of decoration specific options small, and use decoration types wherever possible.
|
1074 | */
|
1075 | renderOptions?: DecorationInstanceRenderOptions;
|
1076 | }
|
1077 |
|
1078 | export interface ThemableDecorationInstanceRenderOptions {
|
1079 | /**
|
1080 | * Defines the rendering options of the attachment that is inserted before the decorated text.
|
1081 | */
|
1082 | before?: ThemableDecorationAttachmentRenderOptions;
|
1083 |
|
1084 | /**
|
1085 | * Defines the rendering options of the attachment that is inserted after the decorated text.
|
1086 | */
|
1087 | after?: ThemableDecorationAttachmentRenderOptions;
|
1088 | }
|
1089 |
|
1090 | export interface DecorationInstanceRenderOptions extends ThemableDecorationInstanceRenderOptions {
|
1091 | /**
|
1092 | * Overwrite options for light themes.
|
1093 | */
|
1094 | light?: ThemableDecorationInstanceRenderOptions;
|
1095 |
|
1096 | /**
|
1097 | * Overwrite options for dark themes.
|
1098 | */
|
1099 | dark?: ThemableDecorationInstanceRenderOptions;
|
1100 | }
|
1101 |
|
1102 | /**
|
1103 | * Represents an editor that is attached to a {@link TextDocument document}.
|
1104 | */
|
1105 | export interface TextEditor {
|
1106 |
|
1107 | /**
|
1108 | * The document associated with this text editor. The document will be the same for the entire lifetime of this text editor.
|
1109 | */
|
1110 | readonly document: TextDocument;
|
1111 |
|
1112 | /**
|
1113 | * The primary selection on this text editor. Shorthand for `TextEditor.selections[0]`.
|
1114 | */
|
1115 | selection: Selection;
|
1116 |
|
1117 | /**
|
1118 | * The selections in this text editor. The primary selection is always at index 0.
|
1119 | */
|
1120 | selections: Selection[];
|
1121 |
|
1122 | /**
|
1123 | * The current visible ranges in the editor (vertically).
|
1124 | * This accounts only for vertical scrolling, and not for horizontal scrolling.
|
1125 | */
|
1126 | readonly visibleRanges: Range[];
|
1127 |
|
1128 | /**
|
1129 | * Text editor options.
|
1130 | */
|
1131 | options: TextEditorOptions;
|
1132 |
|
1133 | /**
|
1134 | * The column in which this editor shows. Will be `undefined` in case this
|
1135 | * isn't one of the main editors, e.g. an embedded editor, or when the editor
|
1136 | * column is larger than three.
|
1137 | */
|
1138 | readonly viewColumn?: ViewColumn;
|
1139 |
|
1140 | /**
|
1141 | * Perform an edit on the document associated with this text editor.
|
1142 | *
|
1143 | * The given callback-function is invoked with an {@link TextEditorEdit edit-builder} which must
|
1144 | * be used to make edits. Note that the edit-builder is only valid while the
|
1145 | * callback executes.
|
1146 | *
|
1147 | * @param callback A function which can create edits using an {@link TextEditorEdit edit-builder}.
|
1148 | * @param options The undo/redo behavior around this edit. By default, undo stops will be created before and after this edit.
|
1149 | * @return A promise that resolves with a value indicating if the edits could be applied.
|
1150 | */
|
1151 | edit(callback: (editBuilder: TextEditorEdit) => void, options?: { undoStopBefore: boolean; undoStopAfter: boolean; }): Thenable<boolean>;
|
1152 |
|
1153 | /**
|
1154 | * Insert a {@link SnippetString snippet} and put the editor into snippet mode. "Snippet mode"
|
1155 | * means the editor adds placeholders and additional cursors so that the user can complete
|
1156 | * or accept the snippet.
|
1157 | *
|
1158 | * @param snippet The snippet to insert in this edit.
|
1159 | * @param location Position or range at which to insert the snippet, defaults to the current editor selection or selections.
|
1160 | * @param options The undo/redo behavior around this edit. By default, undo stops will be created before and after this edit.
|
1161 | * @return A promise that resolves with a value indicating if the snippet could be inserted. Note that the promise does not signal
|
1162 | * that the snippet is completely filled-in or accepted.
|
1163 | */
|
1164 | insertSnippet(snippet: SnippetString, location?: Position | Range | readonly Position[] | readonly Range[], options?: { undoStopBefore: boolean; undoStopAfter: boolean; }): Thenable<boolean>;
|
1165 |
|
1166 | /**
|
1167 | * Adds a set of decorations to the text editor. If a set of decorations already exists with
|
1168 | * the given {@link TextEditorDecorationType decoration type}, they will be replaced. If
|
1169 | * `rangesOrOptions` is empty, the existing decorations with the given {@link TextEditorDecorationType decoration type}
|
1170 | * will be removed.
|
1171 | *
|
1172 | * @see {@link window.createTextEditorDecorationType createTextEditorDecorationType}.
|
1173 | *
|
1174 | * @param decorationType A decoration type.
|
1175 | * @param rangesOrOptions Either {@link Range ranges} or more detailed {@link DecorationOptions options}.
|
1176 | */
|
1177 | setDecorations(decorationType: TextEditorDecorationType, rangesOrOptions: readonly Range[] | readonly DecorationOptions[]): void;
|
1178 |
|
1179 | /**
|
1180 | * Scroll as indicated by `revealType` in order to reveal the given range.
|
1181 | *
|
1182 | * @param range A range.
|
1183 | * @param revealType The scrolling strategy for revealing `range`.
|
1184 | */
|
1185 | revealRange(range: Range, revealType?: TextEditorRevealType): void;
|
1186 |
|
1187 | /**
|
1188 | * Show the text editor.
|
1189 | *
|
1190 | * @deprecated Use {@link window.showTextDocument} instead.
|
1191 | *
|
1192 | * @param column The {@link ViewColumn column} in which to show this editor.
|
1193 | * This method shows unexpected behavior and will be removed in the next major update.
|
1194 | */
|
1195 | show(column?: ViewColumn): void;
|
1196 |
|
1197 | /**
|
1198 | * Hide the text editor.
|
1199 | *
|
1200 | * @deprecated Use the command `workbench.action.closeActiveEditor` instead.
|
1201 | * This method shows unexpected behavior and will be removed in the next major update.
|
1202 | */
|
1203 | hide(): void;
|
1204 | }
|
1205 |
|
1206 | /**
|
1207 | * Represents an end of line character sequence in a {@link TextDocument document}.
|
1208 | */
|
1209 | export enum EndOfLine {
|
1210 | /**
|
1211 | * The line feed `\n` character.
|
1212 | */
|
1213 | LF = 1,
|
1214 | /**
|
1215 | * The carriage return line feed `\r\n` sequence.
|
1216 | */
|
1217 | CRLF = 2
|
1218 | }
|
1219 |
|
1220 | /**
|
1221 | * A complex edit that will be applied in one transaction on a TextEditor.
|
1222 | * 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.)
|
1223 | * they can be applied on a {@link TextDocument document} associated with a {@link TextEditor text editor}.
|
1224 | */
|
1225 | export interface TextEditorEdit {
|
1226 | /**
|
1227 | * Replace a certain text region with a new value.
|
1228 | * You can use \r\n or \n in `value` and they will be normalized to the current {@link TextDocument document}.
|
1229 | *
|
1230 | * @param location The range this operation should remove.
|
1231 | * @param value The new text this operation should insert after removing `location`.
|
1232 | */
|
1233 | replace(location: Position | Range | Selection, value: string): void;
|
1234 |
|
1235 | /**
|
1236 | * Insert text at a location.
|
1237 | * You can use \r\n or \n in `value` and they will be normalized to the current {@link TextDocument document}.
|
1238 | * Although the equivalent text edit can be made with {@link TextEditorEdit.replace replace}, `insert` will produce a different resulting selection (it will get moved).
|
1239 | *
|
1240 | * @param location The position where the new text should be inserted.
|
1241 | * @param value The new text this operation should insert.
|
1242 | */
|
1243 | insert(location: Position, value: string): void;
|
1244 |
|
1245 | /**
|
1246 | * Delete a certain text region.
|
1247 | *
|
1248 | * @param location The range this operation should remove.
|
1249 | */
|
1250 | delete(location: Range | Selection): void;
|
1251 |
|
1252 | /**
|
1253 | * Set the end of line sequence.
|
1254 | *
|
1255 | * @param endOfLine The new end of line for the {@link TextDocument document}.
|
1256 | */
|
1257 | setEndOfLine(endOfLine: EndOfLine): void;
|
1258 | }
|
1259 |
|
1260 | /**
|
1261 | * A universal resource identifier representing either a file on disk
|
1262 | * or another resource, like untitled resources.
|
1263 | */
|
1264 | export class Uri {
|
1265 |
|
1266 | /**
|
1267 | * Create an URI from a string, e.g. `http://www.msft.com/some/path`,
|
1268 | * `file:///usr/home`, or `scheme:with/path`.
|
1269 | *
|
1270 | * *Note* that for a while uris without a `scheme` were accepted. That is not correct
|
1271 | * as all uris should have a scheme. To avoid breakage of existing code the optional
|
1272 | * `strict`-argument has been added. We *strongly* advise to use it, e.g. `Uri.parse('my:uri', true)`
|
1273 | *
|
1274 | * @see {@link Uri.toString}
|
1275 | * @param value The string value of an Uri.
|
1276 | * @param strict Throw an error when `value` is empty or when no `scheme` can be parsed.
|
1277 | * @return A new Uri instance.
|
1278 | */
|
1279 | static parse(value: string, strict?: boolean): Uri;
|
1280 |
|
1281 | /**
|
1282 | * Create an URI from a file system path. The {@link Uri.scheme scheme}
|
1283 | * will be `file`.
|
1284 | *
|
1285 | * The *difference* between {@link Uri.parse} and {@link Uri.file} is that the latter treats the argument
|
1286 | * as path, not as stringified-uri. E.g. `Uri.file(path)` is *not* the same as
|
1287 | * `Uri.parse('file://' + path)` because the path might contain characters that are
|
1288 | * interpreted (# and ?). See the following sample:
|
1289 | * ```ts
|
1290 | const good = URI.file('/coding/c#/project1');
|
1291 | good.scheme === 'file';
|
1292 | good.path === '/coding/c#/project1';
|
1293 | good.fragment === '';
|
1294 |
|
1295 | const bad = URI.parse('file://' + '/coding/c#/project1');
|
1296 | bad.scheme === 'file';
|
1297 | bad.path === '/coding/c'; // path is now broken
|
1298 | bad.fragment === '/project1';
|
1299 | ```
|
1300 | *
|
1301 | * @param path A file system or UNC path.
|
1302 | * @return A new Uri instance.
|
1303 | */
|
1304 | static file(path: string): Uri;
|
1305 |
|
1306 | /**
|
1307 | * Create a new uri which path is the result of joining
|
1308 | * the path of the base uri with the provided path segments.
|
1309 | *
|
1310 | * - Note 1: `joinPath` only affects the path component
|
1311 | * and all other components (scheme, authority, query, and fragment) are
|
1312 | * left as they are.
|
1313 | * - Note 2: The base uri must have a path; an error is thrown otherwise.
|
1314 | *
|
1315 | * The path segments are normalized in the following ways:
|
1316 | * - sequences of path separators (`/` or `\`) are replaced with a single separator
|
1317 | * - for `file`-uris on windows, the backslash-character (`\`) is considered a path-separator
|
1318 | * - the `..`-segment denotes the parent segment, the `.` denotes the current segment
|
1319 | * - paths have a root which always remains, for instance on windows drive-letters are roots
|
1320 | * so that is true: `joinPath(Uri.file('file:///c:/root'), '../../other').fsPath === 'c:/other'`
|
1321 | *
|
1322 | * @param base An uri. Must have a path.
|
1323 | * @param pathSegments One more more path fragments
|
1324 | * @returns A new uri which path is joined with the given fragments
|
1325 | */
|
1326 | static joinPath(base: Uri, ...pathSegments: string[]): Uri;
|
1327 |
|
1328 | /**
|
1329 | * Create an URI from its component parts
|
1330 | *
|
1331 | * @see {@link Uri.toString}
|
1332 | * @param components The component parts of an Uri.
|
1333 | * @return A new Uri instance.
|
1334 | */
|
1335 | static from(components: { scheme: string; authority?: string; path?: string; query?: string; fragment?: string }): Uri;
|
1336 |
|
1337 | /**
|
1338 | * Use the `file` and `parse` factory functions to create new `Uri` objects.
|
1339 | */
|
1340 | private constructor(scheme: string, authority: string, path: string, query: string, fragment: string);
|
1341 |
|
1342 | /**
|
1343 | * Scheme is the `http` part of `http://www.msft.com/some/path?query#fragment`.
|
1344 | * The part before the first colon.
|
1345 | */
|
1346 | readonly scheme: string;
|
1347 |
|
1348 | /**
|
1349 | * Authority is the `www.msft.com` part of `http://www.msft.com/some/path?query#fragment`.
|
1350 | * The part between the first double slashes and the next slash.
|
1351 | */
|
1352 | readonly authority: string;
|
1353 |
|
1354 | /**
|
1355 | * Path is the `/some/path` part of `http://www.msft.com/some/path?query#fragment`.
|
1356 | */
|
1357 | readonly path: string;
|
1358 |
|
1359 | /**
|
1360 | * Query is the `query` part of `http://www.msft.com/some/path?query#fragment`.
|
1361 | */
|
1362 | readonly query: string;
|
1363 |
|
1364 | /**
|
1365 | * Fragment is the `fragment` part of `http://www.msft.com/some/path?query#fragment`.
|
1366 | */
|
1367 | readonly fragment: string;
|
1368 |
|
1369 | /**
|
1370 | * The string representing the corresponding file system path of this Uri.
|
1371 | *
|
1372 | * Will handle UNC paths and normalize windows drive letters to lower-case. Also
|
1373 | * uses the platform specific path separator.
|
1374 | *
|
1375 | * * Will *not* validate the path for invalid characters and semantics.
|
1376 | * * Will *not* look at the scheme of this Uri.
|
1377 | * * The resulting string shall *not* be used for display purposes but
|
1378 | * for disk operations, like `readFile` et al.
|
1379 | *
|
1380 | * The *difference* to the {`path`}-property is the use of the platform specific
Uri.path |
1381 | * path separator and the handling of UNC paths. The sample below outlines the difference:
|
1382 | * ```ts
|
1383 | const u = URI.parse('file://server/c$/folder/file.txt')
|
1384 | u.authority === 'server'
|
1385 | u.path === '/shares/c$/file.txt'
|
1386 | u.fsPath === '\\server\c$\folder\file.txt'
|
1387 | ```
|
1388 | */
|
1389 | readonly fsPath: string;
|
1390 |
|
1391 | /**
|
1392 | * Derive a new Uri from this Uri.
|
1393 | *
|
1394 | * ```ts
|
1395 | * let file = Uri.parse('before:some/file/path');
|
1396 | * let other = file.with({ scheme: 'after' });
|
1397 | * assert.ok(other.toString() === 'after:some/file/path');
|
1398 | * ```
|
1399 | *
|
1400 | * @param change An object that describes a change to this Uri. To unset components use `null` or
|
1401 | * the empty string.
|
1402 | * @return A new Uri that reflects the given change. Will return `this` Uri if the change
|
1403 | * is not changing anything.
|
1404 | */
|
1405 | with(change: { scheme?: string; authority?: string; path?: string; query?: string; fragment?: string }): Uri;
|
1406 |
|
1407 | /**
|
1408 | * Returns a string representation of this Uri. The representation and normalization
|
1409 | * of a URI depends on the scheme.
|
1410 | *
|
1411 | * * The resulting string can be safely used with {@link Uri.parse}.
|
1412 | * * The resulting string shall *not* be used for display purposes.
|
1413 | *
|
1414 | * *Note* that the implementation will encode _aggressive_ which often leads to unexpected,
|
1415 | * but not incorrect, results. For instance, colons are encoded to `%3A` which might be unexpected
|
1416 | * in file-uri. Also `&` and `=` will be encoded which might be unexpected for http-uris. For stability
|
1417 | * reasons this cannot be changed anymore. If you suffer from too aggressive encoding you should use
|
1418 | * the `skipEncoding`-argument: `uri.toString(true)`.
|
1419 | *
|
1420 | * @param skipEncoding Do not percentage-encode the result, defaults to `false`. Note that
|
1421 | * the `#` and `?` characters occurring in the path will always be encoded.
|
1422 | * @returns A string representation of this Uri.
|
1423 | */
|
1424 | toString(skipEncoding?: boolean): string;
|
1425 |
|
1426 | /**
|
1427 | * Returns a JSON representation of this Uri.
|
1428 | *
|
1429 | * @return An object.
|
1430 | */
|
1431 | toJSON(): any;
|
1432 | }
|
1433 |
|
1434 | /**
|
1435 | * A cancellation token is passed to an asynchronous or long running
|
1436 | * operation to request cancellation, like cancelling a request
|
1437 | * for completion items because the user continued to type.
|
1438 | *
|
1439 | * To get an instance of a `CancellationToken` use a
|
1440 | * {@link CancellationTokenSource}.
|
1441 | */
|
1442 | export interface CancellationToken {
|
1443 |
|
1444 | /**
|
1445 | * Is `true` when the token has been cancelled, `false` otherwise.
|
1446 | */
|
1447 | isCancellationRequested: boolean;
|
1448 |
|
1449 | /**
|
1450 | * An {@link Event} which fires upon cancellation.
|
1451 | */
|
1452 | onCancellationRequested: Event<any>;
|
1453 | }
|
1454 |
|
1455 | /**
|
1456 | * A cancellation source creates and controls a {@link CancellationToken cancellation token}.
|
1457 | */
|
1458 | export class CancellationTokenSource {
|
1459 |
|
1460 | /**
|
1461 | * The cancellation token of this source.
|
1462 | */
|
1463 | token: CancellationToken;
|
1464 |
|
1465 | /**
|
1466 | * Signal cancellation on the token.
|
1467 | */
|
1468 | cancel(): void;
|
1469 |
|
1470 | /**
|
1471 | * Dispose object and free resources.
|
1472 | */
|
1473 | dispose(): void;
|
1474 | }
|
1475 |
|
1476 | /**
|
1477 | * An error type that should be used to signal cancellation of an operation.
|
1478 | *
|
1479 | * This type can be used in response to a {@link CancellationToken cancellation token}
|
1480 | * being cancelled or when an operation is being cancelled by the
|
1481 | * executor of that operation.
|
1482 | */
|
1483 | export class CancellationError extends Error {
|
1484 |
|
1485 | /**
|
1486 | * Creates a new cancellation error.
|
1487 | */
|
1488 | constructor();
|
1489 | }
|
1490 |
|
1491 | /**
|
1492 | * Represents a type which can release resources, such
|
1493 | * as event listening or a timer.
|
1494 | */
|
1495 | export class Disposable {
|
1496 |
|
1497 | /**
|
1498 | * Combine many disposable-likes into one. Use this method
|
1499 | * when having objects with a dispose function which are not
|
1500 | * instances of Disposable.
|
1501 | *
|
1502 | * @param disposableLikes Objects that have at least a `dispose`-function member.
|
1503 | * @return Returns a new disposable which, upon dispose, will
|
1504 | * dispose all provided disposables.
|
1505 | */
|
1506 | static from(...disposableLikes: { dispose: () => any }[]): Disposable;
|
1507 |
|
1508 | /**
|
1509 | * Creates a new Disposable calling the provided function
|
1510 | * on dispose.
|
1511 | * @param callOnDispose Function that disposes something.
|
1512 | */
|
1513 | constructor(callOnDispose: Function);
|
1514 |
|
1515 | /**
|
1516 | * Dispose this object.
|
1517 | */
|
1518 | dispose(): any;
|
1519 | }
|
1520 |
|
1521 | /**
|
1522 | * Represents a typed event.
|
1523 | *
|
1524 | * A function that represents an event to which you subscribe by calling it with
|
1525 | * a listener function as argument.
|
1526 | *
|
1527 | * @example
|
1528 | * item.onDidChange(function(event) { console.log("Event happened: " + event); });
|
1529 | */
|
1530 | export interface Event<T> {
|
1531 |
|
1532 | /**
|
1533 | * A function that represents an event to which you subscribe by calling it with
|
1534 | * a listener function as argument.
|
1535 | *
|
1536 | * @param listener The listener function will be called when the event happens.
|
1537 | * @param thisArgs The `this`-argument which will be used when calling the event listener.
|
1538 | * @param disposables An array to which a {@link Disposable} will be added.
|
1539 | * @return A disposable which unsubscribes the event listener.
|
1540 | */
|
1541 | (listener: (e: T) => any, thisArgs?: any, disposables?: Disposable[]): Disposable;
|
1542 | }
|
1543 |
|
1544 | /**
|
1545 | * An event emitter can be used to create and manage an {@link Event} for others
|
1546 | * to subscribe to. One emitter always owns one event.
|
1547 | *
|
1548 | * Use this class if you want to provide event from within your extension, for instance
|
1549 | * inside a {@link TextDocumentContentProvider} or when providing
|
1550 | * API to other extensions.
|
1551 | */
|
1552 | export class EventEmitter<T> {
|
1553 |
|
1554 | /**
|
1555 | * The event listeners can subscribe to.
|
1556 | */
|
1557 | event: Event<T>;
|
1558 |
|
1559 | /**
|
1560 | * Notify all subscribers of the {@link EventEmitter.event event}. Failure
|
1561 | * of one or more listener will not fail this function call.
|
1562 | *
|
1563 | * @param data The event object.
|
1564 | */
|
1565 | fire(data: T): void;
|
1566 |
|
1567 | /**
|
1568 | * Dispose this object and free resources.
|
1569 | */
|
1570 | dispose(): void;
|
1571 | }
|
1572 |
|
1573 | /**
|
1574 | * A file system watcher notifies about changes to files and folders
|
1575 | * on disk or from other {@link FileSystemProvider FileSystemProviders}.
|
1576 | *
|
1577 | * To get an instance of a `FileSystemWatcher` use
|
1578 | * {@link workspace.createFileSystemWatcher createFileSystemWatcher}.
|
1579 | */
|
1580 | export interface FileSystemWatcher extends Disposable {
|
1581 |
|
1582 | /**
|
1583 | * true if this file system watcher has been created such that
|
1584 | * it ignores creation file system events.
|
1585 | */
|
1586 | ignoreCreateEvents: boolean;
|
1587 |
|
1588 | /**
|
1589 | * true if this file system watcher has been created such that
|
1590 | * it ignores change file system events.
|
1591 | */
|
1592 | ignoreChangeEvents: boolean;
|
1593 |
|
1594 | /**
|
1595 | * true if this file system watcher has been created such that
|
1596 | * it ignores delete file system events.
|
1597 | */
|
1598 | ignoreDeleteEvents: boolean;
|
1599 |
|
1600 | /**
|
1601 | * An event which fires on file/folder creation.
|
1602 | */
|
1603 | onDidCreate: Event<Uri>;
|
1604 |
|
1605 | /**
|
1606 | * An event which fires on file/folder change.
|
1607 | */
|
1608 | onDidChange: Event<Uri>;
|
1609 |
|
1610 | /**
|
1611 | * An event which fires on file/folder deletion.
|
1612 | */
|
1613 | onDidDelete: Event<Uri>;
|
1614 | }
|
1615 |
|
1616 | /**
|
1617 | * A text document content provider allows to add readonly documents
|
1618 | * to the editor, such as source from a dll or generated html from md.
|
1619 | *
|
1620 | * Content providers are {@link workspace.registerTextDocumentContentProvider registered}
|
1621 | * for a {@link Uri.scheme uri-scheme}. When a uri with that scheme is to
|
1622 | * be {@link workspace.openTextDocument loaded} the content provider is
|
1623 | * asked.
|
1624 | */
|
1625 | export interface TextDocumentContentProvider {
|
1626 |
|
1627 | /**
|
1628 | * An event to signal a resource has changed.
|
1629 | */
|
1630 | onDidChange?: Event<Uri>;
|
1631 |
|
1632 | /**
|
1633 | * Provide textual content for a given uri.
|
1634 | *
|
1635 | * The editor will use the returned string-content to create a readonly
|
1636 | * {@link TextDocument document}. Resources allocated should be released when
|
1637 | * the corresponding document has been {@link workspace.onDidCloseTextDocument closed}.
|
1638 | *
|
1639 | * **Note**: The contents of the created {@link TextDocument document} might not be
|
1640 | * identical to the provided text due to end-of-line-sequence normalization.
|
1641 | *
|
1642 | * @param uri An uri which scheme matches the scheme this provider was {@link workspace.registerTextDocumentContentProvider registered} for.
|
1643 | * @param token A cancellation token.
|
1644 | * @return A string or a thenable that resolves to such.
|
1645 | */
|
1646 | provideTextDocumentContent(uri: Uri, token: CancellationToken): ProviderResult<string>;
|
1647 | }
|
1648 |
|
1649 | /**
|
1650 | * Represents an item that can be selected from
|
1651 | * a list of items.
|
1652 | */
|
1653 | export interface QuickPickItem {
|
1654 |
|
1655 | /**
|
1656 | * A human-readable string which is rendered prominent. Supports rendering of {@link ThemeIcon theme icons} via
|
1657 | * the `$(<name>)`-syntax.
|
1658 | */
|
1659 | label: string;
|
1660 |
|
1661 | /**
|
1662 | * A human-readable string which is rendered less prominent in the same line. Supports rendering of
|
1663 | * {@link ThemeIcon theme icons} via the `$(<name>)`-syntax.
|
1664 | */
|
1665 | description?: string;
|
1666 |
|
1667 | /**
|
1668 | * A human-readable string which is rendered less prominent in a separate line. Supports rendering of
|
1669 | * {@link ThemeIcon theme icons} via the `$(<name>)`-syntax.
|
1670 | */
|
1671 | detail?: string;
|
1672 |
|
1673 | /**
|
1674 | * Optional flag indicating if this item is picked initially.
|
1675 | * (Only honored when the picker allows multiple selections.)
|
1676 | *
|
1677 | * @see {@link QuickPickOptions.canPickMany}
|
1678 | */
|
1679 | picked?: boolean;
|
1680 |
|
1681 | /**
|
1682 | * Always show this item.
|
1683 | */
|
1684 | alwaysShow?: boolean;
|
1685 | }
|
1686 |
|
1687 | /**
|
1688 | * Options to configure the behavior of the quick pick UI.
|
1689 | */
|
1690 | export interface QuickPickOptions {
|
1691 |
|
1692 | /**
|
1693 | * An optional string that represents the title of the quick pick.
|
1694 | */
|
1695 | title?: string;
|
1696 |
|
1697 | /**
|
1698 | * An optional flag to include the description when filtering the picks.
|
1699 | */
|
1700 | matchOnDescription?: boolean;
|
1701 |
|
1702 | /**
|
1703 | * An optional flag to include the detail when filtering the picks.
|
1704 | */
|
1705 | matchOnDetail?: boolean;
|
1706 |
|
1707 | /**
|
1708 | * An optional string to show as placeholder in the input box to guide the user what to pick on.
|
1709 | */
|
1710 | placeHolder?: string;
|
1711 |
|
1712 | /**
|
1713 | * Set to `true` to keep the picker open when focus moves to another part of the editor or to another window.
|
1714 | * This setting is ignored on iPad and is always false.
|
1715 | */
|
1716 | ignoreFocusOut?: boolean;
|
1717 |
|
1718 | /**
|
1719 | * An optional flag to make the picker accept multiple selections, if true the result is an array of picks.
|
1720 | */
|
1721 | canPickMany?: boolean;
|
1722 |
|
1723 | /**
|
1724 | * An optional function that is invoked whenever an item is selected.
|
1725 | */
|
1726 | onDidSelectItem?(item: QuickPickItem | string): any;
|
1727 | }
|
1728 |
|
1729 | /**
|
1730 | * Options to configure the behaviour of the {@link WorkspaceFolder workspace folder} pick UI.
|
1731 | */
|
1732 | export interface WorkspaceFolderPickOptions {
|
1733 |
|
1734 | /**
|
1735 | * An optional string to show as placeholder in the input box to guide the user what to pick on.
|
1736 | */
|
1737 | placeHolder?: string;
|
1738 |
|
1739 | /**
|
1740 | * Set to `true` to keep the picker open when focus moves to another part of the editor or to another window.
|
1741 | * This setting is ignored on iPad and is always false.
|
1742 | */
|
1743 | ignoreFocusOut?: boolean;
|
1744 | }
|
1745 |
|
1746 | /**
|
1747 | * Options to configure the behaviour of a file open dialog.
|
1748 | *
|
1749 | * * Note 1: On Windows and Linux, a file dialog cannot be both a file selector and a folder selector, so if you
|
1750 | * set both `canSelectFiles` and `canSelectFolders` to `true` on these platforms, a folder selector will be shown.
|
1751 | * * Note 2: Explicitly setting `canSelectFiles` and `canSelectFolders` to `false` is futile
|
1752 | * and the editor then silently adjusts the options to select files.
|
1753 | */
|
1754 | export interface OpenDialogOptions {
|
1755 | /**
|
1756 | * The resource the dialog shows when opened.
|
1757 | */
|
1758 | defaultUri?: Uri;
|
1759 |
|
1760 | /**
|
1761 | * A human-readable string for the open button.
|
1762 | */
|
1763 | openLabel?: string;
|
1764 |
|
1765 | /**
|
1766 | * Allow to select files, defaults to `true`.
|
1767 | */
|
1768 | canSelectFiles?: boolean;
|
1769 |
|
1770 | /**
|
1771 | * Allow to select folders, defaults to `false`.
|
1772 | */
|
1773 | canSelectFolders?: boolean;
|
1774 |
|
1775 | /**
|
1776 | * Allow to select many files or folders.
|
1777 | */
|
1778 | canSelectMany?: boolean;
|
1779 |
|
1780 | /**
|
1781 | * A set of file filters that are used by the dialog. Each entry is a human-readable label,
|
1782 | * like "TypeScript", and an array of extensions, e.g.
|
1783 | * ```ts
|
1784 | * {
|
1785 | * 'Images': ['png', 'jpg']
|
1786 | * 'TypeScript': ['ts', 'tsx']
|
1787 | * }
|
1788 | * ```
|
1789 | */
|
1790 | filters?: { [name: string]: string[] };
|
1791 |
|
1792 | /**
|
1793 | * Dialog title.
|
1794 | *
|
1795 | * This parameter might be ignored, as not all operating systems display a title on open dialogs
|
1796 | * (for example, macOS).
|
1797 | */
|
1798 | title?: string;
|
1799 | }
|
1800 |
|
1801 | /**
|
1802 | * Options to configure the behaviour of a file save dialog.
|
1803 | */
|
1804 | export interface SaveDialogOptions {
|
1805 | /**
|
1806 | * The resource the dialog shows when opened.
|
1807 | */
|
1808 | defaultUri?: Uri;
|
1809 |
|
1810 | /**
|
1811 | * A human-readable string for the save button.
|
1812 | */
|
1813 | saveLabel?: string;
|
1814 |
|
1815 | /**
|
1816 | * A set of file filters that are used by the dialog. Each entry is a human-readable label,
|
1817 | * like "TypeScript", and an array of extensions, e.g.
|
1818 | * ```ts
|
1819 | * {
|
1820 | * 'Images': ['png', 'jpg']
|
1821 | * 'TypeScript': ['ts', 'tsx']
|
1822 | * }
|
1823 | * ```
|
1824 | */
|
1825 | filters?: { [name: string]: string[] };
|
1826 |
|
1827 | /**
|
1828 | * Dialog title.
|
1829 | *
|
1830 | * This parameter might be ignored, as not all operating systems display a title on save dialogs
|
1831 | * (for example, macOS).
|
1832 | */
|
1833 | title?: string;
|
1834 | }
|
1835 |
|
1836 | /**
|
1837 | * Represents an action that is shown with an information, warning, or
|
1838 | * error message.
|
1839 | *
|
1840 | * @see {@link window.showInformationMessage showInformationMessage}
|
1841 | * @see {@link window.showWarningMessage showWarningMessage}
|
1842 | * @see {@link window.showErrorMessage showErrorMessage}
|
1843 | */
|
1844 | export interface MessageItem {
|
1845 |
|
1846 | /**
|
1847 | * A short title like 'Retry', 'Open Log' etc.
|
1848 | */
|
1849 | title: string;
|
1850 |
|
1851 | /**
|
1852 | * A hint for modal dialogs that the item should be triggered
|
1853 | * when the user cancels the dialog (e.g. by pressing the ESC
|
1854 | * key).
|
1855 | *
|
1856 | * Note: this option is ignored for non-modal messages.
|
1857 | */
|
1858 | isCloseAffordance?: boolean;
|
1859 | }
|
1860 |
|
1861 | /**
|
1862 | * Options to configure the behavior of the message.
|
1863 | *
|
1864 | * @see {@link window.showInformationMessage showInformationMessage}
|
1865 | * @see {@link window.showWarningMessage showWarningMessage}
|
1866 | * @see {@link window.showErrorMessage showErrorMessage}
|
1867 | */
|
1868 | export interface MessageOptions {
|
1869 |
|
1870 | /**
|
1871 | * Indicates that this message should be modal.
|
1872 | */
|
1873 | modal?: boolean;
|
1874 |
|
1875 | /**
|
1876 | * Human-readable detail message that is rendered less prominent. _Note_ that detail
|
1877 | * is only shown for {@link MessageOptions.modal modal} messages.
|
1878 | */
|
1879 | detail?: string;
|
1880 | }
|
1881 |
|
1882 | /**
|
1883 | * Options to configure the behavior of the input box UI.
|
1884 | */
|
1885 | export interface InputBoxOptions {
|
1886 |
|
1887 | /**
|
1888 | * An optional string that represents the title of the input box.
|
1889 | */
|
1890 | title?: string;
|
1891 |
|
1892 | /**
|
1893 | * The value to prefill in the input box.
|
1894 | */
|
1895 | value?: string;
|
1896 |
|
1897 | /**
|
1898 | * Selection of the prefilled {@link InputBoxOptions.value `value`}. Defined as tuple of two number where the
|
1899 | * first is the inclusive start index and the second the exclusive end index. When `undefined` the whole
|
1900 | * word will be selected, when empty (start equals end) only the cursor will be set,
|
1901 | * otherwise the defined range will be selected.
|
1902 | */
|
1903 | valueSelection?: [number, number];
|
1904 |
|
1905 | /**
|
1906 | * The text to display underneath the input box.
|
1907 | */
|
1908 | prompt?: string;
|
1909 |
|
1910 | /**
|
1911 | * An optional string to show as placeholder in the input box to guide the user what to type.
|
1912 | */
|
1913 | placeHolder?: string;
|
1914 |
|
1915 | /**
|
1916 | * Controls if a password input is shown. Password input hides the typed text.
|
1917 | */
|
1918 | password?: boolean;
|
1919 |
|
1920 | /**
|
1921 | * Set to `true` to keep the input box open when focus moves to another part of the editor or to another window.
|
1922 | * This setting is ignored on iPad and is always false.
|
1923 | */
|
1924 | ignoreFocusOut?: boolean;
|
1925 |
|
1926 | /**
|
1927 | * An optional function that will be called to validate input and to give a hint
|
1928 | * to the user.
|
1929 | *
|
1930 | * @param value The current value of the input box.
|
1931 | * @return A human-readable string which is presented as diagnostic message.
|
1932 | * Return `undefined`, `null`, or the empty string when 'value' is valid.
|
1933 | */
|
1934 | validateInput?(value: string): string | undefined | null | Thenable<string | undefined | null>;
|
1935 | }
|
1936 |
|
1937 | /**
|
1938 | * A relative pattern is a helper to construct glob patterns that are matched
|
1939 | * relatively to a base file path. The base path can either be an absolute file
|
1940 | * path as string or uri or a {@link WorkspaceFolder workspace folder}, which is the
|
1941 | * preferred way of creating the relative pattern.
|
1942 | */
|
1943 | export class RelativePattern {
|
1944 |
|
1945 | /**
|
1946 | * A base file path to which this pattern will be matched against relatively.
|
1947 | */
|
1948 | base: string;
|
1949 |
|
1950 | /**
|
1951 | * A file glob pattern like `*.{ts,js}` that will be matched on file paths
|
1952 | * relative to the base path.
|
1953 | *
|
1954 | * Example: Given a base of `/home/work/folder` and a file path of `/home/work/folder/index.js`,
|
1955 | * the file glob pattern will match on `index.js`.
|
1956 | */
|
1957 | pattern: string;
|
1958 |
|
1959 | /**
|
1960 | * Creates a new relative pattern object with a base file path and pattern to match. This pattern
|
1961 | * will be matched on file paths relative to the base.
|
1962 | *
|
1963 | * Example:
|
1964 | * ```ts
|
1965 | * const folder = vscode.workspace.workspaceFolders?.[0];
|
1966 | * if (folder) {
|
1967 | *
|
1968 | * // Match any TypeScript file in the root of this workspace folder
|
1969 | * const pattern1 = new vscode.RelativePattern(folder, '*.ts');
|
1970 | *
|
1971 | * // Match any TypeScript file in `someFolder` inside this workspace folder
|
1972 | * const pattern2 = new vscode.RelativePattern(folder, 'someFolder/*.ts');
|
1973 | * }
|
1974 | * ```
|
1975 | *
|
1976 | * @param base A base to which this pattern will be matched against relatively. It is recommended
|
1977 | * to pass in a {@link WorkspaceFolder workspace folder} if the pattern should match inside the workspace.
|
1978 | * Otherwise, a uri or string should only be used if the pattern is for a file path outside the workspace.
|
1979 | * @param pattern A file glob pattern like `*.{ts,js}` that will be matched on paths relative to the base.
|
1980 | */
|
1981 | constructor(base: WorkspaceFolder | Uri | string, pattern: string)
|
1982 | }
|
1983 |
|
1984 | /**
|
1985 | * A file glob pattern to match file paths against. This can either be a glob pattern string
|
1986 | * (like `**/*.{ts,js}` or `*.{ts,js}`) or a {@link RelativePattern relative pattern}.
|
1987 | *
|
1988 | * Glob patterns can have the following syntax:
|
1989 | * * `*` to match one or more characters in a path segment
|
1990 | * * `?` to match on one character in a path segment
|
1991 | * * `**` to match any number of path segments, including none
|
1992 | * * `{}` to group conditions (e.g. `**/*.{ts,js}` matches all TypeScript and JavaScript files)
|
1993 | * * `[]` to declare a range of characters to match in a path segment (e.g., `example.[0-9]` to match on `example.0`, `example.1`, …)
|
1994 | * * `[!...]` 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`)
|
1995 | *
|
1996 | * Note: a backslash (`\`) is not valid within a glob pattern. If you have an existing file
|
1997 | * path to match against, consider to use the {@link RelativePattern relative pattern} support
|
1998 | * that takes care of converting any backslash into slash. Otherwise, make sure to convert
|
1999 | * any backslash to slash when creating the glob pattern.
|
2000 | */
|
2001 | export type GlobPattern = string | RelativePattern;
|
2002 |
|
2003 | /**
|
2004 | * A document filter denotes a document by different properties like
|
2005 | * the {@link TextDocument.languageId language}, the {@link Uri.scheme scheme} of
|
2006 | * its resource, or a glob-pattern that is applied to the {@link TextDocument.fileName path}.
|
2007 | *
|
2008 | * @example <caption>A language filter that applies to typescript files on disk</caption>
|
2009 | * { language: 'typescript', scheme: 'file' }
|
2010 | *
|
2011 | * @example <caption>A language filter that applies to all package.json paths</caption>
|
2012 | * { language: 'json', pattern: '**/package.json' }
|
2013 | */
|
2014 | export interface DocumentFilter {
|
2015 |
|
2016 | /**
|
2017 | * A language id, like `typescript`.
|
2018 | */
|
2019 | readonly language?: string;
|
2020 |
|
2021 | /**
|
2022 | * A Uri {@link Uri.scheme scheme}, like `file` or `untitled`.
|
2023 | */
|
2024 | readonly scheme?: string;
|
2025 |
|
2026 | /**
|
2027 | * A {@link GlobPattern glob pattern} that is matched on the absolute path of the document. Use a {@link RelativePattern relative pattern}
|
2028 | * to filter documents to a {@link WorkspaceFolder workspace folder}.
|
2029 | */
|
2030 | readonly pattern?: GlobPattern;
|
2031 | }
|
2032 |
|
2033 | /**
|
2034 | * A language selector is the combination of one or many language identifiers
|
2035 | * and {@link DocumentFilter language filters}.
|
2036 | *
|
2037 | * *Note* that a document selector that is just a language identifier selects *all*
|
2038 | * documents, even those that are not saved on disk. Only use such selectors when
|
2039 | * a feature works without further context, e.g. without the need to resolve related
|
2040 | * 'files'.
|
2041 | *
|
2042 | * @example
|
2043 | * let sel:DocumentSelector = { scheme: 'file', language: 'typescript' };
|
2044 | */
|
2045 | export type DocumentSelector = DocumentFilter | string | ReadonlyArray<DocumentFilter | string>;
|
2046 |
|
2047 | /**
|
2048 | * A provider result represents the values a provider, like the {@link HoverProvider `HoverProvider`},
|
2049 | * may return. For once this is the actual result type `T`, like `Hover`, or a thenable that resolves
|
2050 | * to that type `T`. In addition, `null` and `undefined` can be returned - either directly or from a
|
2051 | * thenable.
|
2052 | *
|
2053 | * The snippets below are all valid implementations of the {@link HoverProvider `HoverProvider`}:
|
2054 | *
|
2055 | * ```ts
|
2056 | * let a: HoverProvider = {
|
2057 | * provideHover(doc, pos, token): ProviderResult<Hover> {
|
2058 | * return new Hover('Hello World');
|
2059 | * }
|
2060 | * }
|
2061 | *
|
2062 | * let b: HoverProvider = {
|
2063 | * provideHover(doc, pos, token): ProviderResult<Hover> {
|
2064 | * return new Promise(resolve => {
|
2065 | * resolve(new Hover('Hello World'));
|
2066 | * });
|
2067 | * }
|
2068 | * }
|
2069 | *
|
2070 | * let c: HoverProvider = {
|
2071 | * provideHover(doc, pos, token): ProviderResult<Hover> {
|
2072 | * return; // undefined
|
2073 | * }
|
2074 | * }
|
2075 | * ```
|
2076 | */
|
2077 | export type ProviderResult<T> = T | undefined | null | Thenable<T | undefined | null>;
|
2078 |
|
2079 | /**
|
2080 | * Kind of a code action.
|
2081 | *
|
2082 | * Kinds are a hierarchical list of identifiers separated by `.`, e.g. `"refactor.extract.function"`.
|
2083 | *
|
2084 | * Code action kinds are used by the editor for UI elements such as the refactoring context menu. Users
|
2085 | * can also trigger code actions with a specific kind with the `editor.action.codeAction` command.
|
2086 | */
|
2087 | export class CodeActionKind {
|
2088 | /**
|
2089 | * Empty kind.
|
2090 | */
|
2091 | static readonly Empty: CodeActionKind;
|
2092 |
|
2093 | /**
|
2094 | * Base kind for quickfix actions: `quickfix`.
|
2095 | *
|
2096 | * Quick fix actions address a problem in the code and are shown in the normal code action context menu.
|
2097 | */
|
2098 | static readonly QuickFix: CodeActionKind;
|
2099 |
|
2100 | /**
|
2101 | * Base kind for refactoring actions: `refactor`
|
2102 | *
|
2103 | * Refactoring actions are shown in the refactoring context menu.
|
2104 | */
|
2105 | static readonly Refactor: CodeActionKind;
|
2106 |
|
2107 | /**
|
2108 | * Base kind for refactoring extraction actions: `refactor.extract`
|
2109 | *
|
2110 | * Example extract actions:
|
2111 | *
|
2112 | * - Extract method
|
2113 | * - Extract function
|
2114 | * - Extract variable
|
2115 | * - Extract interface from class
|
2116 | * - ...
|
2117 | */
|
2118 | static readonly RefactorExtract: CodeActionKind;
|
2119 |
|
2120 | /**
|
2121 | * Base kind for refactoring inline actions: `refactor.inline`
|
2122 | *
|
2123 | * Example inline actions:
|
2124 | *
|
2125 | * - Inline function
|
2126 | * - Inline variable
|
2127 | * - Inline constant
|
2128 | * - ...
|
2129 | */
|
2130 | static readonly RefactorInline: CodeActionKind;
|
2131 |
|
2132 | /**
|
2133 | * Base kind for refactoring rewrite actions: `refactor.rewrite`
|
2134 | *
|
2135 | * Example rewrite actions:
|
2136 | *
|
2137 | * - Convert JavaScript function to class
|
2138 | * - Add or remove parameter
|
2139 | * - Encapsulate field
|
2140 | * - Make method static
|
2141 | * - Move method to base class
|
2142 | * - ...
|
2143 | */
|
2144 | static readonly RefactorRewrite: CodeActionKind;
|
2145 |
|
2146 | /**
|
2147 | * Base kind for source actions: `source`
|
2148 | *
|
2149 | * Source code actions apply to the entire file. They must be explicitly requested and will not show in the
|
2150 | * normal [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) menu. Source actions
|
2151 | * can be run on save using `editor.codeActionsOnSave` and are also shown in the `source` context menu.
|
2152 | */
|
2153 | static readonly Source: CodeActionKind;
|
2154 |
|
2155 | /**
|
2156 | * Base kind for an organize imports source action: `source.organizeImports`.
|
2157 | */
|
2158 | static readonly SourceOrganizeImports: CodeActionKind;
|
2159 |
|
2160 | /**
|
2161 | * Base kind for auto-fix source actions: `source.fixAll`.
|
2162 | *
|
2163 | * Fix all actions automatically fix errors that have a clear fix that do not require user input.
|
2164 | * They should not suppress errors or perform unsafe fixes such as generating new types or classes.
|
2165 | */
|
2166 | static readonly SourceFixAll: CodeActionKind;
|
2167 |
|
2168 | private constructor(value: string);
|
2169 |
|
2170 | /**
|
2171 | * String value of the kind, e.g. `"refactor.extract.function"`.
|
2172 | */
|
2173 | readonly value: string;
|
2174 |
|
2175 | /**
|
2176 | * Create a new kind by appending a more specific selector to the current kind.
|
2177 | *
|
2178 | * Does not modify the current kind.
|
2179 | */
|
2180 | append(parts: string): CodeActionKind;
|
2181 |
|
2182 | /**
|
2183 | * Checks if this code action kind intersects `other`.
|
2184 | *
|
2185 | * The kind `"refactor.extract"` for example intersects `refactor`, `"refactor.extract"` and ``"refactor.extract.function"`,
|
2186 | * but not `"unicorn.refactor.extract"`, or `"refactor.extractAll"`.
|
2187 | *
|
2188 | * @param other Kind to check.
|
2189 | */
|
2190 | intersects(other: CodeActionKind): boolean;
|
2191 |
|
2192 | /**
|
2193 | * Checks if `other` is a sub-kind of this `CodeActionKind`.
|
2194 | *
|
2195 | * The kind `"refactor.extract"` for example contains `"refactor.extract"` and ``"refactor.extract.function"`,
|
2196 | * but not `"unicorn.refactor.extract"`, or `"refactor.extractAll"` or `refactor`.
|
2197 | *
|
2198 | * @param other Kind to check.
|
2199 | */
|
2200 | contains(other: CodeActionKind): boolean;
|
2201 | }
|
2202 |
|
2203 | /**
|
2204 | * The reason why code actions were requested.
|
2205 | */
|
2206 | export enum CodeActionTriggerKind {
|
2207 | /**
|
2208 | * Code actions were explicitly requested by the user or by an extension.
|
2209 | */
|
2210 | Invoke = 1,
|
2211 |
|
2212 | /**
|
2213 | * Code actions were requested automatically.
|
2214 | *
|
2215 | * This typically happens when current selection in a file changes, but can
|
2216 | * also be triggered when file content changes.
|
2217 | */
|
2218 | Automatic = 2,
|
2219 | }
|
2220 |
|
2221 | /**
|
2222 | * Contains additional diagnostic information about the context in which
|
2223 | * a {@link CodeActionProvider.provideCodeActions code action} is run.
|
2224 | */
|
2225 | export interface CodeActionContext {
|
2226 | /**
|
2227 | * The reason why code actions were requested.
|
2228 | */
|
2229 | readonly triggerKind: CodeActionTriggerKind;
|
2230 |
|
2231 | /**
|
2232 | * An array of diagnostics.
|
2233 | */
|
2234 | readonly diagnostics: readonly Diagnostic[];
|
2235 |
|
2236 | /**
|
2237 | * Requested kind of actions to return.
|
2238 | *
|
2239 | * Actions not of this kind are filtered out before being shown by the [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action).
|
2240 | */
|
2241 | readonly only?: CodeActionKind;
|
2242 | }
|
2243 |
|
2244 | /**
|
2245 | * A code action represents a change that can be performed in code, e.g. to fix a problem or
|
2246 | * to refactor code.
|
2247 | *
|
2248 | * A CodeAction must set either {@link CodeAction.edit `edit`} and/or a {@link CodeAction.command `command`}. If both are supplied, the `edit` is applied first, then the command is executed.
|
2249 | */
|
2250 | export class CodeAction {
|
2251 |
|
2252 | /**
|
2253 | * A short, human-readable, title for this code action.
|
2254 | */
|
2255 | title: string;
|
2256 |
|
2257 | /**
|
2258 | * A {@link WorkspaceEdit workspace edit} this code action performs.
|
2259 | */
|
2260 | edit?: WorkspaceEdit;
|
2261 |
|
2262 | /**
|
2263 | * {@link Diagnostic Diagnostics} that this code action resolves.
|
2264 | */
|
2265 | diagnostics?: Diagnostic[];
|
2266 |
|
2267 | /**
|
2268 | * A {@link Command} this code action executes.
|
2269 | *
|
2270 | * If this command throws an exception, the editor displays the exception message to users in the editor at the
|
2271 | * current cursor position.
|
2272 | */
|
2273 | command?: Command;
|
2274 |
|
2275 | /**
|
2276 | * {@link CodeActionKind Kind} of the code action.
|
2277 | *
|
2278 | * Used to filter code actions.
|
2279 | */
|
2280 | kind?: CodeActionKind;
|
2281 |
|
2282 | /**
|
2283 | * Marks this as a preferred action. Preferred actions are used by the `auto fix` command and can be targeted
|
2284 | * by keybindings.
|
2285 | *
|
2286 | * A quick fix should be marked preferred if it properly addresses the underlying error.
|
2287 | * A refactoring should be marked preferred if it is the most reasonable choice of actions to take.
|
2288 | */
|
2289 | isPreferred?: boolean;
|
2290 |
|
2291 | /**
|
2292 | * Marks that the code action cannot currently be applied.
|
2293 | *
|
2294 | * - Disabled code actions are not shown in automatic [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action)
|
2295 | * code action menu.
|
2296 | *
|
2297 | * - Disabled actions are shown as faded out in the code action menu when the user request a more specific type
|
2298 | * of code action, such as refactorings.
|
2299 | *
|
2300 | * - If the user has a [keybinding](https://code.visualstudio.com/docs/editor/refactoring#_keybindings-for-code-actions)
|
2301 | * that auto applies a code action and only a disabled code actions are returned, the editor will show the user an
|
2302 | * error message with `reason` in the editor.
|
2303 | */
|
2304 | disabled?: {
|
2305 | /**
|
2306 | * Human readable description of why the code action is currently disabled.
|
2307 | *
|
2308 | * This is displayed in the code actions UI.
|
2309 | */
|
2310 | readonly reason: string;
|
2311 | };
|
2312 |
|
2313 | /**
|
2314 | * Creates a new code action.
|
2315 | *
|
2316 | * A code action must have at least a {@link CodeAction.title title} and {@link CodeAction.edit edits}
|
2317 | * and/or a {@link CodeAction.command command}.
|
2318 | *
|
2319 | * @param title The title of the code action.
|
2320 | * @param kind The kind of the code action.
|
2321 | */
|
2322 | constructor(title: string, kind?: CodeActionKind);
|
2323 | }
|
2324 |
|
2325 | /**
|
2326 | * The code action interface defines the contract between extensions and
|
2327 | * the [lightbulb](https://code.visualstudio.com/docs/editor/editingevolved#_code-action) feature.
|
2328 | *
|
2329 | * A code action can be any command that is {@link commands.getCommands known} to the system.
|
2330 | */
|
2331 | export interface CodeActionProvider<T extends CodeAction = CodeAction> {
|
2332 | /**
|
2333 | * Provide commands for the given document and range.
|
2334 | *
|
2335 | * @param document The document in which the command was invoked.
|
2336 | * @param range The selector or range for which the command was invoked. This will always be a selection if
|
2337 | * there is a currently active editor.
|
2338 | * @param context Context carrying additional information.
|
2339 | * @param token A cancellation token.
|
2340 | *
|
2341 | * @return An array of code actions, such as quick fixes or refactorings. The lack of a result can be signaled
|
2342 | * by returning `undefined`, `null`, or an empty array.
|
2343 | *
|
2344 | * We also support returning `Command` for legacy reasons, however all new extensions should return
|
2345 | * `CodeAction` object instead.
|
2346 | */
|
2347 | provideCodeActions(document: TextDocument, range: Range | Selection, context: CodeActionContext, token: CancellationToken): ProviderResult<(Command | T)[]>;
|
2348 |
|
2349 | /**
|
2350 | * Given a code action fill in its {@link CodeAction.edit `edit`}-property. Changes to
|
2351 | * all other properties, like title, are ignored. A code action that has an edit
|
2352 | * will not be resolved.
|
2353 | *
|
2354 | * *Note* that a code action provider that returns commands, not code actions, cannot successfully
|
2355 | * implement this function. Returning commands is deprecated and instead code actions should be
|
2356 | * returned.
|
2357 | *
|
2358 | * @param codeAction A code action.
|
2359 | * @param token A cancellation token.
|
2360 | * @return The resolved code action or a thenable that resolves to such. It is OK to return the given
|
2361 | * `item`. When no result is returned, the given `item` will be used.
|
2362 | */
|
2363 | resolveCodeAction?(codeAction: T, token: CancellationToken): ProviderResult<T>;
|
2364 | }
|
2365 |
|
2366 | /**
|
2367 | * Metadata about the type of code actions that a {@link CodeActionProvider} provides.
|
2368 | */
|
2369 | export interface CodeActionProviderMetadata {
|
2370 | /**
|
2371 | * List of {@link CodeActionKind CodeActionKinds} that a {@link CodeActionProvider} may return.
|
2372 | *
|
2373 | * This list is used to determine if a given `CodeActionProvider` should be invoked or not.
|
2374 | * To avoid unnecessary computation, every `CodeActionProvider` should list use `providedCodeActionKinds`. The
|
2375 | * list of kinds may either be generic, such as `[CodeActionKind.Refactor]`, or list out every kind provided,
|
2376 | * such as `[CodeActionKind.Refactor.Extract.append('function'), CodeActionKind.Refactor.Extract.append('constant'), ...]`.
|
2377 | */
|
2378 | readonly providedCodeActionKinds?: readonly CodeActionKind[];
|
2379 |
|
2380 | /**
|
2381 | * Static documentation for a class of code actions.
|
2382 | *
|
2383 | * Documentation from the provider is shown in the code actions menu if either:
|
2384 | *
|
2385 | * - Code actions of `kind` are requested by the editor. In this case, the editor will show the documentation that
|
2386 | * most closely matches the requested code action kind. For example, if a provider has documentation for
|
2387 | * both `Refactor` and `RefactorExtract`, when the user requests code actions for `RefactorExtract`,
|
2388 | * the editor will use the documentation for `RefactorExtract` instead of the documentation for `Refactor`.
|
2389 | *
|
2390 | * - Any code actions of `kind` are returned by the provider.
|
2391 | *
|
2392 | * At most one documentation entry will be shown per provider.
|
2393 | */
|
2394 | readonly documentation?: ReadonlyArray<{
|
2395 | /**
|
2396 | * The kind of the code action being documented.
|
2397 | *
|
2398 | * If the kind is generic, such as `CodeActionKind.Refactor`, the documentation will be shown whenever any
|
2399 | * refactorings are returned. If the kind if more specific, such as `CodeActionKind.RefactorExtract`, the
|
2400 | * documentation will only be shown when extract refactoring code actions are returned.
|
2401 | */
|
2402 | readonly kind: CodeActionKind;
|
2403 |
|
2404 | /**
|
2405 | * Command that displays the documentation to the user.
|
2406 | *
|
2407 | * This can display the documentation directly in the editor or open a website using {@link env.openExternal `env.openExternal`};
|
2408 | *
|
2409 | * The title of this documentation code action is taken from {@link Command.title `Command.title`}
|
2410 | */
|
2411 | readonly command: Command;
|
2412 | }>;
|
2413 | }
|
2414 |
|
2415 | /**
|
2416 | * A code lens represents a {@link Command} that should be shown along with
|
2417 | * source text, like the number of references, a way to run tests, etc.
|
2418 | *
|
2419 | * A code lens is _unresolved_ when no command is associated to it. For performance
|
2420 | * reasons the creation of a code lens and resolving should be done to two stages.
|
2421 | *
|
2422 | * @see {@link CodeLensProvider.provideCodeLenses}
|
2423 | * @see {@link CodeLensProvider.resolveCodeLens}
|
2424 | */
|
2425 | export class CodeLens {
|
2426 |
|
2427 | /**
|
2428 | * The range in which this code lens is valid. Should only span a single line.
|
2429 | */
|
2430 | range: Range;
|
2431 |
|
2432 | /**
|
2433 | * The command this code lens represents.
|
2434 | */
|
2435 | command?: Command;
|
2436 |
|
2437 | /**
|
2438 | * `true` when there is a command associated.
|
2439 | */
|
2440 | readonly isResolved: boolean;
|
2441 |
|
2442 | /**
|
2443 | * Creates a new code lens object.
|
2444 | *
|
2445 | * @param range The range to which this code lens applies.
|
2446 | * @param command The command associated to this code lens.
|
2447 | */
|
2448 | constructor(range: Range, command?: Command);
|
2449 | }
|
2450 |
|
2451 | /**
|
2452 | * A code lens provider adds {@link Command commands} to source text. The commands will be shown
|
2453 | * as dedicated horizontal lines in between the source text.
|
2454 | */
|
2455 | export interface CodeLensProvider<T extends CodeLens = CodeLens> {
|
2456 |
|
2457 | /**
|
2458 | * An optional event to signal that the code lenses from this provider have changed.
|
2459 | */
|
2460 | onDidChangeCodeLenses?: Event<void>;
|
2461 |
|
2462 | /**
|
2463 | * Compute a list of {@link CodeLens lenses}. This call should return as fast as possible and if
|
2464 | * computing the commands is expensive implementors should only return code lens objects with the
|
2465 | * range set and implement {@link CodeLensProvider.resolveCodeLens resolve}.
|
2466 | *
|
2467 | * @param document The document in which the command was invoked.
|
2468 | * @param token A cancellation token.
|
2469 | * @return An array of code lenses or a thenable that resolves to such. The lack of a result can be
|
2470 | * signaled by returning `undefined`, `null`, or an empty array.
|
2471 | */
|
2472 | provideCodeLenses(document: TextDocument, token: CancellationToken): ProviderResult<T[]>;
|
2473 |
|
2474 | /**
|
2475 | * This function will be called for each visible code lens, usually when scrolling and after
|
2476 | * calls to {@link CodeLensProvider.provideCodeLenses compute}-lenses.
|
2477 | *
|
2478 | * @param codeLens Code lens that must be resolved.
|
2479 | * @param token A cancellation token.
|
2480 | * @return The given, resolved code lens or thenable that resolves to such.
|
2481 | */
|
2482 | resolveCodeLens?(codeLens: T, token: CancellationToken): ProviderResult<T>;
|
2483 | }
|
2484 |
|
2485 | /**
|
2486 | * Information about where a symbol is defined.
|
2487 | *
|
2488 | * Provides additional metadata over normal {@link Location} definitions, including the range of
|
2489 | * the defining symbol
|
2490 | */
|
2491 | export type DefinitionLink = LocationLink;
|
2492 |
|
2493 | /**
|
2494 | * The definition of a symbol represented as one or many {@link Location locations}.
|
2495 | * For most programming languages there is only one location at which a symbol is
|
2496 | * defined.
|
2497 | */
|
2498 | export type Definition = Location | Location[];
|
2499 |
|
2500 | /**
|
2501 | * The definition provider interface defines the contract between extensions and
|
2502 | * the [go to definition](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-definition)
|
2503 | * and peek definition features.
|
2504 | */
|
2505 | export interface DefinitionProvider {
|
2506 |
|
2507 | /**
|
2508 | * Provide the definition of the symbol at the given position and document.
|
2509 | *
|
2510 | * @param document The document in which the command was invoked.
|
2511 | * @param position The position at which the command was invoked.
|
2512 | * @param token A cancellation token.
|
2513 | * @return A definition or a thenable that resolves to such. The lack of a result can be
|
2514 | * signaled by returning `undefined` or `null`.
|
2515 | */
|
2516 | provideDefinition(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
|
2517 | }
|
2518 |
|
2519 | /**
|
2520 | * The implementation provider interface defines the contract between extensions and
|
2521 | * the go to implementation feature.
|
2522 | */
|
2523 | export interface ImplementationProvider {
|
2524 |
|
2525 | /**
|
2526 | * Provide the implementations of the symbol at the given position and document.
|
2527 | *
|
2528 | * @param document The document in which the command was invoked.
|
2529 | * @param position The position at which the command was invoked.
|
2530 | * @param token A cancellation token.
|
2531 | * @return A definition or a thenable that resolves to such. The lack of a result can be
|
2532 | * signaled by returning `undefined` or `null`.
|
2533 | */
|
2534 | provideImplementation(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
|
2535 | }
|
2536 |
|
2537 | /**
|
2538 | * The type definition provider defines the contract between extensions and
|
2539 | * the go to type definition feature.
|
2540 | */
|
2541 | export interface TypeDefinitionProvider {
|
2542 |
|
2543 | /**
|
2544 | * Provide the type definition of the symbol at the given position and document.
|
2545 | *
|
2546 | * @param document The document in which the command was invoked.
|
2547 | * @param position The position at which the command was invoked.
|
2548 | * @param token A cancellation token.
|
2549 | * @return A definition or a thenable that resolves to such. The lack of a result can be
|
2550 | * signaled by returning `undefined` or `null`.
|
2551 | */
|
2552 | provideTypeDefinition(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
|
2553 | }
|
2554 |
|
2555 | /**
|
2556 | * The declaration of a symbol representation as one or many {@link Location locations}
|
2557 | * or {@link LocationLink location links}.
|
2558 | */
|
2559 | export type Declaration = Location | Location[] | LocationLink[];
|
2560 |
|
2561 | /**
|
2562 | * The declaration provider interface defines the contract between extensions and
|
2563 | * the go to declaration feature.
|
2564 | */
|
2565 | export interface DeclarationProvider {
|
2566 |
|
2567 | /**
|
2568 | * Provide the declaration of the symbol at the given position and document.
|
2569 | *
|
2570 | * @param document The document in which the command was invoked.
|
2571 | * @param position The position at which the command was invoked.
|
2572 | * @param token A cancellation token.
|
2573 | * @return A declaration or a thenable that resolves to such. The lack of a result can be
|
2574 | * signaled by returning `undefined` or `null`.
|
2575 | */
|
2576 | provideDeclaration(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Declaration>;
|
2577 | }
|
2578 |
|
2579 | /**
|
2580 | * The MarkdownString represents human-readable text that supports formatting via the
|
2581 | * markdown syntax. Standard markdown is supported, also tables, but no embedded html.
|
2582 | *
|
2583 | * Rendering of {@link ThemeIcon theme icons} via the `$(<name>)`-syntax is supported
|
2584 | * when the {@link MarkdownString.supportThemeIcons `supportThemeIcons`} is set to `true`.
|
2585 | */
|
2586 | export class MarkdownString {
|
2587 |
|
2588 | /**
|
2589 | * The markdown string.
|
2590 | */
|
2591 | value: string;
|
2592 |
|
2593 | /**
|
2594 | * Indicates that this markdown string is from a trusted source. Only *trusted*
|
2595 | * markdown supports links that execute commands, e.g. `[Run it](command:myCommandId)`.
|
2596 | */
|
2597 | isTrusted?: boolean;
|
2598 |
|
2599 | /**
|
2600 | * Indicates that this markdown string can contain {@link ThemeIcon ThemeIcons}, e.g. `$(zap)`.
|
2601 | */
|
2602 | supportThemeIcons?: boolean;
|
2603 |
|
2604 | /**
|
2605 | * Creates a new markdown string with the given value.
|
2606 | *
|
2607 | * @param value Optional, initial value.
|
2608 | * @param supportThemeIcons Optional, Specifies whether {@link ThemeIcon ThemeIcons} are supported within the {@link MarkdownString `MarkdownString`}.
|
2609 | */
|
2610 | constructor(value?: string, supportThemeIcons?: boolean);
|
2611 |
|
2612 | /**
|
2613 | * Appends and escapes the given string to this markdown string.
|
2614 | * @param value Plain text.
|
2615 | */
|
2616 | appendText(value: string): MarkdownString;
|
2617 |
|
2618 | /**
|
2619 | * Appends the given string 'as is' to this markdown string. When {@link MarkdownString.supportThemeIcons `supportThemeIcons`} is `true`, {@link ThemeIcon ThemeIcons} in the `value` will be iconified.
|
2620 | * @param value Markdown string.
|
2621 | */
|
2622 | appendMarkdown(value: string): MarkdownString;
|
2623 |
|
2624 | /**
|
2625 | * Appends the given string as codeblock using the provided language.
|
2626 | * @param value A code snippet.
|
2627 | * @param language An optional {@link languages.getLanguages language identifier}.
|
2628 | */
|
2629 | appendCodeblock(value: string, language?: string): MarkdownString;
|
2630 | }
|
2631 |
|
2632 | /**
|
2633 | * MarkedString can be used to render human-readable text. It is either a markdown string
|
2634 | * or a code-block that provides a language and a code snippet. Note that
|
2635 | * markdown strings will be sanitized - that means html will be escaped.
|
2636 | *
|
2637 | * @deprecated This type is deprecated, please use {@link MarkdownString `MarkdownString`} instead.
|
2638 | */
|
2639 | export type MarkedString = string | { language: string; value: string };
|
2640 |
|
2641 | /**
|
2642 | * A hover represents additional information for a symbol or word. Hovers are
|
2643 | * rendered in a tooltip-like widget.
|
2644 | */
|
2645 | export class Hover {
|
2646 |
|
2647 | /**
|
2648 | * The contents of this hover.
|
2649 | */
|
2650 | contents: Array<MarkdownString | MarkedString>;
|
2651 |
|
2652 | /**
|
2653 | * The range to which this hover applies. When missing, the
|
2654 | * editor will use the range at the current position or the
|
2655 | * current position itself.
|
2656 | */
|
2657 | range?: Range;
|
2658 |
|
2659 | /**
|
2660 | * Creates a new hover object.
|
2661 | *
|
2662 | * @param contents The contents of the hover.
|
2663 | * @param range The range to which the hover applies.
|
2664 | */
|
2665 | constructor(contents: MarkdownString | MarkedString | Array<MarkdownString | MarkedString>, range?: Range);
|
2666 | }
|
2667 |
|
2668 | /**
|
2669 | * The hover provider interface defines the contract between extensions and
|
2670 | * the [hover](https://code.visualstudio.com/docs/editor/intellisense)-feature.
|
2671 | */
|
2672 | export interface HoverProvider {
|
2673 |
|
2674 | /**
|
2675 | * Provide a hover for the given position and document. Multiple hovers at the same
|
2676 | * position will be merged by the editor. A hover can have a range which defaults
|
2677 | * to the word range at the position when omitted.
|
2678 | *
|
2679 | * @param document The document in which the command was invoked.
|
2680 | * @param position The position at which the command was invoked.
|
2681 | * @param token A cancellation token.
|
2682 | * @return A hover or a thenable that resolves to such. The lack of a result can be
|
2683 | * signaled by returning `undefined` or `null`.
|
2684 | */
|
2685 | provideHover(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Hover>;
|
2686 | }
|
2687 |
|
2688 | /**
|
2689 | * An EvaluatableExpression represents an expression in a document that can be evaluated by an active debugger or runtime.
|
2690 | * The result of this evaluation is shown in a tooltip-like widget.
|
2691 | * If only a range is specified, the expression will be extracted from the underlying document.
|
2692 | * An optional expression can be used to override the extracted expression.
|
2693 | * In this case the range is still used to highlight the range in the document.
|
2694 | */
|
2695 | export class EvaluatableExpression {
|
2696 |
|
2697 | /*
|
2698 | * The range is used to extract the evaluatable expression from the underlying document and to highlight it.
|
2699 | */
|
2700 | readonly range: Range;
|
2701 |
|
2702 | /*
|
2703 | * If specified the expression overrides the extracted expression.
|
2704 | */
|
2705 | readonly expression?: string;
|
2706 |
|
2707 | /**
|
2708 | * Creates a new evaluatable expression object.
|
2709 | *
|
2710 | * @param range The range in the underlying document from which the evaluatable expression is extracted.
|
2711 | * @param expression If specified overrides the extracted expression.
|
2712 | */
|
2713 | constructor(range: Range, expression?: string);
|
2714 | }
|
2715 |
|
2716 | /**
|
2717 | * The evaluatable expression provider interface defines the contract between extensions and
|
2718 | * the debug hover. In this contract the provider returns an evaluatable expression for a given position
|
2719 | * in a document and the editor evaluates this expression in the active debug session and shows the result in a debug hover.
|
2720 | */
|
2721 | export interface EvaluatableExpressionProvider {
|
2722 |
|
2723 | /**
|
2724 | * Provide an evaluatable expression for the given document and position.
|
2725 | * The editor will evaluate this expression in the active debug session and will show the result in the debug hover.
|
2726 | * The expression can be implicitly specified by the range in the underlying document or by explicitly returning an expression.
|
2727 | *
|
2728 | * @param document The document for which the debug hover is about to appear.
|
2729 | * @param position The line and character position in the document where the debug hover is about to appear.
|
2730 | * @param token A cancellation token.
|
2731 | * @return An EvaluatableExpression or a thenable that resolves to such. The lack of a result can be
|
2732 | * signaled by returning `undefined` or `null`.
|
2733 | */
|
2734 | provideEvaluatableExpression(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<EvaluatableExpression>;
|
2735 | }
|
2736 |
|
2737 | /**
|
2738 | * Provide inline value as text.
|
2739 | */
|
2740 | export class InlineValueText {
|
2741 | /**
|
2742 | * The document range for which the inline value applies.
|
2743 | */
|
2744 | readonly range: Range;
|
2745 | /**
|
2746 | * The text of the inline value.
|
2747 | */
|
2748 | readonly text: string;
|
2749 | /**
|
2750 | * Creates a new InlineValueText object.
|
2751 | *
|
2752 | * @param range The document line where to show the inline value.
|
2753 | * @param text The value to be shown for the line.
|
2754 | */
|
2755 | constructor(range: Range, text: string);
|
2756 | }
|
2757 |
|
2758 | /**
|
2759 | * Provide inline value through a variable lookup.
|
2760 | * If only a range is specified, the variable name will be extracted from the underlying document.
|
2761 | * An optional variable name can be used to override the extracted name.
|
2762 | */
|
2763 | export class InlineValueVariableLookup {
|
2764 | /**
|
2765 | * The document range for which the inline value applies.
|
2766 | * The range is used to extract the variable name from the underlying document.
|
2767 | */
|
2768 | readonly range: Range;
|
2769 | /**
|
2770 | * If specified the name of the variable to look up.
|
2771 | */
|
2772 | readonly variableName?: string;
|
2773 | /**
|
2774 | * How to perform the lookup.
|
2775 | */
|
2776 | readonly caseSensitiveLookup: boolean;
|
2777 | /**
|
2778 | * Creates a new InlineValueVariableLookup object.
|
2779 | *
|
2780 | * @param range The document line where to show the inline value.
|
2781 | * @param variableName The name of the variable to look up.
|
2782 | * @param caseSensitiveLookup How to perform the lookup. If missing lookup is case sensitive.
|
2783 | */
|
2784 | constructor(range: Range, variableName?: string, caseSensitiveLookup?: boolean);
|
2785 | }
|
2786 |
|
2787 | /**
|
2788 | * Provide an inline value through an expression evaluation.
|
2789 | * If only a range is specified, the expression will be extracted from the underlying document.
|
2790 | * An optional expression can be used to override the extracted expression.
|
2791 | */
|
2792 | export class InlineValueEvaluatableExpression {
|
2793 | /**
|
2794 | * The document range for which the inline value applies.
|
2795 | * The range is used to extract the evaluatable expression from the underlying document.
|
2796 | */
|
2797 | readonly range: Range;
|
2798 | /**
|
2799 | * If specified the expression overrides the extracted expression.
|
2800 | */
|
2801 | readonly expression?: string;
|
2802 | /**
|
2803 | * Creates a new InlineValueEvaluatableExpression object.
|
2804 | *
|
2805 | * @param range The range in the underlying document from which the evaluatable expression is extracted.
|
2806 | * @param expression If specified overrides the extracted expression.
|
2807 | */
|
2808 | constructor(range: Range, expression?: string);
|
2809 | }
|
2810 |
|
2811 | /**
|
2812 | * Inline value information can be provided by different means:
|
2813 | * - directly as a text value (class InlineValueText).
|
2814 | * - as a name to use for a variable lookup (class InlineValueVariableLookup)
|
2815 | * - as an evaluatable expression (class InlineValueEvaluatableExpression)
|
2816 | * The InlineValue types combines all inline value types into one type.
|
2817 | */
|
2818 | export type InlineValue = InlineValueText | InlineValueVariableLookup | InlineValueEvaluatableExpression;
|
2819 |
|
2820 | /**
|
2821 | * A value-object that contains contextual information when requesting inline values from a InlineValuesProvider.
|
2822 | */
|
2823 | export interface InlineValueContext {
|
2824 |
|
2825 | /**
|
2826 | * The stack frame (as a DAP Id) where the execution has stopped.
|
2827 | */
|
2828 | readonly frameId: number;
|
2829 |
|
2830 | /**
|
2831 | * The document range where execution has stopped.
|
2832 | * Typically the end position of the range denotes the line where the inline values are shown.
|
2833 | */
|
2834 | readonly stoppedLocation: Range;
|
2835 | }
|
2836 |
|
2837 | /**
|
2838 | * The inline values provider interface defines the contract between extensions and the editor's debugger inline values feature.
|
2839 | * In this contract the provider returns inline value information for a given document range
|
2840 | * and the editor shows this information in the editor at the end of lines.
|
2841 | */
|
2842 | export interface InlineValuesProvider {
|
2843 |
|
2844 | /**
|
2845 | * An optional event to signal that inline values have changed.
|
2846 | * @see {@link EventEmitter}
|
2847 | */
|
2848 | onDidChangeInlineValues?: Event<void> | undefined;
|
2849 |
|
2850 | /**
|
2851 | * Provide "inline value" information for a given document and range.
|
2852 | * The editor calls this method whenever debugging stops in the given document.
|
2853 | * The returned inline values information is rendered in the editor at the end of lines.
|
2854 | *
|
2855 | * @param document The document for which the inline values information is needed.
|
2856 | * @param viewPort The visible document range for which inline values should be computed.
|
2857 | * @param context A bag containing contextual information like the current location.
|
2858 | * @param token A cancellation token.
|
2859 | * @return An array of InlineValueDescriptors or a thenable that resolves to such. The lack of a result can be
|
2860 | * signaled by returning `undefined` or `null`.
|
2861 | */
|
2862 | provideInlineValues(document: TextDocument, viewPort: Range, context: InlineValueContext, token: CancellationToken): ProviderResult<InlineValue[]>;
|
2863 | }
|
2864 |
|
2865 | /**
|
2866 | * A document highlight kind.
|
2867 | */
|
2868 | export enum DocumentHighlightKind {
|
2869 |
|
2870 | /**
|
2871 | * A textual occurrence.
|
2872 | */
|
2873 | Text = 0,
|
2874 |
|
2875 | /**
|
2876 | * Read-access of a symbol, like reading a variable.
|
2877 | */
|
2878 | Read = 1,
|
2879 |
|
2880 | /**
|
2881 | * Write-access of a symbol, like writing to a variable.
|
2882 | */
|
2883 | Write = 2
|
2884 | }
|
2885 |
|
2886 | /**
|
2887 | * A document highlight is a range inside a text document which deserves
|
2888 | * special attention. Usually a document highlight is visualized by changing
|
2889 | * the background color of its range.
|
2890 | */
|
2891 | export class DocumentHighlight {
|
2892 |
|
2893 | /**
|
2894 | * The range this highlight applies to.
|
2895 | */
|
2896 | range: Range;
|
2897 |
|
2898 | /**
|
2899 | * The highlight kind, default is {@link DocumentHighlightKind.Text text}.
|
2900 | */
|
2901 | kind?: DocumentHighlightKind;
|
2902 |
|
2903 | /**
|
2904 | * Creates a new document highlight object.
|
2905 | *
|
2906 | * @param range The range the highlight applies to.
|
2907 | * @param kind The highlight kind, default is {@link DocumentHighlightKind.Text text}.
|
2908 | */
|
2909 | constructor(range: Range, kind?: DocumentHighlightKind);
|
2910 | }
|
2911 |
|
2912 | /**
|
2913 | * The document highlight provider interface defines the contract between extensions and
|
2914 | * the word-highlight-feature.
|
2915 | */
|
2916 | export interface DocumentHighlightProvider {
|
2917 |
|
2918 | /**
|
2919 | * Provide a set of document highlights, like all occurrences of a variable or
|
2920 | * all exit-points of a function.
|
2921 | *
|
2922 | * @param document The document in which the command was invoked.
|
2923 | * @param position The position at which the command was invoked.
|
2924 | * @param token A cancellation token.
|
2925 | * @return An array of document highlights or a thenable that resolves to such. The lack of a result can be
|
2926 | * signaled by returning `undefined`, `null`, or an empty array.
|
2927 | */
|
2928 | provideDocumentHighlights(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<DocumentHighlight[]>;
|
2929 | }
|
2930 |
|
2931 | /**
|
2932 | * A symbol kind.
|
2933 | */
|
2934 | export enum SymbolKind {
|
2935 | File = 0,
|
2936 | Module = 1,
|
2937 | Namespace = 2,
|
2938 | Package = 3,
|
2939 | Class = 4,
|
2940 | Method = 5,
|
2941 | Property = 6,
|
2942 | Field = 7,
|
2943 | Constructor = 8,
|
2944 | Enum = 9,
|
2945 | Interface = 10,
|
2946 | Function = 11,
|
2947 | Variable = 12,
|
2948 | Constant = 13,
|
2949 | String = 14,
|
2950 | Number = 15,
|
2951 | Boolean = 16,
|
2952 | Array = 17,
|
2953 | Object = 18,
|
2954 | Key = 19,
|
2955 | Null = 20,
|
2956 | EnumMember = 21,
|
2957 | Struct = 22,
|
2958 | Event = 23,
|
2959 | Operator = 24,
|
2960 | TypeParameter = 25
|
2961 | }
|
2962 |
|
2963 | /**
|
2964 | * Symbol tags are extra annotations that tweak the rendering of a symbol.
|
2965 | */
|
2966 | export enum SymbolTag {
|
2967 |
|
2968 | /**
|
2969 | * Render a symbol as obsolete, usually using a strike-out.
|
2970 | */
|
2971 | Deprecated = 1
|
2972 | }
|
2973 |
|
2974 | /**
|
2975 | * Represents information about programming constructs like variables, classes,
|
2976 | * interfaces etc.
|
2977 | */
|
2978 | export class SymbolInformation {
|
2979 |
|
2980 | /**
|
2981 | * The name of this symbol.
|
2982 | */
|
2983 | name: string;
|
2984 |
|
2985 | /**
|
2986 | * The name of the symbol containing this symbol.
|
2987 | */
|
2988 | containerName: string;
|
2989 |
|
2990 | /**
|
2991 | * The kind of this symbol.
|
2992 | */
|
2993 | kind: SymbolKind;
|
2994 |
|
2995 | /**
|
2996 | * Tags for this symbol.
|
2997 | */
|
2998 | tags?: readonly SymbolTag[];
|
2999 |
|
3000 | /**
|
3001 | * The location of this symbol.
|
3002 | */
|
3003 | location: Location;
|
3004 |
|
3005 | /**
|
3006 | * Creates a new symbol information object.
|
3007 | *
|
3008 | * @param name The name of the symbol.
|
3009 | * @param kind The kind of the symbol.
|
3010 | * @param containerName The name of the symbol containing the symbol.
|
3011 | * @param location The location of the symbol.
|
3012 | */
|
3013 | constructor(name: string, kind: SymbolKind, containerName: string, location: Location);
|
3014 |
|
3015 | /**
|
3016 | * Creates a new symbol information object.
|
3017 | *
|
3018 | * @deprecated Please use the constructor taking a {@link Location} object.
|
3019 | *
|
3020 | * @param name The name of the symbol.
|
3021 | * @param kind The kind of the symbol.
|
3022 | * @param range The range of the location of the symbol.
|
3023 | * @param uri The resource of the location of symbol, defaults to the current document.
|
3024 | * @param containerName The name of the symbol containing the symbol.
|
3025 | */
|
3026 | constructor(name: string, kind: SymbolKind, range: Range, uri?: Uri, containerName?: string);
|
3027 | }
|
3028 |
|
3029 | /**
|
3030 | * Represents programming constructs like variables, classes, interfaces etc. that appear in a document. Document
|
3031 | * symbols can be hierarchical and they have two ranges: one that encloses its definition and one that points to
|
3032 | * its most interesting range, e.g. the range of an identifier.
|
3033 | */
|
3034 | export class DocumentSymbol {
|
3035 |
|
3036 | /**
|
3037 | * The name of this symbol.
|
3038 | */
|
3039 | name: string;
|
3040 |
|
3041 | /**
|
3042 | * More detail for this symbol, e.g. the signature of a function.
|
3043 | */
|
3044 | detail: string;
|
3045 |
|
3046 | /**
|
3047 | * The kind of this symbol.
|
3048 | */
|
3049 | kind: SymbolKind;
|
3050 |
|
3051 | /**
|
3052 | * Tags for this symbol.
|
3053 | */
|
3054 | tags?: readonly SymbolTag[];
|
3055 |
|
3056 | /**
|
3057 | * The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code.
|
3058 | */
|
3059 | range: Range;
|
3060 |
|
3061 | /**
|
3062 | * The range that should be selected and reveal when this symbol is being picked, e.g. the name of a function.
|
3063 | * Must be contained by the {@link DocumentSymbol.range `range`}.
|
3064 | */
|
3065 | selectionRange: Range;
|
3066 |
|
3067 | /**
|
3068 | * Children of this symbol, e.g. properties of a class.
|
3069 | */
|
3070 | children: DocumentSymbol[];
|
3071 |
|
3072 | /**
|
3073 | * Creates a new document symbol.
|
3074 | *
|
3075 | * @param name The name of the symbol.
|
3076 | * @param detail Details for the symbol.
|
3077 | * @param kind The kind of the symbol.
|
3078 | * @param range The full range of the symbol.
|
3079 | * @param selectionRange The range that should be reveal.
|
3080 | */
|
3081 | constructor(name: string, detail: string, kind: SymbolKind, range: Range, selectionRange: Range);
|
3082 | }
|
3083 |
|
3084 | /**
|
3085 | * The document symbol provider interface defines the contract between extensions and
|
3086 | * the [go to symbol](https://code.visualstudio.com/docs/editor/editingevolved#_go-to-symbol)-feature.
|
3087 | */
|
3088 | export interface DocumentSymbolProvider {
|
3089 |
|
3090 | /**
|
3091 | * Provide symbol information for the given document.
|
3092 | *
|
3093 | * @param document The document in which the command was invoked.
|
3094 | * @param token A cancellation token.
|
3095 | * @return An array of document highlights or a thenable that resolves to such. The lack of a result can be
|
3096 | * signaled by returning `undefined`, `null`, or an empty array.
|
3097 | */
|
3098 | provideDocumentSymbols(document: TextDocument, token: CancellationToken): ProviderResult<SymbolInformation[] | DocumentSymbol[]>;
|
3099 | }
|
3100 |
|
3101 | /**
|
3102 | * Metadata about a document symbol provider.
|
3103 | */
|
3104 | export interface DocumentSymbolProviderMetadata {
|
3105 | /**
|
3106 | * A human-readable string that is shown when multiple outlines trees show for one document.
|
3107 | */
|
3108 | label?: string;
|
3109 | }
|
3110 |
|
3111 | /**
|
3112 | * The workspace symbol provider interface defines the contract between extensions and
|
3113 | * the [symbol search](https://code.visualstudio.com/docs/editor/editingevolved#_open-symbol-by-name)-feature.
|
3114 | */
|
3115 | export interface WorkspaceSymbolProvider<T extends SymbolInformation = SymbolInformation> {
|
3116 |
|
3117 | /**
|
3118 | * Project-wide search for a symbol matching the given query string.
|
3119 | *
|
3120 | * The `query`-parameter should be interpreted in a *relaxed way* as the editor will apply its own highlighting
|
3121 | * and scoring on the results. A good rule of thumb is to match case-insensitive and to simply check that the
|
3122 | * characters of *query* appear in their order in a candidate symbol. Don't use prefix, substring, or similar
|
3123 | * strict matching.
|
3124 | *
|
3125 | * To improve performance implementors can implement `resolveWorkspaceSymbol` and then provide symbols with partial
|
3126 | * {@link SymbolInformation.location location}-objects, without a `range` defined. The editor will then call
|
3127 | * `resolveWorkspaceSymbol` for selected symbols only, e.g. when opening a workspace symbol.
|
3128 | *
|
3129 | * @param query A query string, can be the empty string in which case all symbols should be returned.
|
3130 | * @param token A cancellation token.
|
3131 | * @return An array of document highlights or a thenable that resolves to such. The lack of a result can be
|
3132 | * signaled by returning `undefined`, `null`, or an empty array.
|
3133 | */
|
3134 | provideWorkspaceSymbols(query: string, token: CancellationToken): ProviderResult<T[]>;
|
3135 |
|
3136 | /**
|
3137 | * Given a symbol fill in its {@link SymbolInformation.location location}. This method is called whenever a symbol
|
3138 | * is selected in the UI. Providers can implement this method and return incomplete symbols from
|
3139 | * {@link WorkspaceSymbolProvider.provideWorkspaceSymbols `provideWorkspaceSymbols`} which often helps to improve
|
3140 | * performance.
|
3141 | *
|
3142 | * @param symbol The symbol that is to be resolved. Guaranteed to be an instance of an object returned from an
|
3143 | * earlier call to `provideWorkspaceSymbols`.
|
3144 | * @param token A cancellation token.
|
3145 | * @return The resolved symbol or a thenable that resolves to that. When no result is returned,
|
3146 | * the given `symbol` is used.
|
3147 | */
|
3148 | resolveWorkspaceSymbol?(symbol: T, token: CancellationToken): ProviderResult<T>;
|
3149 | }
|
3150 |
|
3151 | /**
|
3152 | * Value-object that contains additional information when
|
3153 | * requesting references.
|
3154 | */
|
3155 | export interface ReferenceContext {
|
3156 |
|
3157 | /**
|
3158 | * Include the declaration of the current symbol.
|
3159 | */
|
3160 | includeDeclaration: boolean;
|
3161 | }
|
3162 |
|
3163 | /**
|
3164 | * The reference provider interface defines the contract between extensions and
|
3165 | * the [find references](https://code.visualstudio.com/docs/editor/editingevolved#_peek)-feature.
|
3166 | */
|
3167 | export interface ReferenceProvider {
|
3168 |
|
3169 | /**
|
3170 | * Provide a set of project-wide references for the given position and document.
|
3171 | *
|
3172 | * @param document The document in which the command was invoked.
|
3173 | * @param position The position at which the command was invoked.
|
3174 | * @param token A cancellation token.
|
3175 | *
|
3176 | * @return An array of locations or a thenable that resolves to such. The lack of a result can be
|
3177 | * signaled by returning `undefined`, `null`, or an empty array.
|
3178 | */
|
3179 | provideReferences(document: TextDocument, position: Position, context: ReferenceContext, token: CancellationToken): ProviderResult<Location[]>;
|
3180 | }
|
3181 |
|
3182 | /**
|
3183 | * A text edit represents edits that should be applied
|
3184 | * to a document.
|
3185 | */
|
3186 | export class TextEdit {
|
3187 |
|
3188 | /**
|
3189 | * Utility to create a replace edit.
|
3190 | *
|
3191 | * @param range A range.
|
3192 | * @param newText A string.
|
3193 | * @return A new text edit object.
|
3194 | */
|
3195 | static replace(range: Range, newText: string): TextEdit;
|
3196 |
|
3197 | /**
|
3198 | * Utility to create an insert edit.
|
3199 | *
|
3200 | * @param position A position, will become an empty range.
|
3201 | * @param newText A string.
|
3202 | * @return A new text edit object.
|
3203 | */
|
3204 | static insert(position: Position, newText: string): TextEdit;
|
3205 |
|
3206 | /**
|
3207 | * Utility to create a delete edit.
|
3208 | *
|
3209 | * @param range A range.
|
3210 | * @return A new text edit object.
|
3211 | */
|
3212 | static delete(range: Range): TextEdit;
|
3213 |
|
3214 | /**
|
3215 | * Utility to create an eol-edit.
|
3216 | *
|
3217 | * @param eol An eol-sequence
|
3218 | * @return A new text edit object.
|
3219 | */
|
3220 | static setEndOfLine(eol: EndOfLine): TextEdit;
|
3221 |
|
3222 | /**
|
3223 | * The range this edit applies to.
|
3224 | */
|
3225 | range: Range;
|
3226 |
|
3227 | /**
|
3228 | * The string this edit will insert.
|
3229 | */
|
3230 | newText: string;
|
3231 |
|
3232 | /**
|
3233 | * The eol-sequence used in the document.
|
3234 | *
|
3235 | * *Note* that the eol-sequence will be applied to the
|
3236 | * whole document.
|
3237 | */
|
3238 | newEol?: EndOfLine;
|
3239 |
|
3240 | /**
|
3241 | * Create a new TextEdit.
|
3242 | *
|
3243 | * @param range A range.
|
3244 | * @param newText A string.
|
3245 | */
|
3246 | constructor(range: Range, newText: string);
|
3247 | }
|
3248 |
|
3249 | /**
|
3250 | * Additional data for entries of a workspace edit. Supports to label entries and marks entries
|
3251 | * as needing confirmation by the user. The editor groups edits with equal labels into tree nodes,
|
3252 | * for instance all edits labelled with "Changes in Strings" would be a tree node.
|
3253 | */
|
3254 | export interface WorkspaceEditEntryMetadata {
|
3255 |
|
3256 | /**
|
3257 | * A flag which indicates that user confirmation is needed.
|
3258 | */
|
3259 | needsConfirmation: boolean;
|
3260 |
|
3261 | /**
|
3262 | * A human-readable string which is rendered prominent.
|
3263 | */
|
3264 | label: string;
|
3265 |
|
3266 | /**
|
3267 | * A human-readable string which is rendered less prominent on the same line.
|
3268 | */
|
3269 | description?: string;
|
3270 |
|
3271 | /**
|
3272 | * The icon path or {@link ThemeIcon} for the edit.
|
3273 | */
|
3274 | iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
|
3275 | }
|
3276 |
|
3277 | /**
|
3278 | * A workspace edit is a collection of textual and files changes for
|
3279 | * multiple resources and documents.
|
3280 | *
|
3281 | * Use the {@link workspace.applyEdit applyEdit}-function to apply a workspace edit.
|
3282 | */
|
3283 | export class WorkspaceEdit {
|
3284 |
|
3285 | /**
|
3286 | * The number of affected resources of textual or resource changes.
|
3287 | */
|
3288 | readonly size: number;
|
3289 |
|
3290 | /**
|
3291 | * Replace the given range with given text for the given resource.
|
3292 | *
|
3293 | * @param uri A resource identifier.
|
3294 | * @param range A range.
|
3295 | * @param newText A string.
|
3296 | * @param metadata Optional metadata for the entry.
|
3297 | */
|
3298 | replace(uri: Uri, range: Range, newText: string, metadata?: WorkspaceEditEntryMetadata): void;
|
3299 |
|
3300 | /**
|
3301 | * Insert the given text at the given position.
|
3302 | *
|
3303 | * @param uri A resource identifier.
|
3304 | * @param position A position.
|
3305 | * @param newText A string.
|
3306 | * @param metadata Optional metadata for the entry.
|
3307 | */
|
3308 | insert(uri: Uri, position: Position, newText: string, metadata?: WorkspaceEditEntryMetadata): void;
|
3309 |
|
3310 | /**
|
3311 | * Delete the text at the given range.
|
3312 | *
|
3313 | * @param uri A resource identifier.
|
3314 | * @param range A range.
|
3315 | * @param metadata Optional metadata for the entry.
|
3316 | */
|
3317 | delete(uri: Uri, range: Range, metadata?: WorkspaceEditEntryMetadata): void;
|
3318 |
|
3319 | /**
|
3320 | * Check if a text edit for a resource exists.
|
3321 | *
|
3322 | * @param uri A resource identifier.
|
3323 | * @return `true` if the given resource will be touched by this edit.
|
3324 | */
|
3325 | has(uri: Uri): boolean;
|
3326 |
|
3327 | /**
|
3328 | * Set (and replace) text edits for a resource.
|
3329 | *
|
3330 | * @param uri A resource identifier.
|
3331 | * @param edits An array of text edits.
|
3332 | */
|
3333 | set(uri: Uri, edits: TextEdit[]): void;
|
3334 |
|
3335 | /**
|
3336 | * Get the text edits for a resource.
|
3337 | *
|
3338 | * @param uri A resource identifier.
|
3339 | * @return An array of text edits.
|
3340 | */
|
3341 | get(uri: Uri): TextEdit[];
|
3342 |
|
3343 | /**
|
3344 | * Create a regular file.
|
3345 | *
|
3346 | * @param uri Uri of the new file..
|
3347 | * @param options Defines if an existing file should be overwritten or be
|
3348 | * ignored. When overwrite and ignoreIfExists are both set overwrite wins.
|
3349 | * When both are unset and when the file already exists then the edit cannot
|
3350 | * be applied successfully.
|
3351 | * @param metadata Optional metadata for the entry.
|
3352 | */
|
3353 | createFile(uri: Uri, options?: { overwrite?: boolean, ignoreIfExists?: boolean }, metadata?: WorkspaceEditEntryMetadata): void;
|
3354 |
|
3355 | /**
|
3356 | * Delete a file or folder.
|
3357 | *
|
3358 | * @param uri The uri of the file that is to be deleted.
|
3359 | * @param metadata Optional metadata for the entry.
|
3360 | */
|
3361 | deleteFile(uri: Uri, options?: { recursive?: boolean, ignoreIfNotExists?: boolean }, metadata?: WorkspaceEditEntryMetadata): void;
|
3362 |
|
3363 | /**
|
3364 | * Rename a file or folder.
|
3365 | *
|
3366 | * @param oldUri The existing file.
|
3367 | * @param newUri The new location.
|
3368 | * @param options Defines if existing files should be overwritten or be
|
3369 | * ignored. When overwrite and ignoreIfExists are both set overwrite wins.
|
3370 | * @param metadata Optional metadata for the entry.
|
3371 | */
|
3372 | renameFile(oldUri: Uri, newUri: Uri, options?: { overwrite?: boolean, ignoreIfExists?: boolean }, metadata?: WorkspaceEditEntryMetadata): void;
|
3373 |
|
3374 | /**
|
3375 | * Get all text edits grouped by resource.
|
3376 | *
|
3377 | * @return A shallow copy of `[Uri, TextEdit[]]`-tuples.
|
3378 | */
|
3379 | entries(): [Uri, TextEdit[]][];
|
3380 | }
|
3381 |
|
3382 | /**
|
3383 | * A snippet string is a template which allows to insert text
|
3384 | * and to control the editor cursor when insertion happens.
|
3385 | *
|
3386 | * A snippet can define tab stops and placeholders with `$1`, `$2`
|
3387 | * and `${3:foo}`. `$0` defines the final tab stop, it defaults to
|
3388 | * the end of the snippet. Variables are defined with `$name` and
|
3389 | * `${name:default value}`. The full snippet syntax is documented
|
3390 | * [here](https://code.visualstudio.com/docs/editor/userdefinedsnippets#_creating-your-own-snippets).
|
3391 | */
|
3392 | export class SnippetString {
|
3393 |
|
3394 | /**
|
3395 | * The snippet string.
|
3396 | */
|
3397 | value: string;
|
3398 |
|
3399 | constructor(value?: string);
|
3400 |
|
3401 | /**
|
3402 | * Builder-function that appends the given string to
|
3403 | * the {@link SnippetString.value `value`} of this snippet string.
|
3404 | *
|
3405 | * @param string A value to append 'as given'. The string will be escaped.
|
3406 | * @return This snippet string.
|
3407 | */
|
3408 | appendText(string: string): SnippetString;
|
3409 |
|
3410 | /**
|
3411 | * Builder-function that appends a tabstop (`$1`, `$2` etc) to
|
3412 | * the {@link SnippetString.value `value`} of this snippet string.
|
3413 | *
|
3414 | * @param number The number of this tabstop, defaults to an auto-increment
|
3415 | * value starting at 1.
|
3416 | * @return This snippet string.
|
3417 | */
|
3418 | appendTabstop(number?: number): SnippetString;
|
3419 |
|
3420 | /**
|
3421 | * Builder-function that appends a placeholder (`${1:value}`) to
|
3422 | * the {@link SnippetString.value `value`} of this snippet string.
|
3423 | *
|
3424 | * @param value The value of this placeholder - either a string or a function
|
3425 | * with which a nested snippet can be created.
|
3426 | * @param number The number of this tabstop, defaults to an auto-increment
|
3427 | * value starting at 1.
|
3428 | * @return This snippet string.
|
3429 | */
|
3430 | appendPlaceholder(value: string | ((snippet: SnippetString) => any), number?: number): SnippetString;
|
3431 |
|
3432 | /**
|
3433 | * Builder-function that appends a choice (`${1|a,b,c|}`) to
|
3434 | * the {@link SnippetString.value `value`} of this snippet string.
|
3435 | *
|
3436 | * @param values The values for choices - the array of strings
|
3437 | * @param number The number of this tabstop, defaults to an auto-increment
|
3438 | * value starting at 1.
|
3439 | * @return This snippet string.
|
3440 | */
|
3441 | appendChoice(values: string[], number?: number): SnippetString;
|
3442 |
|
3443 | /**
|
3444 | * Builder-function that appends a variable (`${VAR}`) to
|
3445 | * the {@link SnippetString.value `value`} of this snippet string.
|
3446 | *
|
3447 | * @param name The name of the variable - excluding the `$`.
|
3448 | * @param defaultValue The default value which is used when the variable name cannot
|
3449 | * be resolved - either a string or a function with which a nested snippet can be created.
|
3450 | * @return This snippet string.
|
3451 | */
|
3452 | appendVariable(name: string, defaultValue: string | ((snippet: SnippetString) => any)): SnippetString;
|
3453 | }
|
3454 |
|
3455 | /**
|
3456 | * The rename provider interface defines the contract between extensions and
|
3457 | * the [rename](https://code.visualstudio.com/docs/editor/editingevolved#_rename-symbol)-feature.
|
3458 | */
|
3459 | export interface RenameProvider {
|
3460 |
|
3461 | /**
|
3462 | * Provide an edit that describes changes that have to be made to one
|
3463 | * or many resources to rename a symbol to a different name.
|
3464 | *
|
3465 | * @param document The document in which the command was invoked.
|
3466 | * @param position The position at which the command was invoked.
|
3467 | * @param newName The new name of the symbol. If the given name is not valid, the provider must return a rejected promise.
|
3468 | * @param token A cancellation token.
|
3469 | * @return A workspace edit or a thenable that resolves to such. The lack of a result can be
|
3470 | * signaled by returning `undefined` or `null`.
|
3471 | */
|
3472 | provideRenameEdits(document: TextDocument, position: Position, newName: string, token: CancellationToken): ProviderResult<WorkspaceEdit>;
|
3473 |
|
3474 | /**
|
3475 | * Optional function for resolving and validating a position *before* running rename. The result can
|
3476 | * be a range or a range and a placeholder text. The placeholder text should be the identifier of the symbol
|
3477 | * which is being renamed - when omitted the text in the returned range is used.
|
3478 | *
|
3479 | * *Note: * This function should throw an error or return a rejected thenable when the provided location
|
3480 | * doesn't allow for a rename.
|
3481 | *
|
3482 | * @param document The document in which rename will be invoked.
|
3483 | * @param position The position at which rename will be invoked.
|
3484 | * @param token A cancellation token.
|
3485 | * @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`.
|
3486 | */
|
3487 | prepareRename?(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Range | { range: Range, placeholder: string }>;
|
3488 | }
|
3489 |
|
3490 | /**
|
3491 | * A semantic tokens legend contains the needed information to decipher
|
3492 | * the integer encoded representation of semantic tokens.
|
3493 | */
|
3494 | export class SemanticTokensLegend {
|
3495 | /**
|
3496 | * The possible token types.
|
3497 | */
|
3498 | readonly tokenTypes: string[];
|
3499 | /**
|
3500 | * The possible token modifiers.
|
3501 | */
|
3502 | readonly tokenModifiers: string[];
|
3503 |
|
3504 | constructor(tokenTypes: string[], tokenModifiers?: string[]);
|
3505 | }
|
3506 |
|
3507 | /**
|
3508 | * A semantic tokens builder can help with creating a `SemanticTokens` instance
|
3509 | * which contains delta encoded semantic tokens.
|
3510 | */
|
3511 | export class SemanticTokensBuilder {
|
3512 |
|
3513 | constructor(legend?: SemanticTokensLegend);
|
3514 |
|
3515 | /**
|
3516 | * Add another token.
|
3517 | *
|
3518 | * @param line The token start line number (absolute value).
|
3519 | * @param char The token start character (absolute value).
|
3520 | * @param length The token length in characters.
|
3521 | * @param tokenType The encoded token type.
|
3522 | * @param tokenModifiers The encoded token modifiers.
|
3523 | */
|
3524 | push(line: number, char: number, length: number, tokenType: number, tokenModifiers?: number): void;
|
3525 |
|
3526 | /**
|
3527 | * Add another token. Use only when providing a legend.
|
3528 | *
|
3529 | * @param range The range of the token. Must be single-line.
|
3530 | * @param tokenType The token type.
|
3531 | * @param tokenModifiers The token modifiers.
|
3532 | */
|
3533 | push(range: Range, tokenType: string, tokenModifiers?: string[]): void;
|
3534 |
|
3535 | /**
|
3536 | * Finish and create a `SemanticTokens` instance.
|
3537 | */
|
3538 | build(resultId?: string): SemanticTokens;
|
3539 | }
|
3540 |
|
3541 | /**
|
3542 | * Represents semantic tokens, either in a range or in an entire document.
|
3543 | * @see {@link DocumentSemanticTokensProvider.provideDocumentSemanticTokens provideDocumentSemanticTokens} for an explanation of the format.
|
3544 | * @see {@link SemanticTokensBuilder} for a helper to create an instance.
|
3545 | */
|
3546 | export class SemanticTokens {
|
3547 | /**
|
3548 | * The result id of the tokens.
|
3549 | *
|
3550 | * This is the id that will be passed to `DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits` (if implemented).
|
3551 | */
|
3552 | readonly resultId?: string;
|
3553 | /**
|
3554 | * The actual tokens data.
|
3555 | * @see {@link DocumentSemanticTokensProvider.provideDocumentSemanticTokens provideDocumentSemanticTokens} for an explanation of the format.
|
3556 | */
|
3557 | readonly data: Uint32Array;
|
3558 |
|
3559 | constructor(data: Uint32Array, resultId?: string);
|
3560 | }
|
3561 |
|
3562 | /**
|
3563 | * Represents edits to semantic tokens.
|
3564 | * @see {@link DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits provideDocumentSemanticTokensEdits} for an explanation of the format.
|
3565 | */
|
3566 | export class SemanticTokensEdits {
|
3567 | /**
|
3568 | * The result id of the tokens.
|
3569 | *
|
3570 | * This is the id that will be passed to `DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits` (if implemented).
|
3571 | */
|
3572 | readonly resultId?: string;
|
3573 | /**
|
3574 | * The edits to the tokens data.
|
3575 | * All edits refer to the initial data state.
|
3576 | */
|
3577 | readonly edits: SemanticTokensEdit[];
|
3578 |
|
3579 | constructor(edits: SemanticTokensEdit[], resultId?: string);
|
3580 | }
|
3581 |
|
3582 | /**
|
3583 | * Represents an edit to semantic tokens.
|
3584 | * @see {@link DocumentSemanticTokensProvider.provideDocumentSemanticTokensEdits provideDocumentSemanticTokensEdits} for an explanation of the format.
|
3585 | */
|
3586 | export class SemanticTokensEdit {
|
3587 | /**
|
3588 | * The start offset of the edit.
|
3589 | */
|
3590 | readonly start: number;
|
3591 | /**
|
3592 | * The count of elements to remove.
|
3593 | */
|
3594 | readonly deleteCount: number;
|
3595 | /**
|
3596 | * The elements to insert.
|
3597 | */
|
3598 | readonly data?: Uint32Array;
|
3599 |
|
3600 | constructor(start: number, deleteCount: number, data?: Uint32Array);
|
3601 | }
|
3602 |
|
3603 | /**
|
3604 | * The document semantic tokens provider interface defines the contract between extensions and
|
3605 | * semantic tokens.
|
3606 | */
|
3607 | export interface DocumentSemanticTokensProvider {
|
3608 | /**
|
3609 | * An optional event to signal that the semantic tokens from this provider have changed.
|
3610 | */
|
3611 | onDidChangeSemanticTokens?: Event<void>;
|
3612 |
|
3613 | /**
|
3614 | * Tokens in a file are represented as an array of integers. The position of each token is expressed relative to
|
3615 | * the token before it, because most tokens remain stable relative to each other when edits are made in a file.
|
3616 | *
|
3617 | * ---
|
3618 | * In short, each token takes 5 integers to represent, so a specific token `i` in the file consists of the following array indices:
|
3619 | * - at index `5*i` - `deltaLine`: token line number, relative to the previous token
|
3620 | * - 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)
|
3621 | * - at index `5*i+2` - `length`: the length of the token. A token cannot be multiline.
|
3622 | * - at index `5*i+3` - `tokenType`: will be looked up in `SemanticTokensLegend.tokenTypes`. We currently ask that `tokenType` < 65536.
|
3623 | * - at index `5*i+4` - `tokenModifiers`: each set bit will be looked up in `SemanticTokensLegend.tokenModifiers`
|
3624 | *
|
3625 | * ---
|
3626 | * ### How to encode tokens
|
3627 | *
|
3628 | * Here is an example for encoding a file with 3 tokens in a uint32 array:
|
3629 | * ```
|
3630 | * { line: 2, startChar: 5, length: 3, tokenType: "property", tokenModifiers: ["private", "static"] },
|
3631 | * { line: 2, startChar: 10, length: 4, tokenType: "type", tokenModifiers: [] },
|
3632 | * { line: 5, startChar: 2, length: 7, tokenType: "class", tokenModifiers: [] }
|
3633 | * ```
|
3634 | *
|
3635 | * 1. First of all, a legend must be devised. This legend must be provided up-front and capture all possible token types.
|
3636 | * For this example, we will choose the following legend which must be passed in when registering the provider:
|
3637 | * ```
|
3638 | * tokenTypes: ['property', 'type', 'class'],
|
3639 | * tokenModifiers: ['private', 'static']
|
3640 | * ```
|
3641 | *
|
3642 | * 2. The first transformation step is to encode `tokenType` and `tokenModifiers` as integers using the legend. Token types are looked
|
3643 | * up by index, so a `tokenType` value of `1` means `tokenTypes[1]`. Multiple token modifiers can be set by using bit flags,
|
3644 | * so a `tokenModifier` value of `3` is first viewed as binary `0b00000011`, which means `[tokenModifiers[0], tokenModifiers[1]]` because
|
3645 | * bits 0 and 1 are set. Using this legend, the tokens now are:
|
3646 | * ```
|
3647 | * { line: 2, startChar: 5, length: 3, tokenType: 0, tokenModifiers: 3 },
|
3648 | * { line: 2, startChar: 10, length: 4, tokenType: 1, tokenModifiers: 0 },
|
3649 | * { line: 5, startChar: 2, length: 7, tokenType: 2, tokenModifiers: 0 }
|
3650 | * ```
|
3651 | *
|
3652 | * 3. The next step is to represent each token relative to the previous token in the file. In this case, the second token
|
3653 | * is on the same line as the first token, so the `startChar` of the second token is made relative to the `startChar`
|
3654 | * of the first token, so it will be `10 - 5`. The third token is on a different line than the second token, so the
|
3655 | * `startChar` of the third token will not be altered:
|
3656 | * ```
|
3657 | * { deltaLine: 2, deltaStartChar: 5, length: 3, tokenType: 0, tokenModifiers: 3 },
|
3658 | * { deltaLine: 0, deltaStartChar: 5, length: 4, tokenType: 1, tokenModifiers: 0 },
|
3659 | * { deltaLine: 3, deltaStartChar: 2, length: 7, tokenType: 2, tokenModifiers: 0 }
|
3660 | * ```
|
3661 | *
|
3662 | * 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:
|
3663 | * ```
|
3664 | * // 1st token, 2nd token, 3rd token
|
3665 | * [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
|
3666 | * ```
|
3667 | *
|
3668 | * @see {@link SemanticTokensBuilder} for a helper to encode tokens as integers.
|
3669 | * *NOTE*: When doing edits, it is possible that multiple edits occur until the editor decides to invoke the semantic tokens provider.
|
3670 | * *NOTE*: If the provider cannot temporarily compute semantic tokens, it can indicate this by throwing an error with the message 'Busy'.
|
3671 | */
|
3672 | provideDocumentSemanticTokens(document: TextDocument, token: CancellationToken): ProviderResult<SemanticTokens>;
|
3673 |
|
3674 | /**
|
3675 | * Instead of always returning all the tokens in a file, it is possible for a `DocumentSemanticTokensProvider` to implement
|
3676 | * this method (`provideDocumentSemanticTokensEdits`) and then return incremental updates to the previously provided semantic tokens.
|
3677 | *
|
3678 | * ---
|
3679 | * ### How tokens change when the document changes
|
3680 | *
|
3681 | * Suppose that `provideDocumentSemanticTokens` has previously returned the following semantic tokens:
|
3682 | * ```
|
3683 | * // 1st token, 2nd token, 3rd token
|
3684 | * [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
|
3685 | * ```
|
3686 | *
|
3687 | * Also suppose that after some edits, the new semantic tokens in a file are:
|
3688 | * ```
|
3689 | * // 1st token, 2nd token, 3rd token
|
3690 | * [ 3,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ]
|
3691 | * ```
|
3692 | * It is possible to express these new tokens in terms of an edit applied to the previous tokens:
|
3693 | * ```
|
3694 | * [ 2,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ] // old tokens
|
3695 | * [ 3,5,3,0,3, 0,5,4,1,0, 3,2,7,2,0 ] // new tokens
|
3696 | *
|
3697 | * edit: { start: 0, deleteCount: 1, data: [3] } // replace integer at offset 0 with 3
|
3698 | * ```
|
3699 | *
|
3700 | * *NOTE*: If the provider cannot compute `SemanticTokensEdits`, it can "give up" and return all the tokens in the document again.
|
3701 | * *NOTE*: All edits in `SemanticTokensEdits` contain indices in the old integers array, so they all refer to the previous result state.
|
3702 | */
|
3703 | provideDocumentSemanticTokensEdits?(document: TextDocument, previousResultId: string, token: CancellationToken): ProviderResult<SemanticTokens | SemanticTokensEdits>;
|
3704 | }
|
3705 |
|
3706 | /**
|
3707 | * The document range semantic tokens provider interface defines the contract between extensions and
|
3708 | * semantic tokens.
|
3709 | */
|
3710 | export interface DocumentRangeSemanticTokensProvider {
|
3711 | /**
|
3712 | * @see {@link DocumentSemanticTokensProvider.provideDocumentSemanticTokens provideDocumentSemanticTokens}.
|
3713 | */
|
3714 | provideDocumentRangeSemanticTokens(document: TextDocument, range: Range, token: CancellationToken): ProviderResult<SemanticTokens>;
|
3715 | }
|
3716 |
|
3717 | /**
|
3718 | * Value-object describing what options formatting should use.
|
3719 | */
|
3720 | export interface FormattingOptions {
|
3721 |
|
3722 | /**
|
3723 | * Size of a tab in spaces.
|
3724 | */
|
3725 | tabSize: number;
|
3726 |
|
3727 | /**
|
3728 | * Prefer spaces over tabs.
|
3729 | */
|
3730 | insertSpaces: boolean;
|
3731 |
|
3732 | /**
|
3733 | * Signature for further properties.
|
3734 | */
|
3735 | [key: string]: boolean | number | string;
|
3736 | }
|
3737 |
|
3738 | /**
|
3739 | * The document formatting provider interface defines the contract between extensions and
|
3740 | * the formatting-feature.
|
3741 | */
|
3742 | export interface DocumentFormattingEditProvider {
|
3743 |
|
3744 | /**
|
3745 | * Provide formatting edits for a whole document.
|
3746 | *
|
3747 | * @param document The document in which the command was invoked.
|
3748 | * @param options Options controlling formatting.
|
3749 | * @param token A cancellation token.
|
3750 | * @return A set of text edits or a thenable that resolves to such. The lack of a result can be
|
3751 | * signaled by returning `undefined`, `null`, or an empty array.
|
3752 | */
|
3753 | provideDocumentFormattingEdits(document: TextDocument, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
|
3754 | }
|
3755 |
|
3756 | /**
|
3757 | * The document formatting provider interface defines the contract between extensions and
|
3758 | * the formatting-feature.
|
3759 | */
|
3760 | export interface DocumentRangeFormattingEditProvider {
|
3761 |
|
3762 | /**
|
3763 | * Provide formatting edits for a range in a document.
|
3764 | *
|
3765 | * The given range is a hint and providers can decide to format a smaller
|
3766 | * or larger range. Often this is done by adjusting the start and end
|
3767 | * of the range to full syntax nodes.
|
3768 | *
|
3769 | * @param document The document in which the command was invoked.
|
3770 | * @param range The range which should be formatted.
|
3771 | * @param options Options controlling formatting.
|
3772 | * @param token A cancellation token.
|
3773 | * @return A set of text edits or a thenable that resolves to such. The lack of a result can be
|
3774 | * signaled by returning `undefined`, `null`, or an empty array.
|
3775 | */
|
3776 | provideDocumentRangeFormattingEdits(document: TextDocument, range: Range, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
|
3777 | }
|
3778 |
|
3779 | /**
|
3780 | * The document formatting provider interface defines the contract between extensions and
|
3781 | * the formatting-feature.
|
3782 | */
|
3783 | export interface OnTypeFormattingEditProvider {
|
3784 |
|
3785 | /**
|
3786 | * Provide formatting edits after a character has been typed.
|
3787 | *
|
3788 | * The given position and character should hint to the provider
|
3789 | * what range the position to expand to, like find the matching `{`
|
3790 | * when `}` has been entered.
|
3791 | *
|
3792 | * @param document The document in which the command was invoked.
|
3793 | * @param position The position at which the command was invoked.
|
3794 | * @param ch The character that has been typed.
|
3795 | * @param options Options controlling formatting.
|
3796 | * @param token A cancellation token.
|
3797 | * @return A set of text edits or a thenable that resolves to such. The lack of a result can be
|
3798 | * signaled by returning `undefined`, `null`, or an empty array.
|
3799 | */
|
3800 | provideOnTypeFormattingEdits(document: TextDocument, position: Position, ch: string, options: FormattingOptions, token: CancellationToken): ProviderResult<TextEdit[]>;
|
3801 | }
|
3802 |
|
3803 | /**
|
3804 | * Represents a parameter of a callable-signature. A parameter can
|
3805 | * have a label and a doc-comment.
|
3806 | */
|
3807 | export class ParameterInformation {
|
3808 |
|
3809 | /**
|
3810 | * The label of this signature.
|
3811 | *
|
3812 | * Either a string or inclusive start and exclusive end offsets within its containing
|
3813 | * {@link SignatureInformation.label signature label}. *Note*: A label of type string must be
|
3814 | * a substring of its containing signature information's {@link SignatureInformation.label label}.
|
3815 | */
|
3816 | label: string | [number, number];
|
3817 |
|
3818 | /**
|
3819 | * The human-readable doc-comment of this signature. Will be shown
|
3820 | * in the UI but can be omitted.
|
3821 | */
|
3822 | documentation?: string | MarkdownString;
|
3823 |
|
3824 | /**
|
3825 | * Creates a new parameter information object.
|
3826 | *
|
3827 | * @param label A label string or inclusive start and exclusive end offsets within its containing signature label.
|
3828 | * @param documentation A doc string.
|
3829 | */
|
3830 | constructor(label: string | [number, number], documentation?: string | MarkdownString);
|
3831 | }
|
3832 |
|
3833 | /**
|
3834 | * Represents the signature of something callable. A signature
|
3835 | * can have a label, like a function-name, a doc-comment, and
|
3836 | * a set of parameters.
|
3837 | */
|
3838 | export class SignatureInformation {
|
3839 |
|
3840 | /**
|
3841 | * The label of this signature. Will be shown in
|
3842 | * the UI.
|
3843 | */
|
3844 | label: string;
|
3845 |
|
3846 | /**
|
3847 | * The human-readable doc-comment of this signature. Will be shown
|
3848 | * in the UI but can be omitted.
|
3849 | */
|
3850 | documentation?: string | MarkdownString;
|
3851 |
|
3852 | /**
|
3853 | * The parameters of this signature.
|
3854 | */
|
3855 | parameters: ParameterInformation[];
|
3856 |
|
3857 | /**
|
3858 | * The index of the active parameter.
|
3859 | *
|
3860 | * If provided, this is used in place of {@link SignatureHelp.activeSignature `SignatureHelp.activeSignature`}.
|
3861 | */
|
3862 | activeParameter?: number;
|
3863 |
|
3864 | /**
|
3865 | * Creates a new signature information object.
|
3866 | *
|
3867 | * @param label A label string.
|
3868 | * @param documentation A doc string.
|
3869 | */
|
3870 | constructor(label: string, documentation?: string | MarkdownString);
|
3871 | }
|
3872 |
|
3873 | /**
|
3874 | * Signature help represents the signature of something
|
3875 | * callable. There can be multiple signatures but only one
|
3876 | * active and only one active parameter.
|
3877 | */
|
3878 | export class SignatureHelp {
|
3879 |
|
3880 | /**
|
3881 | * One or more signatures.
|
3882 | */
|
3883 | signatures: SignatureInformation[];
|
3884 |
|
3885 | /**
|
3886 | * The active signature.
|
3887 | */
|
3888 | activeSignature: number;
|
3889 |
|
3890 | /**
|
3891 | * The active parameter of the active signature.
|
3892 | */
|
3893 | activeParameter: number;
|
3894 | }
|
3895 |
|
3896 | /**
|
3897 | * How a {@link SignatureHelpProvider `SignatureHelpProvider`} was triggered.
|
3898 | */
|
3899 | export enum SignatureHelpTriggerKind {
|
3900 | /**
|
3901 | * Signature help was invoked manually by the user or by a command.
|
3902 | */
|
3903 | Invoke = 1,
|
3904 |
|
3905 | /**
|
3906 | * Signature help was triggered by a trigger character.
|
3907 | */
|
3908 | TriggerCharacter = 2,
|
3909 |
|
3910 | /**
|
3911 | * Signature help was triggered by the cursor moving or by the document content changing.
|
3912 | */
|
3913 | ContentChange = 3,
|
3914 | }
|
3915 |
|
3916 | /**
|
3917 | * Additional information about the context in which a
|
3918 | * {@link SignatureHelpProvider.provideSignatureHelp `SignatureHelpProvider`} was triggered.
|
3919 | */
|
3920 | export interface SignatureHelpContext {
|
3921 | /**
|
3922 | * Action that caused signature help to be triggered.
|
3923 | */
|
3924 | readonly triggerKind: SignatureHelpTriggerKind;
|
3925 |
|
3926 | /**
|
3927 | * Character that caused signature help to be triggered.
|
3928 | *
|
3929 | * This is `undefined` when signature help is not triggered by typing, such as when manually invoking
|
3930 | * signature help or when moving the cursor.
|
3931 | */
|
3932 | readonly triggerCharacter?: string;
|
3933 |
|
3934 | /**
|
3935 | * `true` if signature help was already showing when it was triggered.
|
3936 | *
|
3937 | * Retriggers occur when the signature help is already active and can be caused by actions such as
|
3938 | * typing a trigger character, a cursor move, or document content changes.
|
3939 | */
|
3940 | readonly isRetrigger: boolean;
|
3941 |
|
3942 | /**
|
3943 | * The currently active {@link SignatureHelp `SignatureHelp`}.
|
3944 | *
|
3945 | * The `activeSignatureHelp` has its [`SignatureHelp.activeSignature`] field updated based on
|
3946 | * the user arrowing through available signatures.
|
3947 | */
|
3948 | readonly activeSignatureHelp?: SignatureHelp;
|
3949 | }
|
3950 |
|
3951 | /**
|
3952 | * The signature help provider interface defines the contract between extensions and
|
3953 | * the [parameter hints](https://code.visualstudio.com/docs/editor/intellisense)-feature.
|
3954 | */
|
3955 | export interface SignatureHelpProvider {
|
3956 |
|
3957 | /**
|
3958 | * Provide help for the signature at the given position and document.
|
3959 | *
|
3960 | * @param document The document in which the command was invoked.
|
3961 | * @param position The position at which the command was invoked.
|
3962 | * @param token A cancellation token.
|
3963 | * @param context Information about how signature help was triggered.
|
3964 | *
|
3965 | * @return Signature help or a thenable that resolves to such. The lack of a result can be
|
3966 | * signaled by returning `undefined` or `null`.
|
3967 | */
|
3968 | provideSignatureHelp(document: TextDocument, position: Position, token: CancellationToken, context: SignatureHelpContext): ProviderResult<SignatureHelp>;
|
3969 | }
|
3970 |
|
3971 | /**
|
3972 | * Metadata about a registered {@link SignatureHelpProvider `SignatureHelpProvider`}.
|
3973 | */
|
3974 | export interface SignatureHelpProviderMetadata {
|
3975 | /**
|
3976 | * List of characters that trigger signature help.
|
3977 | */
|
3978 | readonly triggerCharacters: readonly string[];
|
3979 |
|
3980 | /**
|
3981 | * List of characters that re-trigger signature help.
|
3982 | *
|
3983 | * These trigger characters are only active when signature help is already showing. All trigger characters
|
3984 | * are also counted as re-trigger characters.
|
3985 | */
|
3986 | readonly retriggerCharacters: readonly string[];
|
3987 | }
|
3988 |
|
3989 | /**
|
3990 | * A structured label for a {@link CompletionItem completion item}.
|
3991 | */
|
3992 | export interface CompletionItemLabel {
|
3993 |
|
3994 | /**
|
3995 | * The label of this completion item.
|
3996 | *
|
3997 | * By default this is also the text that is inserted when this completion is selected.
|
3998 | */
|
3999 | label: string;
|
4000 |
|
4001 | /**
|
4002 | * An optional string which is rendered less prominently directly after {@link CompletionItemLabel.label label},
|
4003 | * without any spacing. Should be used for function signatures or type annotations.
|
4004 | */
|
4005 | detail?: string;
|
4006 |
|
4007 | /**
|
4008 | * An optional string which is rendered less prominently after {@link CompletionItemLabel.detail}. Should be used
|
4009 | * for fully qualified names or file path.
|
4010 | */
|
4011 | description?: string;
|
4012 | }
|
4013 |
|
4014 | /**
|
4015 | * Completion item kinds.
|
4016 | */
|
4017 | export enum CompletionItemKind {
|
4018 | Text = 0,
|
4019 | Method = 1,
|
4020 | Function = 2,
|
4021 | Constructor = 3,
|
4022 | Field = 4,
|
4023 | Variable = 5,
|
4024 | Class = 6,
|
4025 | Interface = 7,
|
4026 | Module = 8,
|
4027 | Property = 9,
|
4028 | Unit = 10,
|
4029 | Value = 11,
|
4030 | Enum = 12,
|
4031 | Keyword = 13,
|
4032 | Snippet = 14,
|
4033 | Color = 15,
|
4034 | Reference = 17,
|
4035 | File = 16,
|
4036 | Folder = 18,
|
4037 | EnumMember = 19,
|
4038 | Constant = 20,
|
4039 | Struct = 21,
|
4040 | Event = 22,
|
4041 | Operator = 23,
|
4042 | TypeParameter = 24,
|
4043 | User = 25,
|
4044 | Issue = 26,
|
4045 | }
|
4046 |
|
4047 | /**
|
4048 | * Completion item tags are extra annotations that tweak the rendering of a completion
|
4049 | * item.
|
4050 | */
|
4051 | export enum CompletionItemTag {
|
4052 | /**
|
4053 | * Render a completion as obsolete, usually using a strike-out.
|
4054 | */
|
4055 | Deprecated = 1
|
4056 | }
|
4057 |
|
4058 | /**
|
4059 | * A completion item represents a text snippet that is proposed to complete text that is being typed.
|
4060 | *
|
4061 | * It is sufficient to create a completion item from just a {@link CompletionItem.label label}. In that
|
4062 | * case the completion item will replace the {@link TextDocument.getWordRangeAtPosition word}
|
4063 | * until the cursor with the given label or {@link CompletionItem.insertText insertText}. Otherwise the
|
4064 | * given {@link CompletionItem.textEdit edit} is used.
|
4065 | *
|
4066 | * When selecting a completion item in the editor its defined or synthesized text edit will be applied
|
4067 | * to *all* cursors/selections whereas {@link CompletionItem.additionalTextEdits additionalTextEdits} will be
|
4068 | * applied as provided.
|
4069 | *
|
4070 | * @see {@link CompletionItemProvider.provideCompletionItems}
|
4071 | * @see {@link CompletionItemProvider.resolveCompletionItem}
|
4072 | */
|
4073 | export class CompletionItem {
|
4074 |
|
4075 | /**
|
4076 | * The label of this completion item. By default
|
4077 | * this is also the text that is inserted when selecting
|
4078 | * this completion.
|
4079 | */
|
4080 | label: string | CompletionItemLabel;
|
4081 |
|
4082 | /**
|
4083 | * The kind of this completion item. Based on the kind
|
4084 | * an icon is chosen by the editor.
|
4085 | */
|
4086 | kind?: CompletionItemKind;
|
4087 |
|
4088 | /**
|
4089 | * Tags for this completion item.
|
4090 | */
|
4091 | tags?: readonly CompletionItemTag[];
|
4092 |
|
4093 | /**
|
4094 | * A human-readable string with additional information
|
4095 | * about this item, like type or symbol information.
|
4096 | */
|
4097 | detail?: string;
|
4098 |
|
4099 | /**
|
4100 | * A human-readable string that represents a doc-comment.
|
4101 | */
|
4102 | documentation?: string | MarkdownString;
|
4103 |
|
4104 | /**
|
4105 | * A string that should be used when comparing this item
|
4106 | * with other items. When `falsy` the {@link CompletionItem.label label}
|
4107 | * is used.
|
4108 | *
|
4109 | * Note that `sortText` is only used for the initial ordering of completion
|
4110 | * items. When having a leading word (prefix) ordering is based on how
|
4111 | * well completions match that prefix and the initial ordering is only used
|
4112 | * when completions match equally well. The prefix is defined by the
|
4113 | * {@link CompletionItem.range `range`}-property and can therefore be different
|
4114 | * for each completion.
|
4115 | */
|
4116 | sortText?: string;
|
4117 |
|
4118 | /**
|
4119 | * A string that should be used when filtering a set of
|
4120 | * completion items. When `falsy` the {@link CompletionItem.label label}
|
4121 | * is used.
|
4122 | *
|
4123 | * Note that the filter text is matched against the leading word (prefix) which is defined
|
4124 | * by the {@link CompletionItem.range `range`}-property.
|
4125 | */
|
4126 | filterText?: string;
|
4127 |
|
4128 | /**
|
4129 | * Select this item when showing. *Note* that only one completion item can be selected and
|
4130 | * that the editor decides which item that is. The rule is that the *first* item of those
|
4131 | * that match best is selected.
|
4132 | */
|
4133 | preselect?: boolean;
|
4134 |
|
4135 | /**
|
4136 | * A string or snippet that should be inserted in a document when selecting
|
4137 | * this completion. When `falsy` the {@link CompletionItem.label label}
|
4138 | * is used.
|
4139 | */
|
4140 | insertText?: string | SnippetString;
|
4141 |
|
4142 | /**
|
4143 | * A range or a insert and replace range selecting the text that should be replaced by this completion item.
|
4144 | *
|
4145 | * When omitted, the range of the {@link TextDocument.getWordRangeAtPosition current word} is used as replace-range
|
4146 | * and as insert-range the start of the {@link TextDocument.getWordRangeAtPosition current word} to the
|
4147 | * current position is used.
|
4148 | *
|
4149 | * *Note 1:* A range must be a {@link Range.isSingleLine single line} and it must
|
4150 | * {@link Range.contains contain} the position at which completion has been {@link CompletionItemProvider.provideCompletionItems requested}.
|
4151 | * *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.
|
4152 | */
|
4153 | range?: Range | { inserting: Range; replacing: Range; };
|
4154 |
|
4155 | /**
|
4156 | * An optional set of characters that when pressed while this completion is active will accept it first and
|
4157 | * then type that character. *Note* that all commit characters should have `length=1` and that superfluous
|
4158 | * characters will be ignored.
|
4159 | */
|
4160 | commitCharacters?: string[];
|
4161 |
|
4162 | /**
|
4163 | * Keep whitespace of the {@link CompletionItem.insertText insertText} as is. By default, the editor adjusts leading
|
4164 | * whitespace of new lines so that they match the indentation of the line for which the item is accepted - setting
|
4165 | * this to `true` will prevent that.
|
4166 | */
|
4167 | keepWhitespace?: boolean;
|
4168 |
|
4169 | /**
|
4170 | * @deprecated Use `CompletionItem.insertText` and `CompletionItem.range` instead.
|
4171 | *
|
4172 | * An {@link TextEdit edit} which is applied to a document when selecting
|
4173 | * this completion. When an edit is provided the value of
|
4174 | * {@link CompletionItem.insertText insertText} is ignored.
|
4175 | *
|
4176 | * The {@link Range} of the edit must be single-line and on the same
|
4177 | * line completions were {@link CompletionItemProvider.provideCompletionItems requested} at.
|
4178 | */
|
4179 | textEdit?: TextEdit;
|
4180 |
|
4181 | /**
|
4182 | * An optional array of additional {@link TextEdit text edits} that are applied when
|
4183 | * selecting this completion. Edits must not overlap with the main {@link CompletionItem.textEdit edit}
|
4184 | * nor with themselves.
|
4185 | */
|
4186 | additionalTextEdits?: TextEdit[];
|
4187 |
|
4188 | /**
|
4189 | * An optional {@link Command} that is executed *after* inserting this completion. *Note* that
|
4190 | * additional modifications to the current document should be described with the
|
4191 | * {@link CompletionItem.additionalTextEdits additionalTextEdits}-property.
|
4192 | */
|
4193 | command?: Command;
|
4194 |
|
4195 | /**
|
4196 | * Creates a new completion item.
|
4197 | *
|
4198 | * Completion items must have at least a {@link CompletionItem.label label} which then
|
4199 | * will be used as insert text as well as for sorting and filtering.
|
4200 | *
|
4201 | * @param label The label of the completion.
|
4202 | * @param kind The {@link CompletionItemKind kind} of the completion.
|
4203 | */
|
4204 | constructor(label: string | CompletionItemLabel, kind?: CompletionItemKind);
|
4205 | }
|
4206 |
|
4207 | /**
|
4208 | * Represents a collection of {@link CompletionItem completion items} to be presented
|
4209 | * in the editor.
|
4210 | */
|
4211 | export class CompletionList<T extends CompletionItem = CompletionItem> {
|
4212 |
|
4213 | /**
|
4214 | * This list is not complete. Further typing should result in recomputing
|
4215 | * this list.
|
4216 | */
|
4217 | isIncomplete?: boolean;
|
4218 |
|
4219 | /**
|
4220 | * The completion items.
|
4221 | */
|
4222 | items: T[];
|
4223 |
|
4224 | /**
|
4225 | * Creates a new completion list.
|
4226 | *
|
4227 | * @param items The completion items.
|
4228 | * @param isIncomplete The list is not complete.
|
4229 | */
|
4230 | constructor(items?: T[], isIncomplete?: boolean);
|
4231 | }
|
4232 |
|
4233 | /**
|
4234 | * How a {@link CompletionItemProvider completion provider} was triggered
|
4235 | */
|
4236 | export enum CompletionTriggerKind {
|
4237 | /**
|
4238 | * Completion was triggered normally.
|
4239 | */
|
4240 | Invoke = 0,
|
4241 | /**
|
4242 | * Completion was triggered by a trigger character.
|
4243 | */
|
4244 | TriggerCharacter = 1,
|
4245 | /**
|
4246 | * Completion was re-triggered as current completion list is incomplete
|
4247 | */
|
4248 | TriggerForIncompleteCompletions = 2
|
4249 | }
|
4250 |
|
4251 | /**
|
4252 | * Contains additional information about the context in which
|
4253 | * {@link CompletionItemProvider.provideCompletionItems completion provider} is triggered.
|
4254 | */
|
4255 | export interface CompletionContext {
|
4256 | /**
|
4257 | * How the completion was triggered.
|
4258 | */
|
4259 | readonly triggerKind: CompletionTriggerKind;
|
4260 |
|
4261 | /**
|
4262 | * Character that triggered the completion item provider.
|
4263 | *
|
4264 | * `undefined` if provider was not triggered by a character.
|
4265 | *
|
4266 | * The trigger character is already in the document when the completion provider is triggered.
|
4267 | */
|
4268 | readonly triggerCharacter?: string;
|
4269 | }
|
4270 |
|
4271 | /**
|
4272 | * The completion item provider interface defines the contract between extensions and
|
4273 | * [IntelliSense](https://code.visualstudio.com/docs/editor/intellisense).
|
4274 | *
|
4275 | * Providers can delay the computation of the {@link CompletionItem.detail `detail`}
|
4276 | * and {@link CompletionItem.documentation `documentation`} properties by implementing the
|
4277 | * {@link CompletionItemProvider.resolveCompletionItem `resolveCompletionItem`}-function. However, properties that
|
4278 | * are needed for the initial sorting and filtering, like `sortText`, `filterText`, `insertText`, and `range`, must
|
4279 | * not be changed during resolve.
|
4280 | *
|
4281 | * Providers are asked for completions either explicitly by a user gesture or -depending on the configuration-
|
4282 | * implicitly when typing words or trigger characters.
|
4283 | */
|
4284 | export interface CompletionItemProvider<T extends CompletionItem = CompletionItem> {
|
4285 |
|
4286 | /**
|
4287 | * Provide completion items for the given position and document.
|
4288 | *
|
4289 | * @param document The document in which the command was invoked.
|
4290 | * @param position The position at which the command was invoked.
|
4291 | * @param token A cancellation token.
|
4292 | * @param context How the completion was triggered.
|
4293 | *
|
4294 | * @return An array of completions, a {@link CompletionList completion list}, or a thenable that resolves to either.
|
4295 | * The lack of a result can be signaled by returning `undefined`, `null`, or an empty array.
|
4296 | */
|
4297 | provideCompletionItems(document: TextDocument, position: Position, token: CancellationToken, context: CompletionContext): ProviderResult<T[] | CompletionList<T>>;
|
4298 |
|
4299 | /**
|
4300 | * Given a completion item fill in more data, like {@link CompletionItem.documentation doc-comment}
|
4301 | * or {@link CompletionItem.detail details}.
|
4302 | *
|
4303 | * The editor will only resolve a completion item once.
|
4304 | *
|
4305 | * *Note* that this function is called when completion items are already showing in the UI or when an item has been
|
4306 | * selected for insertion. Because of that, no property that changes the presentation (label, sorting, filtering etc)
|
4307 | * or the (primary) insert behaviour ({@link CompletionItem.insertText insertText}) can be changed.
|
4308 | *
|
4309 | * This function may fill in {@link CompletionItem.additionalTextEdits additionalTextEdits}. However, that means an item might be
|
4310 | * inserted *before* resolving is done and in that case the editor will do a best effort to still apply those additional
|
4311 | * text edits.
|
4312 | *
|
4313 | * @param item A completion item currently active in the UI.
|
4314 | * @param token A cancellation token.
|
4315 | * @return The resolved completion item or a thenable that resolves to of such. It is OK to return the given
|
4316 | * `item`. When no result is returned, the given `item` will be used.
|
4317 | */
|
4318 | resolveCompletionItem?(item: T, token: CancellationToken): ProviderResult<T>;
|
4319 | }
|
4320 |
|
4321 | /**
|
4322 | * A document link is a range in a text document that links to an internal or external resource, like another
|
4323 | * text document or a web site.
|
4324 | */
|
4325 | export class DocumentLink {
|
4326 |
|
4327 | /**
|
4328 | * The range this link applies to.
|
4329 | */
|
4330 | range: Range;
|
4331 |
|
4332 | /**
|
4333 | * The uri this link points to.
|
4334 | */
|
4335 | target?: Uri;
|
4336 |
|
4337 | /**
|
4338 | * The tooltip text when you hover over this link.
|
4339 | *
|
4340 | * If a tooltip is provided, is will be displayed in a string that includes instructions on how to
|
4341 | * trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary depending on OS,
|
4342 | * user settings, and localization.
|
4343 | */
|
4344 | tooltip?: string;
|
4345 |
|
4346 | /**
|
4347 | * Creates a new document link.
|
4348 | *
|
4349 | * @param range The range the document link applies to. Must not be empty.
|
4350 | * @param target The uri the document link points to.
|
4351 | */
|
4352 | constructor(range: Range, target?: Uri);
|
4353 | }
|
4354 |
|
4355 | /**
|
4356 | * The document link provider defines the contract between extensions and feature of showing
|
4357 | * links in the editor.
|
4358 | */
|
4359 | export interface DocumentLinkProvider<T extends DocumentLink = DocumentLink> {
|
4360 |
|
4361 | /**
|
4362 | * Provide links for the given document. Note that the editor ships with a default provider that detects
|
4363 | * `http(s)` and `file` links.
|
4364 | *
|
4365 | * @param document The document in which the command was invoked.
|
4366 | * @param token A cancellation token.
|
4367 | * @return An array of {@link DocumentLink document links} or a thenable that resolves to such. The lack of a result
|
4368 | * can be signaled by returning `undefined`, `null`, or an empty array.
|
4369 | */
|
4370 | provideDocumentLinks(document: TextDocument, token: CancellationToken): ProviderResult<T[]>;
|
4371 |
|
4372 | /**
|
4373 | * Given a link fill in its {@link DocumentLink.target target}. This method is called when an incomplete
|
4374 | * link is selected in the UI. Providers can implement this method and return incomplete links
|
4375 | * (without target) from the {@link DocumentLinkProvider.provideDocumentLinks `provideDocumentLinks`} method which
|
4376 | * often helps to improve performance.
|
4377 | *
|
4378 | * @param link The link that is to be resolved.
|
4379 | * @param token A cancellation token.
|
4380 | */
|
4381 | resolveDocumentLink?(link: T, token: CancellationToken): ProviderResult<T>;
|
4382 | }
|
4383 |
|
4384 | /**
|
4385 | * Represents a color in RGBA space.
|
4386 | */
|
4387 | export class Color {
|
4388 |
|
4389 | /**
|
4390 | * The red component of this color in the range [0-1].
|
4391 | */
|
4392 | readonly red: number;
|
4393 |
|
4394 | /**
|
4395 | * The green component of this color in the range [0-1].
|
4396 | */
|
4397 | readonly green: number;
|
4398 |
|
4399 | /**
|
4400 | * The blue component of this color in the range [0-1].
|
4401 | */
|
4402 | readonly blue: number;
|
4403 |
|
4404 | /**
|
4405 | * The alpha component of this color in the range [0-1].
|
4406 | */
|
4407 | readonly alpha: number;
|
4408 |
|
4409 | /**
|
4410 | * Creates a new color instance.
|
4411 | *
|
4412 | * @param red The red component.
|
4413 | * @param green The green component.
|
4414 | * @param blue The blue component.
|
4415 | * @param alpha The alpha component.
|
4416 | */
|
4417 | constructor(red: number, green: number, blue: number, alpha: number);
|
4418 | }
|
4419 |
|
4420 | /**
|
4421 | * Represents a color range from a document.
|
4422 | */
|
4423 | export class ColorInformation {
|
4424 |
|
4425 | /**
|
4426 | * The range in the document where this color appears.
|
4427 | */
|
4428 | range: Range;
|
4429 |
|
4430 | /**
|
4431 | * The actual color value for this color range.
|
4432 | */
|
4433 | color: Color;
|
4434 |
|
4435 | /**
|
4436 | * Creates a new color range.
|
4437 | *
|
4438 | * @param range The range the color appears in. Must not be empty.
|
4439 | * @param color The value of the color.
|
4440 | * @param format The format in which this color is currently formatted.
|
4441 | */
|
4442 | constructor(range: Range, color: Color);
|
4443 | }
|
4444 |
|
4445 | /**
|
4446 | * A color presentation object describes how a {@link Color `color`} should be represented as text and what
|
4447 | * edits are required to refer to it from source code.
|
4448 | *
|
4449 | * For some languages one color can have multiple presentations, e.g. css can represent the color red with
|
4450 | * the constant `Red`, the hex-value `#ff0000`, or in rgba and hsla forms. In csharp other representations
|
4451 | * apply, e.g. `System.Drawing.Color.Red`.
|
4452 | */
|
4453 | export class ColorPresentation {
|
4454 |
|
4455 | /**
|
4456 | * The label of this color presentation. It will be shown on the color
|
4457 | * picker header. By default this is also the text that is inserted when selecting
|
4458 | * this color presentation.
|
4459 | */
|
4460 | label: string;
|
4461 |
|
4462 | /**
|
4463 | * An {@link TextEdit edit} which is applied to a document when selecting
|
4464 | * this presentation for the color. When `falsy` the {@link ColorPresentation.label label}
|
4465 | * is used.
|
4466 | */
|
4467 | textEdit?: TextEdit;
|
4468 |
|
4469 | /**
|
4470 | * An optional array of additional {@link TextEdit text edits} that are applied when
|
4471 | * selecting this color presentation. Edits must not overlap with the main {@link ColorPresentation.textEdit edit} nor with themselves.
|
4472 | */
|
4473 | additionalTextEdits?: TextEdit[];
|
4474 |
|
4475 | /**
|
4476 | * Creates a new color presentation.
|
4477 | *
|
4478 | * @param label The label of this color presentation.
|
4479 | */
|
4480 | constructor(label: string);
|
4481 | }
|
4482 |
|
4483 | /**
|
4484 | * The document color provider defines the contract between extensions and feature of
|
4485 | * picking and modifying colors in the editor.
|
4486 | */
|
4487 | export interface DocumentColorProvider {
|
4488 |
|
4489 | /**
|
4490 | * Provide colors for the given document.
|
4491 | *
|
4492 | * @param document The document in which the command was invoked.
|
4493 | * @param token A cancellation token.
|
4494 | * @return An array of {@link ColorInformation color information} or a thenable that resolves to such. The lack of a result
|
4495 | * can be signaled by returning `undefined`, `null`, or an empty array.
|
4496 | */
|
4497 | provideDocumentColors(document: TextDocument, token: CancellationToken): ProviderResult<ColorInformation[]>;
|
4498 |
|
4499 | /**
|
4500 | * Provide {@link ColorPresentation representations} for a color.
|
4501 | *
|
4502 | * @param color The color to show and insert.
|
4503 | * @param context A context object with additional information
|
4504 | * @param token A cancellation token.
|
4505 | * @return An array of color presentations or a thenable that resolves to such. The lack of a result
|
4506 | * can be signaled by returning `undefined`, `null`, or an empty array.
|
4507 | */
|
4508 | provideColorPresentations(color: Color, context: { document: TextDocument, range: Range }, token: CancellationToken): ProviderResult<ColorPresentation[]>;
|
4509 | }
|
4510 |
|
4511 | /**
|
4512 | * 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.
|
4513 | * Invalid ranges will be ignored.
|
4514 | */
|
4515 | export class FoldingRange {
|
4516 |
|
4517 | /**
|
4518 | * The zero-based start line of the range to fold. The folded area starts after the line's last character.
|
4519 | * To be valid, the end must be zero or larger and smaller than the number of lines in the document.
|
4520 | */
|
4521 | start: number;
|
4522 |
|
4523 | /**
|
4524 | * The zero-based end line of the range to fold. The folded area ends with the line's last character.
|
4525 | * To be valid, the end must be zero or larger and smaller than the number of lines in the document.
|
4526 | */
|
4527 | end: number;
|
4528 |
|
4529 | /**
|
4530 | * Describes the {@link FoldingRangeKind Kind} of the folding range such as {@link FoldingRangeKind.Comment Comment} or
|
4531 | * {@link FoldingRangeKind.Region Region}. The kind is used to categorize folding ranges and used by commands
|
4532 | * like 'Fold all comments'. See
|
4533 | * {@link FoldingRangeKind} for an enumeration of all kinds.
|
4534 | * If not set, the range is originated from a syntax element.
|
4535 | */
|
4536 | kind?: FoldingRangeKind;
|
4537 |
|
4538 | /**
|
4539 | * Creates a new folding range.
|
4540 | *
|
4541 | * @param start The start line of the folded range.
|
4542 | * @param end The end line of the folded range.
|
4543 | * @param kind The kind of the folding range.
|
4544 | */
|
4545 | constructor(start: number, end: number, kind?: FoldingRangeKind);
|
4546 | }
|
4547 |
|
4548 | /**
|
4549 | * An enumeration of specific folding range kinds. The kind is an optional field of a {@link FoldingRange}
|
4550 | * and is used to distinguish specific folding ranges such as ranges originated from comments. The kind is used by commands like
|
4551 | * `Fold all comments` or `Fold all regions`.
|
4552 | * If the kind is not set on the range, the range originated from a syntax element other than comments, imports or region markers.
|
4553 | */
|
4554 | export enum FoldingRangeKind {
|
4555 | /**
|
4556 | * Kind for folding range representing a comment.
|
4557 | */
|
4558 | Comment = 1,
|
4559 | /**
|
4560 | * Kind for folding range representing a import.
|
4561 | */
|
4562 | Imports = 2,
|
4563 | /**
|
4564 | * Kind for folding range representing regions originating from folding markers like `#region` and `#endregion`.
|
4565 | */
|
4566 | Region = 3
|
4567 | }
|
4568 |
|
4569 | /**
|
4570 | * Folding context (for future use)
|
4571 | */
|
4572 | export interface FoldingContext {
|
4573 | }
|
4574 |
|
4575 | /**
|
4576 | * The folding range provider interface defines the contract between extensions and
|
4577 | * [Folding](https://code.visualstudio.com/docs/editor/codebasics#_folding) in the editor.
|
4578 | */
|
4579 | export interface FoldingRangeProvider {
|
4580 |
|
4581 | /**
|
4582 | * An optional event to signal that the folding ranges from this provider have changed.
|
4583 | */
|
4584 | onDidChangeFoldingRanges?: Event<void>;
|
4585 |
|
4586 | /**
|
4587 | * Returns a list of folding ranges or null and undefined if the provider
|
4588 | * does not want to participate or was cancelled.
|
4589 | * @param document The document in which the command was invoked.
|
4590 | * @param context Additional context information (for future use)
|
4591 | * @param token A cancellation token.
|
4592 | */
|
4593 | provideFoldingRanges(document: TextDocument, context: FoldingContext, token: CancellationToken): ProviderResult<FoldingRange[]>;
|
4594 | }
|
4595 |
|
4596 | /**
|
4597 | * A selection range represents a part of a selection hierarchy. A selection range
|
4598 | * may have a parent selection range that contains it.
|
4599 | */
|
4600 | export class SelectionRange {
|
4601 |
|
4602 | /**
|
4603 | * The {@link Range} of this selection range.
|
4604 | */
|
4605 | range: Range;
|
4606 |
|
4607 | /**
|
4608 | * The parent selection range containing this range.
|
4609 | */
|
4610 | parent?: SelectionRange;
|
4611 |
|
4612 | /**
|
4613 | * Creates a new selection range.
|
4614 | *
|
4615 | * @param range The range of the selection range.
|
4616 | * @param parent The parent of the selection range.
|
4617 | */
|
4618 | constructor(range: Range, parent?: SelectionRange);
|
4619 | }
|
4620 |
|
4621 | export interface SelectionRangeProvider {
|
4622 | /**
|
4623 | * Provide selection ranges for the given positions.
|
4624 | *
|
4625 | * Selection ranges should be computed individually and independent for each position. The editor will merge
|
4626 | * and deduplicate ranges but providers must return hierarchies of selection ranges so that a range
|
4627 | * is {@link Range.contains contained} by its parent.
|
4628 | *
|
4629 | * @param document The document in which the command was invoked.
|
4630 | * @param positions The positions at which the command was invoked.
|
4631 | * @param token A cancellation token.
|
4632 | * @return Selection ranges or a thenable that resolves to such. The lack of a result can be
|
4633 | * signaled by returning `undefined` or `null`.
|
4634 | */
|
4635 | provideSelectionRanges(document: TextDocument, positions: Position[], token: CancellationToken): ProviderResult<SelectionRange[]>;
|
4636 | }
|
4637 |
|
4638 | /**
|
4639 | * Represents programming constructs like functions or constructors in the context
|
4640 | * of call hierarchy.
|
4641 | */
|
4642 | export class CallHierarchyItem {
|
4643 | /**
|
4644 | * The name of this item.
|
4645 | */
|
4646 | name: string;
|
4647 |
|
4648 | /**
|
4649 | * The kind of this item.
|
4650 | */
|
4651 | kind: SymbolKind;
|
4652 |
|
4653 | /**
|
4654 | * Tags for this item.
|
4655 | */
|
4656 | tags?: readonly SymbolTag[];
|
4657 |
|
4658 | /**
|
4659 | * More detail for this item, e.g. the signature of a function.
|
4660 | */
|
4661 | detail?: string;
|
4662 |
|
4663 | /**
|
4664 | * The resource identifier of this item.
|
4665 | */
|
4666 | uri: Uri;
|
4667 |
|
4668 | /**
|
4669 | * The range enclosing this symbol not including leading/trailing whitespace but everything else, e.g. comments and code.
|
4670 | */
|
4671 | range: Range;
|
4672 |
|
4673 | /**
|
4674 | * The range that should be selected and revealed when this symbol is being picked, e.g. the name of a function.
|
4675 | * Must be contained by the {@link CallHierarchyItem.range `range`}.
|
4676 | */
|
4677 | selectionRange: Range;
|
4678 |
|
4679 | /**
|
4680 | * Creates a new call hierarchy item.
|
4681 | */
|
4682 | constructor(kind: SymbolKind, name: string, detail: string, uri: Uri, range: Range, selectionRange: Range);
|
4683 | }
|
4684 |
|
4685 | /**
|
4686 | * Represents an incoming call, e.g. a caller of a method or constructor.
|
4687 | */
|
4688 | export class CallHierarchyIncomingCall {
|
4689 |
|
4690 | /**
|
4691 | * The item that makes the call.
|
4692 | */
|
4693 | from: CallHierarchyItem;
|
4694 |
|
4695 | /**
|
4696 | * The range at which at which the calls appears. This is relative to the caller
|
4697 | * denoted by {@link CallHierarchyIncomingCall.from `this.from`}.
|
4698 | */
|
4699 | fromRanges: Range[];
|
4700 |
|
4701 | /**
|
4702 | * Create a new call object.
|
4703 | *
|
4704 | * @param item The item making the call.
|
4705 | * @param fromRanges The ranges at which the calls appear.
|
4706 | */
|
4707 | constructor(item: CallHierarchyItem, fromRanges: Range[]);
|
4708 | }
|
4709 |
|
4710 | /**
|
4711 | * Represents an outgoing call, e.g. calling a getter from a method or a method from a constructor etc.
|
4712 | */
|
4713 | export class CallHierarchyOutgoingCall {
|
4714 |
|
4715 | /**
|
4716 | * The item that is called.
|
4717 | */
|
4718 | to: CallHierarchyItem;
|
4719 |
|
4720 | /**
|
4721 | * The range at which this item is called. This is the range relative to the caller, e.g the item
|
4722 | * passed to {@link CallHierarchyProvider.provideCallHierarchyOutgoingCalls `provideCallHierarchyOutgoingCalls`}
|
4723 | * and not {@link CallHierarchyOutgoingCall.to `this.to`}.
|
4724 | */
|
4725 | fromRanges: Range[];
|
4726 |
|
4727 | /**
|
4728 | * Create a new call object.
|
4729 | *
|
4730 | * @param item The item being called
|
4731 | * @param fromRanges The ranges at which the calls appear.
|
4732 | */
|
4733 | constructor(item: CallHierarchyItem, fromRanges: Range[]);
|
4734 | }
|
4735 |
|
4736 | /**
|
4737 | * The call hierarchy provider interface describes the contract between extensions
|
4738 | * and the call hierarchy feature which allows to browse calls and caller of function,
|
4739 | * methods, constructor etc.
|
4740 | */
|
4741 | export interface CallHierarchyProvider {
|
4742 |
|
4743 | /**
|
4744 | * Bootstraps call hierarchy by returning the item that is denoted by the given document
|
4745 | * and position. This item will be used as entry into the call graph. Providers should
|
4746 | * return `undefined` or `null` when there is no item at the given location.
|
4747 | *
|
4748 | * @param document The document in which the command was invoked.
|
4749 | * @param position The position at which the command was invoked.
|
4750 | * @param token A cancellation token.
|
4751 | * @returns A call hierarchy item or a thenable that resolves to such. The lack of a result can be
|
4752 | * signaled by returning `undefined` or `null`.
|
4753 | */
|
4754 | prepareCallHierarchy(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<CallHierarchyItem | CallHierarchyItem[]>;
|
4755 |
|
4756 | /**
|
4757 | * Provide all incoming calls for an item, e.g all callers for a method. In graph terms this describes directed
|
4758 | * and annotated edges inside the call graph, e.g the given item is the starting node and the result is the nodes
|
4759 | * that can be reached.
|
4760 | *
|
4761 | * @param item The hierarchy item for which incoming calls should be computed.
|
4762 | * @param token A cancellation token.
|
4763 | * @returns A set of incoming calls or a thenable that resolves to such. The lack of a result can be
|
4764 | * signaled by returning `undefined` or `null`.
|
4765 | */
|
4766 | provideCallHierarchyIncomingCalls(item: CallHierarchyItem, token: CancellationToken): ProviderResult<CallHierarchyIncomingCall[]>;
|
4767 |
|
4768 | /**
|
4769 | * Provide all outgoing calls for an item, e.g call calls to functions, methods, or constructors from the given item. In
|
4770 | * graph terms this describes directed and annotated edges inside the call graph, e.g the given item is the starting
|
4771 | * node and the result is the nodes that can be reached.
|
4772 | *
|
4773 | * @param item The hierarchy item for which outgoing calls should be computed.
|
4774 | * @param token A cancellation token.
|
4775 | * @returns A set of outgoing calls or a thenable that resolves to such. The lack of a result can be
|
4776 | * signaled by returning `undefined` or `null`.
|
4777 | */
|
4778 | provideCallHierarchyOutgoingCalls(item: CallHierarchyItem, token: CancellationToken): ProviderResult<CallHierarchyOutgoingCall[]>;
|
4779 | }
|
4780 |
|
4781 | /**
|
4782 | * Represents a list of ranges that can be edited together along with a word pattern to describe valid range contents.
|
4783 | */
|
4784 | export class LinkedEditingRanges {
|
4785 | /**
|
4786 | * Create a new linked editing ranges object.
|
4787 | *
|
4788 | * @param ranges A list of ranges that can be edited together
|
4789 | * @param wordPattern An optional word pattern that describes valid contents for the given ranges
|
4790 | */
|
4791 | constructor(ranges: Range[], wordPattern?: RegExp);
|
4792 |
|
4793 | /**
|
4794 | * A list of ranges that can be edited together. The ranges must have
|
4795 | * identical length and text content. The ranges cannot overlap.
|
4796 | */
|
4797 | readonly ranges: Range[];
|
4798 |
|
4799 | /**
|
4800 | * An optional word pattern that describes valid contents for the given ranges.
|
4801 | * If no pattern is provided, the language configuration's word pattern will be used.
|
4802 | */
|
4803 | readonly wordPattern?: RegExp;
|
4804 | }
|
4805 |
|
4806 | /**
|
4807 | * The linked editing range provider interface defines the contract between extensions and
|
4808 | * the linked editing feature.
|
4809 | */
|
4810 | export interface LinkedEditingRangeProvider {
|
4811 | /**
|
4812 | * For a given position in a document, returns the range of the symbol at the position and all ranges
|
4813 | * that have the same content. A change to one of the ranges can be applied to all other ranges if the new content
|
4814 | * is valid. An optional word pattern can be returned with the result to describe valid contents.
|
4815 | * If no result-specific word pattern is provided, the word pattern from the language configuration is used.
|
4816 | *
|
4817 | * @param document The document in which the provider was invoked.
|
4818 | * @param position The position at which the provider was invoked.
|
4819 | * @param token A cancellation token.
|
4820 | * @return A list of ranges that can be edited together
|
4821 | */
|
4822 | provideLinkedEditingRanges(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<LinkedEditingRanges>;
|
4823 | }
|
4824 |
|
4825 | /**
|
4826 | * A tuple of two characters, like a pair of
|
4827 | * opening and closing brackets.
|
4828 | */
|
4829 | export type CharacterPair = [string, string];
|
4830 |
|
4831 | /**
|
4832 | * Describes how comments for a language work.
|
4833 | */
|
4834 | export interface CommentRule {
|
4835 |
|
4836 | /**
|
4837 | * The line comment token, like `// this is a comment`
|
4838 | */
|
4839 | lineComment?: string;
|
4840 |
|
4841 | /**
|
4842 | * The block comment character pair, like `/* block comment */`
|
4843 | */
|
4844 | blockComment?: CharacterPair;
|
4845 | }
|
4846 |
|
4847 | /**
|
4848 | * Describes indentation rules for a language.
|
4849 | */
|
4850 | export interface IndentationRule {
|
4851 | /**
|
4852 | * If a line matches this pattern, then all the lines after it should be unindented once (until another rule matches).
|
4853 | */
|
4854 | decreaseIndentPattern: RegExp;
|
4855 | /**
|
4856 | * If a line matches this pattern, then all the lines after it should be indented once (until another rule matches).
|
4857 | */
|
4858 | increaseIndentPattern: RegExp;
|
4859 | /**
|
4860 | * If a line matches this pattern, then **only the next line** after it should be indented once.
|
4861 | */
|
4862 | indentNextLinePattern?: RegExp;
|
4863 | /**
|
4864 | * If a line matches this pattern, then its indentation should not be changed and it should not be evaluated against the other rules.
|
4865 | */
|
4866 | unIndentedLinePattern?: RegExp;
|
4867 | }
|
4868 |
|
4869 | /**
|
4870 | * Describes what to do with the indentation when pressing Enter.
|
4871 | */
|
4872 | export enum IndentAction {
|
4873 | /**
|
4874 | * Insert new line and copy the previous line's indentation.
|
4875 | */
|
4876 | None = 0,
|
4877 | /**
|
4878 | * Insert new line and indent once (relative to the previous line's indentation).
|
4879 | */
|
4880 | Indent = 1,
|
4881 | /**
|
4882 | * Insert two new lines:
|
4883 | * - the first one indented which will hold the cursor
|
4884 | * - the second one at the same indentation level
|
4885 | */
|
4886 | IndentOutdent = 2,
|
4887 | /**
|
4888 | * Insert new line and outdent once (relative to the previous line's indentation).
|
4889 | */
|
4890 | Outdent = 3
|
4891 | }
|
4892 |
|
4893 | /**
|
4894 | * Describes what to do when pressing Enter.
|
4895 | */
|
4896 | export interface EnterAction {
|
4897 | /**
|
4898 | * Describe what to do with the indentation.
|
4899 | */
|
4900 | indentAction: IndentAction;
|
4901 | /**
|
4902 | * Describes text to be appended after the new line and after the indentation.
|
4903 | */
|
4904 | appendText?: string;
|
4905 | /**
|
4906 | * Describes the number of characters to remove from the new line's indentation.
|
4907 | */
|
4908 | removeText?: number;
|
4909 | }
|
4910 |
|
4911 | /**
|
4912 | * Describes a rule to be evaluated when pressing Enter.
|
4913 | */
|
4914 | export interface OnEnterRule {
|
4915 | /**
|
4916 | * This rule will only execute if the text before the cursor matches this regular expression.
|
4917 | */
|
4918 | beforeText: RegExp;
|
4919 | /**
|
4920 | * This rule will only execute if the text after the cursor matches this regular expression.
|
4921 | */
|
4922 | afterText?: RegExp;
|
4923 | /**
|
4924 | * This rule will only execute if the text above the current line matches this regular expression.
|
4925 | */
|
4926 | previousLineText?: RegExp;
|
4927 | /**
|
4928 | * The action to execute.
|
4929 | */
|
4930 | action: EnterAction;
|
4931 | }
|
4932 |
|
4933 | /**
|
4934 | * The language configuration interfaces defines the contract between extensions
|
4935 | * and various editor features, like automatic bracket insertion, automatic indentation etc.
|
4936 | */
|
4937 | export interface LanguageConfiguration {
|
4938 | /**
|
4939 | * The language's comment settings.
|
4940 | */
|
4941 | comments?: CommentRule;
|
4942 | /**
|
4943 | * The language's brackets.
|
4944 | * This configuration implicitly affects pressing Enter around these brackets.
|
4945 | */
|
4946 | brackets?: CharacterPair[];
|
4947 | /**
|
4948 | * The language's word definition.
|
4949 | * If the language supports Unicode identifiers (e.g. JavaScript), it is preferable
|
4950 | * to provide a word definition that uses exclusion of known separators.
|
4951 | * e.g.: A regex that matches anything except known separators (and dot is allowed to occur in a floating point number):
|
4952 | * /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\-\=\+\[\{\]\}\\\|\;\:\'\"\,\.\<\>\/\?\s]+)/g
|
4953 | */
|
4954 | wordPattern?: RegExp;
|
4955 | /**
|
4956 | * The language's indentation settings.
|
4957 | */
|
4958 | indentationRules?: IndentationRule;
|
4959 | /**
|
4960 | * The language's rules to be evaluated when pressing Enter.
|
4961 | */
|
4962 | onEnterRules?: OnEnterRule[];
|
4963 |
|
4964 | /**
|
4965 | * **Deprecated** Do not use.
|
4966 | *
|
4967 | * @deprecated Will be replaced by a better API soon.
|
4968 | */
|
4969 | __electricCharacterSupport?: {
|
4970 | /**
|
4971 | * This property is deprecated and will be **ignored** from
|
4972 | * the editor.
|
4973 | * @deprecated
|
4974 | */
|
4975 | brackets?: any;
|
4976 | /**
|
4977 | * This property is deprecated and not fully supported anymore by
|
4978 | * the editor (scope and lineStart are ignored).
|
4979 | * Use the autoClosingPairs property in the language configuration file instead.
|
4980 | * @deprecated
|
4981 | */
|
4982 | docComment?: {
|
4983 | scope: string;
|
4984 | open: string;
|
4985 | lineStart: string;
|
4986 | close?: string;
|
4987 | };
|
4988 | };
|
4989 |
|
4990 | /**
|
4991 | * **Deprecated** Do not use.
|
4992 | *
|
4993 | * @deprecated * Use the autoClosingPairs property in the language configuration file instead.
|
4994 | */
|
4995 | __characterPairSupport?: {
|
4996 | autoClosingPairs: {
|
4997 | open: string;
|
4998 | close: string;
|
4999 | notIn?: string[];
|
5000 | }[];
|
5001 | };
|
5002 | }
|
5003 |
|
5004 | /**
|
5005 | * The configuration target
|
5006 | */
|
5007 | export enum ConfigurationTarget {
|
5008 | /**
|
5009 | * Global configuration
|
5010 | */
|
5011 | Global = 1,
|
5012 |
|
5013 | /**
|
5014 | * Workspace configuration
|
5015 | */
|
5016 | Workspace = 2,
|
5017 |
|
5018 | /**
|
5019 | * Workspace folder configuration
|
5020 | */
|
5021 | WorkspaceFolder = 3
|
5022 | }
|
5023 |
|
5024 | /**
|
5025 | * Represents the configuration. It is a merged view of
|
5026 | *
|
5027 | * - *Default Settings*
|
5028 | * - *Global (User) Settings*
|
5029 | * - *Workspace settings*
|
5030 | * - *Workspace Folder settings* - From one of the {@link workspace.workspaceFolders Workspace Folders} under which requested resource belongs to.
|
5031 | * - *Language settings* - Settings defined under requested language.
|
5032 | *
|
5033 | * The *effective* value (returned by {@link WorkspaceConfiguration.get `get`}) is computed by overriding or merging the values in the following order.
|
5034 | *
|
5035 | * ```
|
5036 | * `defaultValue` (if defined in `package.json` otherwise derived from the value's type)
|
5037 | * `globalValue` (if defined)
|
5038 | * `workspaceValue` (if defined)
|
5039 | * `workspaceFolderValue` (if defined)
|
5040 | * `defaultLanguageValue` (if defined)
|
5041 | * `globalLanguageValue` (if defined)
|
5042 | * `workspaceLanguageValue` (if defined)
|
5043 | * `workspaceFolderLanguageValue` (if defined)
|
5044 | * ```
|
5045 | * **Note:** Only `object` value types are merged and all other value types are overridden.
|
5046 | *
|
5047 | * Example 1: Overriding
|
5048 | *
|
5049 | * ```ts
|
5050 | * defaultValue = 'on';
|
5051 | * globalValue = 'relative'
|
5052 | * workspaceFolderValue = 'off'
|
5053 | * value = 'off'
|
5054 | * ```
|
5055 | *
|
5056 | * Example 2: Language Values
|
5057 | *
|
5058 | * ```ts
|
5059 | * defaultValue = 'on';
|
5060 | * globalValue = 'relative'
|
5061 | * workspaceFolderValue = 'off'
|
5062 | * globalLanguageValue = 'on'
|
5063 | * value = 'on'
|
5064 | * ```
|
5065 | *
|
5066 | * Example 3: Object Values
|
5067 | *
|
5068 | * ```ts
|
5069 | * defaultValue = { "a": 1, "b": 2 };
|
5070 | * globalValue = { "b": 3, "c": 4 };
|
5071 | * value = { "a": 1, "b": 3, "c": 4 };
|
5072 | * ```
|
5073 | *
|
5074 | * *Note:* Workspace and Workspace Folder configurations contains `launch` and `tasks` settings. Their basename will be
|
5075 | * part of the section identifier. The following snippets shows how to retrieve all configurations
|
5076 | * from `launch.json`:
|
5077 | *
|
5078 | * ```ts
|
5079 | * // launch.json configuration
|
5080 | * const config = workspace.getConfiguration('launch', vscode.workspace.workspaceFolders[0].uri);
|
5081 | *
|
5082 | * // retrieve values
|
5083 | * const values = config.get('configurations');
|
5084 | * ```
|
5085 | *
|
5086 | * Refer to [Settings](https://code.visualstudio.com/docs/getstarted/settings) for more information.
|
5087 | */
|
5088 | export interface WorkspaceConfiguration {
|
5089 |
|
5090 | /**
|
5091 | * Return a value from this configuration.
|
5092 | *
|
5093 | * @param section Configuration name, supports _dotted_ names.
|
5094 | * @return The value `section` denotes or `undefined`.
|
5095 | */
|
5096 | get<T>(section: string): T | undefined;
|
5097 |
|
5098 | /**
|
5099 | * Return a value from this configuration.
|
5100 | *
|
5101 | * @param section Configuration name, supports _dotted_ names.
|
5102 | * @param defaultValue A value should be returned when no value could be found, is `undefined`.
|
5103 | * @return The value `section` denotes or the default.
|
5104 | */
|
5105 | get<T>(section: string, defaultValue: T): T;
|
5106 |
|
5107 | /**
|
5108 | * Check if this configuration has a certain value.
|
5109 | *
|
5110 | * @param section Configuration name, supports _dotted_ names.
|
5111 | * @return `true` if the section doesn't resolve to `undefined`.
|
5112 | */
|
5113 | has(section: string): boolean;
|
5114 |
|
5115 | /**
|
5116 | * Retrieve all information about a configuration setting. A configuration value
|
5117 | * often consists of a *default* value, a global or installation-wide value,
|
5118 | * a workspace-specific value, folder-specific value
|
5119 | * and language-specific values (if {@link WorkspaceConfiguration} is scoped to a language).
|
5120 | *
|
5121 | * Also provides all language ids under which the given configuration setting is defined.
|
5122 | *
|
5123 | * *Note:* The configuration name must denote a leaf in the configuration tree
|
5124 | * (`editor.fontSize` vs `editor`) otherwise no result is returned.
|
5125 | *
|
5126 | * @param section Configuration name, supports _dotted_ names.
|
5127 | * @return Information about a configuration setting or `undefined`.
|
5128 | */
|
5129 | inspect<T>(section: string): {
|
5130 | key: string;
|
5131 |
|
5132 | defaultValue?: T;
|
5133 | globalValue?: T;
|
5134 | workspaceValue?: T,
|
5135 | workspaceFolderValue?: T,
|
5136 |
|
5137 | defaultLanguageValue?: T;
|
5138 | globalLanguageValue?: T;
|
5139 | workspaceLanguageValue?: T;
|
5140 | workspaceFolderLanguageValue?: T;
|
5141 |
|
5142 | languageIds?: string[];
|
5143 |
|
5144 | } | undefined;
|
5145 |
|
5146 | /**
|
5147 | * Update a configuration value. The updated configuration values are persisted.
|
5148 | *
|
5149 | * A value can be changed in
|
5150 | *
|
5151 | * - {@link ConfigurationTarget.Global Global settings}: Changes the value for all instances of the editor.
|
5152 | * - {@link ConfigurationTarget.Workspace Workspace settings}: Changes the value for current workspace, if available.
|
5153 | * - {@link ConfigurationTarget.WorkspaceFolder Workspace folder settings}: Changes the value for settings from one of the {@link workspace.workspaceFolders Workspace Folders} under which the requested resource belongs to.
|
5154 | * - Language settings: Changes the value for the requested languageId.
|
5155 | *
|
5156 | * *Note:* To remove a configuration value use `undefined`, like so: `config.update('somekey', undefined)`
|
5157 | *
|
5158 | * @param section Configuration name, supports _dotted_ names.
|
5159 | * @param value The new value.
|
5160 | * @param configurationTarget The {@link ConfigurationTarget configuration target} or a boolean value.
|
5161 | * - If `true` updates {@link ConfigurationTarget.Global Global settings}.
|
5162 | * - If `false` updates {@link ConfigurationTarget.Workspace Workspace settings}.
|
5163 | * - If `undefined` or `null` updates to {@link ConfigurationTarget.WorkspaceFolder Workspace folder settings} if configuration is resource specific,
|
5164 | * otherwise to {@link ConfigurationTarget.Workspace Workspace settings}.
|
5165 | * @param overrideInLanguage Whether to update the value in the scope of requested languageId or not.
|
5166 | * - If `true` updates the value under the requested languageId.
|
5167 | * - If `undefined` updates the value under the requested languageId only if the configuration is defined for the language.
|
5168 | * @throws error while updating
|
5169 | * - configuration which is not registered.
|
5170 | * - window configuration to workspace folder
|
5171 | * - configuration to workspace or workspace folder when no workspace is opened.
|
5172 | * - configuration to workspace folder when there is no workspace folder settings.
|
5173 | * - configuration to workspace folder when {@link WorkspaceConfiguration} is not scoped to a resource.
|
5174 | */
|
5175 | update(section: string, value: any, configurationTarget?: ConfigurationTarget | boolean | null, overrideInLanguage?: boolean): Thenable<void>;
|
5176 |
|
5177 | /**
|
5178 | * Readable dictionary that backs this configuration.
|
5179 | */
|
5180 | readonly [key: string]: any;
|
5181 | }
|
5182 |
|
5183 | /**
|
5184 | * Represents a location inside a resource, such as a line
|
5185 | * inside a text file.
|
5186 | */
|
5187 | export class Location {
|
5188 |
|
5189 | /**
|
5190 | * The resource identifier of this location.
|
5191 | */
|
5192 | uri: Uri;
|
5193 |
|
5194 | /**
|
5195 | * The document range of this location.
|
5196 | */
|
5197 | range: Range;
|
5198 |
|
5199 | /**
|
5200 | * Creates a new location object.
|
5201 | *
|
5202 | * @param uri The resource identifier.
|
5203 | * @param rangeOrPosition The range or position. Positions will be converted to an empty range.
|
5204 | */
|
5205 | constructor(uri: Uri, rangeOrPosition: Range | Position);
|
5206 | }
|
5207 |
|
5208 | /**
|
5209 | * Represents the connection of two locations. Provides additional metadata over normal {@link Location locations},
|
5210 | * including an origin range.
|
5211 | */
|
5212 | export interface LocationLink {
|
5213 | /**
|
5214 | * Span of the origin of this link.
|
5215 | *
|
5216 | * Used as the underlined span for mouse definition hover. Defaults to the word range at
|
5217 | * the definition position.
|
5218 | */
|
5219 | originSelectionRange?: Range;
|
5220 |
|
5221 | /**
|
5222 | * The target resource identifier of this link.
|
5223 | */
|
5224 | targetUri: Uri;
|
5225 |
|
5226 | /**
|
5227 | * The full target range of this link.
|
5228 | */
|
5229 | targetRange: Range;
|
5230 |
|
5231 | /**
|
5232 | * The span of this link.
|
5233 | */
|
5234 | targetSelectionRange?: Range;
|
5235 | }
|
5236 |
|
5237 | /**
|
5238 | * The event that is fired when diagnostics change.
|
5239 | */
|
5240 | export interface DiagnosticChangeEvent {
|
5241 |
|
5242 | /**
|
5243 | * An array of resources for which diagnostics have changed.
|
5244 | */
|
5245 | readonly uris: readonly Uri[];
|
5246 | }
|
5247 |
|
5248 | /**
|
5249 | * Represents the severity of diagnostics.
|
5250 | */
|
5251 | export enum DiagnosticSeverity {
|
5252 |
|
5253 | /**
|
5254 | * Something not allowed by the rules of a language or other means.
|
5255 | */
|
5256 | Error = 0,
|
5257 |
|
5258 | /**
|
5259 | * Something suspicious but allowed.
|
5260 | */
|
5261 | Warning = 1,
|
5262 |
|
5263 | /**
|
5264 | * Something to inform about but not a problem.
|
5265 | */
|
5266 | Information = 2,
|
5267 |
|
5268 | /**
|
5269 | * Something to hint to a better way of doing it, like proposing
|
5270 | * a refactoring.
|
5271 | */
|
5272 | Hint = 3
|
5273 | }
|
5274 |
|
5275 | /**
|
5276 | * Represents a related message and source code location for a diagnostic. This should be
|
5277 | * used to point to code locations that cause or related to a diagnostics, e.g. when duplicating
|
5278 | * a symbol in a scope.
|
5279 | */
|
5280 | export class DiagnosticRelatedInformation {
|
5281 |
|
5282 | /**
|
5283 | * The location of this related diagnostic information.
|
5284 | */
|
5285 | location: Location;
|
5286 |
|
5287 | /**
|
5288 | * The message of this related diagnostic information.
|
5289 | */
|
5290 | message: string;
|
5291 |
|
5292 | /**
|
5293 | * Creates a new related diagnostic information object.
|
5294 | *
|
5295 | * @param location The location.
|
5296 | * @param message The message.
|
5297 | */
|
5298 | constructor(location: Location, message: string);
|
5299 | }
|
5300 |
|
5301 | /**
|
5302 | * Additional metadata about the type of a diagnostic.
|
5303 | */
|
5304 | export enum DiagnosticTag {
|
5305 | /**
|
5306 | * Unused or unnecessary code.
|
5307 | *
|
5308 | * Diagnostics with this tag are rendered faded out. The amount of fading
|
5309 | * is controlled by the `"editorUnnecessaryCode.opacity"` theme color. For
|
5310 | * example, `"editorUnnecessaryCode.opacity": "#000000c0"` will render the
|
5311 | * code with 75% opacity. For high contrast themes, use the
|
5312 | * `"editorUnnecessaryCode.border"` theme color to underline unnecessary code
|
5313 | * instead of fading it out.
|
5314 | */
|
5315 | Unnecessary = 1,
|
5316 |
|
5317 | /**
|
5318 | * Deprecated or obsolete code.
|
5319 | *
|
5320 | * Diagnostics with this tag are rendered with a strike through.
|
5321 | */
|
5322 | Deprecated = 2,
|
5323 | }
|
5324 |
|
5325 | /**
|
5326 | * Represents a diagnostic, such as a compiler error or warning. Diagnostic objects
|
5327 | * are only valid in the scope of a file.
|
5328 | */
|
5329 | export class Diagnostic {
|
5330 |
|
5331 | /**
|
5332 | * The range to which this diagnostic applies.
|
5333 | */
|
5334 | range: Range;
|
5335 |
|
5336 | /**
|
5337 | * The human-readable message.
|
5338 | */
|
5339 | message: string;
|
5340 |
|
5341 | /**
|
5342 | * The severity, default is {@link DiagnosticSeverity.Error error}.
|
5343 | */
|
5344 | severity: DiagnosticSeverity;
|
5345 |
|
5346 | /**
|
5347 | * A human-readable string describing the source of this
|
5348 | * diagnostic, e.g. 'typescript' or 'super lint'.
|
5349 | */
|
5350 | source?: string;
|
5351 |
|
5352 | /**
|
5353 | * A code or identifier for this diagnostic.
|
5354 | * Should be used for later processing, e.g. when providing {@link CodeActionContext code actions}.
|
5355 | */
|
5356 | code?: string | number | {
|
5357 | /**
|
5358 | * A code or identifier for this diagnostic.
|
5359 | * Should be used for later processing, e.g. when providing {@link CodeActionContext code actions}.
|
5360 | */
|
5361 | value: string | number;
|
5362 |
|
5363 | /**
|
5364 | * A target URI to open with more information about the diagnostic error.
|
5365 | */
|
5366 | target: Uri;
|
5367 | };
|
5368 |
|
5369 | /**
|
5370 | * An array of related diagnostic information, e.g. when symbol-names within
|
5371 | * a scope collide all definitions can be marked via this property.
|
5372 | */
|
5373 | relatedInformation?: DiagnosticRelatedInformation[];
|
5374 |
|
5375 | /**
|
5376 | * Additional metadata about the diagnostic.
|
5377 | */
|
5378 | tags?: DiagnosticTag[];
|
5379 |
|
5380 | /**
|
5381 | * Creates a new diagnostic object.
|
5382 | *
|
5383 | * @param range The range to which this diagnostic applies.
|
5384 | * @param message The human-readable message.
|
5385 | * @param severity The severity, default is {@link DiagnosticSeverity.Error error}.
|
5386 | */
|
5387 | constructor(range: Range, message: string, severity?: DiagnosticSeverity);
|
5388 | }
|
5389 |
|
5390 | /**
|
5391 | * A diagnostics collection is a container that manages a set of
|
5392 | * {@link Diagnostic diagnostics}. Diagnostics are always scopes to a
|
5393 | * diagnostics collection and a resource.
|
5394 | *
|
5395 | * To get an instance of a `DiagnosticCollection` use
|
5396 | * {@link languages.createDiagnosticCollection createDiagnosticCollection}.
|
5397 | */
|
5398 | export interface DiagnosticCollection {
|
5399 |
|
5400 | /**
|
5401 | * The name of this diagnostic collection, for instance `typescript`. Every diagnostic
|
5402 | * from this collection will be associated with this name. Also, the task framework uses this
|
5403 | * name when defining [problem matchers](https://code.visualstudio.com/docs/editor/tasks#_defining-a-problem-matcher).
|
5404 | */
|
5405 | readonly name: string;
|
5406 |
|
5407 | /**
|
5408 | * Assign diagnostics for given resource. Will replace
|
5409 | * existing diagnostics for that resource.
|
5410 | *
|
5411 | * @param uri A resource identifier.
|
5412 | * @param diagnostics Array of diagnostics or `undefined`
|
5413 | */
|
5414 | set(uri: Uri, diagnostics: readonly Diagnostic[] | undefined): void;
|
5415 |
|
5416 | /**
|
5417 | * Replace diagnostics for multiple resources in this collection.
|
5418 | *
|
5419 | * _Note_ that multiple tuples of the same uri will be merged, e.g
|
5420 | * `[[file1, [d1]], [file1, [d2]]]` is equivalent to `[[file1, [d1, d2]]]`.
|
5421 | * If a diagnostics item is `undefined` as in `[file1, undefined]`
|
5422 | * all previous but not subsequent diagnostics are removed.
|
5423 | *
|
5424 | * @param entries An array of tuples, like `[[file1, [d1, d2]], [file2, [d3, d4, d5]]]`, or `undefined`.
|
5425 | */
|
5426 | set(entries: ReadonlyArray<[Uri, readonly Diagnostic[] | undefined]>): void;
|
5427 |
|
5428 | /**
|
5429 | * Remove all diagnostics from this collection that belong
|
5430 | * to the provided `uri`. The same as `#set(uri, undefined)`.
|
5431 | *
|
5432 | * @param uri A resource identifier.
|
5433 | */
|
5434 | delete(uri: Uri): void;
|
5435 |
|
5436 | /**
|
5437 | * Remove all diagnostics from this collection. The same
|
5438 | * as calling `#set(undefined)`;
|
5439 | */
|
5440 | clear(): void;
|
5441 |
|
5442 | /**
|
5443 | * Iterate over each entry in this collection.
|
5444 | *
|
5445 | * @param callback Function to execute for each entry.
|
5446 | * @param thisArg The `this` context used when invoking the handler function.
|
5447 | */
|
5448 | forEach(callback: (uri: Uri, diagnostics: readonly Diagnostic[], collection: DiagnosticCollection) => any, thisArg?: any): void;
|
5449 |
|
5450 | /**
|
5451 | * Get the diagnostics for a given resource. *Note* that you cannot
|
5452 | * modify the diagnostics-array returned from this call.
|
5453 | *
|
5454 | * @param uri A resource identifier.
|
5455 | * @returns An immutable array of {@link Diagnostic diagnostics} or `undefined`.
|
5456 | */
|
5457 | get(uri: Uri): readonly Diagnostic[] | undefined;
|
5458 |
|
5459 | /**
|
5460 | * Check if this collection contains diagnostics for a
|
5461 | * given resource.
|
5462 | *
|
5463 | * @param uri A resource identifier.
|
5464 | * @returns `true` if this collection has diagnostic for the given resource.
|
5465 | */
|
5466 | has(uri: Uri): boolean;
|
5467 |
|
5468 | /**
|
5469 | * Dispose and free associated resources. Calls
|
5470 | * {@link DiagnosticCollection.clear clear}.
|
5471 | */
|
5472 | dispose(): void;
|
5473 | }
|
5474 |
|
5475 | /**
|
5476 | * Denotes a location of an editor in the window. Editors can be arranged in a grid
|
5477 | * and each column represents one editor location in that grid by counting the editors
|
5478 | * in order of their appearance.
|
5479 | */
|
5480 | export enum ViewColumn {
|
5481 | /**
|
5482 | * A *symbolic* editor column representing the currently active column. This value
|
5483 | * can be used when opening editors, but the *resolved* {@link TextEditor.viewColumn viewColumn}-value
|
5484 | * of editors will always be `One`, `Two`, `Three`,... or `undefined` but never `Active`.
|
5485 | */
|
5486 | Active = -1,
|
5487 | /**
|
5488 | * A *symbolic* editor column representing the column to the side of the active one. This value
|
5489 | * can be used when opening editors, but the *resolved* {@link TextEditor.viewColumn viewColumn}-value
|
5490 | * of editors will always be `One`, `Two`, `Three`,... or `undefined` but never `Beside`.
|
5491 | */
|
5492 | Beside = -2,
|
5493 | /**
|
5494 | * The first editor column.
|
5495 | */
|
5496 | One = 1,
|
5497 | /**
|
5498 | * The second editor column.
|
5499 | */
|
5500 | Two = 2,
|
5501 | /**
|
5502 | * The third editor column.
|
5503 | */
|
5504 | Three = 3,
|
5505 | /**
|
5506 | * The fourth editor column.
|
5507 | */
|
5508 | Four = 4,
|
5509 | /**
|
5510 | * The fifth editor column.
|
5511 | */
|
5512 | Five = 5,
|
5513 | /**
|
5514 | * The sixth editor column.
|
5515 | */
|
5516 | Six = 6,
|
5517 | /**
|
5518 | * The seventh editor column.
|
5519 | */
|
5520 | Seven = 7,
|
5521 | /**
|
5522 | * The eighth editor column.
|
5523 | */
|
5524 | Eight = 8,
|
5525 | /**
|
5526 | * The ninth editor column.
|
5527 | */
|
5528 | Nine = 9
|
5529 | }
|
5530 |
|
5531 | /**
|
5532 | * An output channel is a container for readonly textual information.
|
5533 | *
|
5534 | * To get an instance of an `OutputChannel` use
|
5535 | * {@link window.createOutputChannel createOutputChannel}.
|
5536 | */
|
5537 | export interface OutputChannel {
|
5538 |
|
5539 | /**
|
5540 | * The human-readable name of this output channel.
|
5541 | */
|
5542 | readonly name: string;
|
5543 |
|
5544 | /**
|
5545 | * Append the given value to the channel.
|
5546 | *
|
5547 | * @param value A string, falsy values will not be printed.
|
5548 | */
|
5549 | append(value: string): void;
|
5550 |
|
5551 | /**
|
5552 | * Append the given value and a line feed character
|
5553 | * to the channel.
|
5554 | *
|
5555 | * @param value A string, falsy values will be printed.
|
5556 | */
|
5557 | appendLine(value: string): void;
|
5558 |
|
5559 | /**
|
5560 | * Removes all output from the channel.
|
5561 | */
|
5562 | clear(): void;
|
5563 |
|
5564 | /**
|
5565 | * Reveal this channel in the UI.
|
5566 | *
|
5567 | * @param preserveFocus When `true` the channel will not take focus.
|
5568 | */
|
5569 | show(preserveFocus?: boolean): void;
|
5570 |
|
5571 | /**
|
5572 | * Reveal this channel in the UI.
|
5573 | *
|
5574 | * @deprecated Use the overload with just one parameter (`show(preserveFocus?: boolean): void`).
|
5575 | *
|
5576 | * @param column This argument is **deprecated** and will be ignored.
|
5577 | * @param preserveFocus When `true` the channel will not take focus.
|
5578 | */
|
5579 | show(column?: ViewColumn, preserveFocus?: boolean): void;
|
5580 |
|
5581 | /**
|
5582 | * Hide this channel from the UI.
|
5583 | */
|
5584 | hide(): void;
|
5585 |
|
5586 | /**
|
5587 | * Dispose and free associated resources.
|
5588 | */
|
5589 | dispose(): void;
|
5590 | }
|
5591 |
|
5592 | /**
|
5593 | * Accessibility information which controls screen reader behavior.
|
5594 | */
|
5595 | export interface AccessibilityInformation {
|
5596 | /**
|
5597 | * Label to be read out by a screen reader once the item has focus.
|
5598 | */
|
5599 | label: string;
|
5600 |
|
5601 | /**
|
5602 | * Role of the widget which defines how a screen reader interacts with it.
|
5603 | * The role should be set in special cases when for example a tree-like element behaves like a checkbox.
|
5604 | * If role is not specified the editor will pick the appropriate role automatically.
|
5605 | * More about aria roles can be found here https://w3c.github.io/aria/#widget_roles
|
5606 | */
|
5607 | role?: string;
|
5608 | }
|
5609 |
|
5610 | /**
|
5611 | * Represents the alignment of status bar items.
|
5612 | */
|
5613 | export enum StatusBarAlignment {
|
5614 |
|
5615 | /**
|
5616 | * Aligned to the left side.
|
5617 | */
|
5618 | Left = 1,
|
5619 |
|
5620 | /**
|
5621 | * Aligned to the right side.
|
5622 | */
|
5623 | Right = 2
|
5624 | }
|
5625 |
|
5626 | /**
|
5627 | * A status bar item is a status bar contribution that can
|
5628 | * show text and icons and run a command on click.
|
5629 | */
|
5630 | export interface StatusBarItem {
|
5631 |
|
5632 | /**
|
5633 | * The identifier of this item.
|
5634 | *
|
5635 | * *Note*: if no identifier was provided by the {@link window.createStatusBarItem `window.createStatusBarItem`}
|
5636 | * method, the identifier will match the {@link Extension.id extension identifier}.
|
5637 | */
|
5638 | readonly id: string;
|
5639 |
|
5640 | /**
|
5641 | * The alignment of this item.
|
5642 | */
|
5643 | readonly alignment: StatusBarAlignment;
|
5644 |
|
5645 | /**
|
5646 | * The priority of this item. Higher value means the item should
|
5647 | * be shown more to the left.
|
5648 | */
|
5649 | readonly priority?: number;
|
5650 |
|
5651 | /**
|
5652 | * The name of the entry, like 'Python Language Indicator', 'Git Status' etc.
|
5653 | * Try to keep the length of the name short, yet descriptive enough that
|
5654 | * users can understand what the status bar item is about.
|
5655 | */
|
5656 | name: string | undefined;
|
5657 |
|
5658 | /**
|
5659 | * The text to show for the entry. You can embed icons in the text by leveraging the syntax:
|
5660 | *
|
5661 | * `My text $(icon-name) contains icons like $(icon-name) this one.`
|
5662 | *
|
5663 | * Where the icon-name is taken from the ThemeIcon [icon set](https://code.visualstudio.com/api/references/icons-in-labels#icon-listing), e.g.
|
5664 | * `light-bulb`, `thumbsup`, `zap` etc.
|
5665 | */
|
5666 | text: string;
|
5667 |
|
5668 | /**
|
5669 | * The tooltip text when you hover over this entry.
|
5670 | */
|
5671 | tooltip: string | MarkdownString | undefined;
|
5672 |
|
5673 | /**
|
5674 | * The foreground color for this entry.
|
5675 | */
|
5676 | color: string | ThemeColor | undefined;
|
5677 |
|
5678 | /**
|
5679 | * The background color for this entry.
|
5680 | *
|
5681 | * *Note*: only the following colors are supported:
|
5682 | * * `new ThemeColor('statusBarItem.errorBackground')`
|
5683 | * * `new ThemeColor('statusBarItem.warningBackground')`
|
5684 | *
|
5685 | * More background colors may be supported in the future.
|
5686 | *
|
5687 | * *Note*: when a background color is set, the statusbar may override
|
5688 | * the `color` choice to ensure the entry is readable in all themes.
|
5689 | */
|
5690 | backgroundColor: ThemeColor | undefined;
|
5691 |
|
5692 | /**
|
5693 | * {@link Command `Command`} or identifier of a command to run on click.
|
5694 | *
|
5695 | * The command must be {@link commands.getCommands known}.
|
5696 | *
|
5697 | * Note that if this is a {@link Command `Command`} object, only the {@link Command.command `command`} and {@link Command.arguments `arguments`}
|
5698 | * are used by the editor.
|
5699 | */
|
5700 | command: string | Command | undefined;
|
5701 |
|
5702 | /**
|
5703 | * Accessibility information used when a screen reader interacts with this StatusBar item
|
5704 | */
|
5705 | accessibilityInformation?: AccessibilityInformation;
|
5706 |
|
5707 | /**
|
5708 | * Shows the entry in the status bar.
|
5709 | */
|
5710 | show(): void;
|
5711 |
|
5712 | /**
|
5713 | * Hide the entry in the status bar.
|
5714 | */
|
5715 | hide(): void;
|
5716 |
|
5717 | /**
|
5718 | * Dispose and free associated resources. Call
|
5719 | * {@link StatusBarItem.hide hide}.
|
5720 | */
|
5721 | dispose(): void;
|
5722 | }
|
5723 |
|
5724 | /**
|
5725 | * Defines a generalized way of reporting progress updates.
|
5726 | */
|
5727 | export interface Progress<T> {
|
5728 |
|
5729 | /**
|
5730 | * Report a progress update.
|
5731 | * @param value A progress item, like a message and/or an
|
5732 | * report on how much work finished
|
5733 | */
|
5734 | report(value: T): void;
|
5735 | }
|
5736 |
|
5737 | /**
|
5738 | * An individual terminal instance within the integrated terminal.
|
5739 | */
|
5740 | export interface Terminal {
|
5741 |
|
5742 | /**
|
5743 | * The name of the terminal.
|
5744 | */
|
5745 | readonly name: string;
|
5746 |
|
5747 | /**
|
5748 | * The process ID of the shell process.
|
5749 | */
|
5750 | readonly processId: Thenable<number | undefined>;
|
5751 |
|
5752 | /**
|
5753 | * The object used to initialize the terminal, this is useful for example to detecting the
|
5754 | * shell type of when the terminal was not launched by this extension or for detecting what
|
5755 | * folder the shell was launched in.
|
5756 | */
|
5757 | readonly creationOptions: Readonly<TerminalOptions | ExtensionTerminalOptions>;
|
5758 |
|
5759 | /**
|
5760 | * The exit status of the terminal, this will be undefined while the terminal is active.
|
5761 | *
|
5762 | * **Example:** Show a notification with the exit code when the terminal exits with a
|
5763 | * non-zero exit code.
|
5764 | * ```typescript
|
5765 | * window.onDidCloseTerminal(t => {
|
5766 | * if (t.exitStatus && t.exitStatus.code) {
|
5767 | * vscode.window.showInformationMessage(`Exit code: ${t.exitStatus.code}`);
|
5768 | * }
|
5769 | * });
|
5770 | * ```
|
5771 | */
|
5772 | readonly exitStatus: TerminalExitStatus | undefined;
|
5773 |
|
5774 | /**
|
5775 | * Send text to the terminal. The text is written to the stdin of the underlying pty process
|
5776 | * (shell) of the terminal.
|
5777 | *
|
5778 | * @param text The text to send.
|
5779 | * @param addNewLine Whether to add a new line to the text being sent, this is normally
|
5780 | * required to run a command in the terminal. The character(s) added are \n or \r\n
|
5781 | * depending on the platform. This defaults to `true`.
|
5782 | */
|
5783 | sendText(text: string, addNewLine?: boolean): void;
|
5784 |
|
5785 | /**
|
5786 | * Show the terminal panel and reveal this terminal in the UI.
|
5787 | *
|
5788 | * @param preserveFocus When `true` the terminal will not take focus.
|
5789 | */
|
5790 | show(preserveFocus?: boolean): void;
|
5791 |
|
5792 | /**
|
5793 | * Hide the terminal panel if this terminal is currently showing.
|
5794 | */
|
5795 | hide(): void;
|
5796 |
|
5797 | /**
|
5798 | * Dispose and free associated resources.
|
5799 | */
|
5800 | dispose(): void;
|
5801 | }
|
5802 |
|
5803 | /**
|
5804 | * Provides information on a line in a terminal in order to provide links for it.
|
5805 | */
|
5806 | export interface TerminalLinkContext {
|
5807 | /**
|
5808 | * This is the text from the unwrapped line in the terminal.
|
5809 | */
|
5810 | line: string;
|
5811 |
|
5812 | /**
|
5813 | * The terminal the link belongs to.
|
5814 | */
|
5815 | terminal: Terminal;
|
5816 | }
|
5817 |
|
5818 | /**
|
5819 | * A provider that enables detection and handling of links within terminals.
|
5820 | */
|
5821 | export interface TerminalLinkProvider<T extends TerminalLink = TerminalLink> {
|
5822 | /**
|
5823 | * Provide terminal links for the given context. Note that this can be called multiple times
|
5824 | * even before previous calls resolve, make sure to not share global objects (eg. `RegExp`)
|
5825 | * that could have problems when asynchronous usage may overlap.
|
5826 | * @param context Information about what links are being provided for.
|
5827 | * @param token A cancellation token.
|
5828 | * @return A list of terminal links for the given line.
|
5829 | */
|
5830 | provideTerminalLinks(context: TerminalLinkContext, token: CancellationToken): ProviderResult<T[]>;
|
5831 |
|
5832 | /**
|
5833 | * Handle an activated terminal link.
|
5834 | * @param link The link to handle.
|
5835 | */
|
5836 | handleTerminalLink(link: T): ProviderResult<void>;
|
5837 | }
|
5838 |
|
5839 | /**
|
5840 | * A link on a terminal line.
|
5841 | */
|
5842 | export class TerminalLink {
|
5843 | /**
|
5844 | * The start index of the link on {@link TerminalLinkContext.line}.
|
5845 | */
|
5846 | startIndex: number;
|
5847 |
|
5848 | /**
|
5849 | * The length of the link on {@link TerminalLinkContext.line}.
|
5850 | */
|
5851 | length: number;
|
5852 |
|
5853 | /**
|
5854 | * The tooltip text when you hover over this link.
|
5855 | *
|
5856 | * If a tooltip is provided, is will be displayed in a string that includes instructions on
|
5857 | * how to trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary
|
5858 | * depending on OS, user settings, and localization.
|
5859 | */
|
5860 | tooltip?: string;
|
5861 |
|
5862 | /**
|
5863 | * Creates a new terminal link.
|
5864 | * @param startIndex The start index of the link on {@link TerminalLinkContext.line}.
|
5865 | * @param length The length of the link on {@link TerminalLinkContext.line}.
|
5866 | * @param tooltip The tooltip text when you hover over this link.
|
5867 | *
|
5868 | * If a tooltip is provided, is will be displayed in a string that includes instructions on
|
5869 | * how to trigger the link, such as `{0} (ctrl + click)`. The specific instructions vary
|
5870 | * depending on OS, user settings, and localization.
|
5871 | */
|
5872 | constructor(startIndex: number, length: number, tooltip?: string);
|
5873 | }
|
5874 |
|
5875 | /**
|
5876 | * Provides a terminal profile for the contributed terminal profile when launched via the UI or
|
5877 | * command.
|
5878 | */
|
5879 | export interface TerminalProfileProvider {
|
5880 | /**
|
5881 | * Provide the terminal profile.
|
5882 | * @param token A cancellation token that indicates the result is no longer needed.
|
5883 | * @returns The terminal profile.
|
5884 | */
|
5885 | provideTerminalProfile(token: CancellationToken): ProviderResult<TerminalProfile>;
|
5886 | }
|
5887 |
|
5888 | /**
|
5889 | * A terminal profile defines how a terminal will be launched.
|
5890 | */
|
5891 | export class TerminalProfile {
|
5892 | /**
|
5893 | * The options that the terminal will launch with.
|
5894 | */
|
5895 | options: TerminalOptions | ExtensionTerminalOptions;
|
5896 |
|
5897 | /**
|
5898 | * Creates a new terminal profile.
|
5899 | * @param options The options that the terminal will launch with.
|
5900 | */
|
5901 | constructor(options: TerminalOptions | ExtensionTerminalOptions);
|
5902 | }
|
5903 |
|
5904 | /**
|
5905 | * A file decoration represents metadata that can be rendered with a file.
|
5906 | */
|
5907 | export class FileDecoration {
|
5908 |
|
5909 | /**
|
5910 | * A very short string that represents this decoration.
|
5911 | */
|
5912 | badge?: string;
|
5913 |
|
5914 | /**
|
5915 | * A human-readable tooltip for this decoration.
|
5916 | */
|
5917 | tooltip?: string;
|
5918 |
|
5919 | /**
|
5920 | * The color of this decoration.
|
5921 | */
|
5922 | color?: ThemeColor;
|
5923 |
|
5924 | /**
|
5925 | * A flag expressing that this decoration should be
|
5926 | * propagated to its parents.
|
5927 | */
|
5928 | propagate?: boolean;
|
5929 |
|
5930 | /**
|
5931 | * Creates a new decoration.
|
5932 | *
|
5933 | * @param badge A letter that represents the decoration.
|
5934 | * @param tooltip The tooltip of the decoration.
|
5935 | * @param color The color of the decoration.
|
5936 | */
|
5937 | constructor(badge?: string, tooltip?: string, color?: ThemeColor);
|
5938 | }
|
5939 |
|
5940 | /**
|
5941 | * The decoration provider interfaces defines the contract between extensions and
|
5942 | * file decorations.
|
5943 | */
|
5944 | export interface FileDecorationProvider {
|
5945 |
|
5946 | /**
|
5947 | * An optional event to signal that decorations for one or many files have changed.
|
5948 | *
|
5949 | * *Note* that this event should be used to propagate information about children.
|
5950 | *
|
5951 | * @see {@link EventEmitter}
|
5952 | */
|
5953 | onDidChangeFileDecorations?: Event<undefined | Uri | Uri[]>;
|
5954 |
|
5955 | /**
|
5956 | * Provide decorations for a given uri.
|
5957 | *
|
5958 | * *Note* that this function is only called when a file gets rendered in the UI.
|
5959 | * This means a decoration from a descendent that propagates upwards must be signaled
|
5960 | * to the editor via the {@link FileDecorationProvider.onDidChangeFileDecorations onDidChangeFileDecorations}-event.
|
5961 | *
|
5962 | * @param uri The uri of the file to provide a decoration for.
|
5963 | * @param token A cancellation token.
|
5964 | * @returns A decoration or a thenable that resolves to such.
|
5965 | */
|
5966 | provideFileDecoration(uri: Uri, token: CancellationToken): ProviderResult<FileDecoration>;
|
5967 | }
|
5968 |
|
5969 |
|
5970 | /**
|
5971 | * In a remote window the extension kind describes if an extension
|
5972 | * runs where the UI (window) runs or if an extension runs remotely.
|
5973 | */
|
5974 | export enum ExtensionKind {
|
5975 |
|
5976 | /**
|
5977 | * Extension runs where the UI runs.
|
5978 | */
|
5979 | UI = 1,
|
5980 |
|
5981 | /**
|
5982 | * Extension runs where the remote extension host runs.
|
5983 | */
|
5984 | Workspace = 2
|
5985 | }
|
5986 |
|
5987 | /**
|
5988 | * Represents an extension.
|
5989 | *
|
5990 | * To get an instance of an `Extension` use {@link extensions.getExtension getExtension}.
|
5991 | */
|
5992 | export interface Extension<T> {
|
5993 |
|
5994 | /**
|
5995 | * The canonical extension identifier in the form of: `publisher.name`.
|
5996 | */
|
5997 | readonly id: string;
|
5998 |
|
5999 | /**
|
6000 | * The uri of the directory containing the extension.
|
6001 | */
|
6002 | readonly extensionUri: Uri;
|
6003 |
|
6004 | /**
|
6005 | * The absolute file path of the directory containing this extension. Shorthand
|
6006 | * notation for {@link Extension.extensionUri Extension.extensionUri.fsPath} (independent of the uri scheme).
|
6007 | */
|
6008 | readonly extensionPath: string;
|
6009 |
|
6010 | /**
|
6011 | * `true` if the extension has been activated.
|
6012 | */
|
6013 | readonly isActive: boolean;
|
6014 |
|
6015 | /**
|
6016 | * The parsed contents of the extension's package.json.
|
6017 | */
|
6018 | readonly packageJSON: any;
|
6019 |
|
6020 | /**
|
6021 | * The extension kind describes if an extension runs where the UI runs
|
6022 | * or if an extension runs where the remote extension host runs. The extension kind
|
6023 | * is defined in the `package.json`-file of extensions but can also be refined
|
6024 | * via the `remote.extensionKind`-setting. When no remote extension host exists,
|
6025 | * the value is {@link ExtensionKind.UI `ExtensionKind.UI`}.
|
6026 | */
|
6027 | extensionKind: ExtensionKind;
|
6028 |
|
6029 | /**
|
6030 | * The public API exported by this extension. It is an invalid action
|
6031 | * to access this field before this extension has been activated.
|
6032 | */
|
6033 | readonly exports: T;
|
6034 |
|
6035 | /**
|
6036 | * Activates this extension and returns its public API.
|
6037 | *
|
6038 | * @return A promise that will resolve when this extension has been activated.
|
6039 | */
|
6040 | activate(): Thenable<T>;
|
6041 | }
|
6042 |
|
6043 | /**
|
6044 | * The ExtensionMode is provided on the `ExtensionContext` and indicates the
|
6045 | * mode the specific extension is running in.
|
6046 | */
|
6047 | export enum ExtensionMode {
|
6048 | /**
|
6049 | * The extension is installed normally (for example, from the marketplace
|
6050 | * or VSIX) in the editor.
|
6051 | */
|
6052 | Production = 1,
|
6053 |
|
6054 | /**
|
6055 | * The extension is running from an `--extensionDevelopmentPath` provided
|
6056 | * when launching the editor.
|
6057 | */
|
6058 | Development = 2,
|
6059 |
|
6060 | /**
|
6061 | * The extension is running from an `--extensionTestsPath` and
|
6062 | * the extension host is running unit tests.
|
6063 | */
|
6064 | Test = 3,
|
6065 | }
|
6066 |
|
6067 | /**
|
6068 | * An extension context is a collection of utilities private to an
|
6069 | * extension.
|
6070 | *
|
6071 | * An instance of an `ExtensionContext` is provided as the first
|
6072 | * parameter to the `activate`-call of an extension.
|
6073 | */
|
6074 | export interface ExtensionContext {
|
6075 |
|
6076 | /**
|
6077 | * An array to which disposables can be added. When this
|
6078 | * extension is deactivated the disposables will be disposed.
|
6079 | */
|
6080 | readonly subscriptions: { dispose(): any }[];
|
6081 |
|
6082 | /**
|
6083 | * A memento object that stores state in the context
|
6084 | * of the currently opened {@link workspace.workspaceFolders workspace}.
|
6085 | */
|
6086 | readonly workspaceState: Memento;
|
6087 |
|
6088 | /**
|
6089 | * A memento object that stores state independent
|
6090 | * of the current opened {@link workspace.workspaceFolders workspace}.
|
6091 | */
|
6092 | readonly globalState: Memento & {
|
6093 | /**
|
6094 | * Set the keys whose values should be synchronized across devices when synchronizing user-data
|
6095 | * like configuration, extensions, and mementos.
|
6096 | *
|
6097 | * Note that this function defines the whole set of keys whose values are synchronized:
|
6098 | * - calling it with an empty array stops synchronization for this memento
|
6099 | * - calling it with a non-empty array replaces all keys whose values are synchronized
|
6100 | *
|
6101 | * For any given set of keys this function needs to be called only once but there is no harm in
|
6102 | * repeatedly calling it.
|
6103 | *
|
6104 | * @param keys The set of keys whose values are synced.
|
6105 | */
|
6106 | setKeysForSync(keys: readonly string[]): void;
|
6107 | };
|
6108 |
|
6109 | /**
|
6110 | * A storage utility for secrets. Secrets are persisted across reloads and are independent of the
|
6111 | * current opened {@link workspace.workspaceFolders workspace}.
|
6112 | */
|
6113 | readonly secrets: SecretStorage;
|
6114 |
|
6115 | /**
|
6116 | * The uri of the directory containing the extension.
|
6117 | */
|
6118 | readonly extensionUri: Uri;
|
6119 |
|
6120 | /**
|
6121 | * The absolute file path of the directory containing the extension. Shorthand
|
6122 | * notation for {@link TextDocument.uri ExtensionContext.extensionUri.fsPath} (independent of the uri scheme).
|
6123 | */
|
6124 | readonly extensionPath: string;
|
6125 |
|
6126 | /**
|
6127 | * Gets the extension's environment variable collection for this workspace, enabling changes
|
6128 | * to be applied to terminal environment variables.
|
6129 | */
|
6130 | readonly environmentVariableCollection: EnvironmentVariableCollection;
|
6131 |
|
6132 | /**
|
6133 | * Get the absolute path of a resource contained in the extension.
|
6134 | *
|
6135 | * *Note* that an absolute uri can be constructed via {@link Uri.joinPath `Uri.joinPath`} and
|
6136 | * {@link ExtensionContext.extensionUri `extensionUri`}, e.g. `vscode.Uri.joinPath(context.extensionUri, relativePath);`
|
6137 | *
|
6138 | * @param relativePath A relative path to a resource contained in the extension.
|
6139 | * @return The absolute path of the resource.
|
6140 | */
|
6141 | asAbsolutePath(relativePath: string): string;
|
6142 |
|
6143 | /**
|
6144 | * The uri of a workspace specific directory in which the extension
|
6145 | * can store private state. The directory might not exist and creation is
|
6146 | * up to the extension. However, the parent directory is guaranteed to be existent.
|
6147 | * The value is `undefined` when no workspace nor folder has been opened.
|
6148 | *
|
6149 | * Use {@link ExtensionContext.workspaceState `workspaceState`} or
|
6150 | * {@link ExtensionContext.globalState `globalState`} to store key value data.
|
6151 | *
|
6152 | * @see {@link FileSystem `workspace.fs`} for how to read and write files and folders from
|
6153 | * an uri.
|
6154 | */
|
6155 | readonly storageUri: Uri | undefined;
|
6156 |
|
6157 | /**
|
6158 | * An absolute file path of a workspace specific directory in which the extension
|
6159 | * can store private state. The directory might not exist on disk and creation is
|
6160 | * up to the extension. However, the parent directory is guaranteed to be existent.
|
6161 | *
|
6162 | * Use {@link ExtensionContext.workspaceState `workspaceState`} or
|
6163 | * {@link ExtensionContext.globalState `globalState`} to store key value data.
|
6164 | *
|
6165 | * @deprecated Use {@link ExtensionContext.storageUri storageUri} instead.
|
6166 | */
|
6167 | readonly storagePath: string | undefined;
|
6168 |
|
6169 | /**
|
6170 | * The uri of a directory in which the extension can store global state.
|
6171 | * The directory might not exist on disk and creation is
|
6172 | * up to the extension. However, the parent directory is guaranteed to be existent.
|
6173 | *
|
6174 | * Use {@link ExtensionContext.globalState `globalState`} to store key value data.
|
6175 | *
|
6176 | * @see {@link FileSystem `workspace.fs`} for how to read and write files and folders from
|
6177 | * an uri.
|
6178 | */
|
6179 | readonly globalStorageUri: Uri;
|
6180 |
|
6181 | /**
|
6182 | * An absolute file path in which the extension can store global state.
|
6183 | * The directory might not exist on disk and creation is
|
6184 | * up to the extension. However, the parent directory is guaranteed to be existent.
|
6185 | *
|
6186 | * Use {@link ExtensionContext.globalState `globalState`} to store key value data.
|
6187 | *
|
6188 | * @deprecated Use {@link ExtensionContext.globalStorageUri globalStorageUri} instead.
|
6189 | */
|
6190 | readonly globalStoragePath: string;
|
6191 |
|
6192 | /**
|
6193 | * The uri of a directory in which the extension can create log files.
|
6194 | * The directory might not exist on disk and creation is up to the extension. However,
|
6195 | * the parent directory is guaranteed to be existent.
|
6196 | *
|
6197 | * @see {@link FileSystem `workspace.fs`} for how to read and write files and folders from
|
6198 | * an uri.
|
6199 | */
|
6200 | readonly logUri: Uri;
|
6201 |
|
6202 | /**
|
6203 | * An absolute file path of a directory in which the extension can create log files.
|
6204 | * The directory might not exist on disk and creation is up to the extension. However,
|
6205 | * the parent directory is guaranteed to be existent.
|
6206 | *
|
6207 | * @deprecated Use {@link ExtensionContext.logUri logUri} instead.
|
6208 | */
|
6209 | readonly logPath: string;
|
6210 |
|
6211 | /**
|
6212 | * The mode the extension is running in. This is specific to the current
|
6213 | * extension. One extension may be in `ExtensionMode.Development` while
|
6214 | * other extensions in the host run in `ExtensionMode.Release`.
|
6215 | */
|
6216 | readonly extensionMode: ExtensionMode;
|
6217 |
|
6218 | /**
|
6219 | * The current `Extension` instance.
|
6220 | */
|
6221 | readonly extension: Extension<any>;
|
6222 | }
|
6223 |
|
6224 | /**
|
6225 | * A memento represents a storage utility. It can store and retrieve
|
6226 | * values.
|
6227 | */
|
6228 | export interface Memento {
|
6229 |
|
6230 | /**
|
6231 | * Returns the stored keys.
|
6232 | *
|
6233 | * @return The stored keys.
|
6234 | */
|
6235 | keys(): readonly string[];
|
6236 |
|
6237 | /**
|
6238 | * Return a value.
|
6239 | *
|
6240 | * @param key A string.
|
6241 | * @return The stored value or `undefined`.
|
6242 | */
|
6243 | get<T>(key: string): T | undefined;
|
6244 |
|
6245 | /**
|
6246 | * Return a value.
|
6247 | *
|
6248 | * @param key A string.
|
6249 | * @param defaultValue A value that should be returned when there is no
|
6250 | * value (`undefined`) with the given key.
|
6251 | * @return The stored value or the defaultValue.
|
6252 | */
|
6253 | get<T>(key: string, defaultValue: T): T;
|
6254 |
|
6255 | /**
|
6256 | * Store a value. The value must be JSON-stringifyable.
|
6257 | *
|
6258 | * @param key A string.
|
6259 | * @param value A value. MUST not contain cyclic references.
|
6260 | */
|
6261 | update(key: string, value: any): Thenable<void>;
|
6262 | }
|
6263 |
|
6264 | /**
|
6265 | * The event data that is fired when a secret is added or removed.
|
6266 | */
|
6267 | export interface SecretStorageChangeEvent {
|
6268 | /**
|
6269 | * The key of the secret that has changed.
|
6270 | */
|
6271 | readonly key: string;
|
6272 | }
|
6273 |
|
6274 | /**
|
6275 | * Represents a storage utility for secrets, information that is
|
6276 | * sensitive.
|
6277 | */
|
6278 | export interface SecretStorage {
|
6279 | /**
|
6280 | * Retrieve a secret that was stored with key. Returns undefined if there
|
6281 | * is no password matching that key.
|
6282 | * @param key The key the secret was stored under.
|
6283 | * @returns The stored value or `undefined`.
|
6284 | */
|
6285 | get(key: string): Thenable<string | undefined>;
|
6286 |
|
6287 | /**
|
6288 | * Store a secret under a given key.
|
6289 | * @param key The key to store the secret under.
|
6290 | * @param value The secret.
|
6291 | */
|
6292 | store(key: string, value: string): Thenable<void>;
|
6293 |
|
6294 | /**
|
6295 | * Remove a secret from storage.
|
6296 | * @param key The key the secret was stored under.
|
6297 | */
|
6298 | delete(key: string): Thenable<void>;
|
6299 |
|
6300 | /**
|
6301 | * Fires when a secret is stored or deleted.
|
6302 | */
|
6303 | onDidChange: Event<SecretStorageChangeEvent>;
|
6304 | }
|
6305 |
|
6306 | /**
|
6307 | * Represents a color theme kind.
|
6308 | */
|
6309 | export enum ColorThemeKind {
|
6310 | Light = 1,
|
6311 | Dark = 2,
|
6312 | HighContrast = 3
|
6313 | }
|
6314 |
|
6315 | /**
|
6316 | * Represents a color theme.
|
6317 | */
|
6318 | export interface ColorTheme {
|
6319 |
|
6320 | /**
|
6321 | * The kind of this color theme: light, dark or high contrast.
|
6322 | */
|
6323 | readonly kind: ColorThemeKind;
|
6324 | }
|
6325 |
|
6326 | /**
|
6327 | * Controls the behaviour of the terminal's visibility.
|
6328 | */
|
6329 | export enum TaskRevealKind {
|
6330 | /**
|
6331 | * Always brings the terminal to front if the task is executed.
|
6332 | */
|
6333 | Always = 1,
|
6334 |
|
6335 | /**
|
6336 | * Only brings the terminal to front if a problem is detected executing the task
|
6337 | * (e.g. the task couldn't be started because).
|
6338 | */
|
6339 | Silent = 2,
|
6340 |
|
6341 | /**
|
6342 | * The terminal never comes to front when the task is executed.
|
6343 | */
|
6344 | Never = 3
|
6345 | }
|
6346 |
|
6347 | /**
|
6348 | * Controls how the task channel is used between tasks
|
6349 | */
|
6350 | export enum TaskPanelKind {
|
6351 |
|
6352 | /**
|
6353 | * Shares a panel with other tasks. This is the default.
|
6354 | */
|
6355 | Shared = 1,
|
6356 |
|
6357 | /**
|
6358 | * Uses a dedicated panel for this tasks. The panel is not
|
6359 | * shared with other tasks.
|
6360 | */
|
6361 | Dedicated = 2,
|
6362 |
|
6363 | /**
|
6364 | * Creates a new panel whenever this task is executed.
|
6365 | */
|
6366 | New = 3
|
6367 | }
|
6368 |
|
6369 | /**
|
6370 | * Controls how the task is presented in the UI.
|
6371 | */
|
6372 | export interface TaskPresentationOptions {
|
6373 | /**
|
6374 | * Controls whether the task output is reveal in the user interface.
|
6375 | * Defaults to `RevealKind.Always`.
|
6376 | */
|
6377 | reveal?: TaskRevealKind;
|
6378 |
|
6379 | /**
|
6380 | * Controls whether the command associated with the task is echoed
|
6381 | * in the user interface.
|
6382 | */
|
6383 | echo?: boolean;
|
6384 |
|
6385 | /**
|
6386 | * Controls whether the panel showing the task output is taking focus.
|
6387 | */
|
6388 | focus?: boolean;
|
6389 |
|
6390 | /**
|
6391 | * Controls if the task panel is used for this task only (dedicated),
|
6392 | * shared between tasks (shared) or if a new panel is created on
|
6393 | * every task execution (new). Defaults to `TaskInstanceKind.Shared`
|
6394 | */
|
6395 | panel?: TaskPanelKind;
|
6396 |
|
6397 | /**
|
6398 | * Controls whether to show the "Terminal will be reused by tasks, press any key to close it" message.
|
6399 | */
|
6400 | showReuseMessage?: boolean;
|
6401 |
|
6402 | /**
|
6403 | * Controls whether the terminal is cleared before executing the task.
|
6404 | */
|
6405 | clear?: boolean;
|
6406 | }
|
6407 |
|
6408 | /**
|
6409 | * A grouping for tasks. The editor by default supports the
|
6410 | * 'Clean', 'Build', 'RebuildAll' and 'Test' group.
|
6411 | */
|
6412 | export class TaskGroup {
|
6413 |
|
6414 | /**
|
6415 | * The clean task group;
|
6416 | */
|
6417 | static Clean: TaskGroup;
|
6418 |
|
6419 | /**
|
6420 | * The build task group;
|
6421 | */
|
6422 | static Build: TaskGroup;
|
6423 |
|
6424 | /**
|
6425 | * The rebuild all task group;
|
6426 | */
|
6427 | static Rebuild: TaskGroup;
|
6428 |
|
6429 | /**
|
6430 | * The test all task group;
|
6431 | */
|
6432 | static Test: TaskGroup;
|
6433 |
|
6434 | private constructor(id: string, label: string);
|
6435 | }
|
6436 |
|
6437 | /**
|
6438 | * A structure that defines a task kind in the system.
|
6439 | * The value must be JSON-stringifyable.
|
6440 | */
|
6441 | export interface TaskDefinition {
|
6442 | /**
|
6443 | * The task definition describing the task provided by an extension.
|
6444 | * Usually a task provider defines more properties to identify
|
6445 | * a task. They need to be defined in the package.json of the
|
6446 | * extension under the 'taskDefinitions' extension point. The npm
|
6447 | * task definition for example looks like this
|
6448 | * ```typescript
|
6449 | * interface NpmTaskDefinition extends TaskDefinition {
|
6450 | * script: string;
|
6451 | * }
|
6452 | * ```
|
6453 | *
|
6454 | * Note that type identifier starting with a '$' are reserved for internal
|
6455 | * usages and shouldn't be used by extensions.
|
6456 | */
|
6457 | readonly type: string;
|
6458 |
|
6459 | /**
|
6460 | * Additional attributes of a concrete task definition.
|
6461 | */
|
6462 | [name: string]: any;
|
6463 | }
|
6464 |
|
6465 | /**
|
6466 | * Options for a process execution
|
6467 | */
|
6468 | export interface ProcessExecutionOptions {
|
6469 | /**
|
6470 | * The current working directory of the executed program or shell.
|
6471 | * If omitted the tools current workspace root is used.
|
6472 | */
|
6473 | cwd?: string;
|
6474 |
|
6475 | /**
|
6476 | * The additional environment of the executed program or shell. If omitted
|
6477 | * the parent process' environment is used. If provided it is merged with
|
6478 | * the parent process' environment.
|
6479 | */
|
6480 | env?: { [key: string]: string };
|
6481 | }
|
6482 |
|
6483 | /**
|
6484 | * The execution of a task happens as an external process
|
6485 | * without shell interaction.
|
6486 | */
|
6487 | export class ProcessExecution {
|
6488 |
|
6489 | /**
|
6490 | * Creates a process execution.
|
6491 | *
|
6492 | * @param process The process to start.
|
6493 | * @param options Optional options for the started process.
|
6494 | */
|
6495 | constructor(process: string, options?: ProcessExecutionOptions);
|
6496 |
|
6497 | /**
|
6498 | * Creates a process execution.
|
6499 | *
|
6500 | * @param process The process to start.
|
6501 | * @param args Arguments to be passed to the process.
|
6502 | * @param options Optional options for the started process.
|
6503 | */
|
6504 | constructor(process: string, args: string[], options?: ProcessExecutionOptions);
|
6505 |
|
6506 | /**
|
6507 | * The process to be executed.
|
6508 | */
|
6509 | process: string;
|
6510 |
|
6511 | /**
|
6512 | * The arguments passed to the process. Defaults to an empty array.
|
6513 | */
|
6514 | args: string[];
|
6515 |
|
6516 | /**
|
6517 | * The process options used when the process is executed.
|
6518 | * Defaults to undefined.
|
6519 | */
|
6520 | options?: ProcessExecutionOptions;
|
6521 | }
|
6522 |
|
6523 | /**
|
6524 | * The shell quoting options.
|
6525 | */
|
6526 | export interface ShellQuotingOptions {
|
6527 |
|
6528 | /**
|
6529 | * The character used to do character escaping. If a string is provided only spaces
|
6530 | * are escaped. If a `{ escapeChar, charsToEscape }` literal is provide all characters
|
6531 | * in `charsToEscape` are escaped using the `escapeChar`.
|
6532 | */
|
6533 | escape?: string | {
|
6534 | /**
|
6535 | * The escape character.
|
6536 | */
|
6537 | escapeChar: string;
|
6538 | /**
|
6539 | * The characters to escape.
|
6540 | */
|
6541 | charsToEscape: string;
|
6542 | };
|
6543 |
|
6544 | /**
|
6545 | * The character used for strong quoting. The string's length must be 1.
|
6546 | */
|
6547 | strong?: string;
|
6548 |
|
6549 | /**
|
6550 | * The character used for weak quoting. The string's length must be 1.
|
6551 | */
|
6552 | weak?: string;
|
6553 | }
|
6554 |
|
6555 | /**
|
6556 | * Options for a shell execution
|
6557 | */
|
6558 | export interface ShellExecutionOptions {
|
6559 | /**
|
6560 | * The shell executable.
|
6561 | */
|
6562 | executable?: string;
|
6563 |
|
6564 | /**
|
6565 | * The arguments to be passed to the shell executable used to run the task. Most shells
|
6566 | * require special arguments to execute a command. For example `bash` requires the `-c`
|
6567 | * argument to execute a command, `PowerShell` requires `-Command` and `cmd` requires both
|
6568 | * `/d` and `/c`.
|
6569 | */
|
6570 | shellArgs?: string[];
|
6571 |
|
6572 | /**
|
6573 | * The shell quotes supported by this shell.
|
6574 | */
|
6575 | shellQuoting?: ShellQuotingOptions;
|
6576 |
|
6577 | /**
|
6578 | * The current working directory of the executed shell.
|
6579 | * If omitted the tools current workspace root is used.
|
6580 | */
|
6581 | cwd?: string;
|
6582 |
|
6583 | /**
|
6584 | * The additional environment of the executed shell. If omitted
|
6585 | * the parent process' environment is used. If provided it is merged with
|
6586 | * the parent process' environment.
|
6587 | */
|
6588 | env?: { [key: string]: string };
|
6589 | }
|
6590 |
|
6591 | /**
|
6592 | * Defines how an argument should be quoted if it contains
|
6593 | * spaces or unsupported characters.
|
6594 | */
|
6595 | export enum ShellQuoting {
|
6596 |
|
6597 | /**
|
6598 | * Character escaping should be used. This for example
|
6599 | * uses \ on bash and ` on PowerShell.
|
6600 | */
|
6601 | Escape = 1,
|
6602 |
|
6603 | /**
|
6604 | * Strong string quoting should be used. This for example
|
6605 | * uses " for Windows cmd and ' for bash and PowerShell.
|
6606 | * Strong quoting treats arguments as literal strings.
|
6607 | * Under PowerShell echo 'The value is $(2 * 3)' will
|
6608 | * print `The value is $(2 * 3)`
|
6609 | */
|
6610 | Strong = 2,
|
6611 |
|
6612 | /**
|
6613 | * Weak string quoting should be used. This for example
|
6614 | * uses " for Windows cmd, bash and PowerShell. Weak quoting
|
6615 | * still performs some kind of evaluation inside the quoted
|
6616 | * string. Under PowerShell echo "The value is $(2 * 3)"
|
6617 | * will print `The value is 6`
|
6618 | */
|
6619 | Weak = 3
|
6620 | }
|
6621 |
|
6622 | /**
|
6623 | * A string that will be quoted depending on the used shell.
|
6624 | */
|
6625 | export interface ShellQuotedString {
|
6626 | /**
|
6627 | * The actual string value.
|
6628 | */
|
6629 | value: string;
|
6630 |
|
6631 | /**
|
6632 | * The quoting style to use.
|
6633 | */
|
6634 | quoting: ShellQuoting;
|
6635 | }
|
6636 |
|
6637 | export class ShellExecution {
|
6638 | /**
|
6639 | * Creates a shell execution with a full command line.
|
6640 | *
|
6641 | * @param commandLine The command line to execute.
|
6642 | * @param options Optional options for the started the shell.
|
6643 | */
|
6644 | constructor(commandLine: string, options?: ShellExecutionOptions);
|
6645 |
|
6646 | /**
|
6647 | * Creates a shell execution with a command and arguments. For the real execution the editor will
|
6648 | * construct a command line from the command and the arguments. This is subject to interpretation
|
6649 | * especially when it comes to quoting. If full control over the command line is needed please
|
6650 | * use the constructor that creates a `ShellExecution` with the full command line.
|
6651 | *
|
6652 | * @param command The command to execute.
|
6653 | * @param args The command arguments.
|
6654 | * @param options Optional options for the started the shell.
|
6655 | */
|
6656 | constructor(command: string | ShellQuotedString, args: (string | ShellQuotedString)[], options?: ShellExecutionOptions);
|
6657 |
|
6658 | /**
|
6659 | * The shell command line. Is `undefined` if created with a command and arguments.
|
6660 | */
|
6661 | commandLine: string | undefined;
|
6662 |
|
6663 | /**
|
6664 | * The shell command. Is `undefined` if created with a full command line.
|
6665 | */
|
6666 | command: string | ShellQuotedString;
|
6667 |
|
6668 | /**
|
6669 | * The shell args. Is `undefined` if created with a full command line.
|
6670 | */
|
6671 | args: (string | ShellQuotedString)[];
|
6672 |
|
6673 | /**
|
6674 | * The shell options used when the command line is executed in a shell.
|
6675 | * Defaults to undefined.
|
6676 | */
|
6677 | options?: ShellExecutionOptions;
|
6678 | }
|
6679 |
|
6680 | /**
|
6681 | * Class used to execute an extension callback as a task.
|
6682 | */
|
6683 | export class CustomExecution {
|
6684 | /**
|
6685 | * Constructs a CustomExecution task object. The callback will be executed when the task is run, at which point the
|
6686 | * extension should return the Pseudoterminal it will "run in". The task should wait to do further execution until
|
6687 | * {@link Pseudoterminal.open} is called. Task cancellation should be handled using
|
6688 | * {@link Pseudoterminal.close}. When the task is complete fire
|
6689 | * {@link Pseudoterminal.onDidClose}.
|
6690 | * @param callback The callback that will be called when the task is started by a user. Any ${} style variables that
|
6691 | * were in the task definition will be resolved and passed into the callback as `resolvedDefinition`.
|
6692 | */
|
6693 | constructor(callback: (resolvedDefinition: TaskDefinition) => Thenable<Pseudoterminal>);
|
6694 | }
|
6695 |
|
6696 | /**
|
6697 | * The scope of a task.
|
6698 | */
|
6699 | export enum TaskScope {
|
6700 | /**
|
6701 | * The task is a global task. Global tasks are currently not supported.
|
6702 | */
|
6703 | Global = 1,
|
6704 |
|
6705 | /**
|
6706 | * The task is a workspace task
|
6707 | */
|
6708 | Workspace = 2
|
6709 | }
|
6710 |
|
6711 | /**
|
6712 | * Run options for a task.
|
6713 | */
|
6714 | export interface RunOptions {
|
6715 | /**
|
6716 | * Controls whether task variables are re-evaluated on rerun.
|
6717 | */
|
6718 | reevaluateOnRerun?: boolean;
|
6719 | }
|
6720 |
|
6721 | /**
|
6722 | * A task to execute
|
6723 | */
|
6724 | export class Task {
|
6725 |
|
6726 | /**
|
6727 | * Creates a new task.
|
6728 | *
|
6729 | * @param definition The task definition as defined in the taskDefinitions extension point.
|
6730 | * @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.
|
6731 | * @param name The task's name. Is presented in the user interface.
|
6732 | * @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
|
6733 | * @param execution The process or shell execution.
|
6734 | * @param problemMatchers the names of problem matchers to use, like '$tsc'
|
6735 | * or '$eslint'. Problem matchers can be contributed by an extension using
|
6736 | * the `problemMatchers` extension point.
|
6737 | */
|
6738 | constructor(taskDefinition: TaskDefinition, scope: WorkspaceFolder | TaskScope.Global | TaskScope.Workspace, name: string, source: string, execution?: ProcessExecution | ShellExecution | CustomExecution, problemMatchers?: string | string[]);
|
6739 |
|
6740 | /**
|
6741 | * Creates a new task.
|
6742 | *
|
6743 | * @deprecated Use the new constructors that allow specifying a scope for the task.
|
6744 | *
|
6745 | * @param definition The task definition as defined in the taskDefinitions extension point.
|
6746 | * @param name The task's name. Is presented in the user interface.
|
6747 | * @param source The task's source (e.g. 'gulp', 'npm', ...). Is presented in the user interface.
|
6748 | * @param execution The process or shell execution.
|
6749 | * @param problemMatchers the names of problem matchers to use, like '$tsc'
|
6750 | * or '$eslint'. Problem matchers can be contributed by an extension using
|
6751 | * the `problemMatchers` extension point.
|
6752 | */
|
6753 | constructor(taskDefinition: TaskDefinition, name: string, source: string, execution?: ProcessExecution | ShellExecution, problemMatchers?: string | string[]);
|
6754 |
|
6755 | /**
|
6756 | * The task's definition.
|
6757 | */
|
6758 | definition: TaskDefinition;
|
6759 |
|
6760 | /**
|
6761 | * The task's scope.
|
6762 | */
|
6763 | readonly scope?: TaskScope.Global | TaskScope.Workspace | WorkspaceFolder;
|
6764 |
|
6765 | /**
|
6766 | * The task's name
|
6767 | */
|
6768 | name: string;
|
6769 |
|
6770 | /**
|
6771 | * A human-readable string which is rendered less prominently on a separate line in places
|
6772 | * where the task's name is displayed. Supports rendering of {@link ThemeIcon theme icons}
|
6773 | * via the `$(<name>)`-syntax.
|
6774 | */
|
6775 | detail?: string;
|
6776 |
|
6777 | /**
|
6778 | * The task's execution engine
|
6779 | */
|
6780 | execution?: ProcessExecution | ShellExecution | CustomExecution;
|
6781 |
|
6782 | /**
|
6783 | * Whether the task is a background task or not.
|
6784 | */
|
6785 | isBackground: boolean;
|
6786 |
|
6787 | /**
|
6788 | * A human-readable string describing the source of this shell task, e.g. 'gulp'
|
6789 | * or 'npm'. Supports rendering of {@link ThemeIcon theme icons} via the `$(<name>)`-syntax.
|
6790 | */
|
6791 | source: string;
|
6792 |
|
6793 | /**
|
6794 | * The task group this tasks belongs to. See TaskGroup
|
6795 | * for a predefined set of available groups.
|
6796 | * Defaults to undefined meaning that the task doesn't
|
6797 | * belong to any special group.
|
6798 | */
|
6799 | group?: TaskGroup;
|
6800 |
|
6801 | /**
|
6802 | * The presentation options. Defaults to an empty literal.
|
6803 | */
|
6804 | presentationOptions: TaskPresentationOptions;
|
6805 |
|
6806 | /**
|
6807 | * The problem matchers attached to the task. Defaults to an empty
|
6808 | * array.
|
6809 | */
|
6810 | problemMatchers: string[];
|
6811 |
|
6812 | /**
|
6813 | * Run options for the task
|
6814 | */
|
6815 | runOptions: RunOptions;
|
6816 | }
|
6817 |
|
6818 | /**
|
6819 | * A task provider allows to add tasks to the task service.
|
6820 | * A task provider is registered via {@link tasks.registerTaskProvider}.
|
6821 | */
|
6822 | export interface TaskProvider<T extends Task = Task> {
|
6823 | /**
|
6824 | * Provides tasks.
|
6825 | * @param token A cancellation token.
|
6826 | * @return an array of tasks
|
6827 | */
|
6828 | provideTasks(token: CancellationToken): ProviderResult<T[]>;
|
6829 |
|
6830 | /**
|
6831 | * Resolves a task that has no {@link Task.execution `execution`} set. Tasks are
|
6832 | * often created from information found in the `tasks.json`-file. Such tasks miss
|
6833 | * the information on how to execute them and a task provider must fill in
|
6834 | * the missing information in the `resolveTask`-method. This method will not be
|
6835 | * called for tasks returned from the above `provideTasks` method since those
|
6836 | * tasks are always fully resolved. A valid default implementation for the
|
6837 | * `resolveTask` method is to return `undefined`.
|
6838 | *
|
6839 | * Note that when filling in the properties of `task`, you _must_ be sure to
|
6840 | * use the exact same `TaskDefinition` and not create a new one. Other properties
|
6841 | * may be changed.
|
6842 | *
|
6843 | * @param task The task to resolve.
|
6844 | * @param token A cancellation token.
|
6845 | * @return The resolved task
|
6846 | */
|
6847 | resolveTask(task: T, token: CancellationToken): ProviderResult<T>;
|
6848 | }
|
6849 |
|
6850 | /**
|
6851 | * An object representing an executed Task. It can be used
|
6852 | * to terminate a task.
|
6853 | *
|
6854 | * This interface is not intended to be implemented.
|
6855 | */
|
6856 | export interface TaskExecution {
|
6857 | /**
|
6858 | * The task that got started.
|
6859 | */
|
6860 | task: Task;
|
6861 |
|
6862 | /**
|
6863 | * Terminates the task execution.
|
6864 | */
|
6865 | terminate(): void;
|
6866 | }
|
6867 |
|
6868 | /**
|
6869 | * An event signaling the start of a task execution.
|
6870 | *
|
6871 | * This interface is not intended to be implemented.
|
6872 | */
|
6873 | interface TaskStartEvent {
|
6874 | /**
|
6875 | * The task item representing the task that got started.
|
6876 | */
|
6877 | readonly execution: TaskExecution;
|
6878 | }
|
6879 |
|
6880 | /**
|
6881 | * An event signaling the end of an executed task.
|
6882 | *
|
6883 | * This interface is not intended to be implemented.
|
6884 | */
|
6885 | interface TaskEndEvent {
|
6886 | /**
|
6887 | * The task item representing the task that finished.
|
6888 | */
|
6889 | readonly execution: TaskExecution;
|
6890 | }
|
6891 |
|
6892 | /**
|
6893 | * An event signaling the start of a process execution
|
6894 | * triggered through a task
|
6895 | */
|
6896 | export interface TaskProcessStartEvent {
|
6897 |
|
6898 | /**
|
6899 | * The task execution for which the process got started.
|
6900 | */
|
6901 | readonly execution: TaskExecution;
|
6902 |
|
6903 | /**
|
6904 | * The underlying process id.
|
6905 | */
|
6906 | readonly processId: number;
|
6907 | }
|
6908 |
|
6909 | /**
|
6910 | * An event signaling the end of a process execution
|
6911 | * triggered through a task
|
6912 | */
|
6913 | export interface TaskProcessEndEvent {
|
6914 |
|
6915 | /**
|
6916 | * The task execution for which the process got started.
|
6917 | */
|
6918 | readonly execution: TaskExecution;
|
6919 |
|
6920 | /**
|
6921 | * The process's exit code. Will be `undefined` when the task is terminated.
|
6922 | */
|
6923 | readonly exitCode: number | undefined;
|
6924 | }
|
6925 |
|
6926 | export interface TaskFilter {
|
6927 | /**
|
6928 | * The task version as used in the tasks.json file.
|
6929 | * The string support the package.json semver notation.
|
6930 | */
|
6931 | version?: string;
|
6932 |
|
6933 | /**
|
6934 | * The task type to return;
|
6935 | */
|
6936 | type?: string;
|
6937 | }
|
6938 |
|
6939 | /**
|
6940 | * Namespace for tasks functionality.
|
6941 | */
|
6942 | export namespace tasks {
|
6943 |
|
6944 | /**
|
6945 | * Register a task provider.
|
6946 | *
|
6947 | * @param type The task kind type this provider is registered for.
|
6948 | * @param provider A task provider.
|
6949 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
6950 | */
|
6951 | export function registerTaskProvider(type: string, provider: TaskProvider): Disposable;
|
6952 |
|
6953 | /**
|
6954 | * Fetches all tasks available in the systems. This includes tasks
|
6955 | * from `tasks.json` files as well as tasks from task providers
|
6956 | * contributed through extensions.
|
6957 | *
|
6958 | * @param filter Optional filter to select tasks of a certain type or version.
|
6959 | */
|
6960 | export function fetchTasks(filter?: TaskFilter): Thenable<Task[]>;
|
6961 |
|
6962 | /**
|
6963 | * Executes a task that is managed by the editor. The returned
|
6964 | * task execution can be used to terminate the task.
|
6965 | *
|
6966 | * @throws When running a ShellExecution or a ProcessExecution
|
6967 | * task in an environment where a new process cannot be started.
|
6968 | * In such an environment, only CustomExecution tasks can be run.
|
6969 | *
|
6970 | * @param task the task to execute
|
6971 | */
|
6972 | export function executeTask(task: Task): Thenable<TaskExecution>;
|
6973 |
|
6974 | /**
|
6975 | * The currently active task executions or an empty array.
|
6976 | */
|
6977 | export const taskExecutions: readonly TaskExecution[];
|
6978 |
|
6979 | /**
|
6980 | * Fires when a task starts.
|
6981 | */
|
6982 | export const onDidStartTask: Event<TaskStartEvent>;
|
6983 |
|
6984 | /**
|
6985 | * Fires when a task ends.
|
6986 | */
|
6987 | export const onDidEndTask: Event<TaskEndEvent>;
|
6988 |
|
6989 | /**
|
6990 | * Fires when the underlying process has been started.
|
6991 | * This event will not fire for tasks that don't
|
6992 | * execute an underlying process.
|
6993 | */
|
6994 | export const onDidStartTaskProcess: Event<TaskProcessStartEvent>;
|
6995 |
|
6996 | /**
|
6997 | * Fires when the underlying process has ended.
|
6998 | * This event will not fire for tasks that don't
|
6999 | * execute an underlying process.
|
7000 | */
|
7001 | export const onDidEndTaskProcess: Event<TaskProcessEndEvent>;
|
7002 | }
|
7003 |
|
7004 | /**
|
7005 | * Enumeration of file types. The types `File` and `Directory` can also be
|
7006 | * a symbolic links, in that case use `FileType.File | FileType.SymbolicLink` and
|
7007 | * `FileType.Directory | FileType.SymbolicLink`.
|
7008 | */
|
7009 | export enum FileType {
|
7010 | /**
|
7011 | * The file type is unknown.
|
7012 | */
|
7013 | Unknown = 0,
|
7014 | /**
|
7015 | * A regular file.
|
7016 | */
|
7017 | File = 1,
|
7018 | /**
|
7019 | * A directory.
|
7020 | */
|
7021 | Directory = 2,
|
7022 | /**
|
7023 | * A symbolic link to a file.
|
7024 | */
|
7025 | SymbolicLink = 64
|
7026 | }
|
7027 |
|
7028 | /**
|
7029 | * The `FileStat`-type represents metadata about a file
|
7030 | */
|
7031 | export interface FileStat {
|
7032 | /**
|
7033 | * The type of the file, e.g. is a regular file, a directory, or symbolic link
|
7034 | * to a file.
|
7035 | *
|
7036 | * *Note:* This value might be a bitmask, e.g. `FileType.File | FileType.SymbolicLink`.
|
7037 | */
|
7038 | type: FileType;
|
7039 | /**
|
7040 | * The creation timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
|
7041 | */
|
7042 | ctime: number;
|
7043 | /**
|
7044 | * The modification timestamp in milliseconds elapsed since January 1, 1970 00:00:00 UTC.
|
7045 | *
|
7046 | * *Note:* If the file changed, it is important to provide an updated `mtime` that advanced
|
7047 | * from the previous value. Otherwise there may be optimizations in place that will not show
|
7048 | * the updated file contents in an editor for example.
|
7049 | */
|
7050 | mtime: number;
|
7051 | /**
|
7052 | * The size in bytes.
|
7053 | *
|
7054 | * *Note:* If the file changed, it is important to provide an updated `size`. Otherwise there
|
7055 | * may be optimizations in place that will not show the updated file contents in an editor for
|
7056 | * example.
|
7057 | */
|
7058 | size: number;
|
7059 | }
|
7060 |
|
7061 | /**
|
7062 | * A type that filesystem providers should use to signal errors.
|
7063 | *
|
7064 | * This class has factory methods for common error-cases, like `FileNotFound` when
|
7065 | * a file or folder doesn't exist, use them like so: `throw vscode.FileSystemError.FileNotFound(someUri);`
|
7066 | */
|
7067 | export class FileSystemError extends Error {
|
7068 |
|
7069 | /**
|
7070 | * Create an error to signal that a file or folder wasn't found.
|
7071 | * @param messageOrUri Message or uri.
|
7072 | */
|
7073 | static FileNotFound(messageOrUri?: string | Uri): FileSystemError;
|
7074 |
|
7075 | /**
|
7076 | * Create an error to signal that a file or folder already exists, e.g. when
|
7077 | * creating but not overwriting a file.
|
7078 | * @param messageOrUri Message or uri.
|
7079 | */
|
7080 | static FileExists(messageOrUri?: string | Uri): FileSystemError;
|
7081 |
|
7082 | /**
|
7083 | * Create an error to signal that a file is not a folder.
|
7084 | * @param messageOrUri Message or uri.
|
7085 | */
|
7086 | static FileNotADirectory(messageOrUri?: string | Uri): FileSystemError;
|
7087 |
|
7088 | /**
|
7089 | * Create an error to signal that a file is a folder.
|
7090 | * @param messageOrUri Message or uri.
|
7091 | */
|
7092 | static FileIsADirectory(messageOrUri?: string | Uri): FileSystemError;
|
7093 |
|
7094 | /**
|
7095 | * Create an error to signal that an operation lacks required permissions.
|
7096 | * @param messageOrUri Message or uri.
|
7097 | */
|
7098 | static NoPermissions(messageOrUri?: string | Uri): FileSystemError;
|
7099 |
|
7100 | /**
|
7101 | * Create an error to signal that the file system is unavailable or too busy to
|
7102 | * complete a request.
|
7103 | * @param messageOrUri Message or uri.
|
7104 | */
|
7105 | static Unavailable(messageOrUri?: string | Uri): FileSystemError;
|
7106 |
|
7107 | /**
|
7108 | * Creates a new filesystem error.
|
7109 | *
|
7110 | * @param messageOrUri Message or uri.
|
7111 | */
|
7112 | constructor(messageOrUri?: string | Uri);
|
7113 |
|
7114 | /**
|
7115 | * A code that identifies this error.
|
7116 | *
|
7117 | * Possible values are names of errors, like {@link FileSystemError.FileNotFound `FileNotFound`},
|
7118 | * or `Unknown` for unspecified errors.
|
7119 | */
|
7120 | readonly code: string;
|
7121 | }
|
7122 |
|
7123 | /**
|
7124 | * Enumeration of file change types.
|
7125 | */
|
7126 | export enum FileChangeType {
|
7127 |
|
7128 | /**
|
7129 | * The contents or metadata of a file have changed.
|
7130 | */
|
7131 | Changed = 1,
|
7132 |
|
7133 | /**
|
7134 | * A file has been created.
|
7135 | */
|
7136 | Created = 2,
|
7137 |
|
7138 | /**
|
7139 | * A file has been deleted.
|
7140 | */
|
7141 | Deleted = 3,
|
7142 | }
|
7143 |
|
7144 | /**
|
7145 | * The event filesystem providers must use to signal a file change.
|
7146 | */
|
7147 | export interface FileChangeEvent {
|
7148 |
|
7149 | /**
|
7150 | * The type of change.
|
7151 | */
|
7152 | readonly type: FileChangeType;
|
7153 |
|
7154 | /**
|
7155 | * The uri of the file that has changed.
|
7156 | */
|
7157 | readonly uri: Uri;
|
7158 | }
|
7159 |
|
7160 | /**
|
7161 | * The filesystem provider defines what the editor needs to read, write, discover,
|
7162 | * and to manage files and folders. It allows extensions to serve files from remote places,
|
7163 | * like ftp-servers, and to seamlessly integrate those into the editor.
|
7164 | *
|
7165 | * * *Note 1:* The filesystem provider API works with {@link Uri uris} and assumes hierarchical
|
7166 | * paths, e.g. `foo:/my/path` is a child of `foo:/my/` and a parent of `foo:/my/path/deeper`.
|
7167 | * * *Note 2:* There is an activation event `onFileSystem:<scheme>` that fires when a file
|
7168 | * or folder is being accessed.
|
7169 | * * *Note 3:* The word 'file' is often used to denote all {@link FileType kinds} of files, e.g.
|
7170 | * folders, symbolic links, and regular files.
|
7171 | */
|
7172 | export interface FileSystemProvider {
|
7173 |
|
7174 | /**
|
7175 | * An event to signal that a resource has been created, changed, or deleted. This
|
7176 | * event should fire for resources that are being {@link FileSystemProvider.watch watched}
|
7177 | * by clients of this provider.
|
7178 | *
|
7179 | * *Note:* It is important that the metadata of the file that changed provides an
|
7180 | * updated `mtime` that advanced from the previous value in the {@link FileStat stat} and a
|
7181 | * correct `size` value. Otherwise there may be optimizations in place that will not show
|
7182 | * the change in an editor for example.
|
7183 | */
|
7184 | readonly onDidChangeFile: Event<FileChangeEvent[]>;
|
7185 |
|
7186 | /**
|
7187 | * Subscribe to events in the file or folder denoted by `uri`.
|
7188 | *
|
7189 | * The editor will call this function for files and folders. In the latter case, the
|
7190 | * options differ from defaults, e.g. what files/folders to exclude from watching
|
7191 | * and if subfolders, sub-subfolder, etc. should be watched (`recursive`).
|
7192 | *
|
7193 | * @param uri The uri of the file to be watched.
|
7194 | * @param options Configures the watch.
|
7195 | * @returns A disposable that tells the provider to stop watching the `uri`.
|
7196 | */
|
7197 | watch(uri: Uri, options: { recursive: boolean; excludes: string[] }): Disposable;
|
7198 |
|
7199 | /**
|
7200 | * Retrieve metadata about a file.
|
7201 | *
|
7202 | * Note that the metadata for symbolic links should be the metadata of the file they refer to.
|
7203 | * Still, the {@link FileType.SymbolicLink SymbolicLink}-type must be used in addition to the actual type, e.g.
|
7204 | * `FileType.SymbolicLink | FileType.Directory`.
|
7205 | *
|
7206 | * @param uri The uri of the file to retrieve metadata about.
|
7207 | * @return The file metadata about the file.
|
7208 | * @throws {@link FileSystemError.FileNotFound `FileNotFound`} when `uri` doesn't exist.
|
7209 | */
|
7210 | stat(uri: Uri): FileStat | Thenable<FileStat>;
|
7211 |
|
7212 | /**
|
7213 | * Retrieve all entries of a {@link FileType.Directory directory}.
|
7214 | *
|
7215 | * @param uri The uri of the folder.
|
7216 | * @return An array of name/type-tuples or a thenable that resolves to such.
|
7217 | * @throws {@link FileSystemError.FileNotFound `FileNotFound`} when `uri` doesn't exist.
|
7218 | */
|
7219 | readDirectory(uri: Uri): [string, FileType][] | Thenable<[string, FileType][]>;
|
7220 |
|
7221 | /**
|
7222 | * Create a new directory (Note, that new files are created via `write`-calls).
|
7223 | *
|
7224 | * @param uri The uri of the new folder.
|
7225 | * @throws {@link FileSystemError.FileNotFound `FileNotFound`} when the parent of `uri` doesn't exist, e.g. no mkdirp-logic required.
|
7226 | * @throws {@link FileSystemError.FileExists `FileExists`} when `uri` already exists.
|
7227 | * @throws {@link FileSystemError.NoPermissions `NoPermissions`} when permissions aren't sufficient.
|
7228 | */
|
7229 | createDirectory(uri: Uri): void | Thenable<void>;
|
7230 |
|
7231 | /**
|
7232 | * Read the entire contents of a file.
|
7233 | *
|
7234 | * @param uri The uri of the file.
|
7235 | * @return An array of bytes or a thenable that resolves to such.
|
7236 | * @throws {@link FileSystemError.FileNotFound `FileNotFound`} when `uri` doesn't exist.
|
7237 | */
|
7238 | readFile(uri: Uri): Uint8Array | Thenable<Uint8Array>;
|
7239 |
|
7240 | /**
|
7241 | * Write data to a file, replacing its entire contents.
|
7242 | *
|
7243 | * @param uri The uri of the file.
|
7244 | * @param content The new content of the file.
|
7245 | * @param options Defines if missing files should or must be created.
|
7246 | * @throws {@link FileSystemError.FileNotFound `FileNotFound`} when `uri` doesn't exist and `create` is not set.
|
7247 | * @throws {@link FileSystemError.FileNotFound `FileNotFound`} when the parent of `uri` doesn't exist and `create` is set, e.g. no mkdirp-logic required.
|
7248 | * @throws {@link FileSystemError.FileExists `FileExists`} when `uri` already exists, `create` is set but `overwrite` is not set.
|
7249 | * @throws {@link FileSystemError.NoPermissions `NoPermissions`} when permissions aren't sufficient.
|
7250 | */
|
7251 | writeFile(uri: Uri, content: Uint8Array, options: { create: boolean, overwrite: boolean }): void | Thenable<void>;
|
7252 |
|
7253 | /**
|
7254 | * Delete a file.
|
7255 | *
|
7256 | * @param uri The resource that is to be deleted.
|
7257 | * @param options Defines if deletion of folders is recursive.
|
7258 | * @throws {@link FileSystemError.FileNotFound `FileNotFound`} when `uri` doesn't exist.
|
7259 | * @throws {@link FileSystemError.NoPermissions `NoPermissions`} when permissions aren't sufficient.
|
7260 | */
|
7261 | delete(uri: Uri, options: { recursive: boolean }): void | Thenable<void>;
|
7262 |
|
7263 | /**
|
7264 | * Rename a file or folder.
|
7265 | *
|
7266 | * @param oldUri The existing file.
|
7267 | * @param newUri The new location.
|
7268 | * @param options Defines if existing files should be overwritten.
|
7269 | * @throws {@link FileSystemError.FileNotFound `FileNotFound`} when `oldUri` doesn't exist.
|
7270 | * @throws {@link FileSystemError.FileNotFound `FileNotFound`} when parent of `newUri` doesn't exist, e.g. no mkdirp-logic required.
|
7271 | * @throws {@link FileSystemError.FileExists `FileExists`} when `newUri` exists and when the `overwrite` option is not `true`.
|
7272 | * @throws {@link FileSystemError.NoPermissions `NoPermissions`} when permissions aren't sufficient.
|
7273 | */
|
7274 | rename(oldUri: Uri, newUri: Uri, options: { overwrite: boolean }): void | Thenable<void>;
|
7275 |
|
7276 | /**
|
7277 | * Copy files or folders. Implementing this function is optional but it will speedup
|
7278 | * the copy operation.
|
7279 | *
|
7280 | * @param source The existing file.
|
7281 | * @param destination The destination location.
|
7282 | * @param options Defines if existing files should be overwritten.
|
7283 | * @throws {@link FileSystemError.FileNotFound `FileNotFound`} when `source` doesn't exist.
|
7284 | * @throws {@link FileSystemError.FileNotFound `FileNotFound`} when parent of `destination` doesn't exist, e.g. no mkdirp-logic required.
|
7285 | * @throws {@link FileSystemError.FileExists `FileExists`} when `destination` exists and when the `overwrite` option is not `true`.
|
7286 | * @throws {@link FileSystemError.NoPermissions `NoPermissions`} when permissions aren't sufficient.
|
7287 | */
|
7288 | copy?(source: Uri, destination: Uri, options: { overwrite: boolean }): void | Thenable<void>;
|
7289 | }
|
7290 |
|
7291 | /**
|
7292 | * The file system interface exposes the editor's built-in and contributed
|
7293 | * {@link FileSystemProvider file system providers}. It allows extensions to work
|
7294 | * with files from the local disk as well as files from remote places, like the
|
7295 | * remote extension host or ftp-servers.
|
7296 | *
|
7297 | * *Note* that an instance of this interface is available as {@link workspace.fs `workspace.fs`}.
|
7298 | */
|
7299 | export interface FileSystem {
|
7300 |
|
7301 | /**
|
7302 | * Retrieve metadata about a file.
|
7303 | *
|
7304 | * @param uri The uri of the file to retrieve metadata about.
|
7305 | * @return The file metadata about the file.
|
7306 | */
|
7307 | stat(uri: Uri): Thenable<FileStat>;
|
7308 |
|
7309 | /**
|
7310 | * Retrieve all entries of a {@link FileType.Directory directory}.
|
7311 | *
|
7312 | * @param uri The uri of the folder.
|
7313 | * @return An array of name/type-tuples or a thenable that resolves to such.
|
7314 | */
|
7315 | readDirectory(uri: Uri): Thenable<[string, FileType][]>;
|
7316 |
|
7317 | /**
|
7318 | * Create a new directory (Note, that new files are created via `write`-calls).
|
7319 | *
|
7320 | * *Note* that missing directories are created automatically, e.g this call has
|
7321 | * `mkdirp` semantics.
|
7322 | *
|
7323 | * @param uri The uri of the new folder.
|
7324 | */
|
7325 | createDirectory(uri: Uri): Thenable<void>;
|
7326 |
|
7327 | /**
|
7328 | * Read the entire contents of a file.
|
7329 | *
|
7330 | * @param uri The uri of the file.
|
7331 | * @return An array of bytes or a thenable that resolves to such.
|
7332 | */
|
7333 | readFile(uri: Uri): Thenable<Uint8Array>;
|
7334 |
|
7335 | /**
|
7336 | * Write data to a file, replacing its entire contents.
|
7337 | *
|
7338 | * @param uri The uri of the file.
|
7339 | * @param content The new content of the file.
|
7340 | */
|
7341 | writeFile(uri: Uri, content: Uint8Array): Thenable<void>;
|
7342 |
|
7343 | /**
|
7344 | * Delete a file.
|
7345 | *
|
7346 | * @param uri The resource that is to be deleted.
|
7347 | * @param options Defines if trash can should be used and if deletion of folders is recursive
|
7348 | */
|
7349 | delete(uri: Uri, options?: { recursive?: boolean, useTrash?: boolean }): Thenable<void>;
|
7350 |
|
7351 | /**
|
7352 | * Rename a file or folder.
|
7353 | *
|
7354 | * @param oldUri The existing file.
|
7355 | * @param newUri The new location.
|
7356 | * @param options Defines if existing files should be overwritten.
|
7357 | */
|
7358 | rename(source: Uri, target: Uri, options?: { overwrite?: boolean }): Thenable<void>;
|
7359 |
|
7360 | /**
|
7361 | * Copy files or folders.
|
7362 | *
|
7363 | * @param source The existing file.
|
7364 | * @param destination The destination location.
|
7365 | * @param options Defines if existing files should be overwritten.
|
7366 | */
|
7367 | copy(source: Uri, target: Uri, options?: { overwrite?: boolean }): Thenable<void>;
|
7368 |
|
7369 | /**
|
7370 | * Check if a given file system supports writing files.
|
7371 | *
|
7372 | * Keep in mind that just because a file system supports writing, that does
|
7373 | * not mean that writes will always succeed. There may be permissions issues
|
7374 | * or other errors that prevent writing a file.
|
7375 | *
|
7376 | * @param scheme The scheme of the filesystem, for example `file` or `git`.
|
7377 | *
|
7378 | * @return `true` if the file system supports writing, `false` if it does not
|
7379 | * support writing (i.e. it is readonly), and `undefined` if the editor does not
|
7380 | * know about the filesystem.
|
7381 | */
|
7382 | isWritableFileSystem(scheme: string): boolean | undefined;
|
7383 | }
|
7384 |
|
7385 | /**
|
7386 | * Defines a port mapping used for localhost inside the webview.
|
7387 | */
|
7388 | export interface WebviewPortMapping {
|
7389 | /**
|
7390 | * Localhost port to remap inside the webview.
|
7391 | */
|
7392 | readonly webviewPort: number;
|
7393 |
|
7394 | /**
|
7395 | * Destination port. The `webviewPort` is resolved to this port.
|
7396 | */
|
7397 | readonly extensionHostPort: number;
|
7398 | }
|
7399 |
|
7400 | /**
|
7401 | * Content settings for a webview.
|
7402 | */
|
7403 | export interface WebviewOptions {
|
7404 | /**
|
7405 | * Controls whether scripts are enabled in the webview content or not.
|
7406 | *
|
7407 | * Defaults to false (scripts-disabled).
|
7408 | */
|
7409 | readonly enableScripts?: boolean;
|
7410 |
|
7411 | /**
|
7412 | * Controls whether command uris are enabled in webview content or not.
|
7413 | *
|
7414 | * Defaults to false.
|
7415 | */
|
7416 | readonly enableCommandUris?: boolean;
|
7417 |
|
7418 | /**
|
7419 | * Root paths from which the webview can load local (filesystem) resources using uris from `asWebviewUri`
|
7420 | *
|
7421 | * Default to the root folders of the current workspace plus the extension's install directory.
|
7422 | *
|
7423 | * Pass in an empty array to disallow access to any local resources.
|
7424 | */
|
7425 | readonly localResourceRoots?: readonly Uri[];
|
7426 |
|
7427 | /**
|
7428 | * Mappings of localhost ports used inside the webview.
|
7429 | *
|
7430 | * Port mapping allow webviews to transparently define how localhost ports are resolved. This can be used
|
7431 | * to allow using a static localhost port inside the webview that is resolved to random port that a service is
|
7432 | * running on.
|
7433 | *
|
7434 | * If a webview accesses localhost content, we recommend that you specify port mappings even if
|
7435 | * the `webviewPort` and `extensionHostPort` ports are the same.
|
7436 | *
|
7437 | * *Note* that port mappings only work for `http` or `https` urls. Websocket urls (e.g. `ws://localhost:3000`)
|
7438 | * cannot be mapped to another port.
|
7439 | */
|
7440 | readonly portMapping?: readonly WebviewPortMapping[];
|
7441 | }
|
7442 |
|
7443 | /**
|
7444 | * Displays html content, similarly to an iframe.
|
7445 | */
|
7446 | export interface Webview {
|
7447 | /**
|
7448 | * Content settings for the webview.
|
7449 | */
|
7450 | options: WebviewOptions;
|
7451 |
|
7452 | /**
|
7453 | * HTML contents of the webview.
|
7454 | *
|
7455 | * This should be a complete, valid html document. Changing this property causes the webview to be reloaded.
|
7456 | *
|
7457 | * Webviews are sandboxed from normal extension process, so all communication with the webview must use
|
7458 | * message passing. To send a message from the extension to the webview, use {@link Webview.postMessage `postMessage`}.
|
7459 | * To send message from the webview back to an extension, use the `acquireVsCodeApi` function inside the webview
|
7460 | * to get a handle to the editor's api and then call `.postMessage()`:
|
7461 | *
|
7462 | * ```html
|
7463 | * <script>
|
7464 | * const vscode = acquireVsCodeApi(); // acquireVsCodeApi can only be invoked once
|
7465 | * vscode.postMessage({ message: 'hello!' });
|
7466 | * </script>
|
7467 | * ```
|
7468 | *
|
7469 | * To load a resources from the workspace inside a webview, use the {@link Webview.asWebviewUri `asWebviewUri`} method
|
7470 | * and ensure the resource's directory is listed in {@link WebviewOptions.localResourceRoots `WebviewOptions.localResourceRoots`}.
|
7471 | *
|
7472 | * Keep in mind that even though webviews are sandboxed, they still allow running scripts and loading arbitrary content,
|
7473 | * so extensions must follow all standard web security best practices when working with webviews. This includes
|
7474 | * properly sanitizing all untrusted input (including content from the workspace) and
|
7475 | * setting a [content security policy](https://aka.ms/vscode-api-webview-csp).
|
7476 | */
|
7477 | html: string;
|
7478 |
|
7479 | /**
|
7480 | * Fired when the webview content posts a message.
|
7481 | *
|
7482 | * Webview content can post strings or json serializable objects back to an extension. They cannot
|
7483 | * post `Blob`, `File`, `ImageData` and other DOM specific objects since the extension that receives the
|
7484 | * message does not run in a browser environment.
|
7485 | */
|
7486 | readonly onDidReceiveMessage: Event<any>;
|
7487 |
|
7488 | /**
|
7489 | * Post a message to the webview content.
|
7490 | *
|
7491 | * Messages are only delivered if the webview is live (either visible or in the
|
7492 | * background with `retainContextWhenHidden`).
|
7493 | *
|
7494 | * @param message Body of the message. This must be a string or other json serializable object.
|
7495 | *
|
7496 | * For older versions of vscode, if an `ArrayBuffer` is included in `message`,
|
7497 | * it will not be serialized properly and will not be received by the webview.
|
7498 | * Similarly any TypedArrays, such as a `Uint8Array`, will be very inefficiently
|
7499 | * serialized and will also not be recreated as a typed array inside the webview.
|
7500 | *
|
7501 | * However if your extension targets vscode 1.57+ in the `engines` field of its
|
7502 | * `package.json`, any `ArrayBuffer` values that appear in `message` will be more
|
7503 | * efficiently transferred to the webview and will also be correctly recreated inside
|
7504 | * of the webview.
|
7505 | */
|
7506 | postMessage(message: any): Thenable<boolean>;
|
7507 |
|
7508 | /**
|
7509 | * Convert a uri for the local file system to one that can be used inside webviews.
|
7510 | *
|
7511 | * Webviews cannot directly load resources from the workspace or local file system using `file:` uris. The
|
7512 | * `asWebviewUri` function takes a local `file:` uri and converts it into a uri that can be used inside of
|
7513 | * a webview to load the same resource:
|
7514 | *
|
7515 | * ```ts
|
7516 | * webview.html = `<img src="${webview.asWebviewUri(vscode.Uri.file('/Users/codey/workspace/cat.gif'))}">`
|
7517 | * ```
|
7518 | */
|
7519 | asWebviewUri(localResource: Uri): Uri;
|
7520 |
|
7521 | /**
|
7522 | * Content security policy source for webview resources.
|
7523 | *
|
7524 | * This is the origin that should be used in a content security policy rule:
|
7525 | *
|
7526 | * ```
|
7527 | * img-src https: ${webview.cspSource} ...;
|
7528 | * ```
|
7529 | */
|
7530 | readonly cspSource: string;
|
7531 | }
|
7532 |
|
7533 | /**
|
7534 | * Content settings for a webview panel.
|
7535 | */
|
7536 | export interface WebviewPanelOptions {
|
7537 | /**
|
7538 | * Controls if the find widget is enabled in the panel.
|
7539 | *
|
7540 | * Defaults to false.
|
7541 | */
|
7542 | readonly enableFindWidget?: boolean;
|
7543 |
|
7544 | /**
|
7545 | * Controls if the webview panel's content (iframe) is kept around even when the panel
|
7546 | * is no longer visible.
|
7547 | *
|
7548 | * Normally the webview panel's html context is created when the panel becomes visible
|
7549 | * and destroyed when it is hidden. Extensions that have complex state
|
7550 | * or UI can set the `retainContextWhenHidden` to make the editor keep the webview
|
7551 | * context around, even when the webview moves to a background tab. When a webview using
|
7552 | * `retainContextWhenHidden` becomes hidden, its scripts and other dynamic content are suspended.
|
7553 | * When the panel becomes visible again, the context is automatically restored
|
7554 | * in the exact same state it was in originally. You cannot send messages to a
|
7555 | * hidden webview, even with `retainContextWhenHidden` enabled.
|
7556 | *
|
7557 | * `retainContextWhenHidden` has a high memory overhead and should only be used if
|
7558 | * your panel's context cannot be quickly saved and restored.
|
7559 | */
|
7560 | readonly retainContextWhenHidden?: boolean;
|
7561 | }
|
7562 |
|
7563 | /**
|
7564 | * A panel that contains a webview.
|
7565 | */
|
7566 | interface WebviewPanel {
|
7567 | /**
|
7568 | * Identifies the type of the webview panel, such as `'markdown.preview'`.
|
7569 | */
|
7570 | readonly viewType: string;
|
7571 |
|
7572 | /**
|
7573 | * Title of the panel shown in UI.
|
7574 | */
|
7575 | title: string;
|
7576 |
|
7577 | /**
|
7578 | * Icon for the panel shown in UI.
|
7579 | */
|
7580 | iconPath?: Uri | { light: Uri; dark: Uri };
|
7581 |
|
7582 | /**
|
7583 | * {@link Webview `Webview`} belonging to the panel.
|
7584 | */
|
7585 | readonly webview: Webview;
|
7586 |
|
7587 | /**
|
7588 | * Content settings for the webview panel.
|
7589 | */
|
7590 | readonly options: WebviewPanelOptions;
|
7591 |
|
7592 | /**
|
7593 | * Editor position of the panel. This property is only set if the webview is in
|
7594 | * one of the editor view columns.
|
7595 | */
|
7596 | readonly viewColumn?: ViewColumn;
|
7597 |
|
7598 | /**
|
7599 | * Whether the panel is active (focused by the user).
|
7600 | */
|
7601 | readonly active: boolean;
|
7602 |
|
7603 | /**
|
7604 | * Whether the panel is visible.
|
7605 | */
|
7606 | readonly visible: boolean;
|
7607 |
|
7608 | /**
|
7609 | * Fired when the panel's view state changes.
|
7610 | */
|
7611 | readonly onDidChangeViewState: Event<WebviewPanelOnDidChangeViewStateEvent>;
|
7612 |
|
7613 | /**
|
7614 | * Fired when the panel is disposed.
|
7615 | *
|
7616 | * This may be because the user closed the panel or because `.dispose()` was
|
7617 | * called on it.
|
7618 | *
|
7619 | * Trying to use the panel after it has been disposed throws an exception.
|
7620 | */
|
7621 | readonly onDidDispose: Event<void>;
|
7622 |
|
7623 | /**
|
7624 | * Show the webview panel in a given column.
|
7625 | *
|
7626 | * A webview panel may only show in a single column at a time. If it is already showing, this
|
7627 | * method moves it to a new column.
|
7628 | *
|
7629 | * @param viewColumn View column to show the panel in. Shows in the current `viewColumn` if undefined.
|
7630 | * @param preserveFocus When `true`, the webview will not take focus.
|
7631 | */
|
7632 | reveal(viewColumn?: ViewColumn, preserveFocus?: boolean): void;
|
7633 |
|
7634 | /**
|
7635 | * Dispose of the webview panel.
|
7636 | *
|
7637 | * This closes the panel if it showing and disposes of the resources owned by the webview.
|
7638 | * Webview panels are also disposed when the user closes the webview panel. Both cases
|
7639 | * fire the `onDispose` event.
|
7640 | */
|
7641 | dispose(): any;
|
7642 | }
|
7643 |
|
7644 | /**
|
7645 | * Event fired when a webview panel's view state changes.
|
7646 | */
|
7647 | export interface WebviewPanelOnDidChangeViewStateEvent {
|
7648 | /**
|
7649 | * Webview panel whose view state changed.
|
7650 | */
|
7651 | readonly webviewPanel: WebviewPanel;
|
7652 | }
|
7653 |
|
7654 | /**
|
7655 | * Restore webview panels that have been persisted when vscode shuts down.
|
7656 | *
|
7657 | * There are two types of webview persistence:
|
7658 | *
|
7659 | * - Persistence within a session.
|
7660 | * - Persistence across sessions (across restarts of the editor).
|
7661 | *
|
7662 | * A `WebviewPanelSerializer` is only required for the second case: persisting a webview across sessions.
|
7663 | *
|
7664 | * Persistence within a session allows a webview to save its state when it becomes hidden
|
7665 | * and restore its content from this state when it becomes visible again. It is powered entirely
|
7666 | * by the webview content itself. To save off a persisted state, call `acquireVsCodeApi().setState()` with
|
7667 | * any json serializable object. To restore the state again, call `getState()`
|
7668 | *
|
7669 | * ```js
|
7670 | * // Within the webview
|
7671 | * const vscode = acquireVsCodeApi();
|
7672 | *
|
7673 | * // Get existing state
|
7674 | * const oldState = vscode.getState() || { value: 0 };
|
7675 | *
|
7676 | * // Update state
|
7677 | * setState({ value: oldState.value + 1 })
|
7678 | * ```
|
7679 | *
|
7680 | * A `WebviewPanelSerializer` extends this persistence across restarts of the editor. When the editor is shutdown,
|
7681 | * it will save off the state from `setState` of all webviews that have a serializer. When the
|
7682 | * webview first becomes visible after the restart, this state is passed to `deserializeWebviewPanel`.
|
7683 | * The extension can then restore the old `WebviewPanel` from this state.
|
7684 | *
|
7685 | * @param T Type of the webview's state.
|
7686 | */
|
7687 | interface WebviewPanelSerializer<T = unknown> {
|
7688 | /**
|
7689 | * Restore a webview panel from its serialized `state`.
|
7690 | *
|
7691 | * Called when a serialized webview first becomes visible.
|
7692 | *
|
7693 | * @param webviewPanel Webview panel to restore. The serializer should take ownership of this panel. The
|
7694 | * serializer must restore the webview's `.html` and hook up all webview events.
|
7695 | * @param state Persisted state from the webview content.
|
7696 | *
|
7697 | * @return Thenable indicating that the webview has been fully restored.
|
7698 | */
|
7699 | deserializeWebviewPanel(webviewPanel: WebviewPanel, state: T): Thenable<void>;
|
7700 | }
|
7701 |
|
7702 | /**
|
7703 | * A webview based view.
|
7704 | */
|
7705 | export interface WebviewView {
|
7706 | /**
|
7707 | * Identifies the type of the webview view, such as `'hexEditor.dataView'`.
|
7708 | */
|
7709 | readonly viewType: string;
|
7710 |
|
7711 | /**
|
7712 | * The underlying webview for the view.
|
7713 | */
|
7714 | readonly webview: Webview;
|
7715 |
|
7716 | /**
|
7717 | * View title displayed in the UI.
|
7718 | *
|
7719 | * The view title is initially taken from the extension `package.json` contribution.
|
7720 | */
|
7721 | title?: string;
|
7722 |
|
7723 | /**
|
7724 | * Human-readable string which is rendered less prominently in the title.
|
7725 | */
|
7726 | description?: string;
|
7727 |
|
7728 | /**
|
7729 | * Event fired when the view is disposed.
|
7730 | *
|
7731 | * Views are disposed when they are explicitly hidden by a user (this happens when a user
|
7732 | * right clicks in a view and unchecks the webview view).
|
7733 | *
|
7734 | * Trying to use the view after it has been disposed throws an exception.
|
7735 | */
|
7736 | readonly onDidDispose: Event<void>;
|
7737 |
|
7738 | /**
|
7739 | * Tracks if the webview is currently visible.
|
7740 | *
|
7741 | * Views are visible when they are on the screen and expanded.
|
7742 | */
|
7743 | readonly visible: boolean;
|
7744 |
|
7745 | /**
|
7746 | * Event fired when the visibility of the view changes.
|
7747 | *
|
7748 | * Actions that trigger a visibility change:
|
7749 | *
|
7750 | * - The view is collapsed or expanded.
|
7751 | * - The user switches to a different view group in the sidebar or panel.
|
7752 | *
|
7753 | * Note that hiding a view using the context menu instead disposes of the view and fires `onDidDispose`.
|
7754 | */
|
7755 | readonly onDidChangeVisibility: Event<void>;
|
7756 |
|
7757 | /**
|
7758 | * Reveal the view in the UI.
|
7759 | *
|
7760 | * If the view is collapsed, this will expand it.
|
7761 | *
|
7762 | * @param preserveFocus When `true` the view will not take focus.
|
7763 | */
|
7764 | show(preserveFocus?: boolean): void;
|
7765 | }
|
7766 |
|
7767 | /**
|
7768 | * Additional information the webview view being resolved.
|
7769 | *
|
7770 | * @param T Type of the webview's state.
|
7771 | */
|
7772 | interface WebviewViewResolveContext<T = unknown> {
|
7773 | /**
|
7774 | * Persisted state from the webview content.
|
7775 | *
|
7776 | * To save resources, the editor normally deallocates webview documents (the iframe content) that are not visible.
|
7777 | * For example, when the user collapse a view or switches to another top level activity in the sidebar, the
|
7778 | * `WebviewView` itself is kept alive but the webview's underlying document is deallocated. It is recreated when
|
7779 | * the view becomes visible again.
|
7780 | *
|
7781 | * You can prevent this behavior by setting `retainContextWhenHidden` in the `WebviewOptions`. However this
|
7782 | * increases resource usage and should be avoided wherever possible. Instead, you can use persisted state to
|
7783 | * save off a webview's state so that it can be quickly recreated as needed.
|
7784 | *
|
7785 | * To save off a persisted state, inside the webview call `acquireVsCodeApi().setState()` with
|
7786 | * any json serializable object. To restore the state again, call `getState()`. For example:
|
7787 | *
|
7788 | * ```js
|
7789 | * // Within the webview
|
7790 | * const vscode = acquireVsCodeApi();
|
7791 | *
|
7792 | * // Get existing state
|
7793 | * const oldState = vscode.getState() || { value: 0 };
|
7794 | *
|
7795 | * // Update state
|
7796 | * setState({ value: oldState.value + 1 })
|
7797 | * ```
|
7798 | *
|
7799 | * The editor ensures that the persisted state is saved correctly when a webview is hidden and across
|
7800 | * editor restarts.
|
7801 | */
|
7802 | readonly state: T | undefined;
|
7803 | }
|
7804 |
|
7805 | /**
|
7806 | * Provider for creating `WebviewView` elements.
|
7807 | */
|
7808 | export interface WebviewViewProvider {
|
7809 | /**
|
7810 | * Revolves a webview view.
|
7811 | *
|
7812 | * `resolveWebviewView` is called when a view first becomes visible. This may happen when the view is
|
7813 | * first loaded or when the user hides and then shows a view again.
|
7814 | *
|
7815 | * @param webviewView Webview view to restore. The provider should take ownership of this view. The
|
7816 | * provider must set the webview's `.html` and hook up all webview events it is interested in.
|
7817 | * @param context Additional metadata about the view being resolved.
|
7818 | * @param token Cancellation token indicating that the view being provided is no longer needed.
|
7819 | *
|
7820 | * @return Optional thenable indicating that the view has been fully resolved.
|
7821 | */
|
7822 | resolveWebviewView(webviewView: WebviewView, context: WebviewViewResolveContext, token: CancellationToken): Thenable<void> | void;
|
7823 | }
|
7824 |
|
7825 | /**
|
7826 | * Provider for text based custom editors.
|
7827 | *
|
7828 | * Text based custom editors use a {@link TextDocument `TextDocument`} as their data model. This considerably simplifies
|
7829 | * implementing a custom editor as it allows the editor to handle many common operations such as
|
7830 | * undo and backup. The provider is responsible for synchronizing text changes between the webview and the `TextDocument`.
|
7831 | */
|
7832 | export interface CustomTextEditorProvider {
|
7833 |
|
7834 | /**
|
7835 | * Resolve a custom editor for a given text resource.
|
7836 | *
|
7837 | * This is called when a user first opens a resource for a `CustomTextEditorProvider`, or if they reopen an
|
7838 | * existing editor using this `CustomTextEditorProvider`.
|
7839 | *
|
7840 | *
|
7841 | * @param document Document for the resource to resolve.
|
7842 | *
|
7843 | * @param webviewPanel The webview panel used to display the editor UI for this resource.
|
7844 | *
|
7845 | * During resolve, the provider must fill in the initial html for the content webview panel and hook up all
|
7846 | * the event listeners on it that it is interested in. The provider can also hold onto the `WebviewPanel` to
|
7847 | * use later for example in a command. See {@link WebviewPanel `WebviewPanel`} for additional details.
|
7848 | *
|
7849 | * @param token A cancellation token that indicates the result is no longer needed.
|
7850 | *
|
7851 | * @return Thenable indicating that the custom editor has been resolved.
|
7852 | */
|
7853 | resolveCustomTextEditor(document: TextDocument, webviewPanel: WebviewPanel, token: CancellationToken): Thenable<void> | void;
|
7854 | }
|
7855 |
|
7856 | /**
|
7857 | * Represents a custom document used by a {@link CustomEditorProvider `CustomEditorProvider`}.
|
7858 | *
|
7859 | * Custom documents are only used within a given `CustomEditorProvider`. The lifecycle of a `CustomDocument` is
|
7860 | * managed by the editor. When no more references remain to a `CustomDocument`, it is disposed of.
|
7861 | */
|
7862 | interface CustomDocument {
|
7863 | /**
|
7864 | * The associated uri for this document.
|
7865 | */
|
7866 | readonly uri: Uri;
|
7867 |
|
7868 | /**
|
7869 | * Dispose of the custom document.
|
7870 | *
|
7871 | * This is invoked by the editor when there are no more references to a given `CustomDocument` (for example when
|
7872 | * all editors associated with the document have been closed.)
|
7873 | */
|
7874 | dispose(): void;
|
7875 | }
|
7876 |
|
7877 | /**
|
7878 | * Event triggered by extensions to signal to the editor that an edit has occurred on an {@link CustomDocument `CustomDocument`}.
|
7879 | *
|
7880 | * @see {@link CustomEditorProvider.onDidChangeCustomDocument `CustomEditorProvider.onDidChangeCustomDocument`}.
|
7881 | */
|
7882 | interface CustomDocumentEditEvent<T extends CustomDocument = CustomDocument> {
|
7883 |
|
7884 | /**
|
7885 | * The document that the edit is for.
|
7886 | */
|
7887 | readonly document: T;
|
7888 |
|
7889 | /**
|
7890 | * Undo the edit operation.
|
7891 | *
|
7892 | * This is invoked by the editor when the user undoes this edit. To implement `undo`, your
|
7893 | * extension should restore the document and editor to the state they were in just before this
|
7894 | * edit was added to the editor's internal edit stack by `onDidChangeCustomDocument`.
|
7895 | */
|
7896 | undo(): Thenable<void> | void;
|
7897 |
|
7898 | /**
|
7899 | * Redo the edit operation.
|
7900 | *
|
7901 | * This is invoked by the editor when the user redoes this edit. To implement `redo`, your
|
7902 | * extension should restore the document and editor to the state they were in just after this
|
7903 | * edit was added to the editor's internal edit stack by `onDidChangeCustomDocument`.
|
7904 | */
|
7905 | redo(): Thenable<void> | void;
|
7906 |
|
7907 | /**
|
7908 | * Display name describing the edit.
|
7909 | *
|
7910 | * This will be shown to users in the UI for undo/redo operations.
|
7911 | */
|
7912 | readonly label?: string;
|
7913 | }
|
7914 |
|
7915 | /**
|
7916 | * Event triggered by extensions to signal to the editor that the content of a {@link CustomDocument `CustomDocument`}
|
7917 | * has changed.
|
7918 | *
|
7919 | * @see {@link CustomEditorProvider.onDidChangeCustomDocument `CustomEditorProvider.onDidChangeCustomDocument`}.
|
7920 | */
|
7921 | interface CustomDocumentContentChangeEvent<T extends CustomDocument = CustomDocument> {
|
7922 | /**
|
7923 | * The document that the change is for.
|
7924 | */
|
7925 | readonly document: T;
|
7926 | }
|
7927 |
|
7928 | /**
|
7929 | * A backup for an {@link CustomDocument `CustomDocument`}.
|
7930 | */
|
7931 | interface CustomDocumentBackup {
|
7932 | /**
|
7933 | * Unique identifier for the backup.
|
7934 | *
|
7935 | * This id is passed back to your extension in `openCustomDocument` when opening a custom editor from a backup.
|
7936 | */
|
7937 | readonly id: string;
|
7938 |
|
7939 | /**
|
7940 | * Delete the current backup.
|
7941 | *
|
7942 | * This is called by the editor when it is clear the current backup is no longer needed, such as when a new backup
|
7943 | * is made or when the file is saved.
|
7944 | */
|
7945 | delete(): void;
|
7946 | }
|
7947 |
|
7948 | /**
|
7949 | * Additional information used to implement {@link CustomEditableDocument.backup `CustomEditableDocument.backup`}.
|
7950 | */
|
7951 | interface CustomDocumentBackupContext {
|
7952 | /**
|
7953 | * Suggested file location to write the new backup.
|
7954 | *
|
7955 | * Note that your extension is free to ignore this and use its own strategy for backup.
|
7956 | *
|
7957 | * If the editor is for a resource from the current workspace, `destination` will point to a file inside
|
7958 | * `ExtensionContext.storagePath`. The parent folder of `destination` may not exist, so make sure to created it
|
7959 | * before writing the backup to this location.
|
7960 | */
|
7961 | readonly destination: Uri;
|
7962 | }
|
7963 |
|
7964 | /**
|
7965 | * Additional information about the opening custom document.
|
7966 | */
|
7967 | interface CustomDocumentOpenContext {
|
7968 | /**
|
7969 | * The id of the backup to restore the document from or `undefined` if there is no backup.
|
7970 | *
|
7971 | * If this is provided, your extension should restore the editor from the backup instead of reading the file
|
7972 | * from the user's workspace.
|
7973 | */
|
7974 | readonly backupId?: string;
|
7975 |
|
7976 | /**
|
7977 | * If the URI is an untitled file, this will be populated with the byte data of that file
|
7978 | *
|
7979 | * If this is provided, your extension should utilize this byte data rather than executing fs APIs on the URI passed in
|
7980 | */
|
7981 | readonly untitledDocumentData?: Uint8Array;
|
7982 | }
|
7983 |
|
7984 | /**
|
7985 | * Provider for readonly custom editors that use a custom document model.
|
7986 | *
|
7987 | * Custom editors use {@link CustomDocument `CustomDocument`} as their document model instead of a {@link TextDocument `TextDocument`}.
|
7988 | *
|
7989 | * You should use this type of custom editor when dealing with binary files or more complex scenarios. For simple
|
7990 | * text based documents, use {@link CustomTextEditorProvider `CustomTextEditorProvider`} instead.
|
7991 | *
|
7992 | * @param T Type of the custom document returned by this provider.
|
7993 | */
|
7994 | export interface CustomReadonlyEditorProvider<T extends CustomDocument = CustomDocument> {
|
7995 |
|
7996 | /**
|
7997 | * Create a new document for a given resource.
|
7998 | *
|
7999 | * `openCustomDocument` is called when the first time an editor for a given resource is opened. The opened
|
8000 | * document is then passed to `resolveCustomEditor` so that the editor can be shown to the user.
|
8001 | *
|
8002 | * Already opened `CustomDocument` are re-used if the user opened additional editors. When all editors for a
|
8003 | * given resource are closed, the `CustomDocument` is disposed of. Opening an editor at this point will
|
8004 | * trigger another call to `openCustomDocument`.
|
8005 | *
|
8006 | * @param uri Uri of the document to open.
|
8007 | * @param openContext Additional information about the opening custom document.
|
8008 | * @param token A cancellation token that indicates the result is no longer needed.
|
8009 | *
|
8010 | * @return The custom document.
|
8011 | */
|
8012 | openCustomDocument(uri: Uri, openContext: CustomDocumentOpenContext, token: CancellationToken): Thenable<T> | T;
|
8013 |
|
8014 | /**
|
8015 | * Resolve a custom editor for a given resource.
|
8016 | *
|
8017 | * This is called whenever the user opens a new editor for this `CustomEditorProvider`.
|
8018 | *
|
8019 | * @param document Document for the resource being resolved.
|
8020 | *
|
8021 | * @param webviewPanel The webview panel used to display the editor UI for this resource.
|
8022 | *
|
8023 | * During resolve, the provider must fill in the initial html for the content webview panel and hook up all
|
8024 | * the event listeners on it that it is interested in. The provider can also hold onto the `WebviewPanel` to
|
8025 | * use later for example in a command. See {@link WebviewPanel `WebviewPanel`} for additional details.
|
8026 | *
|
8027 | * @param token A cancellation token that indicates the result is no longer needed.
|
8028 | *
|
8029 | * @return Optional thenable indicating that the custom editor has been resolved.
|
8030 | */
|
8031 | resolveCustomEditor(document: T, webviewPanel: WebviewPanel, token: CancellationToken): Thenable<void> | void;
|
8032 | }
|
8033 |
|
8034 | /**
|
8035 | * Provider for editable custom editors that use a custom document model.
|
8036 | *
|
8037 | * Custom editors use {@link CustomDocument `CustomDocument`} as their document model instead of a {@link TextDocument `TextDocument`}.
|
8038 | * This gives extensions full control over actions such as edit, save, and backup.
|
8039 | *
|
8040 | * You should use this type of custom editor when dealing with binary files or more complex scenarios. For simple
|
8041 | * text based documents, use {@link CustomTextEditorProvider `CustomTextEditorProvider`} instead.
|
8042 | *
|
8043 | * @param T Type of the custom document returned by this provider.
|
8044 | */
|
8045 | export interface CustomEditorProvider<T extends CustomDocument = CustomDocument> extends CustomReadonlyEditorProvider<T> {
|
8046 | /**
|
8047 | * Signal that an edit has occurred inside a custom editor.
|
8048 | *
|
8049 | * This event must be fired by your extension whenever an edit happens in a custom editor. An edit can be
|
8050 | * anything from changing some text, to cropping an image, to reordering a list. Your extension is free to
|
8051 | * define what an edit is and what data is stored on each edit.
|
8052 | *
|
8053 | * Firing `onDidChange` causes the editors to be marked as being dirty. This is cleared when the user either
|
8054 | * saves or reverts the file.
|
8055 | *
|
8056 | * Editors that support undo/redo must fire a `CustomDocumentEditEvent` whenever an edit happens. This allows
|
8057 | * users to undo and redo the edit using the editor's standard keyboard shortcuts. The editor will also mark
|
8058 | * the editor as no longer being dirty if the user undoes all edits to the last saved state.
|
8059 | *
|
8060 | * Editors that support editing but cannot use the editor's standard undo/redo mechanism must fire a `CustomDocumentContentChangeEvent`.
|
8061 | * The only way for a user to clear the dirty state of an editor that does not support undo/redo is to either
|
8062 | * `save` or `revert` the file.
|
8063 | *
|
8064 | * An editor should only ever fire `CustomDocumentEditEvent` events, or only ever fire `CustomDocumentContentChangeEvent` events.
|
8065 | */
|
8066 | readonly onDidChangeCustomDocument: Event<CustomDocumentEditEvent<T>> | Event<CustomDocumentContentChangeEvent<T>>;
|
8067 |
|
8068 | /**
|
8069 | * Save a custom document.
|
8070 | *
|
8071 | * This method is invoked by the editor when the user saves a custom editor. This can happen when the user
|
8072 | * triggers save while the custom editor is active, by commands such as `save all`, or by auto save if enabled.
|
8073 | *
|
8074 | * To implement `save`, the implementer must persist the custom editor. This usually means writing the
|
8075 | * file data for the custom document to disk. After `save` completes, any associated editor instances will
|
8076 | * no longer be marked as dirty.
|
8077 | *
|
8078 | * @param document Document to save.
|
8079 | * @param cancellation Token that signals the save is no longer required (for example, if another save was triggered).
|
8080 | *
|
8081 | * @return Thenable signaling that saving has completed.
|
8082 | */
|
8083 | saveCustomDocument(document: T, cancellation: CancellationToken): Thenable<void>;
|
8084 |
|
8085 | /**
|
8086 | * Save a custom document to a different location.
|
8087 | *
|
8088 | * This method is invoked by the editor when the user triggers 'save as' on a custom editor. The implementer must
|
8089 | * persist the custom editor to `destination`.
|
8090 | *
|
8091 | * When the user accepts save as, the current editor is be replaced by an non-dirty editor for the newly saved file.
|
8092 | *
|
8093 | * @param document Document to save.
|
8094 | * @param destination Location to save to.
|
8095 | * @param cancellation Token that signals the save is no longer required.
|
8096 | *
|
8097 | * @return Thenable signaling that saving has completed.
|
8098 | */
|
8099 | saveCustomDocumentAs(document: T, destination: Uri, cancellation: CancellationToken): Thenable<void>;
|
8100 |
|
8101 | /**
|
8102 | * Revert a custom document to its last saved state.
|
8103 | *
|
8104 | * This method is invoked by the editor when the user triggers `File: Revert File` in a custom editor. (Note that
|
8105 | * this is only used using the editor's `File: Revert File` command and not on a `git revert` of the file).
|
8106 | *
|
8107 | * To implement `revert`, the implementer must make sure all editor instances (webviews) for `document`
|
8108 | * are displaying the document in the same state is saved in. This usually means reloading the file from the
|
8109 | * workspace.
|
8110 | *
|
8111 | * @param document Document to revert.
|
8112 | * @param cancellation Token that signals the revert is no longer required.
|
8113 | *
|
8114 | * @return Thenable signaling that the change has completed.
|
8115 | */
|
8116 | revertCustomDocument(document: T, cancellation: CancellationToken): Thenable<void>;
|
8117 |
|
8118 | /**
|
8119 | * Back up a dirty custom document.
|
8120 | *
|
8121 | * Backups are used for hot exit and to prevent data loss. Your `backup` method should persist the resource in
|
8122 | * its current state, i.e. with the edits applied. Most commonly this means saving the resource to disk in
|
8123 | * the `ExtensionContext.storagePath`. When the editor reloads and your custom editor is opened for a resource,
|
8124 | * your extension should first check to see if any backups exist for the resource. If there is a backup, your
|
8125 | * extension should load the file contents from there instead of from the resource in the workspace.
|
8126 | *
|
8127 | * `backup` is triggered approximately one second after the user stops editing the document. If the user
|
8128 | * rapidly edits the document, `backup` will not be invoked until the editing stops.
|
8129 | *
|
8130 | * `backup` is not invoked when `auto save` is enabled (since auto save already persists the resource).
|
8131 | *
|
8132 | * @param document Document to backup.
|
8133 | * @param context Information that can be used to backup the document.
|
8134 | * @param cancellation Token that signals the current backup since a new backup is coming in. It is up to your
|
8135 | * extension to decided how to respond to cancellation. If for example your extension is backing up a large file
|
8136 | * in an operation that takes time to complete, your extension may decide to finish the ongoing backup rather
|
8137 | * than cancelling it to ensure that the editor has some valid backup.
|
8138 | */
|
8139 | backupCustomDocument(document: T, context: CustomDocumentBackupContext, cancellation: CancellationToken): Thenable<CustomDocumentBackup>;
|
8140 | }
|
8141 |
|
8142 | /**
|
8143 | * The clipboard provides read and write access to the system's clipboard.
|
8144 | */
|
8145 | export interface Clipboard {
|
8146 |
|
8147 | /**
|
8148 | * Read the current clipboard contents as text.
|
8149 | * @returns A thenable that resolves to a string.
|
8150 | */
|
8151 | readText(): Thenable<string>;
|
8152 |
|
8153 | /**
|
8154 | * Writes text into the clipboard.
|
8155 | * @returns A thenable that resolves when writing happened.
|
8156 | */
|
8157 | writeText(value: string): Thenable<void>;
|
8158 | }
|
8159 |
|
8160 | /**
|
8161 | * Possible kinds of UI that can use extensions.
|
8162 | */
|
8163 | export enum UIKind {
|
8164 |
|
8165 | /**
|
8166 | * Extensions are accessed from a desktop application.
|
8167 | */
|
8168 | Desktop = 1,
|
8169 |
|
8170 | /**
|
8171 | * Extensions are accessed from a web browser.
|
8172 | */
|
8173 | Web = 2
|
8174 | }
|
8175 |
|
8176 | /**
|
8177 | * Namespace describing the environment the editor runs in.
|
8178 | */
|
8179 | export namespace env {
|
8180 |
|
8181 | /**
|
8182 | * The application name of the editor, like 'VS Code'.
|
8183 | */
|
8184 | export const appName: string;
|
8185 |
|
8186 | /**
|
8187 | * The application root folder from which the editor is running.
|
8188 | *
|
8189 | * *Note* that the value is the empty string when running in an
|
8190 | * environment that has no representation of an application root folder.
|
8191 | */
|
8192 | export const appRoot: string;
|
8193 |
|
8194 | /**
|
8195 | * The custom uri scheme the editor registers to in the operating system.
|
8196 | */
|
8197 | export const uriScheme: string;
|
8198 |
|
8199 | /**
|
8200 | * Represents the preferred user-language, like `de-CH`, `fr`, or `en-US`.
|
8201 | */
|
8202 | export const language: string;
|
8203 |
|
8204 | /**
|
8205 | * The system clipboard.
|
8206 | */
|
8207 | export const clipboard: Clipboard;
|
8208 |
|
8209 | /**
|
8210 | * A unique identifier for the computer.
|
8211 | */
|
8212 | export const machineId: string;
|
8213 |
|
8214 | /**
|
8215 | * A unique identifier for the current session.
|
8216 | * Changes each time the editor is started.
|
8217 | */
|
8218 | export const sessionId: string;
|
8219 |
|
8220 | /**
|
8221 | * Indicates that this is a fresh install of the application.
|
8222 | * `true` if within the first day of installation otherwise `false`.
|
8223 | */
|
8224 | export const isNewAppInstall: boolean;
|
8225 |
|
8226 | /**
|
8227 | * Indicates whether the users has telemetry enabled.
|
8228 | * Can be observed to determine if the extension should send telemetry.
|
8229 | */
|
8230 | export const isTelemetryEnabled: boolean;
|
8231 |
|
8232 | /**
|
8233 | * An {@link Event} which fires when the user enabled or disables telemetry.
|
8234 | * `true` if the user has enabled telemetry or `false` if the user has disabled telemetry.
|
8235 | */
|
8236 | export const onDidChangeTelemetryEnabled: Event<boolean>;
|
8237 |
|
8238 | /**
|
8239 | * The name of a remote. Defined by extensions, popular samples are `wsl` for the Windows
|
8240 | * Subsystem for Linux or `ssh-remote` for remotes using a secure shell.
|
8241 | *
|
8242 | * *Note* that the value is `undefined` when there is no remote extension host but that the
|
8243 | * value is defined in all extension hosts (local and remote) in case a remote extension host
|
8244 | * exists. Use {@link Extension.extensionKind} to know if
|
8245 | * a specific extension runs remote or not.
|
8246 | */
|
8247 | export const remoteName: string | undefined;
|
8248 |
|
8249 | /**
|
8250 | * The detected default shell for the extension host, this is overridden by the
|
8251 | * `terminal.integrated.shell` setting for the extension host's platform. Note that in
|
8252 | * environments that do not support a shell the value is the empty string.
|
8253 | */
|
8254 | export const shell: string;
|
8255 |
|
8256 | /**
|
8257 | * The UI kind property indicates from which UI extensions
|
8258 | * are accessed from. For example, extensions could be accessed
|
8259 | * from a desktop application or a web browser.
|
8260 | */
|
8261 | export const uiKind: UIKind;
|
8262 |
|
8263 | /**
|
8264 | * Opens a link externally using the default application. Depending on the
|
8265 | * used scheme this can be:
|
8266 | * * a browser (`http:`, `https:`)
|
8267 | * * a mail client (`mailto:`)
|
8268 | * * VSCode itself (`vscode:` from `vscode.env.uriScheme`)
|
8269 | *
|
8270 | * *Note* that {@link window.showTextDocument `showTextDocument`} is the right
|
8271 | * way to open a text document inside the editor, not this function.
|
8272 | *
|
8273 | * @param target The uri that should be opened.
|
8274 | * @returns A promise indicating if open was successful.
|
8275 | */
|
8276 | export function openExternal(target: Uri): Thenable<boolean>;
|
8277 |
|
8278 | /**
|
8279 | * Resolves a uri to a form that is accessible externally.
|
8280 | *
|
8281 | * #### `http:` or `https:` scheme
|
8282 | *
|
8283 | * Resolves an *external* uri, such as a `http:` or `https:` link, from where the extension is running to a
|
8284 | * uri to the same resource on the client machine.
|
8285 | *
|
8286 | * This is a no-op if the extension is running on the client machine.
|
8287 | *
|
8288 | * If the extension is running remotely, this function automatically establishes a port forwarding tunnel
|
8289 | * from the local machine to `target` on the remote and returns a local uri to the tunnel. The lifetime of
|
8290 | * the port forwarding tunnel is managed by the editor and the tunnel can be closed by the user.
|
8291 | *
|
8292 | * *Note* that uris passed through `openExternal` are automatically resolved and you should not call `asExternalUri` on them.
|
8293 | *
|
8294 | * #### `vscode.env.uriScheme`
|
8295 | *
|
8296 | * Creates a uri that - if opened in a browser (e.g. via `openExternal`) - will result in a registered {@link UriHandler}
|
8297 | * to trigger.
|
8298 | *
|
8299 | * Extensions should not make any assumptions about the resulting uri and should not alter it in any way.
|
8300 | * Rather, extensions can e.g. use this uri in an authentication flow, by adding the uri as callback query
|
8301 | * argument to the server to authenticate to.
|
8302 | *
|
8303 | * *Note* that if the server decides to add additional query parameters to the uri (e.g. a token or secret), it
|
8304 | * will appear in the uri that is passed to the {@link UriHandler}.
|
8305 | *
|
8306 | * **Example** of an authentication flow:
|
8307 | * ```typescript
|
8308 | * vscode.window.registerUriHandler({
|
8309 | * handleUri(uri: vscode.Uri): vscode.ProviderResult<void> {
|
8310 | * if (uri.path === '/did-authenticate') {
|
8311 | * console.log(uri.toString());
|
8312 | * }
|
8313 | * }
|
8314 | * });
|
8315 | *
|
8316 | * const callableUri = await vscode.env.asExternalUri(vscode.Uri.parse(`${vscode.env.uriScheme}://my.extension/did-authenticate`));
|
8317 | * await vscode.env.openExternal(callableUri);
|
8318 | * ```
|
8319 | *
|
8320 | * *Note* that extensions should not cache the result of `asExternalUri` as the resolved uri may become invalid due to
|
8321 | * a system or user action — for example, in remote cases, a user may close a port forwarding tunnel that was opened by
|
8322 | * `asExternalUri`.
|
8323 | *
|
8324 | * #### Any other scheme
|
8325 | *
|
8326 | * Any other scheme will be handled as if the provided URI is a workspace URI. In that case, the method will return
|
8327 | * a URI which, when handled, will make the editor open the workspace.
|
8328 | *
|
8329 | * @return A uri that can be used on the client machine.
|
8330 | */
|
8331 | export function asExternalUri(target: Uri): Thenable<Uri>;
|
8332 | }
|
8333 |
|
8334 | /**
|
8335 | * Namespace for dealing with commands. In short, a command is a function with a
|
8336 | * unique identifier. The function is sometimes also called _command handler_.
|
8337 | *
|
8338 | * Commands can be added to the editor using the {@link commands.registerCommand registerCommand}
|
8339 | * and {@link commands.registerTextEditorCommand registerTextEditorCommand} functions. Commands
|
8340 | * can be executed {@link commands.executeCommand manually} or from a UI gesture. Those are:
|
8341 | *
|
8342 | * * palette - Use the `commands`-section in `package.json` to make a command show in
|
8343 | * the [command palette](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette).
|
8344 | * * keybinding - Use the `keybindings`-section in `package.json` to enable
|
8345 | * [keybindings](https://code.visualstudio.com/docs/getstarted/keybindings#_customizing-shortcuts)
|
8346 | * for your extension.
|
8347 | *
|
8348 | * Commands from other extensions and from the editor itself are accessible to an extension. However,
|
8349 | * when invoking an editor command not all argument types are supported.
|
8350 | *
|
8351 | * This is a sample that registers a command handler and adds an entry for that command to the palette. First
|
8352 | * register a command handler with the identifier `extension.sayHello`.
|
8353 | * ```javascript
|
8354 | * commands.registerCommand('extension.sayHello', () => {
|
8355 | * window.showInformationMessage('Hello World!');
|
8356 | * });
|
8357 | * ```
|
8358 | * Second, bind the command identifier to a title under which it will show in the palette (`package.json`).
|
8359 | * ```json
|
8360 | * {
|
8361 | * "contributes": {
|
8362 | * "commands": [{
|
8363 | * "command": "extension.sayHello",
|
8364 | * "title": "Hello World"
|
8365 | * }]
|
8366 | * }
|
8367 | * }
|
8368 | * ```
|
8369 | */
|
8370 | export namespace commands {
|
8371 |
|
8372 | /**
|
8373 | * Registers a command that can be invoked via a keyboard shortcut,
|
8374 | * a menu item, an action, or directly.
|
8375 | *
|
8376 | * Registering a command with an existing command identifier twice
|
8377 | * will cause an error.
|
8378 | *
|
8379 | * @param command A unique identifier for the command.
|
8380 | * @param callback A command handler function.
|
8381 | * @param thisArg The `this` context used when invoking the handler function.
|
8382 | * @return Disposable which unregisters this command on disposal.
|
8383 | */
|
8384 | export function registerCommand(command: string, callback: (...args: any[]) => any, thisArg?: any): Disposable;
|
8385 |
|
8386 | /**
|
8387 | * Registers a text editor command that can be invoked via a keyboard shortcut,
|
8388 | * a menu item, an action, or directly.
|
8389 | *
|
8390 | * Text editor commands are different from ordinary {@link commands.registerCommand commands} as
|
8391 | * they only execute when there is an active editor when the command is called. Also, the
|
8392 | * command handler of an editor command has access to the active editor and to an
|
8393 | * {@link TextEditorEdit edit}-builder. Note that the edit-builder is only valid while the
|
8394 | * callback executes.
|
8395 | *
|
8396 | * @param command A unique identifier for the command.
|
8397 | * @param callback A command handler function with access to an {@link TextEditor editor} and an {@link TextEditorEdit edit}.
|
8398 | * @param thisArg The `this` context used when invoking the handler function.
|
8399 | * @return Disposable which unregisters this command on disposal.
|
8400 | */
|
8401 | export function registerTextEditorCommand(command: string, callback: (textEditor: TextEditor, edit: TextEditorEdit, ...args: any[]) => void, thisArg?: any): Disposable;
|
8402 |
|
8403 | /**
|
8404 | * Executes the command denoted by the given command identifier.
|
8405 | *
|
8406 | * * *Note 1:* When executing an editor command not all types are allowed to
|
8407 | * be passed as arguments. Allowed are the primitive types `string`, `boolean`,
|
8408 | * `number`, `undefined`, and `null`, as well as {@link Position `Position`}, {@link Range `Range`}, {@link Uri `Uri`} and {@link Location `Location`}.
|
8409 | * * *Note 2:* There are no restrictions when executing commands that have been contributed
|
8410 | * by extensions.
|
8411 | *
|
8412 | * @param command Identifier of the command to execute.
|
8413 | * @param rest Parameters passed to the command function.
|
8414 | * @return A thenable that resolves to the returned value of the given command. `undefined` when
|
8415 | * the command handler function doesn't return anything.
|
8416 | */
|
8417 | export function executeCommand<T>(command: string, ...rest: any[]): Thenable<T | undefined>;
|
8418 |
|
8419 | /**
|
8420 | * Retrieve the list of all available commands. Commands starting with an underscore are
|
8421 | * treated as internal commands.
|
8422 | *
|
8423 | * @param filterInternal Set `true` to not see internal commands (starting with an underscore)
|
8424 | * @return Thenable that resolves to a list of command ids.
|
8425 | */
|
8426 | export function getCommands(filterInternal?: boolean): Thenable<string[]>;
|
8427 | }
|
8428 |
|
8429 | /**
|
8430 | * Represents the state of a window.
|
8431 | */
|
8432 | export interface WindowState {
|
8433 |
|
8434 | /**
|
8435 | * Whether the current window is focused.
|
8436 | */
|
8437 | readonly focused: boolean;
|
8438 | }
|
8439 |
|
8440 | /**
|
8441 | * A uri handler is responsible for handling system-wide {@link Uri uris}.
|
8442 | *
|
8443 | * @see {@link window.registerUriHandler}.
|
8444 | */
|
8445 | export interface UriHandler {
|
8446 |
|
8447 | /**
|
8448 | * Handle the provided system-wide {@link Uri}.
|
8449 | *
|
8450 | * @see {@link window.registerUriHandler}.
|
8451 | */
|
8452 | handleUri(uri: Uri): ProviderResult<void>;
|
8453 | }
|
8454 |
|
8455 | /**
|
8456 | * Namespace for dealing with the current window of the editor. That is visible
|
8457 | * and active editors, as well as, UI elements to show messages, selections, and
|
8458 | * asking for user input.
|
8459 | */
|
8460 | export namespace window {
|
8461 |
|
8462 | /**
|
8463 | * The currently active editor or `undefined`. The active editor is the one
|
8464 | * that currently has focus or, when none has focus, the one that has changed
|
8465 | * input most recently.
|
8466 | */
|
8467 | export let activeTextEditor: TextEditor | undefined;
|
8468 |
|
8469 | /**
|
8470 | * The currently visible editors or an empty array.
|
8471 | */
|
8472 | export let visibleTextEditors: TextEditor[];
|
8473 |
|
8474 | /**
|
8475 | * An {@link Event} which fires when the {@link window.activeTextEditor active editor}
|
8476 | * has changed. *Note* that the event also fires when the active editor changes
|
8477 | * to `undefined`.
|
8478 | */
|
8479 | export const onDidChangeActiveTextEditor: Event<TextEditor | undefined>;
|
8480 |
|
8481 | /**
|
8482 | * An {@link Event} which fires when the array of {@link window.visibleTextEditors visible editors}
|
8483 | * has changed.
|
8484 | */
|
8485 | export const onDidChangeVisibleTextEditors: Event<TextEditor[]>;
|
8486 |
|
8487 | /**
|
8488 | * An {@link Event} which fires when the selection in an editor has changed.
|
8489 | */
|
8490 | export const onDidChangeTextEditorSelection: Event<TextEditorSelectionChangeEvent>;
|
8491 |
|
8492 | /**
|
8493 | * An {@link Event} which fires when the visible ranges of an editor has changed.
|
8494 | */
|
8495 | export const onDidChangeTextEditorVisibleRanges: Event<TextEditorVisibleRangesChangeEvent>;
|
8496 |
|
8497 | /**
|
8498 | * An {@link Event} which fires when the options of an editor have changed.
|
8499 | */
|
8500 | export const onDidChangeTextEditorOptions: Event<TextEditorOptionsChangeEvent>;
|
8501 |
|
8502 | /**
|
8503 | * An {@link Event} which fires when the view column of an editor has changed.
|
8504 | */
|
8505 | export const onDidChangeTextEditorViewColumn: Event<TextEditorViewColumnChangeEvent>;
|
8506 |
|
8507 | /**
|
8508 | * The currently opened terminals or an empty array.
|
8509 | */
|
8510 | export const terminals: readonly Terminal[];
|
8511 |
|
8512 | /**
|
8513 | * The currently active terminal or `undefined`. The active terminal is the one that
|
8514 | * currently has focus or most recently had focus.
|
8515 | */
|
8516 | export const activeTerminal: Terminal | undefined;
|
8517 |
|
8518 | /**
|
8519 | * An {@link Event} which fires when the {@link window.activeTerminal active terminal}
|
8520 | * has changed. *Note* that the event also fires when the active terminal changes
|
8521 | * to `undefined`.
|
8522 | */
|
8523 | export const onDidChangeActiveTerminal: Event<Terminal | undefined>;
|
8524 |
|
8525 | /**
|
8526 | * An {@link Event} which fires when a terminal has been created, either through the
|
8527 | * {@link window.createTerminal createTerminal} API or commands.
|
8528 | */
|
8529 | export const onDidOpenTerminal: Event<Terminal>;
|
8530 |
|
8531 | /**
|
8532 | * An {@link Event} which fires when a terminal is disposed.
|
8533 | */
|
8534 | export const onDidCloseTerminal: Event<Terminal>;
|
8535 |
|
8536 | /**
|
8537 | * Represents the current window's state.
|
8538 | */
|
8539 | export const state: WindowState;
|
8540 |
|
8541 | /**
|
8542 | * An {@link Event} which fires when the focus state of the current window
|
8543 | * changes. The value of the event represents whether the window is focused.
|
8544 | */
|
8545 | export const onDidChangeWindowState: Event<WindowState>;
|
8546 |
|
8547 | /**
|
8548 | * Show the given document in a text editor. A {@link ViewColumn column} can be provided
|
8549 | * to control where the editor is being shown. Might change the {@link window.activeTextEditor active editor}.
|
8550 | *
|
8551 | * @param document A text document to be shown.
|
8552 | * @param column A view column in which the {@link TextEditor editor} should be shown. The default is the {@link ViewColumn.Active active}, other values
|
8553 | * are adjusted to be `Min(column, columnCount + 1)`, the {@link ViewColumn.Active active}-column is not adjusted. Use {@link ViewColumn.Beside `ViewColumn.Beside`}
|
8554 | * to open the editor to the side of the currently active one.
|
8555 | * @param preserveFocus When `true` the editor will not take focus.
|
8556 | * @return A promise that resolves to an {@link TextEditor editor}.
|
8557 | */
|
8558 | export function showTextDocument(document: TextDocument, column?: ViewColumn, preserveFocus?: boolean): Thenable<TextEditor>;
|
8559 |
|
8560 | /**
|
8561 | * Show the given document in a text editor. {@link TextDocumentShowOptions Options} can be provided
|
8562 | * to control options of the editor is being shown. Might change the {@link window.activeTextEditor active editor}.
|
8563 | *
|
8564 | * @param document A text document to be shown.
|
8565 | * @param options {@link TextDocumentShowOptions Editor options} to configure the behavior of showing the {@link TextEditor editor}.
|
8566 | * @return A promise that resolves to an {@link TextEditor editor}.
|
8567 | */
|
8568 | export function showTextDocument(document: TextDocument, options?: TextDocumentShowOptions): Thenable<TextEditor>;
|
8569 |
|
8570 | /**
|
8571 | * A short-hand for `openTextDocument(uri).then(document => showTextDocument(document, options))`.
|
8572 | *
|
8573 | * @see {@link openTextDocument}
|
8574 | *
|
8575 | * @param uri A resource identifier.
|
8576 | * @param options {@link TextDocumentShowOptions Editor options} to configure the behavior of showing the {@link TextEditor editor}.
|
8577 | * @return A promise that resolves to an {@link TextEditor editor}.
|
8578 | */
|
8579 | export function showTextDocument(uri: Uri, options?: TextDocumentShowOptions): Thenable<TextEditor>;
|
8580 |
|
8581 | /**
|
8582 | * Create a TextEditorDecorationType that can be used to add decorations to text editors.
|
8583 | *
|
8584 | * @param options Rendering options for the decoration type.
|
8585 | * @return A new decoration type instance.
|
8586 | */
|
8587 | export function createTextEditorDecorationType(options: DecorationRenderOptions): TextEditorDecorationType;
|
8588 |
|
8589 | /**
|
8590 | * Show an information message to users. Optionally provide an array of items which will be presented as
|
8591 | * clickable buttons.
|
8592 | *
|
8593 | * @param message The message to show.
|
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 showInformationMessage(message: string, ...items: string[]): Thenable<string | undefined>;
|
8598 |
|
8599 | /**
|
8600 | * Show an information message to users. Optionally provide an array of items which will be presented as
|
8601 | * clickable buttons.
|
8602 | *
|
8603 | * @param message The message to show.
|
8604 | * @param options Configures the behaviour of the message.
|
8605 | * @param items A set of items that will be rendered as actions in the message.
|
8606 | * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
|
8607 | */
|
8608 | export function showInformationMessage(message: string, options: MessageOptions, ...items: string[]): Thenable<string | undefined>;
|
8609 |
|
8610 | /**
|
8611 | * Show an information message.
|
8612 | *
|
8613 | * @see {@link window.showInformationMessage showInformationMessage}
|
8614 | *
|
8615 | * @param message The message to show.
|
8616 | * @param items A set of items that will be rendered as actions in the message.
|
8617 | * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
|
8618 | */
|
8619 | export function showInformationMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T | undefined>;
|
8620 |
|
8621 | /**
|
8622 | * Show an information message.
|
8623 | *
|
8624 | * @see {@link window.showInformationMessage showInformationMessage}
|
8625 | *
|
8626 | * @param message The message to show.
|
8627 | * @param options Configures the behaviour of the message.
|
8628 | * @param items A set of items that will be rendered as actions in the message.
|
8629 | * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
|
8630 | */
|
8631 | export function showInformationMessage<T extends MessageItem>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
|
8632 |
|
8633 | /**
|
8634 | * Show a warning message.
|
8635 | *
|
8636 | * @see {@link window.showInformationMessage showInformationMessage}
|
8637 | *
|
8638 | * @param message The message to show.
|
8639 | * @param items A set of items that will be rendered as actions in the message.
|
8640 | * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
|
8641 | */
|
8642 | export function showWarningMessage(message: string, ...items: string[]): Thenable<string | undefined>;
|
8643 |
|
8644 | /**
|
8645 | * Show a warning message.
|
8646 | *
|
8647 | * @see {@link window.showInformationMessage showInformationMessage}
|
8648 | *
|
8649 | * @param message The message to show.
|
8650 | * @param options Configures the behaviour of the message.
|
8651 | * @param items A set of items that will be rendered as actions in the message.
|
8652 | * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
|
8653 | */
|
8654 | export function showWarningMessage(message: string, options: MessageOptions, ...items: string[]): Thenable<string | undefined>;
|
8655 |
|
8656 | /**
|
8657 | * Show a warning message.
|
8658 | *
|
8659 | * @see {@link window.showInformationMessage showInformationMessage}
|
8660 | *
|
8661 | * @param message The message to show.
|
8662 | * @param items A set of items that will be rendered as actions in the message.
|
8663 | * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
|
8664 | */
|
8665 | export function showWarningMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T | undefined>;
|
8666 |
|
8667 | /**
|
8668 | * Show a warning message.
|
8669 | *
|
8670 | * @see {@link window.showInformationMessage showInformationMessage}
|
8671 | *
|
8672 | * @param message The message to show.
|
8673 | * @param options Configures the behaviour of the message.
|
8674 | * @param items A set of items that will be rendered as actions in the message.
|
8675 | * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
|
8676 | */
|
8677 | export function showWarningMessage<T extends MessageItem>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
|
8678 |
|
8679 | /**
|
8680 | * Show an error message.
|
8681 | *
|
8682 | * @see {@link window.showInformationMessage showInformationMessage}
|
8683 | *
|
8684 | * @param message The message to show.
|
8685 | * @param items A set of items that will be rendered as actions in the message.
|
8686 | * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
|
8687 | */
|
8688 | export function showErrorMessage(message: string, ...items: string[]): Thenable<string | undefined>;
|
8689 |
|
8690 | /**
|
8691 | * Show an error message.
|
8692 | *
|
8693 | * @see {@link window.showInformationMessage showInformationMessage}
|
8694 | *
|
8695 | * @param message The message to show.
|
8696 | * @param options Configures the behaviour of the message.
|
8697 | * @param items A set of items that will be rendered as actions in the message.
|
8698 | * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
|
8699 | */
|
8700 | export function showErrorMessage(message: string, options: MessageOptions, ...items: string[]): Thenable<string | undefined>;
|
8701 |
|
8702 | /**
|
8703 | * Show an error message.
|
8704 | *
|
8705 | * @see {@link window.showInformationMessage showInformationMessage}
|
8706 | *
|
8707 | * @param message The message to show.
|
8708 | * @param items A set of items that will be rendered as actions in the message.
|
8709 | * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
|
8710 | */
|
8711 | export function showErrorMessage<T extends MessageItem>(message: string, ...items: T[]): Thenable<T | undefined>;
|
8712 |
|
8713 | /**
|
8714 | * Show an error message.
|
8715 | *
|
8716 | * @see {@link window.showInformationMessage showInformationMessage}
|
8717 | *
|
8718 | * @param message The message to show.
|
8719 | * @param options Configures the behaviour of the message.
|
8720 | * @param items A set of items that will be rendered as actions in the message.
|
8721 | * @return A thenable that resolves to the selected item or `undefined` when being dismissed.
|
8722 | */
|
8723 | export function showErrorMessage<T extends MessageItem>(message: string, options: MessageOptions, ...items: T[]): Thenable<T | undefined>;
|
8724 |
|
8725 | /**
|
8726 | * Shows a selection list allowing multiple selections.
|
8727 | *
|
8728 | * @param items An array of strings, or a promise that resolves to an array of strings.
|
8729 | * @param options Configures the behavior of the selection list.
|
8730 | * @param token A token that can be used to signal cancellation.
|
8731 | * @return A promise that resolves to the selected items or `undefined`.
|
8732 | */
|
8733 | export function showQuickPick(items: readonly string[] | Thenable<readonly string[]>, options: QuickPickOptions & { canPickMany: true; }, token?: CancellationToken): Thenable<string[] | undefined>;
|
8734 |
|
8735 | /**
|
8736 | * Shows a selection list.
|
8737 | *
|
8738 | * @param items An array of strings, or a promise that resolves to an array of strings.
|
8739 | * @param options Configures the behavior of the selection list.
|
8740 | * @param token A token that can be used to signal cancellation.
|
8741 | * @return A promise that resolves to the selection or `undefined`.
|
8742 | */
|
8743 | export function showQuickPick(items: readonly string[] | Thenable<readonly string[]>, options?: QuickPickOptions, token?: CancellationToken): Thenable<string | undefined>;
|
8744 |
|
8745 | /**
|
8746 | * Shows a selection list allowing multiple selections.
|
8747 | *
|
8748 | * @param items An array of items, or a promise that resolves to an array of items.
|
8749 | * @param options Configures the behavior of the selection list.
|
8750 | * @param token A token that can be used to signal cancellation.
|
8751 | * @return A promise that resolves to the selected items or `undefined`.
|
8752 | */
|
8753 | export function showQuickPick<T extends QuickPickItem>(items: readonly T[] | Thenable<readonly T[]>, options: QuickPickOptions & { canPickMany: true; }, token?: CancellationToken): Thenable<T[] | undefined>;
|
8754 |
|
8755 | /**
|
8756 | * Shows a selection list.
|
8757 | *
|
8758 | * @param items An array of items, or a promise that resolves to an array of items.
|
8759 | * @param options Configures the behavior of the selection list.
|
8760 | * @param token A token that can be used to signal cancellation.
|
8761 | * @return A promise that resolves to the selected item or `undefined`.
|
8762 | */
|
8763 | export function showQuickPick<T extends QuickPickItem>(items: readonly T[] | Thenable<readonly T[]>, options?: QuickPickOptions, token?: CancellationToken): Thenable<T | undefined>;
|
8764 |
|
8765 | /**
|
8766 | * Shows a selection list of {@link workspace.workspaceFolders workspace folders} to pick from.
|
8767 | * Returns `undefined` if no folder is open.
|
8768 | *
|
8769 | * @param options Configures the behavior of the workspace folder list.
|
8770 | * @return A promise that resolves to the workspace folder or `undefined`.
|
8771 | */
|
8772 | export function showWorkspaceFolderPick(options?: WorkspaceFolderPickOptions): Thenable<WorkspaceFolder | undefined>;
|
8773 |
|
8774 | /**
|
8775 | * Shows a file open dialog to the user which allows to select a file
|
8776 | * for opening-purposes.
|
8777 | *
|
8778 | * @param options Options that control the dialog.
|
8779 | * @returns A promise that resolves to the selected resources or `undefined`.
|
8780 | */
|
8781 | export function showOpenDialog(options?: OpenDialogOptions): Thenable<Uri[] | undefined>;
|
8782 |
|
8783 | /**
|
8784 | * Shows a file save dialog to the user which allows to select a file
|
8785 | * for saving-purposes.
|
8786 | *
|
8787 | * @param options Options that control the dialog.
|
8788 | * @returns A promise that resolves to the selected resource or `undefined`.
|
8789 | */
|
8790 | export function showSaveDialog(options?: SaveDialogOptions): Thenable<Uri | undefined>;
|
8791 |
|
8792 | /**
|
8793 | * Opens an input box to ask the user for input.
|
8794 | *
|
8795 | * The returned value will be `undefined` if the input box was canceled (e.g. pressing ESC). Otherwise the
|
8796 | * returned value will be the string typed by the user or an empty string if the user did not type
|
8797 | * anything but dismissed the input box with OK.
|
8798 | *
|
8799 | * @param options Configures the behavior of the input box.
|
8800 | * @param token A token that can be used to signal cancellation.
|
8801 | * @return A promise that resolves to a string the user provided or to `undefined` in case of dismissal.
|
8802 | */
|
8803 | export function showInputBox(options?: InputBoxOptions, token?: CancellationToken): Thenable<string | undefined>;
|
8804 |
|
8805 | /**
|
8806 | * Creates a {@link QuickPick} to let the user pick an item from a list
|
8807 | * of items of type T.
|
8808 | *
|
8809 | * Note that in many cases the more convenient {@link window.showQuickPick}
|
8810 | * is easier to use. {@link window.createQuickPick} should be used
|
8811 | * when {@link window.showQuickPick} does not offer the required flexibility.
|
8812 | *
|
8813 | * @return A new {@link QuickPick}.
|
8814 | */
|
8815 | export function createQuickPick<T extends QuickPickItem>(): QuickPick<T>;
|
8816 |
|
8817 | /**
|
8818 | * Creates a {@link InputBox} to let the user enter some text input.
|
8819 | *
|
8820 | * Note that in many cases the more convenient {@link window.showInputBox}
|
8821 | * is easier to use. {@link window.createInputBox} should be used
|
8822 | * when {@link window.showInputBox} does not offer the required flexibility.
|
8823 | *
|
8824 | * @return A new {@link InputBox}.
|
8825 | */
|
8826 | export function createInputBox(): InputBox;
|
8827 |
|
8828 | /**
|
8829 | * Creates a new {@link OutputChannel output channel} with the given name.
|
8830 | *
|
8831 | * @param name Human-readable string which will be used to represent the channel in the UI.
|
8832 | */
|
8833 | export function createOutputChannel(name: string): OutputChannel;
|
8834 |
|
8835 | /**
|
8836 | * Create and show a new webview panel.
|
8837 | *
|
8838 | * @param viewType Identifies the type of the webview panel.
|
8839 | * @param title Title of the panel.
|
8840 | * @param showOptions Where to show the webview in the editor. If preserveFocus is set, the new webview will not take focus.
|
8841 | * @param options Settings for the new panel.
|
8842 | *
|
8843 | * @return New webview panel.
|
8844 | */
|
8845 | export function createWebviewPanel(viewType: string, title: string, showOptions: ViewColumn | { viewColumn: ViewColumn, preserveFocus?: boolean }, options?: WebviewPanelOptions & WebviewOptions): WebviewPanel;
|
8846 |
|
8847 | /**
|
8848 | * Set a message to the status bar. This is a short hand for the more powerful
|
8849 | * status bar {@link window.createStatusBarItem items}.
|
8850 | *
|
8851 | * @param text The message to show, supports icon substitution as in status bar {@link StatusBarItem.text items}.
|
8852 | * @param hideAfterTimeout Timeout in milliseconds after which the message will be disposed.
|
8853 | * @return A disposable which hides the status bar message.
|
8854 | */
|
8855 | export function setStatusBarMessage(text: string, hideAfterTimeout: number): Disposable;
|
8856 |
|
8857 | /**
|
8858 | * Set a message to the status bar. This is a short hand for the more powerful
|
8859 | * status bar {@link window.createStatusBarItem items}.
|
8860 | *
|
8861 | * @param text The message to show, supports icon substitution as in status bar {@link StatusBarItem.text items}.
|
8862 | * @param hideWhenDone Thenable on which completion (resolve or reject) the message will be disposed.
|
8863 | * @return A disposable which hides the status bar message.
|
8864 | */
|
8865 | export function setStatusBarMessage(text: string, hideWhenDone: Thenable<any>): Disposable;
|
8866 |
|
8867 | /**
|
8868 | * Set a message to the status bar. This is a short hand for the more powerful
|
8869 | * status bar {@link window.createStatusBarItem items}.
|
8870 | *
|
8871 | * *Note* that status bar messages stack and that they must be disposed when no
|
8872 | * longer used.
|
8873 | *
|
8874 | * @param text The message to show, supports icon substitution as in status bar {@link StatusBarItem.text items}.
|
8875 | * @return A disposable which hides the status bar message.
|
8876 | */
|
8877 | export function setStatusBarMessage(text: string): Disposable;
|
8878 |
|
8879 | /**
|
8880 | * Show progress in the Source Control viewlet while running the given callback and while
|
8881 | * its returned promise isn't resolve or rejected.
|
8882 | *
|
8883 | * @deprecated Use `withProgress` instead.
|
8884 | *
|
8885 | * @param task A callback returning a promise. Progress increments can be reported with
|
8886 | * the provided {@link Progress}-object.
|
8887 | * @return The thenable the task did return.
|
8888 | */
|
8889 | export function withScmProgress<R>(task: (progress: Progress<number>) => Thenable<R>): Thenable<R>;
|
8890 |
|
8891 | /**
|
8892 | * Show progress in the editor. Progress is shown while running the given callback
|
8893 | * and while the promise it returned isn't resolved nor rejected. The location at which
|
8894 | * progress should show (and other details) is defined via the passed {@link ProgressOptions `ProgressOptions`}.
|
8895 | *
|
8896 | * @param task A callback returning a promise. Progress state can be reported with
|
8897 | * the provided {@link Progress}-object.
|
8898 | *
|
8899 | * To report discrete progress, use `increment` to indicate how much work has been completed. Each call with
|
8900 | * a `increment` value will be summed up and reflected as overall progress until 100% is reached (a value of
|
8901 | * e.g. `10` accounts for `10%` of work done).
|
8902 | * Note that currently only `ProgressLocation.Notification` is capable of showing discrete progress.
|
8903 | *
|
8904 | * To monitor if the operation has been cancelled by the user, use the provided {@link CancellationToken `CancellationToken`}.
|
8905 | * Note that currently only `ProgressLocation.Notification` is supporting to show a cancel button to cancel the
|
8906 | * long running operation.
|
8907 | *
|
8908 | * @return The thenable the task-callback returned.
|
8909 | */
|
8910 | export function withProgress<R>(options: ProgressOptions, task: (progress: Progress<{ message?: string; increment?: number }>, token: CancellationToken) => Thenable<R>): Thenable<R>;
|
8911 |
|
8912 | /**
|
8913 | * Creates a status bar {@link StatusBarItem item}.
|
8914 | *
|
8915 | * @param alignment The alignment of the item.
|
8916 | * @param priority The priority of the item. Higher values mean the item should be shown more to the left.
|
8917 | * @return A new status bar item.
|
8918 | */
|
8919 | export function createStatusBarItem(alignment?: StatusBarAlignment, priority?: number): StatusBarItem;
|
8920 |
|
8921 | /**
|
8922 | * Creates a status bar {@link StatusBarItem item}.
|
8923 | *
|
8924 | * @param id The unique identifier of the item.
|
8925 | * @param alignment The alignment of the item.
|
8926 | * @param priority The priority of the item. Higher values mean the item should be shown more to the left.
|
8927 | * @return A new status bar item.
|
8928 | */
|
8929 | export function createStatusBarItem(id: string, alignment?: StatusBarAlignment, priority?: number): StatusBarItem;
|
8930 |
|
8931 | /**
|
8932 | * Creates a {@link Terminal} with a backing shell process. The cwd of the terminal will be the workspace
|
8933 | * directory if it exists.
|
8934 | *
|
8935 | * @param name Optional human-readable string which will be used to represent the terminal in the UI.
|
8936 | * @param shellPath Optional path to a custom shell executable to be used in the terminal.
|
8937 | * @param shellArgs Optional args for the custom shell executable. A string can be used on Windows only which
|
8938 | * allows specifying shell args in
|
8939 | * [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6).
|
8940 | * @return A new Terminal.
|
8941 | * @throws When running in an environment where a new process cannot be started.
|
8942 | */
|
8943 | export function createTerminal(name?: string, shellPath?: string, shellArgs?: string[] | string): Terminal;
|
8944 |
|
8945 | /**
|
8946 | * Creates a {@link Terminal} with a backing shell process.
|
8947 | *
|
8948 | * @param options A TerminalOptions object describing the characteristics of the new terminal.
|
8949 | * @return A new Terminal.
|
8950 | * @throws When running in an environment where a new process cannot be started.
|
8951 | */
|
8952 | export function createTerminal(options: TerminalOptions): Terminal;
|
8953 |
|
8954 | /**
|
8955 | * Creates a {@link Terminal} where an extension controls its input and output.
|
8956 | *
|
8957 | * @param options An {@link ExtensionTerminalOptions} object describing
|
8958 | * the characteristics of the new terminal.
|
8959 | * @return A new Terminal.
|
8960 | */
|
8961 | export function createTerminal(options: ExtensionTerminalOptions): Terminal;
|
8962 |
|
8963 | /**
|
8964 | * Register a {@link TreeDataProvider} for the view contributed using the extension point `views`.
|
8965 | * This will allow you to contribute data to the {@link TreeView} and update if the data changes.
|
8966 | *
|
8967 | * **Note:** To get access to the {@link TreeView} and perform operations on it, use {@link window.createTreeView createTreeView}.
|
8968 | *
|
8969 | * @param viewId Id of the view contributed using the extension point `views`.
|
8970 | * @param treeDataProvider A {@link TreeDataProvider} that provides tree data for the view
|
8971 | */
|
8972 | export function registerTreeDataProvider<T>(viewId: string, treeDataProvider: TreeDataProvider<T>): Disposable;
|
8973 |
|
8974 | /**
|
8975 | * Create a {@link TreeView} for the view contributed using the extension point `views`.
|
8976 | * @param viewId Id of the view contributed using the extension point `views`.
|
8977 | * @param options Options for creating the {@link TreeView}
|
8978 | * @returns a {@link TreeView}.
|
8979 | */
|
8980 | export function createTreeView<T>(viewId: string, options: TreeViewOptions<T>): TreeView<T>;
|
8981 |
|
8982 | /**
|
8983 | * Registers a {@link UriHandler uri handler} capable of handling system-wide {@link Uri uris}.
|
8984 | * In case there are multiple windows open, the topmost window will handle the uri.
|
8985 | * A uri handler is scoped to the extension it is contributed from; it will only
|
8986 | * be able to handle uris which are directed to the extension itself. A uri must respect
|
8987 | * the following rules:
|
8988 | *
|
8989 | * - The uri-scheme must be `vscode.env.uriScheme`;
|
8990 | * - The uri-authority must be the extension id (e.g. `my.extension`);
|
8991 | * - The uri-path, -query and -fragment parts are arbitrary.
|
8992 | *
|
8993 | * For example, if the `my.extension` extension registers a uri handler, it will only
|
8994 | * be allowed to handle uris with the prefix `product-name://my.extension`.
|
8995 | *
|
8996 | * An extension can only register a single uri handler in its entire activation lifetime.
|
8997 | *
|
8998 | * * *Note:* There is an activation event `onUri` that fires when a uri directed for
|
8999 | * the current extension is about to be handled.
|
9000 | *
|
9001 | * @param handler The uri handler to register for this extension.
|
9002 | */
|
9003 | export function registerUriHandler(handler: UriHandler): Disposable;
|
9004 |
|
9005 | /**
|
9006 | * Registers a webview panel serializer.
|
9007 | *
|
9008 | * Extensions that support reviving should have an `"onWebviewPanel:viewType"` activation event and
|
9009 | * make sure that {@link registerWebviewPanelSerializer} is called during activation.
|
9010 | *
|
9011 | * Only a single serializer may be registered at a time for a given `viewType`.
|
9012 | *
|
9013 | * @param viewType Type of the webview panel that can be serialized.
|
9014 | * @param serializer Webview serializer.
|
9015 | */
|
9016 | export function registerWebviewPanelSerializer(viewType: string, serializer: WebviewPanelSerializer): Disposable;
|
9017 |
|
9018 | /**
|
9019 | * Register a new provider for webview views.
|
9020 | *
|
9021 | * @param viewId Unique id of the view. This should match the `id` from the
|
9022 | * `views` contribution in the package.json.
|
9023 | * @param provider Provider for the webview views.
|
9024 | *
|
9025 | * @return Disposable that unregisters the provider.
|
9026 | */
|
9027 | export function registerWebviewViewProvider(viewId: string, provider: WebviewViewProvider, options?: {
|
9028 | /**
|
9029 | * Content settings for the webview created for this view.
|
9030 | */
|
9031 | readonly webviewOptions?: {
|
9032 | /**
|
9033 | * Controls if the webview element itself (iframe) is kept around even when the view
|
9034 | * is no longer visible.
|
9035 | *
|
9036 | * Normally the webview's html context is created when the view becomes visible
|
9037 | * and destroyed when it is hidden. Extensions that have complex state
|
9038 | * or UI can set the `retainContextWhenHidden` to make the editor keep the webview
|
9039 | * context around, even when the webview moves to a background tab. When a webview using
|
9040 | * `retainContextWhenHidden` becomes hidden, its scripts and other dynamic content are suspended.
|
9041 | * When the view becomes visible again, the context is automatically restored
|
9042 | * in the exact same state it was in originally. You cannot send messages to a
|
9043 | * hidden webview, even with `retainContextWhenHidden` enabled.
|
9044 | *
|
9045 | * `retainContextWhenHidden` has a high memory overhead and should only be used if
|
9046 | * your view's context cannot be quickly saved and restored.
|
9047 | */
|
9048 | readonly retainContextWhenHidden?: boolean;
|
9049 | };
|
9050 | }): Disposable;
|
9051 |
|
9052 | /**
|
9053 | * Register a provider for custom editors for the `viewType` contributed by the `customEditors` extension point.
|
9054 | *
|
9055 | * When a custom editor is opened, an `onCustomEditor:viewType` activation event is fired. Your extension
|
9056 | * must register a {@link CustomTextEditorProvider `CustomTextEditorProvider`}, {@link CustomReadonlyEditorProvider `CustomReadonlyEditorProvider`},
|
9057 | * {@link CustomEditorProvider `CustomEditorProvider`}for `viewType` as part of activation.
|
9058 | *
|
9059 | * @param viewType Unique identifier for the custom editor provider. This should match the `viewType` from the
|
9060 | * `customEditors` contribution point.
|
9061 | * @param provider Provider that resolves custom editors.
|
9062 | * @param options Options for the provider.
|
9063 | *
|
9064 | * @return Disposable that unregisters the provider.
|
9065 | */
|
9066 | export function registerCustomEditorProvider(viewType: string, provider: CustomTextEditorProvider | CustomReadonlyEditorProvider | CustomEditorProvider, options?: {
|
9067 | /**
|
9068 | * Content settings for the webview panels created for this custom editor.
|
9069 | */
|
9070 | readonly webviewOptions?: WebviewPanelOptions;
|
9071 |
|
9072 | /**
|
9073 | * Only applies to `CustomReadonlyEditorProvider | CustomEditorProvider`.
|
9074 | *
|
9075 | * Indicates that the provider allows multiple editor instances to be open at the same time for
|
9076 | * the same resource.
|
9077 | *
|
9078 | * By default, the editor only allows one editor instance to be open at a time for each resource. If the
|
9079 | * user tries to open a second editor instance for the resource, the first one is instead moved to where
|
9080 | * the second one was to be opened.
|
9081 | *
|
9082 | * When `supportsMultipleEditorsPerDocument` is enabled, users can split and create copies of the custom
|
9083 | * editor. In this case, the custom editor must make sure it can properly synchronize the states of all
|
9084 | * editor instances for a resource so that they are consistent.
|
9085 | */
|
9086 | readonly supportsMultipleEditorsPerDocument?: boolean;
|
9087 | }): Disposable;
|
9088 |
|
9089 | /**
|
9090 | * Register provider that enables the detection and handling of links within the terminal.
|
9091 | * @param provider The provider that provides the terminal links.
|
9092 | * @return Disposable that unregisters the provider.
|
9093 | */
|
9094 | export function registerTerminalLinkProvider(provider: TerminalLinkProvider): Disposable;
|
9095 |
|
9096 | /**
|
9097 | * Registers a provider for a contributed terminal profile.
|
9098 | * @param id The ID of the contributed terminal profile.
|
9099 | * @param provider The terminal profile provider.
|
9100 | */
|
9101 | export function registerTerminalProfileProvider(id: string, provider: TerminalProfileProvider): Disposable;
|
9102 | /**
|
9103 | * Register a file decoration provider.
|
9104 | *
|
9105 | * @param provider A {@link FileDecorationProvider}.
|
9106 | * @return A {@link Disposable} that unregisters the provider.
|
9107 | */
|
9108 | export function registerFileDecorationProvider(provider: FileDecorationProvider): Disposable;
|
9109 |
|
9110 | /**
|
9111 | * The currently active color theme as configured in the settings. The active
|
9112 | * theme can be changed via the `workbench.colorTheme` setting.
|
9113 | */
|
9114 | export let activeColorTheme: ColorTheme;
|
9115 |
|
9116 | /**
|
9117 | * An {@link Event} which fires when the active color theme is changed or has changes.
|
9118 | */
|
9119 | export const onDidChangeActiveColorTheme: Event<ColorTheme>;
|
9120 | }
|
9121 |
|
9122 | /**
|
9123 | * Options for creating a {@link TreeView}
|
9124 | */
|
9125 | export interface TreeViewOptions<T> {
|
9126 |
|
9127 | /**
|
9128 | * A data provider that provides tree data.
|
9129 | */
|
9130 | treeDataProvider: TreeDataProvider<T>;
|
9131 |
|
9132 | /**
|
9133 | * Whether to show collapse all action or not.
|
9134 | */
|
9135 | showCollapseAll?: boolean;
|
9136 |
|
9137 | /**
|
9138 | * Whether the tree supports multi-select. When the tree supports multi-select and a command is executed from the tree,
|
9139 | * the first argument to the command is the tree item that the command was executed on and the second argument is an
|
9140 | * array containing all selected tree items.
|
9141 | */
|
9142 | canSelectMany?: boolean;
|
9143 | }
|
9144 |
|
9145 | /**
|
9146 | * The event that is fired when an element in the {@link TreeView} is expanded or collapsed
|
9147 | */
|
9148 | export interface TreeViewExpansionEvent<T> {
|
9149 |
|
9150 | /**
|
9151 | * Element that is expanded or collapsed.
|
9152 | */
|
9153 | readonly element: T;
|
9154 |
|
9155 | }
|
9156 |
|
9157 | /**
|
9158 | * The event that is fired when there is a change in {@link TreeView.selection tree view's selection}
|
9159 | */
|
9160 | export interface TreeViewSelectionChangeEvent<T> {
|
9161 |
|
9162 | /**
|
9163 | * Selected elements.
|
9164 | */
|
9165 | readonly selection: T[];
|
9166 |
|
9167 | }
|
9168 |
|
9169 | /**
|
9170 | * The event that is fired when there is a change in {@link TreeView.visible tree view's visibility}
|
9171 | */
|
9172 | export interface TreeViewVisibilityChangeEvent {
|
9173 |
|
9174 | /**
|
9175 | * `true` if the {@link TreeView tree view} is visible otherwise `false`.
|
9176 | */
|
9177 | readonly visible: boolean;
|
9178 |
|
9179 | }
|
9180 |
|
9181 | /**
|
9182 | * Represents a Tree view
|
9183 | */
|
9184 | export interface TreeView<T> extends Disposable {
|
9185 |
|
9186 | /**
|
9187 | * Event that is fired when an element is expanded
|
9188 | */
|
9189 | readonly onDidExpandElement: Event<TreeViewExpansionEvent<T>>;
|
9190 |
|
9191 | /**
|
9192 | * Event that is fired when an element is collapsed
|
9193 | */
|
9194 | readonly onDidCollapseElement: Event<TreeViewExpansionEvent<T>>;
|
9195 |
|
9196 | /**
|
9197 | * Currently selected elements.
|
9198 | */
|
9199 | readonly selection: T[];
|
9200 |
|
9201 | /**
|
9202 | * Event that is fired when the {@link TreeView.selection selection} has changed
|
9203 | */
|
9204 | readonly onDidChangeSelection: Event<TreeViewSelectionChangeEvent<T>>;
|
9205 |
|
9206 | /**
|
9207 | * `true` if the {@link TreeView tree view} is visible otherwise `false`.
|
9208 | */
|
9209 | readonly visible: boolean;
|
9210 |
|
9211 | /**
|
9212 | * Event that is fired when {@link TreeView.visible visibility} has changed
|
9213 | */
|
9214 | readonly onDidChangeVisibility: Event<TreeViewVisibilityChangeEvent>;
|
9215 |
|
9216 | /**
|
9217 | * An optional human-readable message that will be rendered in the view.
|
9218 | * Setting the message to null, undefined, or empty string will remove the message from the view.
|
9219 | */
|
9220 | message?: string;
|
9221 |
|
9222 | /**
|
9223 | * The tree view title is initially taken from the extension package.json
|
9224 | * Changes to the title property will be properly reflected in the UI in the title of the view.
|
9225 | */
|
9226 | title?: string;
|
9227 |
|
9228 | /**
|
9229 | * An optional human-readable description which is rendered less prominently in the title of the view.
|
9230 | * Setting the title description to null, undefined, or empty string will remove the description from the view.
|
9231 | */
|
9232 | description?: string;
|
9233 |
|
9234 | /**
|
9235 | * Reveals the given element in the tree view.
|
9236 | * If the tree view is not visible then the tree view is shown and element is revealed.
|
9237 | *
|
9238 | * By default revealed element is selected.
|
9239 | * In order to not to select, set the option `select` to `false`.
|
9240 | * In order to focus, set the option `focus` to `true`.
|
9241 | * 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.
|
9242 | * **NOTE:** You can expand only to 3 levels maximum.
|
9243 | *
|
9244 | * **NOTE:** The {@link TreeDataProvider} that the `TreeView` {@link window.createTreeView is registered with} with must implement {@link TreeDataProvider.getParent getParent} method to access this API.
|
9245 | */
|
9246 | reveal(element: T, options?: { select?: boolean, focus?: boolean, expand?: boolean | number }): Thenable<void>;
|
9247 | }
|
9248 |
|
9249 | /**
|
9250 | * A data provider that provides tree data
|
9251 | */
|
9252 | export interface TreeDataProvider<T> {
|
9253 | /**
|
9254 | * An optional event to signal that an element or root has changed.
|
9255 | * This will trigger the view to update the changed element/root and its children recursively (if shown).
|
9256 | * To signal that root has changed, do not pass any argument or pass `undefined` or `null`.
|
9257 | */
|
9258 | onDidChangeTreeData?: Event<T | undefined | null | void>;
|
9259 |
|
9260 | /**
|
9261 | * Get {@link TreeItem} representation of the `element`
|
9262 | *
|
9263 | * @param element The element for which {@link TreeItem} representation is asked for.
|
9264 | * @return representation of the element
|
9265 | */
|
9266 | getTreeItem(element: T): TreeItem | Thenable<TreeItem>;
|
9267 |
|
9268 | /**
|
9269 | * Get the children of `element` or root if no element is passed.
|
9270 | *
|
9271 | * @param element The element from which the provider gets children. Can be `undefined`.
|
9272 | * @return Children of `element` or root if no element is passed.
|
9273 | */
|
9274 | getChildren(element?: T): ProviderResult<T[]>;
|
9275 |
|
9276 | /**
|
9277 | * Optional method to return the parent of `element`.
|
9278 | * Return `null` or `undefined` if `element` is a child of root.
|
9279 | *
|
9280 | * **NOTE:** This method should be implemented in order to access {@link TreeView.reveal reveal} API.
|
9281 | *
|
9282 | * @param element The element for which the parent has to be returned.
|
9283 | * @return Parent of `element`.
|
9284 | */
|
9285 | getParent?(element: T): ProviderResult<T>;
|
9286 |
|
9287 | /**
|
9288 | * Called on hover to resolve the {@link TreeItem.tooltip TreeItem} property if it is undefined.
|
9289 | * Called on tree item click/open to resolve the {@link TreeItem.command TreeItem} property if it is undefined.
|
9290 | * Only properties that were undefined can be resolved in `resolveTreeItem`.
|
9291 | * Functionality may be expanded later to include being called to resolve other missing
|
9292 | * properties on selection and/or on open.
|
9293 | *
|
9294 | * Will only ever be called once per TreeItem.
|
9295 | *
|
9296 | * onDidChangeTreeData should not be triggered from within resolveTreeItem.
|
9297 | *
|
9298 | * *Note* that this function is called when tree items are already showing in the UI.
|
9299 | * Because of that, no property that changes the presentation (label, description, etc.)
|
9300 | * can be changed.
|
9301 | *
|
9302 | * @param item Undefined properties of `item` should be set then `item` should be returned.
|
9303 | * @param element The object associated with the TreeItem.
|
9304 | * @param token A cancellation token.
|
9305 | * @return The resolved tree item or a thenable that resolves to such. It is OK to return the given
|
9306 | * `item`. When no result is returned, the given `item` will be used.
|
9307 | */
|
9308 | resolveTreeItem?(item: TreeItem, element: T, token: CancellationToken): ProviderResult<TreeItem>;
|
9309 | }
|
9310 |
|
9311 | export class TreeItem {
|
9312 | /**
|
9313 | * A human-readable string describing this item. When `falsy`, it is derived from {@link TreeItem.resourceUri resourceUri}.
|
9314 | */
|
9315 | label?: string | TreeItemLabel;
|
9316 |
|
9317 | /**
|
9318 | * 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.
|
9319 | *
|
9320 | * 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.
|
9321 | */
|
9322 | id?: string;
|
9323 |
|
9324 | /**
|
9325 | * The icon path or {@link ThemeIcon} for the tree item.
|
9326 | * When `falsy`, {@link ThemeIcon.Folder Folder Theme Icon} is assigned, if item is collapsible otherwise {@link ThemeIcon.File File Theme Icon}.
|
9327 | * When a file or folder {@link ThemeIcon} is specified, icon is derived from the current file icon theme for the specified theme icon using {@link TreeItem.resourceUri resourceUri} (if provided).
|
9328 | */
|
9329 | iconPath?: string | Uri | { light: string | Uri; dark: string | Uri } | ThemeIcon;
|
9330 |
|
9331 | /**
|
9332 | * A human-readable string which is rendered less prominent.
|
9333 | * When `true`, it is derived from {@link TreeItem.resourceUri resourceUri} and when `falsy`, it is not shown.
|
9334 | */
|
9335 | description?: string | boolean;
|
9336 |
|
9337 | /**
|
9338 | * The {@link Uri} of the resource representing this item.
|
9339 | *
|
9340 | * Will be used to derive the {@link TreeItem.label label}, when it is not provided.
|
9341 | * Will be used to derive the icon from current file icon theme, when {@link TreeItem.iconPath iconPath} has {@link ThemeIcon} value.
|
9342 | */
|
9343 | resourceUri?: Uri;
|
9344 |
|
9345 | /**
|
9346 | * The tooltip text when you hover over this item.
|
9347 | */
|
9348 | tooltip?: string | MarkdownString | undefined;
|
9349 |
|
9350 | /**
|
9351 | * The {@link Command} that should be executed when the tree item is selected.
|
9352 | *
|
9353 | * Please use `vscode.open` or `vscode.diff` as command IDs when the tree item is opening
|
9354 | * something in the editor. Using these commands ensures that the resulting editor will
|
9355 | * appear consistent with how other built-in trees open editors.
|
9356 | */
|
9357 | command?: Command;
|
9358 |
|
9359 | /**
|
9360 | * {@link TreeItemCollapsibleState} of the tree item.
|
9361 | */
|
9362 | collapsibleState?: TreeItemCollapsibleState;
|
9363 |
|
9364 | /**
|
9365 | * Context value of the tree item. This can be used to contribute item specific actions in the tree.
|
9366 | * For example, a tree item is given a context value as `folder`. When contributing actions to `view/item/context`
|
9367 | * using `menus` extension point, you can specify context value for key `viewItem` in `when` expression like `viewItem == folder`.
|
9368 | * ```
|
9369 | * "contributes": {
|
9370 | * "menus": {
|
9371 | * "view/item/context": [
|
9372 | * {
|
9373 | * "command": "extension.deleteFolder",
|
9374 | * "when": "viewItem == folder"
|
9375 | * }
|
9376 | * ]
|
9377 | * }
|
9378 | * }
|
9379 | * ```
|
9380 | * This will show action `extension.deleteFolder` only for items with `contextValue` is `folder`.
|
9381 | */
|
9382 | contextValue?: string;
|
9383 |
|
9384 | /**
|
9385 | * Accessibility information used when screen reader interacts with this tree item.
|
9386 | * Generally, a TreeItem has no need to set the `role` of the accessibilityInformation;
|
9387 | * however, there are cases where a TreeItem is not displayed in a tree-like way where setting the `role` may make sense.
|
9388 | */
|
9389 | accessibilityInformation?: AccessibilityInformation;
|
9390 |
|
9391 | /**
|
9392 | * @param label A human-readable string describing this item
|
9393 | * @param collapsibleState {@link TreeItemCollapsibleState} of the tree item. Default is {@link TreeItemCollapsibleState.None}
|
9394 | */
|
9395 | constructor(label: string | TreeItemLabel, collapsibleState?: TreeItemCollapsibleState);
|
9396 |
|
9397 | /**
|
9398 | * @param resourceUri The {this item.
Uri} of the resource representing |
9399 | * collapsibleState { TreeItemCollapsibleState} of the tree item. Default is { TreeItemCollapsibleState.None}
|
9400 | */
|
9401 | constructor(resourceUri: Uri, collapsibleState?: TreeItemCollapsibleState);
|
9402 | }
|
9403 |
|
9404 | /**
|
9405 | * Collapsible state of the tree item
|
9406 | */
|
9407 | export enum TreeItemCollapsibleState {
|
9408 | /**
|
9409 | * Determines an item can be neither collapsed nor expanded. Implies it has no children.
|
9410 | */
|
9411 | None = 0,
|
9412 | /**
|
9413 | * Determines an item is collapsed
|
9414 | */
|
9415 | Collapsed = 1,
|
9416 | /**
|
9417 | * Determines an item is expanded
|
9418 | */
|
9419 | Expanded = 2
|
9420 | }
|
9421 |
|
9422 | /**
|
9423 | * Label describing the {@link TreeItem Tree item}
|
9424 | */
|
9425 | export interface TreeItemLabel {
|
9426 |
|
9427 | /**
|
9428 | * A human-readable string describing the {@link TreeItem Tree item}.
|
9429 | */
|
9430 | label: string;
|
9431 |
|
9432 | /**
|
9433 | * Ranges in the label to highlight. A range is defined as a tuple of two number where the
|
9434 | * first is the inclusive start index and the second the exclusive end index
|
9435 | */
|
9436 | highlights?: [number, number][];
|
9437 | }
|
9438 |
|
9439 | /**
|
9440 | * Value-object describing what options a terminal should use.
|
9441 | */
|
9442 | export interface TerminalOptions {
|
9443 | /**
|
9444 | * A human-readable string which will be used to represent the terminal in the UI.
|
9445 | */
|
9446 | name?: string;
|
9447 |
|
9448 | /**
|
9449 | * A path to a custom shell executable to be used in the terminal.
|
9450 | */
|
9451 | shellPath?: string;
|
9452 |
|
9453 | /**
|
9454 | * Args for the custom shell executable. A string can be used on Windows only which allows
|
9455 | * specifying shell args in [command-line format](https://msdn.microsoft.com/en-au/08dfcab2-eb6e-49a4-80eb-87d4076c98c6).
|
9456 | */
|
9457 | shellArgs?: string[] | string;
|
9458 |
|
9459 | /**
|
9460 | * A path or Uri for the current working directory to be used for the terminal.
|
9461 | */
|
9462 | cwd?: string | Uri;
|
9463 |
|
9464 | /**
|
9465 | * Object with environment variables that will be added to the editor process.
|
9466 | */
|
9467 | env?: { [key: string]: string | null | undefined };
|
9468 |
|
9469 | /**
|
9470 | * Whether the terminal process environment should be exactly as provided in
|
9471 | * `TerminalOptions.env`. When this is false (default), the environment will be based on the
|
9472 | * window's environment and also apply configured platform settings like
|
9473 | * `terminal.integrated.windows.env` on top. When this is true, the complete environment
|
9474 | * must be provided as nothing will be inherited from the process or any configuration.
|
9475 | */
|
9476 | strictEnv?: boolean;
|
9477 |
|
9478 | /**
|
9479 | * When enabled the terminal will run the process as normal but not be surfaced to the user
|
9480 | * until `Terminal.show` is called. The typical usage for this is when you need to run
|
9481 | * something that may need interactivity but only want to tell the user about it when
|
9482 | * interaction is needed. Note that the terminals will still be exposed to all extensions
|
9483 | * as normal.
|
9484 | */
|
9485 | hideFromUser?: boolean;
|
9486 |
|
9487 | /**
|
9488 | * A message to write to the terminal on first launch, note that this is not sent to the
|
9489 | * process but, rather written directly to the terminal. This supports escape sequences such
|
9490 | * a setting text style.
|
9491 | */
|
9492 | message?: string;
|
9493 |
|
9494 | /**
|
9495 | * The icon path or {@link ThemeIcon} for the terminal.
|
9496 | */
|
9497 | iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
|
9498 | }
|
9499 |
|
9500 | /**
|
9501 | * Value-object describing what options a virtual process terminal should use.
|
9502 | */
|
9503 | export interface ExtensionTerminalOptions {
|
9504 | /**
|
9505 | * A human-readable string which will be used to represent the terminal in the UI.
|
9506 | */
|
9507 | name: string;
|
9508 |
|
9509 | /**
|
9510 | * An implementation of {@link Pseudoterminal} that allows an extension to
|
9511 | * control a terminal.
|
9512 | */
|
9513 | pty: Pseudoterminal;
|
9514 |
|
9515 | /**
|
9516 | * The icon path or {@link ThemeIcon} for the terminal.
|
9517 | */
|
9518 | iconPath?: Uri | { light: Uri; dark: Uri } | ThemeIcon;
|
9519 | }
|
9520 |
|
9521 | /**
|
9522 | * Defines the interface of a terminal pty, enabling extensions to control a terminal.
|
9523 | */
|
9524 | interface Pseudoterminal {
|
9525 | /**
|
9526 | * An event that when fired will write data to the terminal. Unlike
|
9527 | * {@link Terminal.sendText} which sends text to the underlying child
|
9528 | * pseudo-device (the child), this will write the text to parent pseudo-device (the
|
9529 | * _terminal_ itself).
|
9530 | *
|
9531 | * Note writing `\n` will just move the cursor down 1 row, you need to write `\r` as well
|
9532 | * to move the cursor to the left-most cell.
|
9533 | *
|
9534 | * **Example:** Write red text to the terminal
|
9535 | * ```typescript
|
9536 | * const writeEmitter = new vscode.EventEmitter<string>();
|
9537 | * const pty: vscode.Pseudoterminal = {
|
9538 | * onDidWrite: writeEmitter.event,
|
9539 | * open: () => writeEmitter.fire('\x1b[31mHello world\x1b[0m'),
|
9540 | * close: () => {}
|
9541 | * };
|
9542 | * vscode.window.createTerminal({ name: 'My terminal', pty });
|
9543 | * ```
|
9544 | *
|
9545 | * **Example:** Move the cursor to the 10th row and 20th column and write an asterisk
|
9546 | * ```typescript
|
9547 | * writeEmitter.fire('\x1b[10;20H*');
|
9548 | * ```
|
9549 | */
|
9550 | onDidWrite: Event<string>;
|
9551 |
|
9552 | /**
|
9553 | * An event that when fired allows overriding the {@link Pseudoterminal.setDimensions dimensions} of the
|
9554 | * terminal. Note that when set, the overridden dimensions will only take effect when they
|
9555 | * are lower than the actual dimensions of the terminal (ie. there will never be a scroll
|
9556 | * bar). Set to `undefined` for the terminal to go back to the regular dimensions (fit to
|
9557 | * the size of the panel).
|
9558 | *
|
9559 | * **Example:** Override the dimensions of a terminal to 20 columns and 10 rows
|
9560 | * ```typescript
|
9561 | * const dimensionsEmitter = new vscode.EventEmitter<vscode.TerminalDimensions>();
|
9562 | * const pty: vscode.Pseudoterminal = {
|
9563 | * onDidWrite: writeEmitter.event,
|
9564 | * onDidOverrideDimensions: dimensionsEmitter.event,
|
9565 | * open: () => {
|
9566 | * dimensionsEmitter.fire({
|
9567 | * columns: 20,
|
9568 | * rows: 10
|
9569 | * });
|
9570 | * },
|
9571 | * close: () => {}
|
9572 | * };
|
9573 | * vscode.window.createTerminal({ name: 'My terminal', pty });
|
9574 | * ```
|
9575 | */
|
9576 | onDidOverrideDimensions?: Event<TerminalDimensions | undefined>;
|
9577 |
|
9578 | /**
|
9579 | * An event that when fired will signal that the pty is closed and dispose of the terminal.
|
9580 | *
|
9581 | * A number can be used to provide an exit code for the terminal. Exit codes must be
|
9582 | * positive and a non-zero exit codes signals failure which shows a notification for a
|
9583 | * regular terminal and allows dependent tasks to proceed when used with the
|
9584 | * `CustomExecution` API.
|
9585 | *
|
9586 | * **Example:** Exit the terminal when "y" is pressed, otherwise show a notification.
|
9587 | * ```typescript
|
9588 | * const writeEmitter = new vscode.EventEmitter<string>();
|
9589 | * const closeEmitter = new vscode.EventEmitter<vscode.TerminalDimensions>();
|
9590 | * const pty: vscode.Pseudoterminal = {
|
9591 | * onDidWrite: writeEmitter.event,
|
9592 | * onDidClose: closeEmitter.event,
|
9593 | * open: () => writeEmitter.fire('Press y to exit successfully'),
|
9594 | * close: () => {},
|
9595 | * handleInput: data => {
|
9596 | * if (data !== 'y') {
|
9597 | * vscode.window.showInformationMessage('Something went wrong');
|
9598 | * }
|
9599 | * closeEmitter.fire();
|
9600 | * }
|
9601 | * };
|
9602 | * vscode.window.createTerminal({ name: 'Exit example', pty });
|
9603 | * ```
|
9604 | */
|
9605 | onDidClose?: Event<void | number>;
|
9606 |
|
9607 | /**
|
9608 | * An event that when fired allows changing the name of the terminal.
|
9609 | *
|
9610 | * **Example:** Change the terminal name to "My new terminal".
|
9611 | * ```typescript
|
9612 | * const writeEmitter = new vscode.EventEmitter<string>();
|
9613 | * const changeNameEmitter = new vscode.EventEmitter<string>();
|
9614 | * const pty: vscode.Pseudoterminal = {
|
9615 | * onDidWrite: writeEmitter.event,
|
9616 | * onDidChangeName: changeNameEmitter.event,
|
9617 | * open: () => changeNameEmitter.fire('My new terminal'),
|
9618 | * close: () => {}
|
9619 | * };
|
9620 | * vscode.window.createTerminal({ name: 'My terminal', pty });
|
9621 | * ```
|
9622 | */
|
9623 | onDidChangeName?: Event<string>;
|
9624 |
|
9625 | /**
|
9626 | * Implement to handle when the pty is open and ready to start firing events.
|
9627 | *
|
9628 | * @param initialDimensions The dimensions of the terminal, this will be undefined if the
|
9629 | * terminal panel has not been opened before this is called.
|
9630 | */
|
9631 | open(initialDimensions: TerminalDimensions | undefined): void;
|
9632 |
|
9633 | /**
|
9634 | * Implement to handle when the terminal is closed by an act of the user.
|
9635 | */
|
9636 | close(): void;
|
9637 |
|
9638 | /**
|
9639 | * Implement to handle incoming keystrokes in the terminal or when an extension calls
|
9640 | * {@link Terminal.sendText}. `data` contains the keystrokes/text serialized into
|
9641 | * their corresponding VT sequence representation.
|
9642 | *
|
9643 | * @param data The incoming data.
|
9644 | *
|
9645 | * **Example:** Echo input in the terminal. The sequence for enter (`\r`) is translated to
|
9646 | * CRLF to go to a new line and move the cursor to the start of the line.
|
9647 | * ```typescript
|
9648 | * const writeEmitter = new vscode.EventEmitter<string>();
|
9649 | * const pty: vscode.Pseudoterminal = {
|
9650 | * onDidWrite: writeEmitter.event,
|
9651 | * open: () => {},
|
9652 | * close: () => {},
|
9653 | * handleInput: data => writeEmitter.fire(data === '\r' ? '\r\n' : data)
|
9654 | * };
|
9655 | * vscode.window.createTerminal({ name: 'Local echo', pty });
|
9656 | * ```
|
9657 | */
|
9658 | handleInput?(data: string): void;
|
9659 |
|
9660 | /**
|
9661 | * Implement to handle when the number of rows and columns that fit into the terminal panel
|
9662 | * changes, for example when font size changes or when the panel is resized. The initial
|
9663 | * state of a terminal's dimensions should be treated as `undefined` until this is triggered
|
9664 | * as the size of a terminal isn't known until it shows up in the user interface.
|
9665 | *
|
9666 | * When dimensions are overridden by
|
9667 | * {@link Pseudoterminal.onDidOverrideDimensions onDidOverrideDimensions}, `setDimensions` will
|
9668 | * continue to be called with the regular panel dimensions, allowing the extension continue
|
9669 | * to react dimension changes.
|
9670 | *
|
9671 | * @param dimensions The new dimensions.
|
9672 | */
|
9673 | setDimensions?(dimensions: TerminalDimensions): void;
|
9674 | }
|
9675 |
|
9676 | /**
|
9677 | * Represents the dimensions of a terminal.
|
9678 | */
|
9679 | export interface TerminalDimensions {
|
9680 | /**
|
9681 | * The number of columns in the terminal.
|
9682 | */
|
9683 | readonly columns: number;
|
9684 |
|
9685 | /**
|
9686 | * The number of rows in the terminal.
|
9687 | */
|
9688 | readonly rows: number;
|
9689 | }
|
9690 |
|
9691 | /**
|
9692 | * Represents how a terminal exited.
|
9693 | */
|
9694 | export interface TerminalExitStatus {
|
9695 | /**
|
9696 | * The exit code that a terminal exited with, it can have the following values:
|
9697 | * - Zero: the terminal process or custom execution succeeded.
|
9698 | * - Non-zero: the terminal process or custom execution failed.
|
9699 | * - `undefined`: the user forcibly closed the terminal or a custom execution exited
|
9700 | * without providing an exit code.
|
9701 | */
|
9702 | readonly code: number | undefined;
|
9703 | }
|
9704 |
|
9705 | /**
|
9706 | * A type of mutation that can be applied to an environment variable.
|
9707 | */
|
9708 | export enum EnvironmentVariableMutatorType {
|
9709 | /**
|
9710 | * Replace the variable's existing value.
|
9711 | */
|
9712 | Replace = 1,
|
9713 | /**
|
9714 | * Append to the end of the variable's existing value.
|
9715 | */
|
9716 | Append = 2,
|
9717 | /**
|
9718 | * Prepend to the start of the variable's existing value.
|
9719 | */
|
9720 | Prepend = 3
|
9721 | }
|
9722 |
|
9723 | /**
|
9724 | * A type of mutation and its value to be applied to an environment variable.
|
9725 | */
|
9726 | export interface EnvironmentVariableMutator {
|
9727 | /**
|
9728 | * The type of mutation that will occur to the variable.
|
9729 | */
|
9730 | readonly type: EnvironmentVariableMutatorType;
|
9731 |
|
9732 | /**
|
9733 | * The value to use for the variable.
|
9734 | */
|
9735 | readonly value: string;
|
9736 | }
|
9737 |
|
9738 | /**
|
9739 | * A collection of mutations that an extension can apply to a process environment.
|
9740 | */
|
9741 | export interface EnvironmentVariableCollection {
|
9742 | /**
|
9743 | * Whether the collection should be cached for the workspace and applied to the terminal
|
9744 | * across window reloads. When true the collection will be active immediately such when the
|
9745 | * window reloads. Additionally, this API will return the cached version if it exists. The
|
9746 | * collection will be invalidated when the extension is uninstalled or when the collection
|
9747 | * is cleared. Defaults to true.
|
9748 | */
|
9749 | persistent: boolean;
|
9750 |
|
9751 | /**
|
9752 | * Replace an environment variable with a value.
|
9753 | *
|
9754 | * Note that an extension can only make a single change to any one variable, so this will
|
9755 | * overwrite any previous calls to replace, append or prepend.
|
9756 | *
|
9757 | * @param variable The variable to replace.
|
9758 | * @param value The value to replace the variable with.
|
9759 | */
|
9760 | replace(variable: string, value: string): void;
|
9761 |
|
9762 | /**
|
9763 | * Append a value to an environment variable.
|
9764 | *
|
9765 | * Note that an extension can only make a single change to any one variable, so this will
|
9766 | * overwrite any previous calls to replace, append or prepend.
|
9767 | *
|
9768 | * @param variable The variable to append to.
|
9769 | * @param value The value to append to the variable.
|
9770 | */
|
9771 | append(variable: string, value: string): void;
|
9772 |
|
9773 | /**
|
9774 | * Prepend a value to an environment variable.
|
9775 | *
|
9776 | * Note that an extension can only make a single change to any one variable, so this will
|
9777 | * overwrite any previous calls to replace, append or prepend.
|
9778 | *
|
9779 | * @param variable The variable to prepend.
|
9780 | * @param value The value to prepend to the variable.
|
9781 | */
|
9782 | prepend(variable: string, value: string): void;
|
9783 |
|
9784 | /**
|
9785 | * Gets the mutator that this collection applies to a variable, if any.
|
9786 | *
|
9787 | * @param variable The variable to get the mutator for.
|
9788 | */
|
9789 | get(variable: string): EnvironmentVariableMutator | undefined;
|
9790 |
|
9791 | /**
|
9792 | * Iterate over each mutator in this collection.
|
9793 | *
|
9794 | * @param callback Function to execute for each entry.
|
9795 | * @param thisArg The `this` context used when invoking the handler function.
|
9796 | */
|
9797 | forEach(callback: (variable: string, mutator: EnvironmentVariableMutator, collection: EnvironmentVariableCollection) => any, thisArg?: any): void;
|
9798 |
|
9799 | /**
|
9800 | * Deletes this collection's mutator for a variable.
|
9801 | *
|
9802 | * @param variable The variable to delete the mutator for.
|
9803 | */
|
9804 | delete(variable: string): void;
|
9805 |
|
9806 | /**
|
9807 | * Clears all mutators from this collection.
|
9808 | */
|
9809 | clear(): void;
|
9810 | }
|
9811 |
|
9812 | /**
|
9813 | * A location in the editor at which progress information can be shown. It depends on the
|
9814 | * location how progress is visually represented.
|
9815 | */
|
9816 | export enum ProgressLocation {
|
9817 |
|
9818 | /**
|
9819 | * Show progress for the source control viewlet, as overlay for the icon and as progress bar
|
9820 | * inside the viewlet (when visible). Neither supports cancellation nor discrete progress.
|
9821 | */
|
9822 | SourceControl = 1,
|
9823 |
|
9824 | /**
|
9825 | * Show progress in the status bar of the editor. Neither supports cancellation nor discrete progress.
|
9826 | */
|
9827 | Window = 10,
|
9828 |
|
9829 | /**
|
9830 | * Show progress as notification with an optional cancel button. Supports to show infinite and discrete progress.
|
9831 | */
|
9832 | Notification = 15
|
9833 | }
|
9834 |
|
9835 | /**
|
9836 | * Value-object describing where and how progress should show.
|
9837 | */
|
9838 | export interface ProgressOptions {
|
9839 |
|
9840 | /**
|
9841 | * The location at which progress should show.
|
9842 | */
|
9843 | location: ProgressLocation | { viewId: string };
|
9844 |
|
9845 | /**
|
9846 | * A human-readable string which will be used to describe the
|
9847 | * operation.
|
9848 | */
|
9849 | title?: string;
|
9850 |
|
9851 | /**
|
9852 | * Controls if a cancel button should show to allow the user to
|
9853 | * cancel the long running operation. Note that currently only
|
9854 | * `ProgressLocation.Notification` is supporting to show a cancel
|
9855 | * button.
|
9856 | */
|
9857 | cancellable?: boolean;
|
9858 | }
|
9859 |
|
9860 | /**
|
9861 | * A light-weight user input UI that is initially not visible. After
|
9862 | * configuring it through its properties the extension can make it
|
9863 | * visible by calling {@link QuickInput.show}.
|
9864 | *
|
9865 | * There are several reasons why this UI might have to be hidden and
|
9866 | * the extension will be notified through {@link QuickInput.onDidHide}.
|
9867 | * (Examples include: an explicit call to {@link QuickInput.hide},
|
9868 | * the user pressing Esc, some other input UI opening, etc.)
|
9869 | *
|
9870 | * A user pressing Enter or some other gesture implying acceptance
|
9871 | * of the current state does not automatically hide this UI component.
|
9872 | * It is up to the extension to decide whether to accept the user's input
|
9873 | * and if the UI should indeed be hidden through a call to {@link QuickInput.hide}.
|
9874 | *
|
9875 | * When the extension no longer needs this input UI, it should
|
9876 | * {@link QuickInput.dispose} it to allow for freeing up
|
9877 | * any resources associated with it.
|
9878 | *
|
9879 | * See {@link QuickPick} and {@link InputBox} for concrete UIs.
|
9880 | */
|
9881 | export interface QuickInput {
|
9882 |
|
9883 | /**
|
9884 | * An optional title.
|
9885 | */
|
9886 | title: string | undefined;
|
9887 |
|
9888 | /**
|
9889 | * An optional current step count.
|
9890 | */
|
9891 | step: number | undefined;
|
9892 |
|
9893 | /**
|
9894 | * An optional total step count.
|
9895 | */
|
9896 | totalSteps: number | undefined;
|
9897 |
|
9898 | /**
|
9899 | * If the UI should allow for user input. Defaults to true.
|
9900 | *
|
9901 | * Change this to false, e.g., while validating user input or
|
9902 | * loading data for the next step in user input.
|
9903 | */
|
9904 | enabled: boolean;
|
9905 |
|
9906 | /**
|
9907 | * If the UI should show a progress indicator. Defaults to false.
|
9908 | *
|
9909 | * Change this to true, e.g., while loading more data or validating
|
9910 | * user input.
|
9911 | */
|
9912 | busy: boolean;
|
9913 |
|
9914 | /**
|
9915 | * If the UI should stay open even when loosing UI focus. Defaults to false.
|
9916 | * This setting is ignored on iPad and is always false.
|
9917 | */
|
9918 | ignoreFocusOut: boolean;
|
9919 |
|
9920 | /**
|
9921 | * Makes the input UI visible in its current configuration. Any other input
|
9922 | * UI will first fire an {@link QuickInput.onDidHide} event.
|
9923 | */
|
9924 | show(): void;
|
9925 |
|
9926 | /**
|
9927 | * Hides this input UI. This will also fire an {@link QuickInput.onDidHide}
|
9928 | * event.
|
9929 | */
|
9930 | hide(): void;
|
9931 |
|
9932 | /**
|
9933 | * An event signaling when this input UI is hidden.
|
9934 | *
|
9935 | * There are several reasons why this UI might have to be hidden and
|
9936 | * the extension will be notified through {@link QuickInput.onDidHide}.
|
9937 | * (Examples include: an explicit call to {@link QuickInput.hide},
|
9938 | * the user pressing Esc, some other input UI opening, etc.)
|
9939 | */
|
9940 | onDidHide: Event<void>;
|
9941 |
|
9942 | /**
|
9943 | * Dispose of this input UI and any associated resources. If it is still
|
9944 | * visible, it is first hidden. After this call the input UI is no longer
|
9945 | * functional and no additional methods or properties on it should be
|
9946 | * accessed. Instead a new input UI should be created.
|
9947 | */
|
9948 | dispose(): void;
|
9949 | }
|
9950 |
|
9951 | /**
|
9952 | * A concrete {@link QuickInput} to let the user pick an item from a
|
9953 | * list of items of type T. The items can be filtered through a filter text field and
|
9954 | * there is an option {@link QuickPick.canSelectMany canSelectMany} to allow for
|
9955 | * selecting multiple items.
|
9956 | *
|
9957 | * Note that in many cases the more convenient {@link window.showQuickPick}
|
9958 | * is easier to use. {@link window.createQuickPick} should be used
|
9959 | * when {@link window.showQuickPick} does not offer the required flexibility.
|
9960 | */
|
9961 | export interface QuickPick<T extends QuickPickItem> extends QuickInput {
|
9962 |
|
9963 | /**
|
9964 | * Current value of the filter text.
|
9965 | */
|
9966 | value: string;
|
9967 |
|
9968 | /**
|
9969 | * Optional placeholder in the filter text.
|
9970 | */
|
9971 | placeholder: string | undefined;
|
9972 |
|
9973 | /**
|
9974 | * An event signaling when the value of the filter text has changed.
|
9975 | */
|
9976 | readonly onDidChangeValue: Event<string>;
|
9977 |
|
9978 | /**
|
9979 | * An event signaling when the user indicated acceptance of the selected item(s).
|
9980 | */
|
9981 | readonly onDidAccept: Event<void>;
|
9982 |
|
9983 | /**
|
9984 | * Buttons for actions in the UI.
|
9985 | */
|
9986 | buttons: readonly QuickInputButton[];
|
9987 |
|
9988 | /**
|
9989 | * An event signaling when a button was triggered.
|
9990 | */
|
9991 | readonly onDidTriggerButton: Event<QuickInputButton>;
|
9992 |
|
9993 | /**
|
9994 | * Items to pick from. This can be read and updated by the extension.
|
9995 | */
|
9996 | items: readonly T[];
|
9997 |
|
9998 | /**
|
9999 | * If multiple items can be selected at the same time. Defaults to false.
|
10000 | */
|
10001 | canSelectMany: boolean;
|
10002 |
|
10003 | /**
|
10004 | * If the filter text should also be matched against the description of the items. Defaults to false.
|
10005 | */
|
10006 | matchOnDescription: boolean;
|
10007 |
|
10008 | /**
|
10009 | * If the filter text should also be matched against the detail of the items. Defaults to false.
|
10010 | */
|
10011 | matchOnDetail: boolean;
|
10012 |
|
10013 | /**
|
10014 | * Active items. This can be read and updated by the extension.
|
10015 | */
|
10016 | activeItems: readonly T[];
|
10017 |
|
10018 | /**
|
10019 | * An event signaling when the active items have changed.
|
10020 | */
|
10021 | readonly onDidChangeActive: Event<readonly T[]>;
|
10022 |
|
10023 | /**
|
10024 | * Selected items. This can be read and updated by the extension.
|
10025 | */
|
10026 | selectedItems: readonly T[];
|
10027 |
|
10028 | /**
|
10029 | * An event signaling when the selected items have changed.
|
10030 | */
|
10031 | readonly onDidChangeSelection: Event<readonly T[]>;
|
10032 | }
|
10033 |
|
10034 | /**
|
10035 | * A concrete {@link QuickInput} to let the user input a text value.
|
10036 | *
|
10037 | * Note that in many cases the more convenient {@link window.showInputBox}
|
10038 | * is easier to use. {@link window.createInputBox} should be used
|
10039 | * when {@link window.showInputBox} does not offer the required flexibility.
|
10040 | */
|
10041 | export interface InputBox extends QuickInput {
|
10042 |
|
10043 | /**
|
10044 | * Current input value.
|
10045 | */
|
10046 | value: string;
|
10047 |
|
10048 | /**
|
10049 | * Optional placeholder in the filter text.
|
10050 | */
|
10051 | placeholder: string | undefined;
|
10052 |
|
10053 | /**
|
10054 | * If the input value should be hidden. Defaults to false.
|
10055 | */
|
10056 | password: boolean;
|
10057 |
|
10058 | /**
|
10059 | * An event signaling when the value has changed.
|
10060 | */
|
10061 | readonly onDidChangeValue: Event<string>;
|
10062 |
|
10063 | /**
|
10064 | * An event signaling when the user indicated acceptance of the input value.
|
10065 | */
|
10066 | readonly onDidAccept: Event<void>;
|
10067 |
|
10068 | /**
|
10069 | * Buttons for actions in the UI.
|
10070 | */
|
10071 | buttons: readonly QuickInputButton[];
|
10072 |
|
10073 | /**
|
10074 | * An event signaling when a button was triggered.
|
10075 | */
|
10076 | readonly onDidTriggerButton: Event<QuickInputButton>;
|
10077 |
|
10078 | /**
|
10079 | * An optional prompt text providing some ask or explanation to the user.
|
10080 | */
|
10081 | prompt: string | undefined;
|
10082 |
|
10083 | /**
|
10084 | * An optional validation message indicating a problem with the current input value.
|
10085 | */
|
10086 | validationMessage: string | undefined;
|
10087 | }
|
10088 |
|
10089 | /**
|
10090 | * Button for an action in a {@link QuickPick} or {@link InputBox}.
|
10091 | */
|
10092 | export interface QuickInputButton {
|
10093 |
|
10094 | /**
|
10095 | * Icon for the button.
|
10096 | */
|
10097 | readonly iconPath: Uri | { light: Uri; dark: Uri } | ThemeIcon;
|
10098 |
|
10099 | /**
|
10100 | * An optional tooltip.
|
10101 | */
|
10102 | readonly tooltip?: string | undefined;
|
10103 | }
|
10104 |
|
10105 | /**
|
10106 | * Predefined buttons for {@link QuickPick} and {@link InputBox}.
|
10107 | */
|
10108 | export class QuickInputButtons {
|
10109 |
|
10110 | /**
|
10111 | * A back button for {@link QuickPick} and {@link InputBox}.
|
10112 | *
|
10113 | * When a navigation 'back' button is needed this one should be used for consistency.
|
10114 | * It comes with a predefined icon, tooltip and location.
|
10115 | */
|
10116 | static readonly Back: QuickInputButton;
|
10117 |
|
10118 | /**
|
10119 | * @hidden
|
10120 | */
|
10121 | private constructor();
|
10122 | }
|
10123 |
|
10124 | /**
|
10125 | * An event describing an individual change in the text of a {document}.
TextDocument |
10126 | */
|
10127 | export interface TextDocumentContentChangeEvent {
|
10128 | /**
|
10129 | * The range that got replaced.
|
10130 | */
|
10131 | readonly range: Range;
|
10132 | /**
|
10133 | * The offset of the range that got replaced.
|
10134 | */
|
10135 | readonly rangeOffset: number;
|
10136 | /**
|
10137 | * The length of the range that got replaced.
|
10138 | */
|
10139 | readonly rangeLength: number;
|
10140 | /**
|
10141 | * The new text for the range.
|
10142 | */
|
10143 | readonly text: string;
|
10144 | }
|
10145 |
|
10146 | export enum TextDocumentChangeReason {
|
10147 | /** The text change is caused by an undo operation. */
|
10148 | Undo = 1,
|
10149 |
|
10150 | /** The text change is caused by an redo operation. */
|
10151 | Redo = 2,
|
10152 | }
|
10153 |
|
10154 | /**
|
10155 | * An event describing a transactional {@link TextDocument document} change.
|
10156 | */
|
10157 | export interface TextDocumentChangeEvent {
|
10158 |
|
10159 | /**
|
10160 | * The affected document.
|
10161 | */
|
10162 | readonly document: TextDocument;
|
10163 |
|
10164 | /**
|
10165 | * An array of content changes.
|
10166 | */
|
10167 | readonly contentChanges: readonly TextDocumentContentChangeEvent[];
|
10168 |
|
10169 | /**
|
10170 | * The reason why the document was changed.
|
10171 | * Is undefined if the reason is not known.
|
10172 | */
|
10173 | readonly reason?: TextDocumentChangeReason;
|
10174 | }
|
10175 |
|
10176 | /**
|
10177 | * Represents reasons why a text document is saved.
|
10178 | */
|
10179 | export enum TextDocumentSaveReason {
|
10180 |
|
10181 | /**
|
10182 | * Manually triggered, e.g. by the user pressing save, by starting debugging,
|
10183 | * or by an API call.
|
10184 | */
|
10185 | Manual = 1,
|
10186 |
|
10187 | /**
|
10188 | * Automatic after a delay.
|
10189 | */
|
10190 | AfterDelay = 2,
|
10191 |
|
10192 | /**
|
10193 | * When the editor lost focus.
|
10194 | */
|
10195 | FocusOut = 3
|
10196 | }
|
10197 |
|
10198 | /**
|
10199 | * An event that is fired when a {@link TextDocument document} will be saved.
|
10200 | *
|
10201 | * To make modifications to the document before it is being saved, call the
|
10202 | * {@link TextDocumentWillSaveEvent.waitUntil `waitUntil`}-function with a thenable
|
10203 | * that resolves to an array of {@link TextEdit text edits}.
|
10204 | */
|
10205 | export interface TextDocumentWillSaveEvent {
|
10206 |
|
10207 | /**
|
10208 | * The document that will be saved.
|
10209 | */
|
10210 | readonly document: TextDocument;
|
10211 |
|
10212 | /**
|
10213 | * The reason why save was triggered.
|
10214 | */
|
10215 | readonly reason: TextDocumentSaveReason;
|
10216 |
|
10217 | /**
|
10218 | * Allows to pause the event loop and to apply {@link TextEdit pre-save-edits}.
|
10219 | * Edits of subsequent calls to this function will be applied in order. The
|
10220 | * edits will be *ignored* if concurrent modifications of the document happened.
|
10221 | *
|
10222 | * *Note:* This function can only be called during event dispatch and not
|
10223 | * in an asynchronous manner:
|
10224 | *
|
10225 | * ```ts
|
10226 | * workspace.onWillSaveTextDocument(event => {
|
10227 | * // async, will *throw* an error
|
10228 | * setTimeout(() => event.waitUntil(promise));
|
10229 | *
|
10230 | * // sync, OK
|
10231 | * event.waitUntil(promise);
|
10232 | * })
|
10233 | * ```
|
10234 | *
|
10235 | * @param thenable A thenable that resolves to {@link TextEdit pre-save-edits}.
|
10236 | */
|
10237 | waitUntil(thenable: Thenable<TextEdit[]>): void;
|
10238 |
|
10239 | /**
|
10240 | * Allows to pause the event loop until the provided thenable resolved.
|
10241 | *
|
10242 | * *Note:* This function can only be called during event dispatch.
|
10243 | *
|
10244 | * @param thenable A thenable that delays saving.
|
10245 | */
|
10246 | waitUntil(thenable: Thenable<any>): void;
|
10247 | }
|
10248 |
|
10249 | /**
|
10250 | * An event that is fired when files are going to be created.
|
10251 | *
|
10252 | * To make modifications to the workspace before the files are created,
|
10253 | * call the {@link FileWillCreateEvent.waitUntil `waitUntil`}-function with a
|
10254 | * thenable that resolves to a {@link WorkspaceEdit workspace edit}.
|
10255 | */
|
10256 | export interface FileWillCreateEvent {
|
10257 |
|
10258 | /**
|
10259 | * The files that are going to be created.
|
10260 | */
|
10261 | readonly files: readonly Uri[];
|
10262 |
|
10263 | /**
|
10264 | * Allows to pause the event and to apply a {@link WorkspaceEdit workspace edit}.
|
10265 | *
|
10266 | * *Note:* This function can only be called during event dispatch and not
|
10267 | * in an asynchronous manner:
|
10268 | *
|
10269 | * ```ts
|
10270 | * workspace.onWillCreateFiles(event => {
|
10271 | * // async, will *throw* an error
|
10272 | * setTimeout(() => event.waitUntil(promise));
|
10273 | *
|
10274 | * // sync, OK
|
10275 | * event.waitUntil(promise);
|
10276 | * })
|
10277 | * ```
|
10278 | *
|
10279 | * @param thenable A thenable that delays saving.
|
10280 | */
|
10281 | waitUntil(thenable: Thenable<WorkspaceEdit>): void;
|
10282 |
|
10283 | /**
|
10284 | * Allows to pause the event until the provided thenable resolves.
|
10285 | *
|
10286 | * *Note:* This function can only be called during event dispatch.
|
10287 | *
|
10288 | * @param thenable A thenable that delays saving.
|
10289 | */
|
10290 | waitUntil(thenable: Thenable<any>): void;
|
10291 | }
|
10292 |
|
10293 | /**
|
10294 | * An event that is fired after files are created.
|
10295 | */
|
10296 | export interface FileCreateEvent {
|
10297 |
|
10298 | /**
|
10299 | * The files that got created.
|
10300 | */
|
10301 | readonly files: readonly Uri[];
|
10302 | }
|
10303 |
|
10304 | /**
|
10305 | * An event that is fired when files are going to be deleted.
|
10306 | *
|
10307 | * To make modifications to the workspace before the files are deleted,
|
10308 | * call the {@link FileWillCreateEvent.waitUntil `waitUntil}-function with a
|
10309 | * thenable that resolves to a {@link WorkspaceEdit workspace edit}.
|
10310 | */
|
10311 | export interface FileWillDeleteEvent {
|
10312 |
|
10313 | /**
|
10314 | * The files that are going to be deleted.
|
10315 | */
|
10316 | readonly files: readonly Uri[];
|
10317 |
|
10318 | /**
|
10319 | * Allows to pause the event and to apply a {@link WorkspaceEdit workspace edit}.
|
10320 | *
|
10321 | * *Note:* This function can only be called during event dispatch and not
|
10322 | * in an asynchronous manner:
|
10323 | *
|
10324 | * ```ts
|
10325 | * workspace.onWillCreateFiles(event => {
|
10326 | * // async, will *throw* an error
|
10327 | * setTimeout(() => event.waitUntil(promise));
|
10328 | *
|
10329 | * // sync, OK
|
10330 | * event.waitUntil(promise);
|
10331 | * })
|
10332 | * ```
|
10333 | *
|
10334 | * @param thenable A thenable that delays saving.
|
10335 | */
|
10336 | waitUntil(thenable: Thenable<WorkspaceEdit>): void;
|
10337 |
|
10338 | /**
|
10339 | * Allows to pause the event until the provided thenable resolves.
|
10340 | *
|
10341 | * *Note:* This function can only be called during event dispatch.
|
10342 | *
|
10343 | * @param thenable A thenable that delays saving.
|
10344 | */
|
10345 | waitUntil(thenable: Thenable<any>): void;
|
10346 | }
|
10347 |
|
10348 | /**
|
10349 | * An event that is fired after files are deleted.
|
10350 | */
|
10351 | export interface FileDeleteEvent {
|
10352 |
|
10353 | /**
|
10354 | * The files that got deleted.
|
10355 | */
|
10356 | readonly files: readonly Uri[];
|
10357 | }
|
10358 |
|
10359 | /**
|
10360 | * An event that is fired when files are going to be renamed.
|
10361 | *
|
10362 | * To make modifications to the workspace before the files are renamed,
|
10363 | * call the {@link FileWillCreateEvent.waitUntil `waitUntil}-function with a
|
10364 | * thenable that resolves to a {@link WorkspaceEdit workspace edit}.
|
10365 | */
|
10366 | export interface FileWillRenameEvent {
|
10367 |
|
10368 | /**
|
10369 | * The files that are going to be renamed.
|
10370 | */
|
10371 | readonly files: ReadonlyArray<{ readonly oldUri: Uri, readonly newUri: Uri }>;
|
10372 |
|
10373 | /**
|
10374 | * Allows to pause the event and to apply a {@link WorkspaceEdit workspace edit}.
|
10375 | *
|
10376 | * *Note:* This function can only be called during event dispatch and not
|
10377 | * in an asynchronous manner:
|
10378 | *
|
10379 | * ```ts
|
10380 | * workspace.onWillCreateFiles(event => {
|
10381 | * // async, will *throw* an error
|
10382 | * setTimeout(() => event.waitUntil(promise));
|
10383 | *
|
10384 | * // sync, OK
|
10385 | * event.waitUntil(promise);
|
10386 | * })
|
10387 | * ```
|
10388 | *
|
10389 | * @param thenable A thenable that delays saving.
|
10390 | */
|
10391 | waitUntil(thenable: Thenable<WorkspaceEdit>): void;
|
10392 |
|
10393 | /**
|
10394 | * Allows to pause the event until the provided thenable resolves.
|
10395 | *
|
10396 | * *Note:* This function can only be called during event dispatch.
|
10397 | *
|
10398 | * @param thenable A thenable that delays saving.
|
10399 | */
|
10400 | waitUntil(thenable: Thenable<any>): void;
|
10401 | }
|
10402 |
|
10403 | /**
|
10404 | * An event that is fired after files are renamed.
|
10405 | */
|
10406 | export interface FileRenameEvent {
|
10407 |
|
10408 | /**
|
10409 | * The files that got renamed.
|
10410 | */
|
10411 | readonly files: ReadonlyArray<{ readonly oldUri: Uri, readonly newUri: Uri }>;
|
10412 | }
|
10413 |
|
10414 | /**
|
10415 | * An event describing a change to the set of {@link workspace.workspaceFolders workspace folders}.
|
10416 | */
|
10417 | export interface WorkspaceFoldersChangeEvent {
|
10418 | /**
|
10419 | * Added workspace folders.
|
10420 | */
|
10421 | readonly added: readonly WorkspaceFolder[];
|
10422 |
|
10423 | /**
|
10424 | * Removed workspace folders.
|
10425 | */
|
10426 | readonly removed: readonly WorkspaceFolder[];
|
10427 | }
|
10428 |
|
10429 | /**
|
10430 | * A workspace folder is one of potentially many roots opened by the editor. All workspace folders
|
10431 | * are equal which means there is no notion of an active or primary workspace folder.
|
10432 | */
|
10433 | export interface WorkspaceFolder {
|
10434 |
|
10435 | /**
|
10436 | * The associated uri for this workspace folder.
|
10437 | *
|
10438 | * *Note:* The {@link Uri}-type was intentionally chosen such that future releases of the editor can support
|
10439 | * workspace folders that are not stored on the local disk, e.g. `ftp://server/workspaces/foo`.
|
10440 | */
|
10441 | readonly uri: Uri;
|
10442 |
|
10443 | /**
|
10444 | * The name of this workspace folder. Defaults to
|
10445 | * the basename of its {@link Uri.path uri-path}
|
10446 | */
|
10447 | readonly name: string;
|
10448 |
|
10449 | /**
|
10450 | * The ordinal number of this workspace folder.
|
10451 | */
|
10452 | readonly index: number;
|
10453 | }
|
10454 |
|
10455 | /**
|
10456 | * Namespace for dealing with the current workspace. A workspace is the collection of one
|
10457 | * or more folders that are opened in an editor window (instance).
|
10458 | *
|
10459 | * It is also possible to open an editor without a workspace. For example, when you open a
|
10460 | * new editor window by selecting a file from your platform's File menu, you will not be
|
10461 | * inside a workspace. In this mode, some of the editor's capabilities are reduced but you can
|
10462 | * still open text files and edit them.
|
10463 | *
|
10464 | * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information on
|
10465 | * the concept of workspaces.
|
10466 | *
|
10467 | * The workspace offers support for {@link workspace.createFileSystemWatcher listening} to fs
|
10468 | * events and for {@link workspace.findFiles finding} files. Both perform well and run _outside_
|
10469 | * the editor-process so that they should be always used instead of nodejs-equivalents.
|
10470 | */
|
10471 | export namespace workspace {
|
10472 |
|
10473 | /**
|
10474 | * A {@link FileSystem file system} instance that allows to interact with local and remote
|
10475 | * files, e.g. `vscode.workspace.fs.readDirectory(someUri)` allows to retrieve all entries
|
10476 | * of a directory or `vscode.workspace.fs.stat(anotherUri)` returns the meta data for a
|
10477 | * file.
|
10478 | */
|
10479 | export const fs: FileSystem;
|
10480 |
|
10481 | /**
|
10482 | * The workspace folder that is open in the editor. `undefined` when no workspace
|
10483 | * has been opened.
|
10484 | *
|
10485 | * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information
|
10486 | * on workspaces.
|
10487 | *
|
10488 | * @deprecated Use {@link workspace.workspaceFolders `workspaceFolders`} instead.
|
10489 | */
|
10490 | export const rootPath: string | undefined;
|
10491 |
|
10492 | /**
|
10493 | * List of workspace folders that are open in the editor. `undefined` when no workspace
|
10494 | * has been opened.
|
10495 | *
|
10496 | * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information
|
10497 | * on workspaces.
|
10498 | *
|
10499 | * *Note* that the first entry corresponds to the value of `rootPath`.
|
10500 | */
|
10501 | export const workspaceFolders: readonly WorkspaceFolder[] | undefined;
|
10502 |
|
10503 | /**
|
10504 | * The name of the workspace. `undefined` when no workspace
|
10505 | * has been opened.
|
10506 | *
|
10507 | * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information on
|
10508 | * the concept of workspaces.
|
10509 | */
|
10510 | export const name: string | undefined;
|
10511 |
|
10512 | /**
|
10513 | * The location of the workspace file, for example:
|
10514 | *
|
10515 | * `file:///Users/name/Development/myProject.code-workspace`
|
10516 | *
|
10517 | * or
|
10518 | *
|
10519 | * `untitled:1555503116870`
|
10520 | *
|
10521 | * for a workspace that is untitled and not yet saved.
|
10522 | *
|
10523 | * Depending on the workspace that is opened, the value will be:
|
10524 | * * `undefined` when no workspace is opened
|
10525 | * * the path of the workspace file as `Uri` otherwise. if the workspace
|
10526 | * is untitled, the returned URI will use the `untitled:` scheme
|
10527 | *
|
10528 | * The location can e.g. be used with the `vscode.openFolder` command to
|
10529 | * open the workspace again after it has been closed.
|
10530 | *
|
10531 | * **Example:**
|
10532 | * ```typescript
|
10533 | * vscode.commands.executeCommand('vscode.openFolder', uriOfWorkspace);
|
10534 | * ```
|
10535 | *
|
10536 | * Refer to https://code.visualstudio.com/docs/editor/workspaces for more information on
|
10537 | * the concept of workspaces.
|
10538 | *
|
10539 | * **Note:** it is not advised to use `workspace.workspaceFile` to write
|
10540 | * configuration data into the file. You can use `workspace.getConfiguration().update()`
|
10541 | * for that purpose which will work both when a single folder is opened as
|
10542 | * well as an untitled or saved workspace.
|
10543 | */
|
10544 | export const workspaceFile: Uri | undefined;
|
10545 |
|
10546 | /**
|
10547 | * An event that is emitted when a workspace folder is added or removed.
|
10548 | */
|
10549 | export const onDidChangeWorkspaceFolders: Event<WorkspaceFoldersChangeEvent>;
|
10550 |
|
10551 | /**
|
10552 | * Returns the {@link WorkspaceFolder workspace folder} that contains a given uri.
|
10553 | * * returns `undefined` when the given uri doesn't match any workspace folder
|
10554 | * * returns the *input* when the given uri is a workspace folder itself
|
10555 | *
|
10556 | * @param uri An uri.
|
10557 | * @return A workspace folder or `undefined`
|
10558 | */
|
10559 | export function getWorkspaceFolder(uri: Uri): WorkspaceFolder | undefined;
|
10560 |
|
10561 | /**
|
10562 | * Returns a path that is relative to the workspace folder or folders.
|
10563 | *
|
10564 | * When there are no {@link workspace.workspaceFolders workspace folders} or when the path
|
10565 | * is not contained in them, the input is returned.
|
10566 | *
|
10567 | * @param pathOrUri A path or uri. When a uri is given its {@link Uri.fsPath fsPath} is used.
|
10568 | * @param includeWorkspaceFolder When `true` and when the given path is contained inside a
|
10569 | * workspace folder the name of the workspace is prepended. Defaults to `true` when there are
|
10570 | * multiple workspace folders and `false` otherwise.
|
10571 | * @return A path relative to the root or the input.
|
10572 | */
|
10573 | export function asRelativePath(pathOrUri: string | Uri, includeWorkspaceFolder?: boolean): string;
|
10574 |
|
10575 | /**
|
10576 | * This method replaces `deleteCount` {@link workspace.workspaceFolders workspace folders} starting at index `start`
|
10577 | * by an optional set of `workspaceFoldersToAdd` on the `vscode.workspace.workspaceFolders` array. This "splice"
|
10578 | * behavior can be used to add, remove and change workspace folders in a single operation.
|
10579 | *
|
10580 | * If the first workspace folder is added, removed or changed, the currently executing extensions (including the
|
10581 | * one that called this method) will be terminated and restarted so that the (deprecated) `rootPath` property is
|
10582 | * updated to point to the first workspace folder.
|
10583 | *
|
10584 | * Use the {@link onDidChangeWorkspaceFolders `onDidChangeWorkspaceFolders()`} event to get notified when the
|
10585 | * workspace folders have been updated.
|
10586 | *
|
10587 | * **Example:** adding a new workspace folder at the end of workspace folders
|
10588 | * ```typescript
|
10589 | * workspace.updateWorkspaceFolders(workspace.workspaceFolders ? workspace.workspaceFolders.length : 0, null, { uri: ...});
|
10590 | * ```
|
10591 | *
|
10592 | * **Example:** removing the first workspace folder
|
10593 | * ```typescript
|
10594 | * workspace.updateWorkspaceFolders(0, 1);
|
10595 | * ```
|
10596 | *
|
10597 | * **Example:** replacing an existing workspace folder with a new one
|
10598 | * ```typescript
|
10599 | * workspace.updateWorkspaceFolders(0, 1, { uri: ...});
|
10600 | * ```
|
10601 | *
|
10602 | * It is valid to remove an existing workspace folder and add it again with a different name
|
10603 | * to rename that folder.
|
10604 | *
|
10605 | * **Note:** it is not valid to call {@link updateWorkspaceFolders updateWorkspaceFolders()} multiple times
|
10606 | * without waiting for the {@link onDidChangeWorkspaceFolders `onDidChangeWorkspaceFolders()`} to fire.
|
10607 | *
|
10608 | * @param start the zero-based location in the list of currently opened {@link WorkspaceFolder workspace folders}
|
10609 | * from which to start deleting workspace folders.
|
10610 | * @param deleteCount the optional number of workspace folders to remove.
|
10611 | * @param workspaceFoldersToAdd the optional variable set of workspace folders to add in place of the deleted ones.
|
10612 | * Each workspace is identified with a mandatory URI and an optional name.
|
10613 | * @return true if the operation was successfully started and false otherwise if arguments were used that would result
|
10614 | * in invalid workspace folder state (e.g. 2 folders with the same URI).
|
10615 | */
|
10616 | export function updateWorkspaceFolders(start: number, deleteCount: number | undefined | null, ...workspaceFoldersToAdd: { uri: Uri, name?: string }[]): boolean;
|
10617 |
|
10618 | /**
|
10619 | * Creates a file system watcher.
|
10620 | *
|
10621 | * A glob pattern that filters the file events on their absolute path must be provided. Optionally,
|
10622 | * flags to ignore certain kinds of events can be provided. To stop listening to events the watcher must be disposed.
|
10623 | *
|
10624 | * *Note* that only files within the current {@link workspace.workspaceFolders workspace folders} can be watched.
|
10625 | * *Note* that when watching for file changes such as '**/*.js', notifications will not be sent when a parent folder is
|
10626 | * moved or deleted (this is a known limitation of the current implementation and may change in the future).
|
10627 | *
|
10628 | * @param globPattern A {@link GlobPattern glob pattern} that is applied to the absolute paths of created, changed,
|
10629 | * and deleted files. Use a {@link RelativePattern relative pattern} to limit events to a certain {@link WorkspaceFolder workspace folder}.
|
10630 | * @param ignoreCreateEvents Ignore when files have been created.
|
10631 | * @param ignoreChangeEvents Ignore when files have been changed.
|
10632 | * @param ignoreDeleteEvents Ignore when files have been deleted.
|
10633 | * @return A new file system watcher instance.
|
10634 | */
|
10635 | export function createFileSystemWatcher(globPattern: GlobPattern, ignoreCreateEvents?: boolean, ignoreChangeEvents?: boolean, ignoreDeleteEvents?: boolean): FileSystemWatcher;
|
10636 |
|
10637 | /**
|
10638 | * Find files across all {@link workspace.workspaceFolders workspace folders} in the workspace.
|
10639 | *
|
10640 | * @example
|
10641 | * findFiles('**/*.js', '**/node_modules/**', 10)
|
10642 | *
|
10643 | * @param include A {@link GlobPattern glob pattern} that defines the files to search for. The glob pattern
|
10644 | * will be matched against the file paths of resulting matches relative to their workspace. Use a {@link RelativePattern relative pattern}
|
10645 | * to restrict the search results to a {@link WorkspaceFolder workspace folder}.
|
10646 | * @param exclude A {@link GlobPattern glob pattern} that defines files and folders to exclude. The glob pattern
|
10647 | * will be matched against the file paths of resulting matches relative to their workspace. When `undefined`, default excludes and the user's
|
10648 | * configured excludes will apply. When `null`, no excludes will apply.
|
10649 | * @param maxResults An upper-bound for the result.
|
10650 | * @param token A token that can be used to signal cancellation to the underlying search engine.
|
10651 | * @return A thenable that resolves to an array of resource identifiers. Will return no results if no
|
10652 | * {@link workspace.workspaceFolders workspace folders} are opened.
|
10653 | */
|
10654 | export function findFiles(include: GlobPattern, exclude?: GlobPattern | null, maxResults?: number, token?: CancellationToken): Thenable<Uri[]>;
|
10655 |
|
10656 | /**
|
10657 | * Save all dirty files.
|
10658 | *
|
10659 | * @param includeUntitled Also save files that have been created during this session.
|
10660 | * @return A thenable that resolves when the files have been saved.
|
10661 | */
|
10662 | export function saveAll(includeUntitled?: boolean): Thenable<boolean>;
|
10663 |
|
10664 | /**
|
10665 | * Make changes to one or many resources or create, delete, and rename resources as defined by the given
|
10666 | * {@link WorkspaceEdit workspace edit}.
|
10667 | *
|
10668 | * All changes of a workspace edit are applied in the same order in which they have been added. If
|
10669 | * multiple textual inserts are made at the same position, these strings appear in the resulting text
|
10670 | * in the order the 'inserts' were made, unless that are interleaved with resource edits. Invalid sequences
|
10671 | * like 'delete file a' -> 'insert text in file a' cause failure of the operation.
|
10672 | *
|
10673 | * When applying a workspace edit that consists only of text edits an 'all-or-nothing'-strategy is used.
|
10674 | * A workspace edit with resource creations or deletions aborts the operation, e.g. consecutive edits will
|
10675 | * not be attempted, when a single edit fails.
|
10676 | *
|
10677 | * @param edit A workspace edit.
|
10678 | * @return A thenable that resolves when the edit could be applied.
|
10679 | */
|
10680 | export function applyEdit(edit: WorkspaceEdit): Thenable<boolean>;
|
10681 |
|
10682 | /**
|
10683 | * All text documents currently known to the editor.
|
10684 | */
|
10685 | export const textDocuments: readonly TextDocument[];
|
10686 |
|
10687 | /**
|
10688 | * Opens a document. Will return early if this document is already open. Otherwise
|
10689 | * the document is loaded and the {@link workspace.onDidOpenTextDocument didOpen}-event fires.
|
10690 | *
|
10691 | * The document is denoted by an {@link Uri}. Depending on the {@link Uri.scheme scheme} the
|
10692 | * following rules apply:
|
10693 | * * `file`-scheme: Open a file on disk, will be rejected if the file does not exist or cannot be loaded.
|
10694 | * * `untitled`-scheme: A new file that should be saved on disk, e.g. `untitled:c:\frodo\new.js`. The language
|
10695 | * will be derived from the file name.
|
10696 | * * For all other schemes contributed {@link TextDocumentContentProvider text document content providers} and
|
10697 | * {@link FileSystemProvider file system providers} are consulted.
|
10698 | *
|
10699 | * *Note* that the lifecycle of the returned document is owned by the editor and not by the extension. That means an
|
10700 | * {@link workspace.onDidCloseTextDocument `onDidClose`}-event can occur at any time after opening it.
|
10701 | *
|
10702 | * @param uri Identifies the resource to open.
|
10703 | * @return A promise that resolves to a {@link TextDocument document}.
|
10704 | */
|
10705 | export function openTextDocument(uri: Uri): Thenable<TextDocument>;
|
10706 |
|
10707 | /**
|
10708 | * A short-hand for `openTextDocument(Uri.file(fileName))`.
|
10709 | *
|
10710 | * @see {@link openTextDocument}
|
10711 | * @param fileName A name of a file on disk.
|
10712 | * @return A promise that resolves to a {@link TextDocument document}.
|
10713 | */
|
10714 | export function openTextDocument(fileName: string): Thenable<TextDocument>;
|
10715 |
|
10716 | /**
|
10717 | * Opens an untitled text document. The editor will prompt the user for a file
|
10718 | * path when the document is to be saved. The `options` parameter allows to
|
10719 | * specify the *language* and/or the *content* of the document.
|
10720 | *
|
10721 | * @param options Options to control how the document will be created.
|
10722 | * @return A promise that resolves to a {@link TextDocument document}.
|
10723 | */
|
10724 | export function openTextDocument(options?: { language?: string; content?: string; }): Thenable<TextDocument>;
|
10725 |
|
10726 | /**
|
10727 | * Register a text document content provider.
|
10728 | *
|
10729 | * Only one provider can be registered per scheme.
|
10730 | *
|
10731 | * @param scheme The uri-scheme to register for.
|
10732 | * @param provider A content provider.
|
10733 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
10734 | */
|
10735 | export function registerTextDocumentContentProvider(scheme: string, provider: TextDocumentContentProvider): Disposable;
|
10736 |
|
10737 | /**
|
10738 | * An event that is emitted when a {@link TextDocument text document} is opened or when the language id
|
10739 | * of a text document {@link languages.setTextDocumentLanguage has been changed}.
|
10740 | *
|
10741 | * To add an event listener when a visible text document is opened, use the {@link TextEditor} events in the
|
10742 | * {@link window} namespace. Note that:
|
10743 | *
|
10744 | * - The event is emitted before the {@link TextDocument document} is updated in the
|
10745 | * {@link window.activeTextEditor active text editor}
|
10746 | * - When a {@link TextDocument text document} is already open (e.g.: open in another {@link window.visibleTextEditors visible text editor}) this event is not emitted
|
10747 | *
|
10748 | */
|
10749 | export const onDidOpenTextDocument: Event<TextDocument>;
|
10750 |
|
10751 | /**
|
10752 | * An event that is emitted when a {@link TextDocument text document} is disposed or when the language id
|
10753 | * of a text document {@link languages.setTextDocumentLanguage has been changed}.
|
10754 | *
|
10755 | * *Note 1:* There is no guarantee that this event fires when an editor tab is closed, use the
|
10756 | * {@link window.onDidChangeVisibleTextEditors `onDidChangeVisibleTextEditors`}-event to know when editors change.
|
10757 | *
|
10758 | * *Note 2:* A document can be open but not shown in an editor which means this event can fire
|
10759 | * for a document that has not been shown in an editor.
|
10760 | */
|
10761 | export const onDidCloseTextDocument: Event<TextDocument>;
|
10762 |
|
10763 | /**
|
10764 | * An event that is emitted when a {@link TextDocument text document} is changed. This usually happens
|
10765 | * when the {@link TextDocument.getText contents} changes but also when other things like the
|
10766 | * {@link TextDocument.isDirty dirty}-state changes.
|
10767 | */
|
10768 | export const onDidChangeTextDocument: Event<TextDocumentChangeEvent>;
|
10769 |
|
10770 | /**
|
10771 | * An event that is emitted when a {@link TextDocument text document} will be saved to disk.
|
10772 | *
|
10773 | * *Note 1:* Subscribers can delay saving by registering asynchronous work. For the sake of data integrity the editor
|
10774 | * might save without firing this event. For instance when shutting down with dirty files.
|
10775 | *
|
10776 | * *Note 2:* Subscribers are called sequentially and they can {@link TextDocumentWillSaveEvent.waitUntil delay} saving
|
10777 | * by registering asynchronous work. Protection against misbehaving listeners is implemented as such:
|
10778 | * * there is an overall time budget that all listeners share and if that is exhausted no further listener is called
|
10779 | * * listeners that take a long time or produce errors frequently will not be called anymore
|
10780 | *
|
10781 | * The current thresholds are 1.5 seconds as overall time budget and a listener can misbehave 3 times before being ignored.
|
10782 | */
|
10783 | export const onWillSaveTextDocument: Event<TextDocumentWillSaveEvent>;
|
10784 |
|
10785 | /**
|
10786 | * An event that is emitted when a {@link TextDocument text document} is saved to disk.
|
10787 | */
|
10788 | export const onDidSaveTextDocument: Event<TextDocument>;
|
10789 |
|
10790 | /**
|
10791 | * All notebook documents currently known to the editor.
|
10792 | */
|
10793 | export const notebookDocuments: readonly NotebookDocument[];
|
10794 |
|
10795 | /**
|
10796 | * Open a notebook. Will return early if this notebook is already {@link notebook.notebookDocuments loaded}. Otherwise
|
10797 | * the notebook is loaded and the {@link notebook.onDidOpenNotebookDocument `onDidOpenNotebookDocument`}-event fires.
|
10798 | *
|
10799 | * *Note* that the lifecycle of the returned notebook is owned by the editor and not by the extension. That means an
|
10800 | * {@link notebook.onDidCloseNotebookDocument `onDidCloseNotebookDocument`}-event can occur at any time after.
|
10801 | *
|
10802 | * *Note* that opening a notebook does not show a notebook editor. This function only returns a notebook document which
|
10803 | * can be showns in a notebook editor but it can also be used for other things.
|
10804 | *
|
10805 | * @param uri The resource to open.
|
10806 | * @returns A promise that resolves to a {@link NotebookDocument notebook}
|
10807 | */
|
10808 | export function openNotebookDocument(uri: Uri): Thenable<NotebookDocument>;
|
10809 |
|
10810 | /**
|
10811 | * Open an untitled notebook. The editor will prompt the user for a file
|
10812 | * path when the document is to be saved.
|
10813 | *
|
10814 | * @see {@link openNotebookDocument}
|
10815 | * @param notebookType The notebook type that should be used.
|
10816 | * @param content The initial contents of the notebook.
|
10817 | * @returns A promise that resolves to a {@link NotebookDocument notebook}.
|
10818 | */
|
10819 | export function openNotebookDocument(notebookType: string, content?: NotebookData): Thenable<NotebookDocument>;
|
10820 |
|
10821 | /**
|
10822 | * Register a {@link NotebookSerializer notebook serializer}.
|
10823 | *
|
10824 | * A notebook serializer must be contributed through the `notebooks` extension point. When opening a notebook file, the editor will send
|
10825 | * the `onNotebook:<notebookType>` activation event, and extensions must register their serializer in return.
|
10826 | *
|
10827 | * @param notebookType A notebook.
|
10828 | * @param serializer A notebook serialzier.
|
10829 | * @param options Optional context options that define what parts of a notebook should be persisted
|
10830 | * @return A {@link Disposable} that unregisters this serializer when being disposed.
|
10831 | */
|
10832 | export function registerNotebookSerializer(notebookType: string, serializer: NotebookSerializer, options?: NotebookDocumentContentOptions): Disposable;
|
10833 |
|
10834 | /**
|
10835 | * An event that is emitted when a {@link NotebookDocument notebook} is opened.
|
10836 | */
|
10837 | export const onDidOpenNotebookDocument: Event<NotebookDocument>;
|
10838 |
|
10839 | /**
|
10840 | * An event that is emitted when a {@link NotebookDocument notebook} is disposed.
|
10841 | *
|
10842 | * *Note 1:* There is no guarantee that this event fires when an editor tab is closed.
|
10843 | *
|
10844 | * *Note 2:* A notebook can be open but not shown in an editor which means this event can fire
|
10845 | * for a notebook that has not been shown in an editor.
|
10846 | */
|
10847 | export const onDidCloseNotebookDocument: Event<NotebookDocument>;
|
10848 |
|
10849 | /**
|
10850 | * An event that is emitted when files are being created.
|
10851 | *
|
10852 | * *Note 1:* This event is triggered by user gestures, like creating a file from the
|
10853 | * explorer, or from the {@link workspace.applyEdit `workspace.applyEdit`}-api. This event is *not* fired when
|
10854 | * files change on disk, e.g triggered by another application, or when using the
|
10855 | * {@link FileSystem `workspace.fs`}-api.
|
10856 | *
|
10857 | * *Note 2:* When this event is fired, edits to files that are are being created cannot be applied.
|
10858 | */
|
10859 | export const onWillCreateFiles: Event<FileWillCreateEvent>;
|
10860 |
|
10861 | /**
|
10862 | * An event that is emitted when files have been created.
|
10863 | *
|
10864 | * *Note:* This event is triggered by user gestures, like creating a file from the
|
10865 | * explorer, or from the {@link workspace.applyEdit `workspace.applyEdit`}-api, but this event is *not* fired when
|
10866 | * files change on disk, e.g triggered by another application, or when using the
|
10867 | * {@link FileSystem `workspace.fs`}-api.
|
10868 | */
|
10869 | export const onDidCreateFiles: Event<FileCreateEvent>;
|
10870 |
|
10871 | /**
|
10872 | * An event that is emitted when files are being deleted.
|
10873 | *
|
10874 | * *Note 1:* This event is triggered by user gestures, like deleting a file from the
|
10875 | * explorer, or from the {@link workspace.applyEdit `workspace.applyEdit`}-api, but this event is *not* fired when
|
10876 | * files change on disk, e.g triggered by another application, or when using the
|
10877 | * {@link FileSystem `workspace.fs`}-api.
|
10878 | *
|
10879 | * *Note 2:* When deleting a folder with children only one event is fired.
|
10880 | */
|
10881 | export const onWillDeleteFiles: Event<FileWillDeleteEvent>;
|
10882 |
|
10883 | /**
|
10884 | * An event that is emitted when files have been deleted.
|
10885 | *
|
10886 | * *Note 1:* This event is triggered by user gestures, like deleting a file from the
|
10887 | * explorer, or from the {@link workspace.applyEdit `workspace.applyEdit`}-api, but this event is *not* fired when
|
10888 | * files change on disk, e.g triggered by another application, or when using the
|
10889 | * {@link FileSystem `workspace.fs`}-api.
|
10890 | *
|
10891 | * *Note 2:* When deleting a folder with children only one event is fired.
|
10892 | */
|
10893 | export const onDidDeleteFiles: Event<FileDeleteEvent>;
|
10894 |
|
10895 | /**
|
10896 | * An event that is emitted when files are being renamed.
|
10897 | *
|
10898 | * *Note 1:* This event is triggered by user gestures, like renaming a file from the
|
10899 | * explorer, and from the {@link workspace.applyEdit `workspace.applyEdit`}-api, but this event is *not* fired when
|
10900 | * files change on disk, e.g triggered by another application, or when using the
|
10901 | * {@link FileSystem `workspace.fs`}-api.
|
10902 | *
|
10903 | * *Note 2:* When renaming a folder with children only one event is fired.
|
10904 | */
|
10905 | export const onWillRenameFiles: Event<FileWillRenameEvent>;
|
10906 |
|
10907 | /**
|
10908 | * An event that is emitted when files have been renamed.
|
10909 | *
|
10910 | * *Note 1:* This event is triggered by user gestures, like renaming a file from the
|
10911 | * explorer, and from the {@link workspace.applyEdit `workspace.applyEdit`}-api, but this event is *not* fired when
|
10912 | * files change on disk, e.g triggered by another application, or when using the
|
10913 | * {@link FileSystem `workspace.fs`}-api.
|
10914 | *
|
10915 | * *Note 2:* When renaming a folder with children only one event is fired.
|
10916 | */
|
10917 | export const onDidRenameFiles: Event<FileRenameEvent>;
|
10918 |
|
10919 | /**
|
10920 | * Get a workspace configuration object.
|
10921 | *
|
10922 | * When a section-identifier is provided only that part of the configuration
|
10923 | * is returned. Dots in the section-identifier are interpreted as child-access,
|
10924 | * like `{ myExt: { setting: { doIt: true }}}` and `getConfiguration('myExt.setting').get('doIt') === true`.
|
10925 | *
|
10926 | * When a scope is provided configuration confined to that scope is returned. Scope can be a resource or a language identifier or both.
|
10927 | *
|
10928 | * @param section A dot-separated identifier.
|
10929 | * @param scope A scope for which the configuration is asked for.
|
10930 | * @return The full configuration or a subset.
|
10931 | */
|
10932 | export function getConfiguration(section?: string, scope?: ConfigurationScope | null): WorkspaceConfiguration;
|
10933 |
|
10934 | /**
|
10935 | * An event that is emitted when the {@link WorkspaceConfiguration configuration} changed.
|
10936 | */
|
10937 | export const onDidChangeConfiguration: Event<ConfigurationChangeEvent>;
|
10938 |
|
10939 | /**
|
10940 | * Register a task provider.
|
10941 | *
|
10942 | * @deprecated Use the corresponding function on the `tasks` namespace instead
|
10943 | *
|
10944 | * @param type The task kind type this provider is registered for.
|
10945 | * @param provider A task provider.
|
10946 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
10947 | */
|
10948 | export function registerTaskProvider(type: string, provider: TaskProvider): Disposable;
|
10949 |
|
10950 | /**
|
10951 | * Register a filesystem provider for a given scheme, e.g. `ftp`.
|
10952 | *
|
10953 | * There can only be one provider per scheme and an error is being thrown when a scheme
|
10954 | * has been claimed by another provider or when it is reserved.
|
10955 | *
|
10956 | * @param scheme The uri-{@link Uri.scheme scheme} the provider registers for.
|
10957 | * @param provider The filesystem provider.
|
10958 | * @param options Immutable metadata about the provider.
|
10959 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
10960 | */
|
10961 | export function registerFileSystemProvider(scheme: string, provider: FileSystemProvider, options?: { readonly isCaseSensitive?: boolean, readonly isReadonly?: boolean }): Disposable;
|
10962 |
|
10963 | /**
|
10964 | * When true, the user has explicitly trusted the contents of the workspace.
|
10965 | */
|
10966 | export const isTrusted: boolean;
|
10967 |
|
10968 | /**
|
10969 | * Event that fires when the current workspace has been trusted.
|
10970 | */
|
10971 | export const onDidGrantWorkspaceTrust: Event<void>;
|
10972 | }
|
10973 |
|
10974 | /**
|
10975 | * The configuration scope which can be a
|
10976 | * a 'resource' or a languageId or both or
|
10977 | * a '{@link TextDocument}' or
|
10978 | * a '{@link WorkspaceFolder}'
|
10979 | */
|
10980 | export type ConfigurationScope = Uri | TextDocument | WorkspaceFolder | { uri?: Uri, languageId: string };
|
10981 |
|
10982 | /**
|
10983 | * An event describing the change in Configuration
|
10984 | */
|
10985 | export interface ConfigurationChangeEvent {
|
10986 |
|
10987 | /**
|
10988 | * Checks if the given section has changed.
|
10989 | * If scope is provided, checks if the section has changed for resources under the given scope.
|
10990 | *
|
10991 | * @param section Configuration name, supports _dotted_ names.
|
10992 | * @param scope A scope in which to check.
|
10993 | * @return `true` if the given section has changed.
|
10994 | */
|
10995 | affectsConfiguration(section: string, scope?: ConfigurationScope): boolean;
|
10996 | }
|
10997 |
|
10998 | /**
|
10999 | * Namespace for participating in language-specific editor [features](https://code.visualstudio.com/docs/editor/editingevolved),
|
11000 | * like IntelliSense, code actions, diagnostics etc.
|
11001 | *
|
11002 | * Many programming languages exist and there is huge variety in syntaxes, semantics, and paradigms. Despite that, features
|
11003 | * like automatic word-completion, code navigation, or code checking have become popular across different tools for different
|
11004 | * programming languages.
|
11005 | *
|
11006 | * The editor provides an API that makes it simple to provide such common features by having all UI and actions already in place and
|
11007 | * by allowing you to participate by providing data only. For instance, to contribute a hover all you have to do is provide a function
|
11008 | * that can be called with a {@link TextDocument} and a {@link Position} returning hover info. The rest, like tracking the
|
11009 | * mouse, positioning the hover, keeping the hover stable etc. is taken care of by the editor.
|
11010 | *
|
11011 | * ```javascript
|
11012 | * languages.registerHoverProvider('javascript', {
|
11013 | * provideHover(document, position, token) {
|
11014 | * return new Hover('I am a hover!');
|
11015 | * }
|
11016 | * });
|
11017 | * ```
|
11018 | *
|
11019 | * Registration is done using a {@link DocumentSelector document selector} which is either a language id, like `javascript` or
|
11020 | * a more complex {@link DocumentFilter filter} like `{ language: 'typescript', scheme: 'file' }`. Matching a document against such
|
11021 | * a selector will result in a {@link languages.match score} that is used to determine if and how a provider shall be used. When
|
11022 | * scores are equal the provider that came last wins. For features that allow full arity, like {@link languages.registerHoverProvider hover},
|
11023 | * the score is only checked to be `>0`, for other features, like {@link languages.registerCompletionItemProvider IntelliSense} the
|
11024 | * score is used for determining the order in which providers are asked to participate.
|
11025 | */
|
11026 | export namespace languages {
|
11027 |
|
11028 | /**
|
11029 | * Return the identifiers of all known languages.
|
11030 | * @return Promise resolving to an array of identifier strings.
|
11031 | */
|
11032 | export function getLanguages(): Thenable<string[]>;
|
11033 |
|
11034 | /**
|
11035 | * Set (and change) the {@link TextDocument.languageId language} that is associated
|
11036 | * with the given document.
|
11037 | *
|
11038 | * *Note* that calling this function will trigger the {@link workspace.onDidCloseTextDocument `onDidCloseTextDocument`} event
|
11039 | * followed by the {@link workspace.onDidOpenTextDocument `onDidOpenTextDocument`} event.
|
11040 | *
|
11041 | * @param document The document which language is to be changed
|
11042 | * @param languageId The new language identifier.
|
11043 | * @returns A thenable that resolves with the updated document.
|
11044 | */
|
11045 | export function setTextDocumentLanguage(document: TextDocument, languageId: string): Thenable<TextDocument>;
|
11046 |
|
11047 | /**
|
11048 | * Compute the match between a document {@link DocumentSelector selector} and a document. Values
|
11049 | * greater than zero mean the selector matches the document.
|
11050 | *
|
11051 | * A match is computed according to these rules:
|
11052 | * 1. When {@link DocumentSelector `DocumentSelector`} is an array, compute the match for each contained `DocumentFilter` or language identifier and take the maximum value.
|
11053 | * 2. A string will be desugared to become the `language`-part of a {@link DocumentFilter `DocumentFilter`}, so `"fooLang"` is like `{ language: "fooLang" }`.
|
11054 | * 3. A {@link DocumentFilter `DocumentFilter`} will be matched against the document by comparing its parts with the document. The following rules apply:
|
11055 | * 1. When the `DocumentFilter` is empty (`{}`) the result is `0`
|
11056 | * 2. When `scheme`, `language`, or `pattern` are defined but one doesn’t match, the result is `0`
|
11057 | * 3. Matching against `*` gives a score of `5`, matching via equality or via a glob-pattern gives a score of `10`
|
11058 | * 4. The result is the maximum value of each match
|
11059 | *
|
11060 | * Samples:
|
11061 | * ```js
|
11062 | * // default document from disk (file-scheme)
|
11063 | * doc.uri; //'file:///my/file.js'
|
11064 | * doc.languageId; // 'javascript'
|
11065 | * match('javascript', doc); // 10;
|
11066 | * match({language: 'javascript'}, doc); // 10;
|
11067 | * match({language: 'javascript', scheme: 'file'}, doc); // 10;
|
11068 | * match('*', doc); // 5
|
11069 | * match('fooLang', doc); // 0
|
11070 | * match(['fooLang', '*'], doc); // 5
|
11071 | *
|
11072 | * // virtual document, e.g. from git-index
|
11073 | * doc.uri; // 'git:/my/file.js'
|
11074 | * doc.languageId; // 'javascript'
|
11075 | * match('javascript', doc); // 10;
|
11076 | * match({language: 'javascript', scheme: 'git'}, doc); // 10;
|
11077 | * match('*', doc); // 5
|
11078 | * ```
|
11079 | *
|
11080 | * @param selector A document selector.
|
11081 | * @param document A text document.
|
11082 | * @return A number `>0` when the selector matches and `0` when the selector does not match.
|
11083 | */
|
11084 | export function match(selector: DocumentSelector, document: TextDocument): number;
|
11085 |
|
11086 | /**
|
11087 | * An {@link Event} which fires when the global set of diagnostics changes. This is
|
11088 | * newly added and removed diagnostics.
|
11089 | */
|
11090 | export const onDidChangeDiagnostics: Event<DiagnosticChangeEvent>;
|
11091 |
|
11092 | /**
|
11093 | * Get all diagnostics for a given resource.
|
11094 | *
|
11095 | * @param resource A resource
|
11096 | * @returns An array of {@link Diagnostic diagnostics} objects or an empty array.
|
11097 | */
|
11098 | export function getDiagnostics(resource: Uri): Diagnostic[];
|
11099 |
|
11100 | /**
|
11101 | * Get all diagnostics.
|
11102 | *
|
11103 | * @returns An array of uri-diagnostics tuples or an empty array.
|
11104 | */
|
11105 | export function getDiagnostics(): [Uri, Diagnostic[]][];
|
11106 |
|
11107 | /**
|
11108 | * Create a diagnostics collection.
|
11109 | *
|
11110 | * @param name The {@link DiagnosticCollection.name name} of the collection.
|
11111 | * @return A new diagnostic collection.
|
11112 | */
|
11113 | export function createDiagnosticCollection(name?: string): DiagnosticCollection;
|
11114 |
|
11115 | /**
|
11116 | * Register a completion provider.
|
11117 | *
|
11118 | * Multiple providers can be registered for a language. In that case providers are sorted
|
11119 | * by their {@link languages.match score} and groups of equal score are sequentially asked for
|
11120 | * completion items. The process stops when one or many providers of a group return a
|
11121 | * result. A failing provider (rejected promise or exception) will not fail the whole
|
11122 | * operation.
|
11123 | *
|
11124 | * A completion item provider can be associated with a set of `triggerCharacters`. When trigger
|
11125 | * characters are being typed, completions are requested but only from providers that registered
|
11126 | * the typed character. Because of that trigger characters should be different than {@link LanguageConfiguration.wordPattern word characters},
|
11127 | * a common trigger character is `.` to trigger member completions.
|
11128 | *
|
11129 | * @param selector A selector that defines the documents this provider is applicable to.
|
11130 | * @param provider A completion provider.
|
11131 | * @param triggerCharacters Trigger completion when the user types one of the characters.
|
11132 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11133 | */
|
11134 | export function registerCompletionItemProvider(selector: DocumentSelector, provider: CompletionItemProvider, ...triggerCharacters: string[]): Disposable;
|
11135 |
|
11136 | /**
|
11137 | * Register a code action provider.
|
11138 | *
|
11139 | * Multiple providers can be registered for a language. In that case providers are asked in
|
11140 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
11141 | * not cause a failure of the whole operation.
|
11142 | *
|
11143 | * @param selector A selector that defines the documents this provider is applicable to.
|
11144 | * @param provider A code action provider.
|
11145 | * @param metadata Metadata about the kind of code actions the provider provides.
|
11146 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11147 | */
|
11148 | export function registerCodeActionsProvider(selector: DocumentSelector, provider: CodeActionProvider, metadata?: CodeActionProviderMetadata): Disposable;
|
11149 |
|
11150 | /**
|
11151 | * Register a code lens provider.
|
11152 | *
|
11153 | * Multiple providers can be registered for a language. In that case providers are asked in
|
11154 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
11155 | * not cause a failure of the whole operation.
|
11156 | *
|
11157 | * @param selector A selector that defines the documents this provider is applicable to.
|
11158 | * @param provider A code lens provider.
|
11159 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11160 | */
|
11161 | export function registerCodeLensProvider(selector: DocumentSelector, provider: CodeLensProvider): Disposable;
|
11162 |
|
11163 | /**
|
11164 | * Register a definition provider.
|
11165 | *
|
11166 | * Multiple providers can be registered for a language. In that case providers are asked in
|
11167 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
11168 | * not cause a failure of the whole operation.
|
11169 | *
|
11170 | * @param selector A selector that defines the documents this provider is applicable to.
|
11171 | * @param provider A definition provider.
|
11172 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11173 | */
|
11174 | export function registerDefinitionProvider(selector: DocumentSelector, provider: DefinitionProvider): Disposable;
|
11175 |
|
11176 | /**
|
11177 | * Register an implementation provider.
|
11178 | *
|
11179 | * Multiple providers can be registered for a language. In that case providers are asked in
|
11180 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
11181 | * not cause a failure of the whole operation.
|
11182 | *
|
11183 | * @param selector A selector that defines the documents this provider is applicable to.
|
11184 | * @param provider An implementation provider.
|
11185 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11186 | */
|
11187 | export function registerImplementationProvider(selector: DocumentSelector, provider: ImplementationProvider): Disposable;
|
11188 |
|
11189 | /**
|
11190 | * Register a type definition provider.
|
11191 | *
|
11192 | * Multiple providers can be registered for a language. In that case providers are asked in
|
11193 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
11194 | * not cause a failure of the whole operation.
|
11195 | *
|
11196 | * @param selector A selector that defines the documents this provider is applicable to.
|
11197 | * @param provider A type definition provider.
|
11198 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11199 | */
|
11200 | export function registerTypeDefinitionProvider(selector: DocumentSelector, provider: TypeDefinitionProvider): Disposable;
|
11201 |
|
11202 | /**
|
11203 | * Register a declaration provider.
|
11204 | *
|
11205 | * Multiple providers can be registered for a language. In that case providers are asked in
|
11206 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
11207 | * not cause a failure of the whole operation.
|
11208 | *
|
11209 | * @param selector A selector that defines the documents this provider is applicable to.
|
11210 | * @param provider A declaration provider.
|
11211 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11212 | */
|
11213 | export function registerDeclarationProvider(selector: DocumentSelector, provider: DeclarationProvider): Disposable;
|
11214 |
|
11215 | /**
|
11216 | * Register a hover provider.
|
11217 | *
|
11218 | * Multiple providers can be registered for a language. In that case providers are asked in
|
11219 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
11220 | * not cause a failure of the whole operation.
|
11221 | *
|
11222 | * @param selector A selector that defines the documents this provider is applicable to.
|
11223 | * @param provider A hover provider.
|
11224 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11225 | */
|
11226 | export function registerHoverProvider(selector: DocumentSelector, provider: HoverProvider): Disposable;
|
11227 |
|
11228 | /**
|
11229 | * Register a provider that locates evaluatable expressions in text documents.
|
11230 | * The editor will evaluate the expression in the active debug session and will show the result in the debug hover.
|
11231 | *
|
11232 | * If multiple providers are registered for a language an arbitrary provider will be used.
|
11233 | *
|
11234 | * @param selector A selector that defines the documents this provider is applicable to.
|
11235 | * @param provider An evaluatable expression provider.
|
11236 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11237 | */
|
11238 | export function registerEvaluatableExpressionProvider(selector: DocumentSelector, provider: EvaluatableExpressionProvider): Disposable;
|
11239 |
|
11240 | /**
|
11241 | * Register a provider that returns data for the debugger's 'inline value' feature.
|
11242 | * Whenever the generic debugger has stopped in a source file, providers registered for the language of the file
|
11243 | * are called to return textual data that will be shown in the editor at the end of lines.
|
11244 | *
|
11245 | * Multiple providers can be registered for a language. In that case providers are asked in
|
11246 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
11247 | * not cause a failure of the whole operation.
|
11248 | *
|
11249 | * @param selector A selector that defines the documents this provider is applicable to.
|
11250 | * @param provider An inline values provider.
|
11251 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11252 | */
|
11253 | export function registerInlineValuesProvider(selector: DocumentSelector, provider: InlineValuesProvider): Disposable;
|
11254 |
|
11255 | /**
|
11256 | * Register a document highlight provider.
|
11257 | *
|
11258 | * Multiple providers can be registered for a language. In that case providers are sorted
|
11259 | * by their {@link languages.match score} and groups sequentially asked for document highlights.
|
11260 | * The process stops when a provider returns a `non-falsy` or `non-failure` result.
|
11261 | *
|
11262 | * @param selector A selector that defines the documents this provider is applicable to.
|
11263 | * @param provider A document highlight provider.
|
11264 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11265 | */
|
11266 | export function registerDocumentHighlightProvider(selector: DocumentSelector, provider: DocumentHighlightProvider): Disposable;
|
11267 |
|
11268 | /**
|
11269 | * Register a document symbol provider.
|
11270 | *
|
11271 | * Multiple providers can be registered for a language. In that case providers are asked in
|
11272 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
11273 | * not cause a failure of the whole operation.
|
11274 | *
|
11275 | * @param selector A selector that defines the documents this provider is applicable to.
|
11276 | * @param provider A document symbol provider.
|
11277 | * @param metaData metadata about the provider
|
11278 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11279 | */
|
11280 | export function registerDocumentSymbolProvider(selector: DocumentSelector, provider: DocumentSymbolProvider, metaData?: DocumentSymbolProviderMetadata): Disposable;
|
11281 |
|
11282 | /**
|
11283 | * Register a workspace symbol provider.
|
11284 | *
|
11285 | * Multiple providers can be registered. In that case providers are asked in parallel and
|
11286 | * the results are merged. A failing provider (rejected promise or exception) will not cause
|
11287 | * a failure of the whole operation.
|
11288 | *
|
11289 | * @param provider A workspace symbol provider.
|
11290 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11291 | */
|
11292 | export function registerWorkspaceSymbolProvider(provider: WorkspaceSymbolProvider): Disposable;
|
11293 |
|
11294 | /**
|
11295 | * Register a reference provider.
|
11296 | *
|
11297 | * Multiple providers can be registered for a language. In that case providers are asked in
|
11298 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
11299 | * not cause a failure of the whole operation.
|
11300 | *
|
11301 | * @param selector A selector that defines the documents this provider is applicable to.
|
11302 | * @param provider A reference provider.
|
11303 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11304 | */
|
11305 | export function registerReferenceProvider(selector: DocumentSelector, provider: ReferenceProvider): Disposable;
|
11306 |
|
11307 | /**
|
11308 | * Register a rename provider.
|
11309 | *
|
11310 | * Multiple providers can be registered for a language. In that case providers are sorted
|
11311 | * by their {@link languages.match score} and asked in sequence. The first provider producing a result
|
11312 | * defines the result of the whole operation.
|
11313 | *
|
11314 | * @param selector A selector that defines the documents this provider is applicable to.
|
11315 | * @param provider A rename provider.
|
11316 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11317 | */
|
11318 | export function registerRenameProvider(selector: DocumentSelector, provider: RenameProvider): Disposable;
|
11319 |
|
11320 | /**
|
11321 | * Register a semantic tokens provider for a whole document.
|
11322 | *
|
11323 | * Multiple providers can be registered for a language. In that case providers are sorted
|
11324 | * by their {@link languages.match score} and the best-matching provider is used. Failure
|
11325 | * of the selected provider will cause a failure of the whole operation.
|
11326 | *
|
11327 | * @param selector A selector that defines the documents this provider is applicable to.
|
11328 | * @param provider A document semantic tokens provider.
|
11329 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11330 | */
|
11331 | export function registerDocumentSemanticTokensProvider(selector: DocumentSelector, provider: DocumentSemanticTokensProvider, legend: SemanticTokensLegend): Disposable;
|
11332 |
|
11333 | /**
|
11334 | * Register a semantic tokens provider for a document range.
|
11335 | *
|
11336 | * *Note:* If a document has both a `DocumentSemanticTokensProvider` and a `DocumentRangeSemanticTokensProvider`,
|
11337 | * the range provider will be invoked only initially, for the time in which the full document provider takes
|
11338 | * to resolve the first request. Once the full document provider resolves the first request, the semantic tokens
|
11339 | * provided via the range provider will be discarded and from that point forward, only the document provider
|
11340 | * will be used.
|
11341 | *
|
11342 | * Multiple providers can be registered for a language. In that case providers are sorted
|
11343 | * by their {@link languages.match score} and the best-matching provider is used. Failure
|
11344 | * of the selected provider will cause a failure of the whole operation.
|
11345 | *
|
11346 | * @param selector A selector that defines the documents this provider is applicable to.
|
11347 | * @param provider A document range semantic tokens provider.
|
11348 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11349 | */
|
11350 | export function registerDocumentRangeSemanticTokensProvider(selector: DocumentSelector, provider: DocumentRangeSemanticTokensProvider, legend: SemanticTokensLegend): Disposable;
|
11351 |
|
11352 | /**
|
11353 | * Register a formatting provider for a document.
|
11354 | *
|
11355 | * Multiple providers can be registered for a language. In that case providers are sorted
|
11356 | * by their {@link languages.match score} and the best-matching provider is used. Failure
|
11357 | * of the selected provider will cause a failure of the whole operation.
|
11358 | *
|
11359 | * @param selector A selector that defines the documents this provider is applicable to.
|
11360 | * @param provider A document formatting edit provider.
|
11361 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11362 | */
|
11363 | export function registerDocumentFormattingEditProvider(selector: DocumentSelector, provider: DocumentFormattingEditProvider): Disposable;
|
11364 |
|
11365 | /**
|
11366 | * Register a formatting provider for a document range.
|
11367 | *
|
11368 | * *Note:* A document range provider is also a {@link DocumentFormattingEditProvider document formatter}
|
11369 | * which means there is no need to {@link languages.registerDocumentFormattingEditProvider register} a document
|
11370 | * formatter when also registering a range provider.
|
11371 | *
|
11372 | * Multiple providers can be registered for a language. In that case providers are sorted
|
11373 | * by their {@link languages.match score} and the best-matching provider is used. Failure
|
11374 | * of the selected provider will cause a failure of the whole operation.
|
11375 | *
|
11376 | * @param selector A selector that defines the documents this provider is applicable to.
|
11377 | * @param provider A document range formatting edit provider.
|
11378 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11379 | */
|
11380 | export function registerDocumentRangeFormattingEditProvider(selector: DocumentSelector, provider: DocumentRangeFormattingEditProvider): Disposable;
|
11381 |
|
11382 | /**
|
11383 | * Register a formatting provider that works on type. The provider is active when the user enables the setting `editor.formatOnType`.
|
11384 | *
|
11385 | * Multiple providers can be registered for a language. In that case providers are sorted
|
11386 | * by their {@link languages.match score} and the best-matching provider is used. Failure
|
11387 | * of the selected provider will cause a failure of the whole operation.
|
11388 | *
|
11389 | * @param selector A selector that defines the documents this provider is applicable to.
|
11390 | * @param provider An on type formatting edit provider.
|
11391 | * @param firstTriggerCharacter A character on which formatting should be triggered, like `}`.
|
11392 | * @param moreTriggerCharacter More trigger characters.
|
11393 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11394 | */
|
11395 | export function registerOnTypeFormattingEditProvider(selector: DocumentSelector, provider: OnTypeFormattingEditProvider, firstTriggerCharacter: string, ...moreTriggerCharacter: string[]): Disposable;
|
11396 |
|
11397 | /**
|
11398 | * Register a signature help provider.
|
11399 | *
|
11400 | * Multiple providers can be registered for a language. In that case providers are sorted
|
11401 | * by their {@link languages.match score} and called sequentially until a provider returns a
|
11402 | * valid result.
|
11403 | *
|
11404 | * @param selector A selector that defines the documents this provider is applicable to.
|
11405 | * @param provider A signature help provider.
|
11406 | * @param triggerCharacters Trigger signature help when the user types one of the characters, like `,` or `(`.
|
11407 | * @param metadata Information about the provider.
|
11408 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11409 | */
|
11410 | export function registerSignatureHelpProvider(selector: DocumentSelector, provider: SignatureHelpProvider, ...triggerCharacters: string[]): Disposable;
|
11411 | export function registerSignatureHelpProvider(selector: DocumentSelector, provider: SignatureHelpProvider, metadata: SignatureHelpProviderMetadata): Disposable;
|
11412 |
|
11413 | /**
|
11414 | * Register a document link provider.
|
11415 | *
|
11416 | * Multiple providers can be registered for a language. In that case providers are asked in
|
11417 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
11418 | * not cause a failure of the whole operation.
|
11419 | *
|
11420 | * @param selector A selector that defines the documents this provider is applicable to.
|
11421 | * @param provider A document link provider.
|
11422 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11423 | */
|
11424 | export function registerDocumentLinkProvider(selector: DocumentSelector, provider: DocumentLinkProvider): Disposable;
|
11425 |
|
11426 | /**
|
11427 | * Register a color provider.
|
11428 | *
|
11429 | * Multiple providers can be registered for a language. In that case providers are asked in
|
11430 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
11431 | * not cause a failure of the whole operation.
|
11432 | *
|
11433 | * @param selector A selector that defines the documents this provider is applicable to.
|
11434 | * @param provider A color provider.
|
11435 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11436 | */
|
11437 | export function registerColorProvider(selector: DocumentSelector, provider: DocumentColorProvider): Disposable;
|
11438 |
|
11439 | /**
|
11440 | * Register a folding range provider.
|
11441 | *
|
11442 | * Multiple providers can be registered for a language. In that case providers are asked in
|
11443 | * parallel and the results are merged.
|
11444 | * If multiple folding ranges start at the same position, only the range of the first registered provider is used.
|
11445 | * If a folding range overlaps with an other range that has a smaller position, it is also ignored.
|
11446 | *
|
11447 | * A failing provider (rejected promise or exception) will
|
11448 | * not cause a failure of the whole operation.
|
11449 | *
|
11450 | * @param selector A selector that defines the documents this provider is applicable to.
|
11451 | * @param provider A folding range provider.
|
11452 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11453 | */
|
11454 | export function registerFoldingRangeProvider(selector: DocumentSelector, provider: FoldingRangeProvider): Disposable;
|
11455 |
|
11456 | /**
|
11457 | * Register a selection range provider.
|
11458 | *
|
11459 | * Multiple providers can be registered for a language. In that case providers are asked in
|
11460 | * parallel and the results are merged. A failing provider (rejected promise or exception) will
|
11461 | * not cause a failure of the whole operation.
|
11462 | *
|
11463 | * @param selector A selector that defines the documents this provider is applicable to.
|
11464 | * @param provider A selection range provider.
|
11465 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11466 | */
|
11467 | export function registerSelectionRangeProvider(selector: DocumentSelector, provider: SelectionRangeProvider): Disposable;
|
11468 |
|
11469 | /**
|
11470 | * Register a call hierarchy provider.
|
11471 | *
|
11472 | * @param selector A selector that defines the documents this provider is applicable to.
|
11473 | * @param provider A call hierarchy provider.
|
11474 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11475 | */
|
11476 | export function registerCallHierarchyProvider(selector: DocumentSelector, provider: CallHierarchyProvider): Disposable;
|
11477 |
|
11478 | /**
|
11479 | * Register a linked editing range provider.
|
11480 | *
|
11481 | * Multiple providers can be registered for a language. In that case providers are sorted
|
11482 | * by their {@link languages.match score} and the best-matching provider that has a result is used. Failure
|
11483 | * of the selected provider will cause a failure of the whole operation.
|
11484 | *
|
11485 | * @param selector A selector that defines the documents this provider is applicable to.
|
11486 | * @param provider A linked editing range provider.
|
11487 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
11488 | */
|
11489 | export function registerLinkedEditingRangeProvider(selector: DocumentSelector, provider: LinkedEditingRangeProvider): Disposable;
|
11490 |
|
11491 | /**
|
11492 | * Set a {@link LanguageConfiguration language configuration} for a language.
|
11493 | *
|
11494 | * @param language A language identifier like `typescript`.
|
11495 | * @param configuration Language configuration.
|
11496 | * @return A {@link Disposable} that unsets this configuration.
|
11497 | */
|
11498 | export function setLanguageConfiguration(language: string, configuration: LanguageConfiguration): Disposable;
|
11499 |
|
11500 | }
|
11501 |
|
11502 | /**
|
11503 | * A notebook cell kind.
|
11504 | */
|
11505 | export enum NotebookCellKind {
|
11506 |
|
11507 | /**
|
11508 | * A markup-cell is formatted source that is used for display.
|
11509 | */
|
11510 | Markup = 1,
|
11511 |
|
11512 | /**
|
11513 | * A code-cell is source that can be {@link NotebookController executed} and that
|
11514 | * produces {@link NotebookCellOutput output}.
|
11515 | */
|
11516 | Code = 2
|
11517 | }
|
11518 |
|
11519 | /**
|
11520 | * Represents a cell of a {@link NotebookDocument notebook}, either a {@link NotebookCellKind.Code code}-cell
|
11521 | * or {@link NotebookCellKind.Markup markup}-cell.
|
11522 | *
|
11523 | * NotebookCell instances are immutable and are kept in sync for as long as they are part of their notebook.
|
11524 | */
|
11525 | export interface NotebookCell {
|
11526 |
|
11527 | /**
|
11528 | * The index of this cell in its {@link NotebookDocument.cellAt containing notebook}. The
|
11529 | * index is updated when a cell is moved within its notebook. The index is `-1`
|
11530 | * when the cell has been removed from its notebook.
|
11531 | */
|
11532 | readonly index: number;
|
11533 |
|
11534 | /**
|
11535 | * The {@link NotebookDocument notebook} that contains this cell.
|
11536 | */
|
11537 | readonly notebook: NotebookDocument;
|
11538 |
|
11539 | /**
|
11540 | * The kind of this cell.
|
11541 | */
|
11542 | readonly kind: NotebookCellKind;
|
11543 |
|
11544 | /**
|
11545 | * The {@link TextDocument text} of this cell, represented as text document.
|
11546 | */
|
11547 | readonly document: TextDocument;
|
11548 |
|
11549 | /**
|
11550 | * The metadata of this cell. Can be anything but must be JSON-stringifyable.
|
11551 | */
|
11552 | readonly metadata: { [key: string]: any };
|
11553 |
|
11554 | /**
|
11555 | * The outputs of this cell.
|
11556 | */
|
11557 | readonly outputs: readonly NotebookCellOutput[];
|
11558 |
|
11559 | /**
|
11560 | * The most recent {@link NotebookCellExecutionSummary execution summary} for this cell.
|
11561 | */
|
11562 | readonly executionSummary?: NotebookCellExecutionSummary;
|
11563 | }
|
11564 |
|
11565 | /**
|
11566 | * Represents a notebook editor that is attached to a {@link NotebookDocument notebook}.
|
11567 | * Additional properties of the NotebookEditor are available in the proposed
|
11568 | * API, which will be finalized later.
|
11569 | */
|
11570 | export interface NotebookEditor {
|
11571 |
|
11572 | }
|
11573 |
|
11574 | /**
|
11575 | * Renderer messaging is used to communicate with a single renderer. It's returned from {@link notebooks.createRendererMessaging}.
|
11576 | */
|
11577 | export interface NotebookRendererMessaging {
|
11578 | /**
|
11579 | * An event that fires when a message is received from a renderer.
|
11580 | */
|
11581 | readonly onDidReceiveMessage: Event<{
|
11582 | readonly editor: NotebookEditor;
|
11583 | readonly message: any;
|
11584 | }>;
|
11585 |
|
11586 | /**
|
11587 | * Send a message to one or all renderer.
|
11588 | *
|
11589 | * @param message Message to send
|
11590 | * @param editor Editor to target with the message. If not provided, the
|
11591 | * message is sent to all renderers.
|
11592 | * @returns a boolean indicating whether the message was successfully
|
11593 | * delivered to any renderer.
|
11594 | */
|
11595 | postMessage(message: any, editor?: NotebookEditor): Thenable<boolean>;
|
11596 | }
|
11597 |
|
11598 | /**
|
11599 | * Represents a notebook which itself is a sequence of {@link NotebookCell code or markup cells}. Notebook documents are
|
11600 | * created from {@link NotebookData notebook data}.
|
11601 | */
|
11602 | export interface NotebookDocument {
|
11603 |
|
11604 | /**
|
11605 | * The associated uri for this notebook.
|
11606 | *
|
11607 | * *Note* that most notebooks use the `file`-scheme, which means they are files on disk. However, **not** all notebooks are
|
11608 | * saved on disk and therefore the `scheme` must be checked before trying to access the underlying file or siblings on disk.
|
11609 | *
|
11610 | * @see {@link FileSystemProvider}
|
11611 | */
|
11612 | readonly uri: Uri;
|
11613 |
|
11614 | /**
|
11615 | * The type of notebook.
|
11616 | */
|
11617 | readonly notebookType: string;
|
11618 |
|
11619 | /**
|
11620 | * The version number of this notebook (it will strictly increase after each
|
11621 | * change, including undo/redo).
|
11622 | */
|
11623 | readonly version: number;
|
11624 |
|
11625 | /**
|
11626 | * `true` if there are unpersisted changes.
|
11627 | */
|
11628 | readonly isDirty: boolean;
|
11629 |
|
11630 | /**
|
11631 | * Is this notebook representing an untitled file which has not been saved yet.
|
11632 | */
|
11633 | readonly isUntitled: boolean;
|
11634 |
|
11635 | /**
|
11636 | * `true` if the notebook has been closed. A closed notebook isn't synchronized anymore
|
11637 | * and won't be re-used when the same resource is opened again.
|
11638 | */
|
11639 | readonly isClosed: boolean;
|
11640 |
|
11641 | /**
|
11642 | * Arbitrary metadata for this notebook. Can be anything but must be JSON-stringifyable.
|
11643 | */
|
11644 | readonly metadata: { [key: string]: any };
|
11645 |
|
11646 | /**
|
11647 | * The number of cells in the notebook.
|
11648 | */
|
11649 | readonly cellCount: number;
|
11650 |
|
11651 | /**
|
11652 | * Return the cell at the specified index. The index will be adjusted to the notebook.
|
11653 | *
|
11654 | * @param index - The index of the cell to retrieve.
|
11655 | * @return A {@link NotebookCell cell}.
|
11656 | */
|
11657 | cellAt(index: number): NotebookCell;
|
11658 |
|
11659 | /**
|
11660 | * Get the cells of this notebook. A subset can be retrieved by providing
|
11661 | * a range. The range will be adjusted to the notebook.
|
11662 | *
|
11663 | * @param range A notebook range.
|
11664 | * @returns The cells contained by the range or all cells.
|
11665 | */
|
11666 | getCells(range?: NotebookRange): NotebookCell[];
|
11667 |
|
11668 | /**
|
11669 | * Save the document. The saving will be handled by the corresponding {@link NotebookSerializer serializer}.
|
11670 | *
|
11671 | * @return A promise that will resolve to true when the document
|
11672 | * has been saved. Will return false if the file was not dirty or when save failed.
|
11673 | */
|
11674 | save(): Thenable<boolean>;
|
11675 | }
|
11676 |
|
11677 | /**
|
11678 | * The summary of a notebook cell execution.
|
11679 | */
|
11680 | export interface NotebookCellExecutionSummary {
|
11681 |
|
11682 | /**
|
11683 | * The order in which the execution happened.
|
11684 | */
|
11685 | readonly executionOrder?: number;
|
11686 |
|
11687 | /**
|
11688 | * If the exclusive finished successfully.
|
11689 | */
|
11690 | readonly success?: boolean;
|
11691 |
|
11692 | /**
|
11693 | * The times at which execution started and ended, as unix timestamps
|
11694 | */
|
11695 | readonly timing?: { startTime: number, endTime: number };
|
11696 | }
|
11697 |
|
11698 | /**
|
11699 | * A notebook range represents an ordered pair of two cell indices.
|
11700 | * It is guaranteed that start is less than or equal to end.
|
11701 | */
|
11702 | export class NotebookRange {
|
11703 |
|
11704 | /**
|
11705 | * The zero-based start index of this range.
|
11706 | */
|
11707 | readonly start: number;
|
11708 |
|
11709 | /**
|
11710 | * The exclusive end index of this range (zero-based).
|
11711 | */
|
11712 | readonly end: number;
|
11713 |
|
11714 | /**
|
11715 | * `true` if `start` and `end` are equal.
|
11716 | */
|
11717 | readonly isEmpty: boolean;
|
11718 |
|
11719 | /**
|
11720 | * Create a new notebook range. If `start` is not
|
11721 | * before or equal to `end`, the values will be swapped.
|
11722 | *
|
11723 | * @param start start index
|
11724 | * @param end end index.
|
11725 | */
|
11726 | constructor(start: number, end: number);
|
11727 |
|
11728 | /**
|
11729 | * Derive a new range for this range.
|
11730 | *
|
11731 | * @param change An object that describes a change to this range.
|
11732 | * @return A range that reflects the given change. Will return `this` range if the change
|
11733 | * is not changing anything.
|
11734 | */
|
11735 | with(change: { start?: number, end?: number }): NotebookRange;
|
11736 | }
|
11737 |
|
11738 | /**
|
11739 | * One representation of a {type and data.
NotebookCellOutput notebook output}, defined by MIME |
11740 | */
|
11741 | export class NotebookCellOutputItem {
|
11742 |
|
11743 | /**
|
11744 | * Factory function to create a `NotebookCellOutputItem` from a string.
|
11745 | *
|
11746 | * *Note* that an UTF-8 encoder is used to create bytes for the string.
|
11747 | *
|
11748 | * @param value A string.
|
11749 | * @param mime Optional MIME type, defaults to `text/plain`.
|
11750 | * @returns A new output item object.
|
11751 | */
|
11752 | static text(value: string, mime?: string): NotebookCellOutputItem;
|
11753 |
|
11754 | /**
|
11755 | * Factory function to create a `NotebookCellOutputItem` from
|
11756 | * a JSON object.
|
11757 | *
|
11758 | * *Note* that this function is not expecting "stringified JSON" but
|
11759 | * an object that can be stringified. This function will throw an error
|
11760 | * when the passed value cannot be JSON-stringified.
|
11761 | *
|
11762 | * @param value A JSON-stringifyable value.
|
11763 | * @param mime Optional MIME type, defaults to `application/json`
|
11764 | * @returns A new output item object.
|
11765 | */
|
11766 | static json(value: any, mime?: string): NotebookCellOutputItem;
|
11767 |
|
11768 | /**
|
11769 | * Factory function to create a `NotebookCellOutputItem` that uses
|
11770 | * uses the `application/vnd.code.notebook.stdout` mime type.
|
11771 | *
|
11772 | * @param value A string.
|
11773 | * @returns A new output item object.
|
11774 | */
|
11775 | static stdout(value: string): NotebookCellOutputItem;
|
11776 |
|
11777 | /**
|
11778 | * Factory function to create a `NotebookCellOutputItem` that uses
|
11779 | * uses the `application/vnd.code.notebook.stderr` mime type.
|
11780 | *
|
11781 | * @param value A string.
|
11782 | * @returns A new output item object.
|
11783 | */
|
11784 | static stderr(value: string): NotebookCellOutputItem;
|
11785 |
|
11786 | /**
|
11787 | * Factory function to create a `NotebookCellOutputItem` that uses
|
11788 | * uses the `application/vnd.code.notebook.error` mime type.
|
11789 | *
|
11790 | * @param value An error object.
|
11791 | * @returns A new output item object.
|
11792 | */
|
11793 | static error(value: Error): NotebookCellOutputItem;
|
11794 |
|
11795 | /**
|
11796 | * The mime type which determines how the {@link NotebookCellOutputItem.data `data`}-property
|
11797 | * is interpreted.
|
11798 | *
|
11799 | * Notebooks have built-in support for certain mime-types, extensions can add support for new
|
11800 | * types and override existing types.
|
11801 | */
|
11802 | mime: string;
|
11803 |
|
11804 | /**
|
11805 | * The data of this output item. Must always be an array of unsigned 8-bit integers.
|
11806 | */
|
11807 | data: Uint8Array;
|
11808 |
|
11809 | /**
|
11810 | * Create a new notebook cell output item.
|
11811 | *
|
11812 | * @param data The value of the output item.
|
11813 | * @param mime The mime type of the output item.
|
11814 | */
|
11815 | constructor(data: Uint8Array, mime: string);
|
11816 | }
|
11817 |
|
11818 | /**
|
11819 | * Notebook cell output represents a result of executing a cell. It is a container type for multiple
|
11820 | * { NotebookCellOutputItem output items} where contained items represent the same result but
|
11821 | * use different MIME types.
|
11822 | */
|
11823 | export class NotebookCellOutput {
|
11824 |
|
11825 | /**
|
11826 | * The output items of this output. Each item must represent the same result. _Note_ that repeated
|
11827 | * MIME types per output is invalid and that the editor will just pick one of them.
|
11828 | *
|
11829 | * ```ts
|
11830 | * new vscode.NotebookCellOutput([
|
11831 | * vscode.NotebookCellOutputItem.text('Hello', 'text/plain'),
|
11832 | * vscode.NotebookCellOutputItem.text('<i>Hello</i>', 'text/html'),
|
11833 | * vscode.NotebookCellOutputItem.text('_Hello_', 'text/markdown'),
|
11834 | * vscode.NotebookCellOutputItem.text('Hey', 'text/plain'), // INVALID: repeated type, editor will pick just one
|
11835 | * ])
|
11836 | * ```
|
11837 | */
|
11838 | items: NotebookCellOutputItem[];
|
11839 |
|
11840 | /**
|
11841 | * Arbitrary metadata for this cell output. Can be anything but must be JSON-stringifyable.
|
11842 | */
|
11843 | metadata?: { [key: string]: any };
|
11844 |
|
11845 | /**
|
11846 | * Create new notebook output.
|
11847 | *
|
11848 | * @param items Notebook output items.
|
11849 | * @param metadata Optional metadata.
|
11850 | */
|
11851 | constructor(items: NotebookCellOutputItem[], metadata?: { [key: string]: any });
|
11852 | }
|
11853 |
|
11854 | /**
|
11855 | * NotebookCellData is the raw representation of notebook cells. Its is part of {`NotebookData`}.
NotebookData |
11856 | */
|
11857 | export class NotebookCellData {
|
11858 |
|
11859 | /**
|
11860 | * The {@link NotebookCellKind kind} of this cell data.
|
11861 | */
|
11862 | kind: NotebookCellKind;
|
11863 |
|
11864 | /**
|
11865 | * The source value of this cell data - either source code or formatted text.
|
11866 | */
|
11867 | value: string;
|
11868 |
|
11869 | /**
|
11870 | * The language identifier of the source value of this cell data. Any value from
|
11871 | * {@link languages.getLanguages `getLanguages`} is possible.
|
11872 | */
|
11873 | languageId: string;
|
11874 |
|
11875 | /**
|
11876 | * The outputs of this cell data.
|
11877 | */
|
11878 | outputs?: NotebookCellOutput[];
|
11879 |
|
11880 | /**
|
11881 | * Arbitrary metadata of this cell data. Can be anything but must be JSON-stringifyable.
|
11882 | */
|
11883 | metadata?: { [key: string]: any };
|
11884 |
|
11885 | /**
|
11886 | * The execution summary of this cell data.
|
11887 | */
|
11888 | executionSummary?: NotebookCellExecutionSummary;
|
11889 |
|
11890 | /**
|
11891 | * Create new cell data. Minimal cell data specifies its kind, its source value, and the
|
11892 | * language identifier of its source.
|
11893 | *
|
11894 | * @param kind The kind.
|
11895 | * @param value The source value.
|
11896 | * @param languageId The language identifier of the source value.
|
11897 | */
|
11898 | constructor(kind: NotebookCellKind, value: string, languageId: string);
|
11899 | }
|
11900 |
|
11901 | /**
|
11902 | * Raw representation of a notebook.
|
11903 | *
|
11904 | * Extensions are responsible for creating {`NotebookData`} so that the editor
NotebookData |
11905 | * can create a {`NotebookDocument`}.
NotebookDocument |
11906 | *
|
11907 | * { NotebookSerializer}
|
11908 | */
|
11909 | export class NotebookData {
|
11910 | /**
|
11911 | * The cell data of this notebook data.
|
11912 | */
|
11913 | cells: NotebookCellData[];
|
11914 |
|
11915 | /**
|
11916 | * Arbitrary metadata of notebook data.
|
11917 | */
|
11918 | metadata?: { [key: string]: any };
|
11919 |
|
11920 | /**
|
11921 | * Create new notebook data.
|
11922 | *
|
11923 | * @param cells An array of cell data.
|
11924 | */
|
11925 | constructor(cells: NotebookCellData[]);
|
11926 | }
|
11927 |
|
11928 | /**
|
11929 | * The notebook serializer enables the editor to open notebook files.
|
11930 | *
|
11931 | * At its core the editor only knows a { NotebookData notebook data structure} but not
|
11932 | * how that data structure is written to a file, nor how it is read from a file. The
|
11933 | * notebook serializer bridges this gap by deserializing bytes into notebook data and
|
11934 | * vice versa.
|
11935 | */
|
11936 | export interface NotebookSerializer {
|
11937 |
|
11938 | /**
|
11939 | * Deserialize contents of a notebook file into the notebook data structure.
|
11940 | *
|
11941 | * @param content Contents of a notebook file.
|
11942 | * @param token A cancellation token.
|
11943 | * @return Notebook data or a thenable that resolves to such.
|
11944 | */
|
11945 | deserializeNotebook(content: Uint8Array, token: CancellationToken): NotebookData | Thenable<NotebookData>;
|
11946 |
|
11947 | /**
|
11948 | * Serialize notebook data into file contents.
|
11949 | *
|
11950 | * @param data A notebook data structure.
|
11951 | * @param token A cancellation token.
|
11952 | * @returns An array of bytes or a thenable that resolves to such.
|
11953 | */
|
11954 | serializeNotebook(data: NotebookData, token: CancellationToken): Uint8Array | Thenable<Uint8Array>;
|
11955 | }
|
11956 |
|
11957 | /**
|
11958 | * Notebook content options define what parts of a notebook are persisted. Note
|
11959 | *
|
11960 | * For instance, a notebook serializer can opt-out of saving outputs and in that case the editor doesn't mark a
|
11961 | * notebooks as {@link NotebookDocument.isDirty dirty} when its output has changed.
|
11962 | */
|
11963 | export interface NotebookDocumentContentOptions {
|
11964 | /**
|
11965 | * Controls if outputs change will trigger notebook document content change and if it will be used in the diff editor
|
11966 | * Default to false. If the content provider doesn't persisit the outputs in the file document, this should be set to true.
|
11967 | */
|
11968 | transientOutputs?: boolean;
|
11969 |
|
11970 | /**
|
11971 | * Controls if a cell metadata property change will trigger notebook document content change and if it will be used in the diff editor
|
11972 | * Default to false. If the content provider doesn't persisit a metadata property in the file document, it should be set to true.
|
11973 | */
|
11974 | transientCellMetadata?: { [key: string]: boolean | undefined };
|
11975 |
|
11976 | /**
|
11977 | * Controls if a document metadata property change will trigger notebook document content change and if it will be used in the diff editor
|
11978 | * Default to false. If the content provider doesn't persisit a metadata property in the file document, it should be set to true.
|
11979 | */
|
11980 | transientDocumentMetadata?: { [key: string]: boolean | undefined };
|
11981 | }
|
11982 |
|
11983 | /**
|
11984 | * Notebook controller affinity for notebook documents.
|
11985 | *
|
11986 | * @see {@link NotebookController.updateNotebookAffinity}
|
11987 | */
|
11988 | export enum NotebookControllerAffinity {
|
11989 | /**
|
11990 | * Default affinity.
|
11991 | */
|
11992 | Default = 1,
|
11993 | /**
|
11994 | * A controller is preferred for a notebook.
|
11995 | */
|
11996 | Preferred = 2
|
11997 | }
|
11998 |
|
11999 | /**
|
12000 | * A notebook controller represents an entity that can execute notebook cells. This is often referred to as a kernel.
|
12001 | *
|
12002 | * There can be multiple controllers and the editor will let users choose which controller to use for a certain notebook. The
|
12003 | * {@link NotebookController.notebookType `notebookType`}-property defines for what kind of notebooks a controller is for and
|
12004 | * the {@link NotebookController.updateNotebookAffinity `updateNotebookAffinity`}-function allows controllers to set a preference
|
12005 | * for specific notebook documents. When a controller has been selected its
|
12006 | * {@link NotebookController.onDidChangeSelectedNotebooks onDidChangeSelectedNotebooks}-event fires.
|
12007 | *
|
12008 | * When a cell is being run the editor will invoke the {@link NotebookController.executeHandler `executeHandler`} and a controller
|
12009 | * is expected to create and finalize a {@link NotebookCellExecution notebook cell execution}. However, controllers are also free
|
12010 | * to create executions by themselves.
|
12011 | */
|
12012 | export interface NotebookController {
|
12013 |
|
12014 | /**
|
12015 | * The identifier of this notebook controller.
|
12016 | *
|
12017 | * _Note_ that controllers are remembered by their identifier and that extensions should use
|
12018 | * stable identifiers across sessions.
|
12019 | */
|
12020 | readonly id: string;
|
12021 |
|
12022 | /**
|
12023 | * The notebook type this controller is for.
|
12024 | */
|
12025 | readonly notebookType: string;
|
12026 |
|
12027 | /**
|
12028 | * An array of language identifiers that are supported by this
|
12029 | * controller. Any language identifier from {@link languages.getLanguages `getLanguages`}
|
12030 | * is possible. When falsy all languages are supported.
|
12031 | *
|
12032 | * Samples:
|
12033 | * ```js
|
12034 | * // support JavaScript and TypeScript
|
12035 | * myController.supportedLanguages = ['javascript', 'typescript']
|
12036 | *
|
12037 | * // support all languages
|
12038 | * myController.supportedLanguages = undefined; // falsy
|
12039 | * myController.supportedLanguages = []; // falsy
|
12040 | * ```
|
12041 | */
|
12042 | supportedLanguages?: string[];
|
12043 |
|
12044 | /**
|
12045 | * The human-readable label of this notebook controller.
|
12046 | */
|
12047 | label: string;
|
12048 |
|
12049 | /**
|
12050 | * The human-readable description which is rendered less prominent.
|
12051 | */
|
12052 | description?: string;
|
12053 |
|
12054 | /**
|
12055 | * The human-readable detail which is rendered less prominent.
|
12056 | */
|
12057 | detail?: string;
|
12058 |
|
12059 | /**
|
12060 | * Whether this controller supports execution order so that the
|
12061 | * editor can render placeholders for them.
|
12062 | */
|
12063 | supportsExecutionOrder?: boolean;
|
12064 |
|
12065 | /**
|
12066 | * Create a cell execution task.
|
12067 | *
|
12068 | * _Note_ that there can only be one execution per cell at a time and that an error is thrown if
|
12069 | * a cell execution is created while another is still active.
|
12070 | *
|
12071 | * This should be used in response to the {@link NotebookController.executeHandler execution handler}
|
12072 | * being called or when cell execution has been started else, e.g when a cell was already
|
12073 | * executing or when cell execution was triggered from another source.
|
12074 | *
|
12075 | * @param cell The notebook cell for which to create the execution.
|
12076 | * @returns A notebook cell execution.
|
12077 | */
|
12078 | createNotebookCellExecution(cell: NotebookCell): NotebookCellExecution;
|
12079 |
|
12080 | /**
|
12081 | * The execute handler is invoked when the run gestures in the UI are selected, e.g Run Cell, Run All,
|
12082 | * Run Selection etc. The execute handler is responsible for creating and managing {@link NotebookCellExecution execution}-objects.
|
12083 | */
|
12084 | executeHandler: (cells: NotebookCell[], notebook: NotebookDocument, controller: NotebookController) => void | Thenable<void>;
|
12085 |
|
12086 | /**
|
12087 | * Optional interrupt handler.
|
12088 | *
|
12089 | * By default cell execution is canceled via {@link NotebookCellExecution.token tokens}. Cancellation
|
12090 | * tokens require that a controller can keep track of its execution so that it can cancel a specific execution at a later
|
12091 | * point. Not all scenarios allow for that, eg. REPL-style controllers often work by interrupting whatever is currently
|
12092 | * running. For those cases the interrupt handler exists - it can be thought of as the equivalent of `SIGINT`
|
12093 | * or `Control+C` in terminals.
|
12094 | *
|
12095 | * _Note_ that supporting {@link NotebookCellExecution.token cancellation tokens} is preferred and that interrupt handlers should
|
12096 | * only be used when tokens cannot be supported.
|
12097 | */
|
12098 | interruptHandler?: (notebook: NotebookDocument) => void | Thenable<void>;
|
12099 |
|
12100 | /**
|
12101 | * An event that fires whenever a controller has been selected or un-selected for a notebook document.
|
12102 | *
|
12103 | * There can be multiple controllers for a notebook and in that case a controllers needs to be _selected_. This is a user gesture
|
12104 | * and happens either explicitly or implicitly when interacting with a notebook for which a controller was _suggested_. When possible,
|
12105 | * the editor _suggests_ a controller that is most likely to be _selected_.
|
12106 | *
|
12107 | * _Note_ that controller selection is persisted (by the controllers {@link NotebookController.id id}) and restored as soon as a
|
12108 | * controller is re-created or as a notebook is {@link workspace.onDidOpenNotebookDocument opened}.
|
12109 | */
|
12110 | readonly onDidChangeSelectedNotebooks: Event<{ notebook: NotebookDocument, selected: boolean }>;
|
12111 |
|
12112 | /**
|
12113 | * A controller can set affinities for specific notebook documents. This allows a controller
|
12114 | * to be presented more prominent for some notebooks.
|
12115 | *
|
12116 | * @param notebook The notebook for which a priority is set.
|
12117 | * @param affinity A controller affinity
|
12118 | */
|
12119 | updateNotebookAffinity(notebook: NotebookDocument, affinity: NotebookControllerAffinity): void;
|
12120 |
|
12121 | /**
|
12122 | * Dispose and free associated resources.
|
12123 | */
|
12124 | dispose(): void;
|
12125 | }
|
12126 |
|
12127 | /**
|
12128 | * A NotebookCellExecution is how {@link NotebookController notebook controller} modify a notebook cell as
|
12129 | * it is executing.
|
12130 | *
|
12131 | * When a cell execution object is created, the cell enters the {@link NotebookCellExecutionState.Pending `Pending`} state.
|
12132 | * When {@link NotebookCellExecution.start `start(...)`} is called on the execution task, it enters the {@link NotebookCellExecutionState.Executing `Executing`} state. When
|
12133 | * {@link NotebookCellExecution.end `end(...)`} is called, it enters the {@link NotebookCellExecutionState.Idle `Idle`} state.
|
12134 | */
|
12135 | export interface NotebookCellExecution {
|
12136 |
|
12137 | /**
|
12138 | * The {@link NotebookCell cell} for which this execution has been created.
|
12139 | */
|
12140 | readonly cell: NotebookCell;
|
12141 |
|
12142 | /**
|
12143 | * A cancellation token which will be triggered when the cell execution is canceled
|
12144 | * from the UI.
|
12145 | *
|
12146 | * _Note_ that the cancellation token will not be triggered when the {@link NotebookController controller}
|
12147 | * that created this execution uses an {@link NotebookController.interruptHandler interrupt-handler}.
|
12148 | */
|
12149 | readonly token: CancellationToken;
|
12150 |
|
12151 | /**
|
12152 | * Set and unset the order of this cell execution.
|
12153 | */
|
12154 | executionOrder: number | undefined;
|
12155 |
|
12156 | /**
|
12157 | * Signal that the execution has begun.
|
12158 | *
|
12159 | * @param startTime The time that execution began, in milliseconds in the Unix epoch. Used to drive the clock
|
12160 | * that shows for how long a cell has been running. If not given, the clock won't be shown.
|
12161 | */
|
12162 | start(startTime?: number): void;
|
12163 |
|
12164 | /**
|
12165 | * Signal that execution has ended.
|
12166 | *
|
12167 | * @param success If true, a green check is shown on the cell status bar.
|
12168 | * If false, a red X is shown.
|
12169 | * If undefined, no check or X icon is shown.
|
12170 | * @param endTime The time that execution finished, in milliseconds in the Unix epoch.
|
12171 | */
|
12172 | end(success: boolean | undefined, endTime?: number): void;
|
12173 |
|
12174 | /**
|
12175 | * Clears the output of the cell that is executing or of another cell that is affected by this execution.
|
12176 | *
|
12177 | * @param cell Cell for which output is cleared. Defaults to the {@link NotebookCellExecution.cell cell} of
|
12178 | * this execution.
|
12179 | * @return A thenable that resolves when the operation finished.
|
12180 | */
|
12181 | clearOutput(cell?: NotebookCell): Thenable<void>;
|
12182 |
|
12183 | /**
|
12184 | * Replace the output of the cell that is executing or of another cell that is affected by this execution.
|
12185 | *
|
12186 | * @param out Output that replaces the current output.
|
12187 | * @param cell Cell for which output is cleared. Defaults to the {@link NotebookCellExecution.cell cell} of
|
12188 | * this execution.
|
12189 | * @return A thenable that resolves when the operation finished.
|
12190 | */
|
12191 | replaceOutput(out: NotebookCellOutput | NotebookCellOutput[], cell?: NotebookCell): Thenable<void>;
|
12192 |
|
12193 | /**
|
12194 | * Append to the output of the cell that is executing or to another cell that is affected by this execution.
|
12195 | *
|
12196 | * @param out Output that is appended to the current output.
|
12197 | * @param cell Cell for which output is cleared. Defaults to the {@link NotebookCellExecution.cell cell} of
|
12198 | * this execution.
|
12199 | * @return A thenable that resolves when the operation finished.
|
12200 | */
|
12201 | appendOutput(out: NotebookCellOutput | NotebookCellOutput[], cell?: NotebookCell): Thenable<void>;
|
12202 |
|
12203 | /**
|
12204 | * Replace all output items of existing cell output.
|
12205 | *
|
12206 | * @param items Output items that replace the items of existing output.
|
12207 | * @param output Output object that already exists.
|
12208 | * @return A thenable that resolves when the operation finished.
|
12209 | */
|
12210 | replaceOutputItems(items: NotebookCellOutputItem | NotebookCellOutputItem[], output: NotebookCellOutput): Thenable<void>;
|
12211 |
|
12212 | /**
|
12213 | * Append output items to existing cell output.
|
12214 | *
|
12215 | * @param items Output items that are append to existing output.
|
12216 | * @param output Output object that already exists.
|
12217 | * @return A thenable that resolves when the operation finished.
|
12218 | */
|
12219 | appendOutputItems(items: NotebookCellOutputItem | NotebookCellOutputItem[], output: NotebookCellOutput): Thenable<void>;
|
12220 | }
|
12221 |
|
12222 | /**
|
12223 | * Represents the alignment of status bar items.
|
12224 | */
|
12225 | export enum NotebookCellStatusBarAlignment {
|
12226 |
|
12227 | /**
|
12228 | * Aligned to the left side.
|
12229 | */
|
12230 | Left = 1,
|
12231 |
|
12232 | /**
|
12233 | * Aligned to the right side.
|
12234 | */
|
12235 | Right = 2
|
12236 | }
|
12237 |
|
12238 | /**
|
12239 | * A contribution to a cell's status bar
|
12240 | */
|
12241 | export class NotebookCellStatusBarItem {
|
12242 | /**
|
12243 | * The text to show for the item.
|
12244 | */
|
12245 | text: string;
|
12246 |
|
12247 | /**
|
12248 | * Whether the item is aligned to the left or right.
|
12249 | */
|
12250 | alignment: NotebookCellStatusBarAlignment;
|
12251 |
|
12252 | /**
|
12253 | * An optional {@link Command `Command`} or identifier of a command to run on click.
|
12254 | *
|
12255 | * The command must be {@link commands.getCommands known}.
|
12256 | *
|
12257 | * Note that if this is a {@link Command `Command`} object, only the {@link Command.command `command`} and {@link Command.arguments `arguments`}
|
12258 | * are used by the editor.
|
12259 | */
|
12260 | command?: string | Command;
|
12261 |
|
12262 | /**
|
12263 | * A tooltip to show when the item is hovered.
|
12264 | */
|
12265 | tooltip?: string;
|
12266 |
|
12267 | /**
|
12268 | * The priority of the item. A higher value item will be shown more to the left.
|
12269 | */
|
12270 | priority?: number;
|
12271 |
|
12272 | /**
|
12273 | * Accessibility information used when a screen reader interacts with this item.
|
12274 | */
|
12275 | accessibilityInformation?: AccessibilityInformation;
|
12276 |
|
12277 | /**
|
12278 | * Creates a new NotebookCellStatusBarItem.
|
12279 | * @param text The text to show for the item.
|
12280 | * @param alignment Whether the item is aligned to the left or right.
|
12281 | */
|
12282 | constructor(text: string, alignment: NotebookCellStatusBarAlignment);
|
12283 | }
|
12284 |
|
12285 | /**
|
12286 | * A provider that can contribute items to the status bar that appears below a cell's editor.
|
12287 | */
|
12288 | export interface NotebookCellStatusBarItemProvider {
|
12289 | /**
|
12290 | * An optional event to signal that statusbar items have changed. The provide method will be called again.
|
12291 | */
|
12292 | onDidChangeCellStatusBarItems?: Event<void>;
|
12293 |
|
12294 | /**
|
12295 | * The provider will be called when the cell scrolls into view, when its content, outputs, language, or metadata change, and when it changes execution state.
|
12296 | * @param cell The cell for which to return items.
|
12297 | * @param token A token triggered if this request should be cancelled.
|
12298 | * @return One or more {@link NotebookCellStatusBarItem cell statusbar items}
|
12299 | */
|
12300 | provideCellStatusBarItems(cell: NotebookCell, token: CancellationToken): ProviderResult<NotebookCellStatusBarItem | NotebookCellStatusBarItem[]>;
|
12301 | }
|
12302 |
|
12303 | /**
|
12304 | * Namespace for notebooks.
|
12305 | *
|
12306 | * The notebooks functionality is composed of three loosely coupled components:
|
12307 | *
|
12308 | * 1. {@link NotebookSerializer} enable the editor to open, show, and save notebooks
|
12309 | * 2. {@link NotebookController} own the execution of notebooks, e.g they create output from code cells.
|
12310 | * 3. NotebookRenderer present notebook output in the editor. They run in a separate context.
|
12311 | */
|
12312 | export namespace notebooks {
|
12313 |
|
12314 | /**
|
12315 | * Creates a new notebook controller.
|
12316 | *
|
12317 | * @param id Identifier of the controller. Must be unique per extension.
|
12318 | * @param notebookType A notebook type for which this controller is for.
|
12319 | * @param label The label of the controller.
|
12320 | * @param handler The execute-handler of the controller.
|
12321 | */
|
12322 | export function createNotebookController(id: string, notebookType: string, label: string, handler?: (cells: NotebookCell[], notebook: NotebookDocument, controller: NotebookController) => void | Thenable<void>): NotebookController;
|
12323 |
|
12324 | /**
|
12325 | * Register a {@link NotebookCellStatusBarItemProvider cell statusbar item provider} for the given notebook type.
|
12326 | *
|
12327 | * @param notebookType The notebook type to register for.
|
12328 | * @param provider A cell status bar provider.
|
12329 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
12330 | */
|
12331 | export function registerNotebookCellStatusBarItemProvider(notebookType: string, provider: NotebookCellStatusBarItemProvider): Disposable;
|
12332 |
|
12333 | /**
|
12334 | * Creates a new messaging instance used to communicate with a specific renderer.
|
12335 | *
|
12336 | * * *Note 1:* Extensions can only create renderer that they have defined in their `package.json`-file
|
12337 | * * *Note 2:* A renderer only has access to messaging if `requiresMessaging` is set to `always` or `optional` in
|
12338 | * its `notebookRenderer` contribution.
|
12339 | *
|
12340 | * @param rendererId The renderer ID to communicate with
|
12341 | * @returns A new notebook renderer messaging object.
|
12342 | */
|
12343 | export function createRendererMessaging(rendererId: string): NotebookRendererMessaging;
|
12344 | }
|
12345 |
|
12346 | /**
|
12347 | * Represents the input box in the Source Control viewlet.
|
12348 | */
|
12349 | export interface SourceControlInputBox {
|
12350 |
|
12351 | /**
|
12352 | * Setter and getter for the contents of the input box.
|
12353 | */
|
12354 | value: string;
|
12355 |
|
12356 | /**
|
12357 | * A string to show as placeholder in the input box to guide the user.
|
12358 | */
|
12359 | placeholder: string;
|
12360 |
|
12361 | /**
|
12362 | * Controls whether the input box is visible (default is `true`).
|
12363 | */
|
12364 | visible: boolean;
|
12365 | }
|
12366 |
|
12367 | interface QuickDiffProvider {
|
12368 |
|
12369 | /**
|
12370 | * Provide a {@link Uri} to the original resource of any given resource uri.
|
12371 | *
|
12372 | * @param uri The uri of the resource open in a text editor.
|
12373 | * @param token A cancellation token.
|
12374 | * @return A thenable that resolves to uri of the matching original resource.
|
12375 | */
|
12376 | provideOriginalResource?(uri: Uri, token: CancellationToken): ProviderResult<Uri>;
|
12377 | }
|
12378 |
|
12379 | /**
|
12380 | * The theme-aware decorations for a
|
12381 | * {@link SourceControlResourceState source control resource state}.
|
12382 | */
|
12383 | export interface SourceControlResourceThemableDecorations {
|
12384 |
|
12385 | /**
|
12386 | * The icon path for a specific
|
12387 | * {@link SourceControlResourceState source control resource state}.
|
12388 | */
|
12389 | readonly iconPath?: string | Uri | ThemeIcon;
|
12390 | }
|
12391 |
|
12392 | /**
|
12393 | * The decorations for a {@link SourceControlResourceState source control resource state}.
|
12394 | * Can be independently specified for light and dark themes.
|
12395 | */
|
12396 | export interface SourceControlResourceDecorations extends SourceControlResourceThemableDecorations {
|
12397 |
|
12398 | /**
|
12399 | * Whether the {@link SourceControlResourceState source control resource state} should
|
12400 | * be striked-through in the UI.
|
12401 | */
|
12402 | readonly strikeThrough?: boolean;
|
12403 |
|
12404 | /**
|
12405 | * Whether the {@link SourceControlResourceState source control resource state} should
|
12406 | * be faded in the UI.
|
12407 | */
|
12408 | readonly faded?: boolean;
|
12409 |
|
12410 | /**
|
12411 | * The title for a specific
|
12412 | * {@link SourceControlResourceState source control resource state}.
|
12413 | */
|
12414 | readonly tooltip?: string;
|
12415 |
|
12416 | /**
|
12417 | * The light theme decorations.
|
12418 | */
|
12419 | readonly light?: SourceControlResourceThemableDecorations;
|
12420 |
|
12421 | /**
|
12422 | * The dark theme decorations.
|
12423 | */
|
12424 | readonly dark?: SourceControlResourceThemableDecorations;
|
12425 | }
|
12426 |
|
12427 | /**
|
12428 | * An source control resource state represents the state of an underlying workspace
|
12429 | * resource within a certain {@link SourceControlResourceGroup source control group}.
|
12430 | */
|
12431 | export interface SourceControlResourceState {
|
12432 |
|
12433 | /**
|
12434 | * The {@link Uri} of the underlying resource inside the workspace.
|
12435 | */
|
12436 | readonly resourceUri: Uri;
|
12437 |
|
12438 | /**
|
12439 | * The {@link Command} which should be run when the resource
|
12440 | * state is open in the Source Control viewlet.
|
12441 | */
|
12442 | readonly command?: Command;
|
12443 |
|
12444 | /**
|
12445 | * The {@link SourceControlResourceDecorations decorations} for this source control
|
12446 | * resource state.
|
12447 | */
|
12448 | readonly decorations?: SourceControlResourceDecorations;
|
12449 |
|
12450 | /**
|
12451 | * Context value of the resource state. This can be used to contribute resource specific actions.
|
12452 | * For example, if a resource is given a context value as `diffable`. When contributing actions to `scm/resourceState/context`
|
12453 | * using `menus` extension point, you can specify context value for key `scmResourceState` in `when` expressions, like `scmResourceState == diffable`.
|
12454 | * ```
|
12455 | * "contributes": {
|
12456 | * "menus": {
|
12457 | * "scm/resourceState/context": [
|
12458 | * {
|
12459 | * "command": "extension.diff",
|
12460 | * "when": "scmResourceState == diffable"
|
12461 | * }
|
12462 | * ]
|
12463 | * }
|
12464 | * }
|
12465 | * ```
|
12466 | * This will show action `extension.diff` only for resources with `contextValue` is `diffable`.
|
12467 | */
|
12468 | readonly contextValue?: string;
|
12469 | }
|
12470 |
|
12471 | /**
|
12472 | * A source control resource group is a collection of
|
12473 | * {@link SourceControlResourceState source control resource states}.
|
12474 | */
|
12475 | export interface SourceControlResourceGroup {
|
12476 |
|
12477 | /**
|
12478 | * The id of this source control resource group.
|
12479 | */
|
12480 | readonly id: string;
|
12481 |
|
12482 | /**
|
12483 | * The label of this source control resource group.
|
12484 | */
|
12485 | label: string;
|
12486 |
|
12487 | /**
|
12488 | * Whether this source control resource group is hidden when it contains
|
12489 | * no {@link SourceControlResourceState source control resource states}.
|
12490 | */
|
12491 | hideWhenEmpty?: boolean;
|
12492 |
|
12493 | /**
|
12494 | * This group's collection of
|
12495 | * {@link SourceControlResourceState source control resource states}.
|
12496 | */
|
12497 | resourceStates: SourceControlResourceState[];
|
12498 |
|
12499 | /**
|
12500 | * Dispose this source control resource group.
|
12501 | */
|
12502 | dispose(): void;
|
12503 | }
|
12504 |
|
12505 | /**
|
12506 | * An source control is able to provide {@link SourceControlResourceState resource states}
|
12507 | * to the editor and interact with the editor in several source control related ways.
|
12508 | */
|
12509 | export interface SourceControl {
|
12510 |
|
12511 | /**
|
12512 | * The id of this source control.
|
12513 | */
|
12514 | readonly id: string;
|
12515 |
|
12516 | /**
|
12517 | * The human-readable label of this source control.
|
12518 | */
|
12519 | readonly label: string;
|
12520 |
|
12521 | /**
|
12522 | * The (optional) Uri of the root of this source control.
|
12523 | */
|
12524 | readonly rootUri: Uri | undefined;
|
12525 |
|
12526 | /**
|
12527 | * The {@link SourceControlInputBox input box} for this source control.
|
12528 | */
|
12529 | readonly inputBox: SourceControlInputBox;
|
12530 |
|
12531 | /**
|
12532 | * The UI-visible count of {@link SourceControlResourceState resource states} of
|
12533 | * this source control.
|
12534 | *
|
12535 | * Equals to the total number of {@link SourceControlResourceState resource state}
|
12536 | * of this source control, if undefined.
|
12537 | */
|
12538 | count?: number;
|
12539 |
|
12540 | /**
|
12541 | * An optional {@link QuickDiffProvider quick diff provider}.
|
12542 | */
|
12543 | quickDiffProvider?: QuickDiffProvider;
|
12544 |
|
12545 | /**
|
12546 | * Optional commit template string.
|
12547 | *
|
12548 | * The Source Control viewlet will populate the Source Control
|
12549 | * input with this value when appropriate.
|
12550 | */
|
12551 | commitTemplate?: string;
|
12552 |
|
12553 | /**
|
12554 | * Optional accept input command.
|
12555 | *
|
12556 | * This command will be invoked when the user accepts the value
|
12557 | * in the Source Control input.
|
12558 | */
|
12559 | acceptInputCommand?: Command;
|
12560 |
|
12561 | /**
|
12562 | * Optional status bar commands.
|
12563 | *
|
12564 | * These commands will be displayed in the editor's status bar.
|
12565 | */
|
12566 | statusBarCommands?: Command[];
|
12567 |
|
12568 | /**
|
12569 | * Create a new {@link SourceControlResourceGroup resource group}.
|
12570 | */
|
12571 | createResourceGroup(id: string, label: string): SourceControlResourceGroup;
|
12572 |
|
12573 | /**
|
12574 | * Dispose this source control.
|
12575 | */
|
12576 | dispose(): void;
|
12577 | }
|
12578 |
|
12579 | export namespace scm {
|
12580 |
|
12581 | /**
|
12582 | * The {@link SourceControlInputBox input box} for the last source control
|
12583 | * created by the extension.
|
12584 | *
|
12585 | * @deprecated Use SourceControl.inputBox instead
|
12586 | */
|
12587 | export const inputBox: SourceControlInputBox;
|
12588 |
|
12589 | /**
|
12590 | * Creates a new {@link SourceControl source control} instance.
|
12591 | *
|
12592 | * @param id An `id` for the source control. Something short, e.g.: `git`.
|
12593 | * @param label A human-readable string for the source control. E.g.: `Git`.
|
12594 | * @param rootUri An optional Uri of the root of the source control. E.g.: `Uri.parse(workspaceRoot)`.
|
12595 | * @return An instance of {@link SourceControl source control}.
|
12596 | */
|
12597 | export function createSourceControl(id: string, label: string, rootUri?: Uri): SourceControl;
|
12598 | }
|
12599 |
|
12600 | /**
|
12601 | * 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.
|
12602 | */
|
12603 | export interface DebugProtocolMessage {
|
12604 | // Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Base_Protocol_ProtocolMessage).
|
12605 | }
|
12606 |
|
12607 | /**
|
12608 | * 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.
|
12609 | */
|
12610 | export interface DebugProtocolSource {
|
12611 | // Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Source).
|
12612 | }
|
12613 |
|
12614 | /**
|
12615 | * 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.
|
12616 | */
|
12617 | export interface DebugProtocolBreakpoint {
|
12618 | // Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Types_Breakpoint).
|
12619 | }
|
12620 |
|
12621 | /**
|
12622 | * Configuration for a debug session.
|
12623 | */
|
12624 | export interface DebugConfiguration {
|
12625 | /**
|
12626 | * The type of the debug session.
|
12627 | */
|
12628 | type: string;
|
12629 |
|
12630 | /**
|
12631 | * The name of the debug session.
|
12632 | */
|
12633 | name: string;
|
12634 |
|
12635 | /**
|
12636 | * The request type of the debug session.
|
12637 | */
|
12638 | request: string;
|
12639 |
|
12640 | /**
|
12641 | * Additional debug type specific properties.
|
12642 | */
|
12643 | [key: string]: any;
|
12644 | }
|
12645 |
|
12646 | /**
|
12647 | * A debug session.
|
12648 | */
|
12649 | export interface DebugSession {
|
12650 |
|
12651 | /**
|
12652 | * The unique ID of this debug session.
|
12653 | */
|
12654 | readonly id: string;
|
12655 |
|
12656 | /**
|
12657 | * The debug session's type from the {@link DebugConfiguration debug configuration}.
|
12658 | */
|
12659 | readonly type: string;
|
12660 |
|
12661 | /**
|
12662 | * The parent session of this debug session, if it was created as a child.
|
12663 | * @see DebugSessionOptions.parentSession
|
12664 | */
|
12665 | readonly parentSession?: DebugSession;
|
12666 |
|
12667 | /**
|
12668 | * The debug session's name is initially taken from the {@link DebugConfiguration debug configuration}.
|
12669 | * Any changes will be properly reflected in the UI.
|
12670 | */
|
12671 | name: string;
|
12672 |
|
12673 | /**
|
12674 | * The workspace folder of this session or `undefined` for a folderless setup.
|
12675 | */
|
12676 | readonly workspaceFolder: WorkspaceFolder | undefined;
|
12677 |
|
12678 | /**
|
12679 | * The "resolved" {@link DebugConfiguration debug configuration} of this session.
|
12680 | * "Resolved" means that
|
12681 | * - all variables have been substituted and
|
12682 | * - platform specific attribute sections have been "flattened" for the matching platform and removed for non-matching platforms.
|
12683 | */
|
12684 | readonly configuration: DebugConfiguration;
|
12685 |
|
12686 | /**
|
12687 | * Send a custom request to the debug adapter.
|
12688 | */
|
12689 | customRequest(command: string, args?: any): Thenable<any>;
|
12690 |
|
12691 | /**
|
12692 | * Maps a breakpoint in the editor to the corresponding Debug Adapter Protocol (DAP) breakpoint that is managed by the debug adapter of the debug session.
|
12693 | * If no DAP breakpoint exists (either because the editor breakpoint was not yet registered or because the debug adapter is not interested in the breakpoint), the value `undefined` is returned.
|
12694 | *
|
12695 | * @param breakpoint A {@link Breakpoint} in the editor.
|
12696 | * @return A promise that resolves to the Debug Adapter Protocol breakpoint or `undefined`.
|
12697 | */
|
12698 | getDebugProtocolBreakpoint(breakpoint: Breakpoint): Thenable<DebugProtocolBreakpoint | undefined>;
|
12699 | }
|
12700 |
|
12701 | /**
|
12702 | * A custom Debug Adapter Protocol event received from a {@link DebugSession debug session}.
|
12703 | */
|
12704 | export interface DebugSessionCustomEvent {
|
12705 | /**
|
12706 | * The {@link DebugSession debug session} for which the custom event was received.
|
12707 | */
|
12708 | readonly session: DebugSession;
|
12709 |
|
12710 | /**
|
12711 | * Type of event.
|
12712 | */
|
12713 | readonly event: string;
|
12714 |
|
12715 | /**
|
12716 | * Event specific information.
|
12717 | */
|
12718 | readonly body?: any;
|
12719 | }
|
12720 |
|
12721 | /**
|
12722 | * A debug configuration provider allows to add debug configurations to the debug service
|
12723 | * and to resolve launch configurations before they are used to start a debug session.
|
12724 | * A debug configuration provider is registered via {@link debug.registerDebugConfigurationProvider}.
|
12725 | */
|
12726 | export interface DebugConfigurationProvider {
|
12727 | /**
|
12728 | * Provides {@link DebugConfiguration debug configuration} to the debug service. If more than one debug configuration provider is
|
12729 | * registered for the same type, debug configurations are concatenated in arbitrary order.
|
12730 | *
|
12731 | * @param folder The workspace folder for which the configurations are used or `undefined` for a folderless setup.
|
12732 | * @param token A cancellation token.
|
12733 | * @return An array of {@link DebugConfiguration debug configurations}.
|
12734 | */
|
12735 | provideDebugConfigurations?(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult<DebugConfiguration[]>;
|
12736 |
|
12737 | /**
|
12738 | * Resolves a {@link DebugConfiguration debug configuration} by filling in missing values or by adding/changing/removing attributes.
|
12739 | * If more than one debug configuration provider is registered for the same type, the resolveDebugConfiguration calls are chained
|
12740 | * in arbitrary order and the initial debug configuration is piped through the chain.
|
12741 | * Returning the value 'undefined' prevents the debug session from starting.
|
12742 | * Returning the value 'null' prevents the debug session from starting and opens the underlying debug configuration instead.
|
12743 | *
|
12744 | * @param folder The workspace folder from which the configuration originates from or `undefined` for a folderless setup.
|
12745 | * @param debugConfiguration The {@link DebugConfiguration debug configuration} to resolve.
|
12746 | * @param token A cancellation token.
|
12747 | * @return The resolved debug configuration or undefined or null.
|
12748 | */
|
12749 | resolveDebugConfiguration?(folder: WorkspaceFolder | undefined, debugConfiguration: DebugConfiguration, token?: CancellationToken): ProviderResult<DebugConfiguration>;
|
12750 |
|
12751 | /**
|
12752 | * This hook is directly called after 'resolveDebugConfiguration' but with all variables substituted.
|
12753 | * It can be used to resolve or verify a {@link DebugConfiguration debug configuration} by filling in missing values or by adding/changing/removing attributes.
|
12754 | * If more than one debug configuration provider is registered for the same type, the 'resolveDebugConfigurationWithSubstitutedVariables' calls are chained
|
12755 | * in arbitrary order and the initial debug configuration is piped through the chain.
|
12756 | * Returning the value 'undefined' prevents the debug session from starting.
|
12757 | * Returning the value 'null' prevents the debug session from starting and opens the underlying debug configuration instead.
|
12758 | *
|
12759 | * @param folder The workspace folder from which the configuration originates from or `undefined` for a folderless setup.
|
12760 | * @param debugConfiguration The {@link DebugConfiguration debug configuration} to resolve.
|
12761 | * @param token A cancellation token.
|
12762 | * @return The resolved debug configuration or undefined or null.
|
12763 | */
|
12764 | resolveDebugConfigurationWithSubstitutedVariables?(folder: WorkspaceFolder | undefined, debugConfiguration: DebugConfiguration, token?: CancellationToken): ProviderResult<DebugConfiguration>;
|
12765 | }
|
12766 |
|
12767 | /**
|
12768 | * Represents a debug adapter executable and optional arguments and runtime options passed to it.
|
12769 | */
|
12770 | export class DebugAdapterExecutable {
|
12771 |
|
12772 | /**
|
12773 | * Creates a description for a debug adapter based on an executable program.
|
12774 | *
|
12775 | * @param command The command or executable path that implements the debug adapter.
|
12776 | * @param args Optional arguments to be passed to the command or executable.
|
12777 | * @param options Optional options to be used when starting the command or executable.
|
12778 | */
|
12779 | constructor(command: string, args?: string[], options?: DebugAdapterExecutableOptions);
|
12780 |
|
12781 | /**
|
12782 | * The command or path of the debug adapter executable.
|
12783 | * 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.
|
12784 | * The special value 'node' will be mapped to the editor's built-in Node.js runtime.
|
12785 | */
|
12786 | readonly command: string;
|
12787 |
|
12788 | /**
|
12789 | * The arguments passed to the debug adapter executable. Defaults to an empty array.
|
12790 | */
|
12791 | readonly args: string[];
|
12792 |
|
12793 | /**
|
12794 | * Optional options to be used when the debug adapter is started.
|
12795 | * Defaults to undefined.
|
12796 | */
|
12797 | readonly options?: DebugAdapterExecutableOptions;
|
12798 | }
|
12799 |
|
12800 | /**
|
12801 | * Options for a debug adapter executable.
|
12802 | */
|
12803 | export interface DebugAdapterExecutableOptions {
|
12804 |
|
12805 | /**
|
12806 | * The additional environment of the executed program or shell. If omitted
|
12807 | * the parent process' environment is used. If provided it is merged with
|
12808 | * the parent process' environment.
|
12809 | */
|
12810 | env?: { [key: string]: string };
|
12811 |
|
12812 | /**
|
12813 | * The current working directory for the executed debug adapter.
|
12814 | */
|
12815 | cwd?: string;
|
12816 | }
|
12817 |
|
12818 | /**
|
12819 | * Represents a debug adapter running as a socket based server.
|
12820 | */
|
12821 | export class DebugAdapterServer {
|
12822 |
|
12823 | /**
|
12824 | * The port.
|
12825 | */
|
12826 | readonly port: number;
|
12827 |
|
12828 | /**
|
12829 | * The host.
|
12830 | */
|
12831 | readonly host?: string;
|
12832 |
|
12833 | /**
|
12834 | * Create a description for a debug adapter running as a socket based server.
|
12835 | */
|
12836 | constructor(port: number, host?: string);
|
12837 | }
|
12838 |
|
12839 | /**
|
12840 | * Represents a debug adapter running as a Named Pipe (on Windows)/UNIX Domain Socket (on non-Windows) based server.
|
12841 | */
|
12842 | export class DebugAdapterNamedPipeServer {
|
12843 | /**
|
12844 | * The path to the NamedPipe/UNIX Domain Socket.
|
12845 | */
|
12846 | readonly path: string;
|
12847 |
|
12848 | /**
|
12849 | * Create a description for a debug adapter running as a Named Pipe (on Windows)/UNIX Domain Socket (on non-Windows) based server.
|
12850 | */
|
12851 | constructor(path: string);
|
12852 | }
|
12853 |
|
12854 | /**
|
12855 | * A debug adapter that implements the Debug Adapter Protocol can be registered with the editor if it implements the DebugAdapter interface.
|
12856 | */
|
12857 | export interface DebugAdapter extends Disposable {
|
12858 |
|
12859 | /**
|
12860 | * An event which fires after the debug adapter has sent a Debug Adapter Protocol message to the editor.
|
12861 | * Messages can be requests, responses, or events.
|
12862 | */
|
12863 | readonly onDidSendMessage: Event<DebugProtocolMessage>;
|
12864 |
|
12865 | /**
|
12866 | * Handle a Debug Adapter Protocol message.
|
12867 | * Messages can be requests, responses, or events.
|
12868 | * Results or errors are returned via onSendMessage events.
|
12869 | * @param message A Debug Adapter Protocol message
|
12870 | */
|
12871 | handleMessage(message: DebugProtocolMessage): void;
|
12872 | }
|
12873 |
|
12874 | /**
|
12875 | * A debug adapter descriptor for an inline implementation.
|
12876 | */
|
12877 | export class DebugAdapterInlineImplementation {
|
12878 |
|
12879 | /**
|
12880 | * Create a descriptor for an inline implementation of a debug adapter.
|
12881 | */
|
12882 | constructor(implementation: DebugAdapter);
|
12883 | }
|
12884 |
|
12885 | export type DebugAdapterDescriptor = DebugAdapterExecutable | DebugAdapterServer | DebugAdapterNamedPipeServer | DebugAdapterInlineImplementation;
|
12886 |
|
12887 | export interface DebugAdapterDescriptorFactory {
|
12888 | /**
|
12889 | * 'createDebugAdapterDescriptor' is called at the start of a debug session to provide details about the debug adapter to use.
|
12890 | * These details must be returned as objects of type {@link DebugAdapterDescriptor}.
|
12891 | * Currently two types of debug adapters are supported:
|
12892 | * - a debug adapter executable is specified as a command path and arguments (see {@link DebugAdapterExecutable}),
|
12893 | * - a debug adapter server reachable via a communication port (see {@link DebugAdapterServer}).
|
12894 | * If the method is not implemented the default behavior is this:
|
12895 | * createDebugAdapter(session: DebugSession, executable: DebugAdapterExecutable) {
|
12896 | * if (typeof session.configuration.debugServer === 'number') {
|
12897 | * return new DebugAdapterServer(session.configuration.debugServer);
|
12898 | * }
|
12899 | * return executable;
|
12900 | * }
|
12901 | * @param session The {@link DebugSession debug session} for which the debug adapter will be used.
|
12902 | * @param executable The debug adapter's executable information as specified in the package.json (or undefined if no such information exists).
|
12903 | * @return a {@link DebugAdapterDescriptor debug adapter descriptor} or undefined.
|
12904 | */
|
12905 | createDebugAdapterDescriptor(session: DebugSession, executable: DebugAdapterExecutable | undefined): ProviderResult<DebugAdapterDescriptor>;
|
12906 | }
|
12907 |
|
12908 | /**
|
12909 | * A Debug Adapter Tracker is a means to track the communication between the editor and a Debug Adapter.
|
12910 | */
|
12911 | export interface DebugAdapterTracker {
|
12912 | /**
|
12913 | * A session with the debug adapter is about to be started.
|
12914 | */
|
12915 | onWillStartSession?(): void;
|
12916 | /**
|
12917 | * The debug adapter is about to receive a Debug Adapter Protocol message from the editor.
|
12918 | */
|
12919 | onWillReceiveMessage?(message: any): void;
|
12920 | /**
|
12921 | * The debug adapter has sent a Debug Adapter Protocol message to the editor.
|
12922 | */
|
12923 | onDidSendMessage?(message: any): void;
|
12924 | /**
|
12925 | * The debug adapter session is about to be stopped.
|
12926 | */
|
12927 | onWillStopSession?(): void;
|
12928 | /**
|
12929 | * An error with the debug adapter has occurred.
|
12930 | */
|
12931 | onError?(error: Error): void;
|
12932 | /**
|
12933 | * The debug adapter has exited with the given exit code or signal.
|
12934 | */
|
12935 | onExit?(code: number | undefined, signal: string | undefined): void;
|
12936 | }
|
12937 |
|
12938 | export interface DebugAdapterTrackerFactory {
|
12939 | /**
|
12940 | * The method 'createDebugAdapterTracker' is called at the start of a debug session in order
|
12941 | * to return a "tracker" object that provides read-access to the communication between the editor and a debug adapter.
|
12942 | *
|
12943 | * @param session The {@link DebugSession debug session} for which the debug adapter tracker will be used.
|
12944 | * @return A {@link DebugAdapterTracker debug adapter tracker} or undefined.
|
12945 | */
|
12946 | createDebugAdapterTracker(session: DebugSession): ProviderResult<DebugAdapterTracker>;
|
12947 | }
|
12948 |
|
12949 | /**
|
12950 | * Represents the debug console.
|
12951 | */
|
12952 | export interface DebugConsole {
|
12953 | /**
|
12954 | * Append the given value to the debug console.
|
12955 | *
|
12956 | * @param value A string, falsy values will not be printed.
|
12957 | */
|
12958 | append(value: string): void;
|
12959 |
|
12960 | /**
|
12961 | * Append the given value and a line feed character
|
12962 | * to the debug console.
|
12963 | *
|
12964 | * @param value A string, falsy values will be printed.
|
12965 | */
|
12966 | appendLine(value: string): void;
|
12967 | }
|
12968 |
|
12969 | /**
|
12970 | * An event describing the changes to the set of {@link Breakpoint breakpoints}.
|
12971 | */
|
12972 | export interface BreakpointsChangeEvent {
|
12973 | /**
|
12974 | * Added breakpoints.
|
12975 | */
|
12976 | readonly added: readonly Breakpoint[];
|
12977 |
|
12978 | /**
|
12979 | * Removed breakpoints.
|
12980 | */
|
12981 | readonly removed: readonly Breakpoint[];
|
12982 |
|
12983 | /**
|
12984 | * Changed breakpoints.
|
12985 | */
|
12986 | readonly changed: readonly Breakpoint[];
|
12987 | }
|
12988 |
|
12989 | /**
|
12990 | * The base class of all breakpoint types.
|
12991 | */
|
12992 | export class Breakpoint {
|
12993 | /**
|
12994 | * The unique ID of the breakpoint.
|
12995 | */
|
12996 | readonly id: string;
|
12997 | /**
|
12998 | * Is breakpoint enabled.
|
12999 | */
|
13000 | readonly enabled: boolean;
|
13001 | /**
|
13002 | * An optional expression for conditional breakpoints.
|
13003 | */
|
13004 | readonly condition?: string;
|
13005 | /**
|
13006 | * An optional expression that controls how many hits of the breakpoint are ignored.
|
13007 | */
|
13008 | readonly hitCondition?: string;
|
13009 | /**
|
13010 | * An optional message that gets logged when this breakpoint is hit. Embedded expressions within {} are interpolated by the debug adapter.
|
13011 | */
|
13012 | readonly logMessage?: string;
|
13013 |
|
13014 | protected constructor(enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string);
|
13015 | }
|
13016 |
|
13017 | /**
|
13018 | * A breakpoint specified by a source location.
|
13019 | */
|
13020 | export class SourceBreakpoint extends Breakpoint {
|
13021 | /**
|
13022 | * The source and line position of this breakpoint.
|
13023 | */
|
13024 | readonly location: Location;
|
13025 |
|
13026 | /**
|
13027 | * Create a new breakpoint for a source location.
|
13028 | */
|
13029 | constructor(location: Location, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string);
|
13030 | }
|
13031 |
|
13032 | /**
|
13033 | * A breakpoint specified by a function name.
|
13034 | */
|
13035 | export class FunctionBreakpoint extends Breakpoint {
|
13036 | /**
|
13037 | * The name of the function to which this breakpoint is attached.
|
13038 | */
|
13039 | readonly functionName: string;
|
13040 |
|
13041 | /**
|
13042 | * Create a new function breakpoint.
|
13043 | */
|
13044 | constructor(functionName: string, enabled?: boolean, condition?: string, hitCondition?: string, logMessage?: string);
|
13045 | }
|
13046 |
|
13047 | /**
|
13048 | * Debug console mode used by debug session, see { DebugSessionOptions options}.
|
13049 | */
|
13050 | export enum DebugConsoleMode {
|
13051 | /**
|
13052 | * Debug session should have a separate debug console.
|
13053 | */
|
13054 | Separate = 0,
|
13055 |
|
13056 | /**
|
13057 | * Debug session should share debug console with its parent session.
|
13058 | * This value has no effect for sessions which do not have a parent session.
|
13059 | */
|
13060 | MergeWithParent = 1
|
13061 | }
|
13062 |
|
13063 | /**
|
13064 | * Options for {@link debug.startDebugging starting a debug session}.
|
13065 | */
|
13066 | export interface DebugSessionOptions {
|
13067 |
|
13068 | /**
|
13069 | * When specified the newly created debug session is registered as a "child" session of this
|
13070 | * "parent" debug session.
|
13071 | */
|
13072 | parentSession?: DebugSession;
|
13073 |
|
13074 | /**
|
13075 | * Controls whether lifecycle requests like 'restart' are sent to the newly created session or its parent session.
|
13076 | * By default (if the property is false or missing), lifecycle requests are sent to the new session.
|
13077 | * This property is ignored if the session has no parent session.
|
13078 | */
|
13079 | lifecycleManagedByParent?: boolean;
|
13080 |
|
13081 | /**
|
13082 | * Controls whether this session should have a separate debug console or share it
|
13083 | * with the parent session. Has no effect for sessions which do not have a parent session.
|
13084 | * Defaults to Separate.
|
13085 | */
|
13086 | consoleMode?: DebugConsoleMode;
|
13087 |
|
13088 | /**
|
13089 | * Controls whether this session should run without debugging, thus ignoring breakpoints.
|
13090 | * When this property is not specified, the value from the parent session (if there is one) is used.
|
13091 | */
|
13092 | noDebug?: boolean;
|
13093 |
|
13094 | /**
|
13095 | * Controls if the debug session's parent session is shown in the CALL STACK view even if it has only a single child.
|
13096 | * By default, the debug session will never hide its parent.
|
13097 | * If compact is true, debug sessions with a single child are hidden in the CALL STACK view to make the tree more compact.
|
13098 | */
|
13099 | compact?: boolean;
|
13100 | }
|
13101 |
|
13102 | /**
|
13103 | * A DebugConfigurationProviderTriggerKind specifies when the `provideDebugConfigurations` method of a `DebugConfigurationProvider` is triggered.
|
13104 | * Currently there are two situations: to provide the initial debug configurations for a newly created launch.json or
|
13105 | * to provide dynamically generated debug configurations when the user asks for them through the UI (e.g. via the "Select and Start Debugging" command).
|
13106 | * A trigger kind is used when registering a `DebugConfigurationProvider` with {@link debug.registerDebugConfigurationProvider}.
|
13107 | */
|
13108 | export enum DebugConfigurationProviderTriggerKind {
|
13109 | /**
|
13110 | * `DebugConfigurationProvider.provideDebugConfigurations` is called to provide the initial debug configurations for a newly created launch.json.
|
13111 | */
|
13112 | Initial = 1,
|
13113 | /**
|
13114 | * `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).
|
13115 | */
|
13116 | Dynamic = 2
|
13117 | }
|
13118 |
|
13119 | /**
|
13120 | * Namespace for debug functionality.
|
13121 | */
|
13122 | export namespace debug {
|
13123 |
|
13124 | /**
|
13125 | * The currently active {@link DebugSession debug session} or `undefined`. The active debug session is the one
|
13126 | * represented by the debug action floating window or the one currently shown in the drop down menu of the debug action floating window.
|
13127 | * If no debug session is active, the value is `undefined`.
|
13128 | */
|
13129 | export let activeDebugSession: DebugSession | undefined;
|
13130 |
|
13131 | /**
|
13132 | * The currently active {@link DebugConsole debug console}.
|
13133 | * If no debug session is active, output sent to the debug console is not shown.
|
13134 | */
|
13135 | export let activeDebugConsole: DebugConsole;
|
13136 |
|
13137 | /**
|
13138 | * List of breakpoints.
|
13139 | */
|
13140 | export let breakpoints: Breakpoint[];
|
13141 |
|
13142 | /**
|
13143 | * An {@link Event} which fires when the {@link debug.activeDebugSession active debug session}
|
13144 | * has changed. *Note* that the event also fires when the active debug session changes
|
13145 | * to `undefined`.
|
13146 | */
|
13147 | export const onDidChangeActiveDebugSession: Event<DebugSession | undefined>;
|
13148 |
|
13149 | /**
|
13150 | * An {@link Event} which fires when a new {@link DebugSession debug session} has been started.
|
13151 | */
|
13152 | export const onDidStartDebugSession: Event<DebugSession>;
|
13153 |
|
13154 | /**
|
13155 | * An {@link Event} which fires when a custom DAP event is received from the {@link DebugSession debug session}.
|
13156 | */
|
13157 | export const onDidReceiveDebugSessionCustomEvent: Event<DebugSessionCustomEvent>;
|
13158 |
|
13159 | /**
|
13160 | * An {@link Event} which fires when a {@link DebugSession debug session} has terminated.
|
13161 | */
|
13162 | export const onDidTerminateDebugSession: Event<DebugSession>;
|
13163 |
|
13164 | /**
|
13165 | * An {@link Event} that is emitted when the set of breakpoints is added, removed, or changed.
|
13166 | */
|
13167 | export const onDidChangeBreakpoints: Event<BreakpointsChangeEvent>;
|
13168 |
|
13169 | /**
|
13170 | * Register a {@link DebugConfigurationProvider debug configuration provider} for a specific debug type.
|
13171 | * The optional {@link DebugConfigurationProviderTriggerKind triggerKind} can be used to specify when the `provideDebugConfigurations` method of the provider is triggered.
|
13172 | * 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.
|
13173 | * 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).
|
13174 | * Please note that the `triggerKind` argument only applies to the `provideDebugConfigurations` method: so the `resolveDebugConfiguration` methods are not affected at all.
|
13175 | * Registering a single provider with resolve methods for different trigger kinds, results in the same resolve methods called multiple times.
|
13176 | * More than one provider can be registered for the same type.
|
13177 | *
|
13178 | * @param type The debug type for which the provider is registered.
|
13179 | * @param provider The {@link DebugConfigurationProvider debug configuration provider} to register.
|
13180 | * @param triggerKind The {@link DebugConfigurationProviderTrigger trigger} for which the 'provideDebugConfiguration' method of the provider is registered. If `triggerKind` is missing, the value `DebugConfigurationProviderTriggerKind.Initial` is assumed.
|
13181 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
13182 | */
|
13183 | export function registerDebugConfigurationProvider(debugType: string, provider: DebugConfigurationProvider, triggerKind?: DebugConfigurationProviderTriggerKind): Disposable;
|
13184 |
|
13185 | /**
|
13186 | * Register a {@link DebugAdapterDescriptorFactory debug adapter descriptor factory} for a specific debug type.
|
13187 | * An extension is only allowed to register a DebugAdapterDescriptorFactory for the debug type(s) defined by the extension. Otherwise an error is thrown.
|
13188 | * Registering more than one DebugAdapterDescriptorFactory for a debug type results in an error.
|
13189 | *
|
13190 | * @param debugType The debug type for which the factory is registered.
|
13191 | * @param factory The {@link DebugAdapterDescriptorFactory debug adapter descriptor factory} to register.
|
13192 | * @return A {@link Disposable} that unregisters this factory when being disposed.
|
13193 | */
|
13194 | export function registerDebugAdapterDescriptorFactory(debugType: string, factory: DebugAdapterDescriptorFactory): Disposable;
|
13195 |
|
13196 | /**
|
13197 | * Register a debug adapter tracker factory for the given debug type.
|
13198 | *
|
13199 | * @param debugType The debug type for which the factory is registered or '*' for matching all debug types.
|
13200 | * @param factory The {@link DebugAdapterTrackerFactory debug adapter tracker factory} to register.
|
13201 | * @return A {@link Disposable} that unregisters this factory when being disposed.
|
13202 | */
|
13203 | export function registerDebugAdapterTrackerFactory(debugType: string, factory: DebugAdapterTrackerFactory): Disposable;
|
13204 |
|
13205 | /**
|
13206 | * Start debugging by using either a named launch or named compound configuration,
|
13207 | * or by directly passing a {@link DebugConfiguration}.
|
13208 | * The named configurations are looked up in '.vscode/launch.json' found in the given folder.
|
13209 | * Before debugging starts, all unsaved files are saved and the launch configurations are brought up-to-date.
|
13210 | * Folder specific variables used in the configuration (e.g. '${workspaceFolder}') are resolved against the given folder.
|
13211 | * @param folder The {@link WorkspaceFolder workspace folder} for looking up named configurations and resolving variables or `undefined` for a non-folder setup.
|
13212 | * @param nameOrConfiguration Either the name of a debug or compound configuration or a {@link DebugConfiguration} object.
|
13213 | * @param parentSessionOrOptions Debug session options. When passed a parent {@link DebugSession debug session}, assumes options with just this parent session.
|
13214 | * @return A thenable that resolves when debugging could be successfully started.
|
13215 | */
|
13216 | export function startDebugging(folder: WorkspaceFolder | undefined, nameOrConfiguration: string | DebugConfiguration, parentSessionOrOptions?: DebugSession | DebugSessionOptions): Thenable<boolean>;
|
13217 |
|
13218 | /**
|
13219 | * Stop the given debug session or stop all debug sessions if session is omitted.
|
13220 | * @param session The {@link DebugSession debug session} to stop; if omitted all sessions are stopped.
|
13221 | */
|
13222 | export function stopDebugging(session?: DebugSession): Thenable<void>;
|
13223 |
|
13224 | /**
|
13225 | * Add breakpoints.
|
13226 | * @param breakpoints The breakpoints to add.
|
13227 | */
|
13228 | export function addBreakpoints(breakpoints: readonly Breakpoint[]): void;
|
13229 |
|
13230 | /**
|
13231 | * Remove breakpoints.
|
13232 | * @param breakpoints The breakpoints to remove.
|
13233 | */
|
13234 | export function removeBreakpoints(breakpoints: readonly Breakpoint[]): void;
|
13235 |
|
13236 | /**
|
13237 | * Converts a "Source" descriptor object received via the Debug Adapter Protocol into a Uri that can be used to load its contents.
|
13238 | * If the source descriptor is based on a path, a file Uri is returned.
|
13239 | * If the source descriptor uses a reference number, a specific debug Uri (scheme 'debug') is constructed that requires a corresponding ContentProvider and a running debug session
|
13240 | *
|
13241 | * If the "Source" descriptor has insufficient information for creating the Uri, an error is thrown.
|
13242 | *
|
13243 | * @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.
|
13244 | * @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.
|
13245 | * @return A uri that can be used to load the contents of the source.
|
13246 | */
|
13247 | export function asDebugSourceUri(source: DebugProtocolSource, session?: DebugSession): Uri;
|
13248 | }
|
13249 |
|
13250 | /**
|
13251 | * Namespace for dealing with installed extensions. Extensions are represented
|
13252 | * by an {@link Extension}-interface which enables reflection on them.
|
13253 | *
|
13254 | * Extension writers can provide APIs to other extensions by returning their API public
|
13255 | * surface from the `activate`-call.
|
13256 | *
|
13257 | * ```javascript
|
13258 | * export function activate(context: vscode.ExtensionContext) {
|
13259 | * let api = {
|
13260 | * sum(a, b) {
|
13261 | * return a + b;
|
13262 | * },
|
13263 | * mul(a, b) {
|
13264 | * return a * b;
|
13265 | * }
|
13266 | * };
|
13267 | * // 'export' public api-surface
|
13268 | * return api;
|
13269 | * }
|
13270 | * ```
|
13271 | * When depending on the API of another extension add an `extensionDependencies`-entry
|
13272 | * to `package.json`, and use the {@link extensions.getExtension getExtension}-function
|
13273 | * and the {@link Extension.exports exports}-property, like below:
|
13274 | *
|
13275 | * ```javascript
|
13276 | * let mathExt = extensions.getExtension('genius.math');
|
13277 | * let importedApi = mathExt.exports;
|
13278 | *
|
13279 | * console.log(importedApi.mul(42, 1));
|
13280 | * ```
|
13281 | */
|
13282 | export namespace extensions {
|
13283 |
|
13284 | /**
|
13285 | * Get an extension by its full identifier in the form of: `publisher.name`.
|
13286 | *
|
13287 | * @param extensionId An extension identifier.
|
13288 | * @return An extension or `undefined`.
|
13289 | */
|
13290 | export function getExtension(extensionId: string): Extension<any> | undefined;
|
13291 |
|
13292 | /**
|
13293 | * Get an extension by its full identifier in the form of: `publisher.name`.
|
13294 | *
|
13295 | * @param extensionId An extension identifier.
|
13296 | * @return An extension or `undefined`.
|
13297 | */
|
13298 | export function getExtension<T>(extensionId: string): Extension<T> | undefined;
|
13299 |
|
13300 | /**
|
13301 | * All extensions currently known to the system.
|
13302 | */
|
13303 | export const all: readonly Extension<any>[];
|
13304 |
|
13305 | /**
|
13306 | * An event which fires when `extensions.all` changes. This can happen when extensions are
|
13307 | * installed, uninstalled, enabled or disabled.
|
13308 | */
|
13309 | export const onDidChange: Event<void>;
|
13310 | }
|
13311 |
|
13312 | /**
|
13313 | * Collapsible state of a {@link CommentThread comment thread}
|
13314 | */
|
13315 | export enum CommentThreadCollapsibleState {
|
13316 | /**
|
13317 | * Determines an item is collapsed
|
13318 | */
|
13319 | Collapsed = 0,
|
13320 |
|
13321 | /**
|
13322 | * Determines an item is expanded
|
13323 | */
|
13324 | Expanded = 1
|
13325 | }
|
13326 |
|
13327 | /**
|
13328 | * Comment mode of a {@link Comment}
|
13329 | */
|
13330 | export enum CommentMode {
|
13331 | /**
|
13332 | * Displays the comment editor
|
13333 | */
|
13334 | Editing = 0,
|
13335 |
|
13336 | /**
|
13337 | * Displays the preview of the comment
|
13338 | */
|
13339 | Preview = 1
|
13340 | }
|
13341 |
|
13342 | /**
|
13343 | * A collection of {@link Comment comments} representing a conversation at a particular range in a document.
|
13344 | */
|
13345 | export interface CommentThread {
|
13346 | /**
|
13347 | * The uri of the document the thread has been created on.
|
13348 | */
|
13349 | readonly uri: Uri;
|
13350 |
|
13351 | /**
|
13352 | * The range the comment thread is located within the document. The thread icon will be shown
|
13353 | * at the first line of the range.
|
13354 | */
|
13355 | range: Range;
|
13356 |
|
13357 | /**
|
13358 | * The ordered comments of the thread.
|
13359 | */
|
13360 | comments: readonly Comment[];
|
13361 |
|
13362 | /**
|
13363 | * Whether the thread should be collapsed or expanded when opening the document.
|
13364 | * Defaults to Collapsed.
|
13365 | */
|
13366 | collapsibleState: CommentThreadCollapsibleState;
|
13367 |
|
13368 | /**
|
13369 | * Whether the thread supports reply.
|
13370 | * Defaults to true.
|
13371 | */
|
13372 | canReply: boolean;
|
13373 |
|
13374 | /**
|
13375 | * Context value of the comment thread. This can be used to contribute thread specific actions.
|
13376 | * For example, a comment thread is given a context value as `editable`. When contributing actions to `comments/commentThread/title`
|
13377 | * using `menus` extension point, you can specify context value for key `commentThread` in `when` expression like `commentThread == editable`.
|
13378 | * ```
|
13379 | * "contributes": {
|
13380 | * "menus": {
|
13381 | * "comments/commentThread/title": [
|
13382 | * {
|
13383 | * "command": "extension.deleteCommentThread",
|
13384 | * "when": "commentThread == editable"
|
13385 | * }
|
13386 | * ]
|
13387 | * }
|
13388 | * }
|
13389 | * ```
|
13390 | * This will show action `extension.deleteCommentThread` only for comment threads with `contextValue` is `editable`.
|
13391 | */
|
13392 | contextValue?: string;
|
13393 |
|
13394 | /**
|
13395 | * The optional human-readable label describing the {@link CommentThread Comment Thread}
|
13396 | */
|
13397 | label?: string;
|
13398 |
|
13399 | /**
|
13400 | * Dispose this comment thread.
|
13401 | *
|
13402 | * Once disposed, this comment thread will be removed from visible editors and Comment Panel when appropriate.
|
13403 | */
|
13404 | dispose(): void;
|
13405 | }
|
13406 |
|
13407 | /**
|
13408 | * Author information of a {@link Comment}
|
13409 | */
|
13410 | export interface CommentAuthorInformation {
|
13411 | /**
|
13412 | * The display name of the author of the comment
|
13413 | */
|
13414 | name: string;
|
13415 |
|
13416 | /**
|
13417 | * The optional icon path for the author
|
13418 | */
|
13419 | iconPath?: Uri;
|
13420 | }
|
13421 |
|
13422 | /**
|
13423 | * Reactions of a {@link Comment}
|
13424 | */
|
13425 | export interface CommentReaction {
|
13426 | /**
|
13427 | * The human-readable label for the reaction
|
13428 | */
|
13429 | readonly label: string;
|
13430 |
|
13431 | /**
|
13432 | * Icon for the reaction shown in UI.
|
13433 | */
|
13434 | readonly iconPath: string | Uri;
|
13435 |
|
13436 | /**
|
13437 | * The number of users who have reacted to this reaction
|
13438 | */
|
13439 | readonly count: number;
|
13440 |
|
13441 | /**
|
13442 | * Whether the [author](CommentAuthorInformation) of the comment has reacted to this reaction
|
13443 | */
|
13444 | readonly authorHasReacted: boolean;
|
13445 | }
|
13446 |
|
13447 | /**
|
13448 | * A comment is displayed within the editor or the Comments Panel, depending on how it is provided.
|
13449 | */
|
13450 | export interface Comment {
|
13451 | /**
|
13452 | * The human-readable comment body
|
13453 | */
|
13454 | body: string | MarkdownString;
|
13455 |
|
13456 | /**
|
13457 | * {@link CommentMode Comment mode} of the comment
|
13458 | */
|
13459 | mode: CommentMode;
|
13460 |
|
13461 | /**
|
13462 | * The {@link CommentAuthorInformation author information} of the comment
|
13463 | */
|
13464 | author: CommentAuthorInformation;
|
13465 |
|
13466 | /**
|
13467 | * Context value of the comment. This can be used to contribute comment specific actions.
|
13468 | * For example, a comment is given a context value as `editable`. When contributing actions to `comments/comment/title`
|
13469 | * using `menus` extension point, you can specify context value for key `comment` in `when` expression like `comment == editable`.
|
13470 | * ```json
|
13471 | * "contributes": {
|
13472 | * "menus": {
|
13473 | * "comments/comment/title": [
|
13474 | * {
|
13475 | * "command": "extension.deleteComment",
|
13476 | * "when": "comment == editable"
|
13477 | * }
|
13478 | * ]
|
13479 | * }
|
13480 | * }
|
13481 | * ```
|
13482 | * This will show action `extension.deleteComment` only for comments with `contextValue` is `editable`.
|
13483 | */
|
13484 | contextValue?: string;
|
13485 |
|
13486 | /**
|
13487 | * Optional reactions of the {@link Comment}
|
13488 | */
|
13489 | reactions?: CommentReaction[];
|
13490 |
|
13491 | /**
|
13492 | * Optional label describing the {@link Comment}
|
13493 | * Label will be rendered next to authorName if exists.
|
13494 | */
|
13495 | label?: string;
|
13496 | }
|
13497 |
|
13498 | /**
|
13499 | * Command argument for actions registered in `comments/commentThread/context`.
|
13500 | */
|
13501 | export interface CommentReply {
|
13502 | /**
|
13503 | * The active {@link CommentThread comment thread}
|
13504 | */
|
13505 | thread: CommentThread;
|
13506 |
|
13507 | /**
|
13508 | * The value in the comment editor
|
13509 | */
|
13510 | text: string;
|
13511 | }
|
13512 |
|
13513 | /**
|
13514 | * Commenting range provider for a {@link CommentController comment controller}.
|
13515 | */
|
13516 | export interface CommentingRangeProvider {
|
13517 | /**
|
13518 | * Provide a list of ranges which allow new comment threads creation or null for a given document
|
13519 | */
|
13520 | provideCommentingRanges(document: TextDocument, token: CancellationToken): ProviderResult<Range[]>;
|
13521 | }
|
13522 |
|
13523 | /**
|
13524 | * Represents a {@link CommentController comment controller}'s {@link CommentController.options options}.
|
13525 | */
|
13526 | export interface CommentOptions {
|
13527 | /**
|
13528 | * An optional string to show on the comment input box when it's collapsed.
|
13529 | */
|
13530 | prompt?: string;
|
13531 |
|
13532 | /**
|
13533 | * An optional string to show as placeholder in the comment input box when it's focused.
|
13534 | */
|
13535 | placeHolder?: string;
|
13536 | }
|
13537 |
|
13538 | /**
|
13539 | * A comment controller is able to provide {@link CommentThread comments} support to the editor and
|
13540 | * provide users various ways to interact with comments.
|
13541 | */
|
13542 | export interface CommentController {
|
13543 | /**
|
13544 | * The id of this comment controller.
|
13545 | */
|
13546 | readonly id: string;
|
13547 |
|
13548 | /**
|
13549 | * The human-readable label of this comment controller.
|
13550 | */
|
13551 | readonly label: string;
|
13552 |
|
13553 | /**
|
13554 | * Comment controller options
|
13555 | */
|
13556 | options?: CommentOptions;
|
13557 |
|
13558 | /**
|
13559 | * Optional commenting range provider. Provide a list {@link Range ranges} which support commenting to any given resource uri.
|
13560 | *
|
13561 | * If not provided, users can leave comments in any document opened in the editor.
|
13562 | */
|
13563 | commentingRangeProvider?: CommentingRangeProvider;
|
13564 |
|
13565 | /**
|
13566 | * Create a {@link CommentThread comment thread}. The comment thread will be displayed in visible text editors (if the resource matches)
|
13567 | * and Comments Panel once created.
|
13568 | *
|
13569 | * @param uri The uri of the document the thread has been created on.
|
13570 | * @param range The range the comment thread is located within the document.
|
13571 | * @param comments The ordered comments of the thread.
|
13572 | */
|
13573 | createCommentThread(uri: Uri, range: Range, comments: readonly Comment[]): CommentThread;
|
13574 |
|
13575 | /**
|
13576 | * Optional reaction handler for creating and deleting reactions on a {@link Comment}.
|
13577 | */
|
13578 | reactionHandler?: (comment: Comment, reaction: CommentReaction) => Thenable<void>;
|
13579 |
|
13580 | /**
|
13581 | * Dispose this comment controller.
|
13582 | *
|
13583 | * Once disposed, all {@link CommentThread comment threads} created by this comment controller will also be removed from the editor
|
13584 | * and Comments Panel.
|
13585 | */
|
13586 | dispose(): void;
|
13587 | }
|
13588 |
|
13589 | namespace comments {
|
13590 | /**
|
13591 | * Creates a new {@link CommentController comment controller} instance.
|
13592 | *
|
13593 | * @param id An `id` for the comment controller.
|
13594 | * @param label A human-readable string for the comment controller.
|
13595 | * @return An instance of {@link CommentController comment controller}.
|
13596 | */
|
13597 | export function createCommentController(id: string, label: string): CommentController;
|
13598 | }
|
13599 |
|
13600 | //#endregion
|
13601 |
|
13602 | /**
|
13603 | * Represents a session of a currently logged in user.
|
13604 | */
|
13605 | export interface AuthenticationSession {
|
13606 | /**
|
13607 | * The identifier of the authentication session.
|
13608 | */
|
13609 | readonly id: string;
|
13610 |
|
13611 | /**
|
13612 | * The access token.
|
13613 | */
|
13614 | readonly accessToken: string;
|
13615 |
|
13616 | /**
|
13617 | * The account associated with the session.
|
13618 | */
|
13619 | readonly account: AuthenticationSessionAccountInformation;
|
13620 |
|
13621 | /**
|
13622 | * The permissions granted by the session's access token. Available scopes
|
13623 | * are defined by the {@link AuthenticationProvider}.
|
13624 | */
|
13625 | readonly scopes: readonly string[];
|
13626 | }
|
13627 |
|
13628 | /**
|
13629 | * The information of an account associated with an {@link AuthenticationSession}.
|
13630 | */
|
13631 | export interface AuthenticationSessionAccountInformation {
|
13632 | /**
|
13633 | * The unique identifier of the account.
|
13634 | */
|
13635 | readonly id: string;
|
13636 |
|
13637 | /**
|
13638 | * The human-readable name of the account.
|
13639 | */
|
13640 | readonly label: string;
|
13641 | }
|
13642 |
|
13643 |
|
13644 | /**
|
13645 | * Options to be used when getting an {@link AuthenticationSession} from an {@link AuthenticationProvider}.
|
13646 | */
|
13647 | export interface AuthenticationGetSessionOptions {
|
13648 | /**
|
13649 | * Whether login should be performed if there is no matching session.
|
13650 | *
|
13651 | * If true, a modal dialog will be shown asking the user to sign in. If false, a numbered badge will be shown
|
13652 | * on the accounts activity bar icon. An entry for the extension will be added under the menu to sign in. This
|
13653 | * allows quietly prompting the user to sign in.
|
13654 | *
|
13655 | * If there is a matching session but the extension has not been granted access to it, setting this to true
|
13656 | * will also result in an immediate modal dialog, and false will add a numbered badge to the accounts icon.
|
13657 | *
|
13658 | * Defaults to false.
|
13659 | */
|
13660 | createIfNone?: boolean;
|
13661 |
|
13662 | /**
|
13663 | * Whether the existing user session preference should be cleared.
|
13664 | *
|
13665 | * For authentication providers that support being signed into multiple accounts at once, the user will be
|
13666 | * prompted to select an account to use when {@link authentication.getSession getSession} is called. This preference
|
13667 | * is remembered until {@link authentication.getSession getSession} is called with this flag.
|
13668 | *
|
13669 | * Defaults to false.
|
13670 | */
|
13671 | clearSessionPreference?: boolean;
|
13672 | }
|
13673 |
|
13674 | /**
|
13675 | * Basic information about an {@link AuthenticationProvider}
|
13676 | */
|
13677 | export interface AuthenticationProviderInformation {
|
13678 | /**
|
13679 | * The unique identifier of the authentication provider.
|
13680 | */
|
13681 | readonly id: string;
|
13682 |
|
13683 | /**
|
13684 | * The human-readable name of the authentication provider.
|
13685 | */
|
13686 | readonly label: string;
|
13687 | }
|
13688 |
|
13689 | /**
|
13690 | * An {@link Event} which fires when an {@link AuthenticationSession} is added, removed, or changed.
|
13691 | */
|
13692 | export interface AuthenticationSessionsChangeEvent {
|
13693 | /**
|
13694 | * The {@link AuthenticationProvider} that has had its sessions change.
|
13695 | */
|
13696 | readonly provider: AuthenticationProviderInformation;
|
13697 | }
|
13698 |
|
13699 | /**
|
13700 | * Options for creating an {@link AuthenticationProvider}.
|
13701 | */
|
13702 | export interface AuthenticationProviderOptions {
|
13703 | /**
|
13704 | * Whether it is possible to be signed into multiple accounts at once with this provider.
|
13705 | * If not specified, will default to false.
|
13706 | */
|
13707 | readonly supportsMultipleAccounts?: boolean;
|
13708 | }
|
13709 |
|
13710 | /**
|
13711 | * An {@link Event} which fires when an {@link AuthenticationSession} is added, removed, or changed.
|
13712 | */
|
13713 | export interface AuthenticationProviderAuthenticationSessionsChangeEvent {
|
13714 | /**
|
13715 | * The {@link AuthenticationSession}s of the {@link AuthenticationProvider} that have been added.
|
13716 | */
|
13717 | readonly added?: readonly AuthenticationSession[];
|
13718 |
|
13719 | /**
|
13720 | * The {@link AuthenticationSession}s of the {@link AuthenticationProvider} that have been removed.
|
13721 | */
|
13722 | readonly removed?: readonly AuthenticationSession[];
|
13723 |
|
13724 | /**
|
13725 | * The {@link AuthenticationSession}s of the {@link AuthenticationProvider} that have been changed.
|
13726 | * A session changes when its data excluding the id are updated. An example of this is a session refresh that results in a new
|
13727 | * access token being set for the session.
|
13728 | */
|
13729 | readonly changed?: readonly AuthenticationSession[];
|
13730 | }
|
13731 |
|
13732 | /**
|
13733 | * A provider for performing authentication to a service.
|
13734 | */
|
13735 | export interface AuthenticationProvider {
|
13736 | /**
|
13737 | * An {@link Event} which fires when the array of sessions has changed, or data
|
13738 | * within a session has changed.
|
13739 | */
|
13740 | readonly onDidChangeSessions: Event<AuthenticationProviderAuthenticationSessionsChangeEvent>;
|
13741 |
|
13742 | /**
|
13743 | * Get a list of sessions.
|
13744 | * @param scopes An optional list of scopes. If provided, the sessions returned should match
|
13745 | * these permissions, otherwise all sessions should be returned.
|
13746 | * @returns A promise that resolves to an array of authentication sessions.
|
13747 | */
|
13748 | getSessions(scopes?: readonly string[]): Thenable<readonly AuthenticationSession[]>;
|
13749 |
|
13750 | /**
|
13751 | * Prompts a user to login.
|
13752 | *
|
13753 | * If login is successful, the onDidChangeSessions event should be fired.
|
13754 | *
|
13755 | * If login fails, a rejected promise should be returned.
|
13756 | *
|
13757 | * If the provider has specified that it does not support multiple accounts,
|
13758 | * then this should never be called if there is already an existing session matching these
|
13759 | * scopes.
|
13760 | * @param scopes A list of scopes, permissions, that the new session should be created with.
|
13761 | * @returns A promise that resolves to an authentication session.
|
13762 | */
|
13763 | createSession(scopes: readonly string[]): Thenable<AuthenticationSession>;
|
13764 |
|
13765 | /**
|
13766 | * Removes the session corresponding to session id.
|
13767 | *
|
13768 | * If the removal is successful, the onDidChangeSessions event should be fired.
|
13769 | *
|
13770 | * If a session cannot be removed, the provider should reject with an error message.
|
13771 | * @param sessionId The id of the session to remove.
|
13772 | */
|
13773 | removeSession(sessionId: string): Thenable<void>;
|
13774 | }
|
13775 |
|
13776 |
|
13777 | /**
|
13778 | * Namespace for authentication.
|
13779 | */
|
13780 | export namespace authentication {
|
13781 | /**
|
13782 | * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
|
13783 | * registered, or if the user does not consent to sharing authentication information with
|
13784 | * the extension. If there are multiple sessions with the same scopes, the user will be shown a
|
13785 | * quickpick to select which account they would like to use.
|
13786 | *
|
13787 | * Currently, there are only two authentication providers that are contributed from built in extensions
|
13788 | * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
|
13789 | * @param providerId The id of the provider to use
|
13790 | * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
|
13791 | * @param options The {@link GetSessionOptions} to use
|
13792 | * @returns A thenable that resolves to an authentication session
|
13793 | */
|
13794 | export function getSession(providerId: string, scopes: readonly string[], options: AuthenticationGetSessionOptions & { createIfNone: true }): Thenable<AuthenticationSession>;
|
13795 |
|
13796 | /**
|
13797 | * Get an authentication session matching the desired scopes. Rejects if a provider with providerId is not
|
13798 | * registered, or if the user does not consent to sharing authentication information with
|
13799 | * the extension. If there are multiple sessions with the same scopes, the user will be shown a
|
13800 | * quickpick to select which account they would like to use.
|
13801 | *
|
13802 | * Currently, there are only two authentication providers that are contributed from built in extensions
|
13803 | * to the editor that implement GitHub and Microsoft authentication: their providerId's are 'github' and 'microsoft'.
|
13804 | * @param providerId The id of the provider to use
|
13805 | * @param scopes A list of scopes representing the permissions requested. These are dependent on the authentication provider
|
13806 | * @param options The {@link GetSessionOptions} to use
|
13807 | * @returns A thenable that resolves to an authentication session if available, or undefined if there are no sessions
|
13808 | */
|
13809 | export function getSession(providerId: string, scopes: readonly string[], options?: AuthenticationGetSessionOptions): Thenable<AuthenticationSession | undefined>;
|
13810 |
|
13811 | /**
|
13812 | * An {@link Event} which fires when the authentication sessions of an authentication provider have
|
13813 | * been added, removed, or changed.
|
13814 | */
|
13815 | export const onDidChangeSessions: Event<AuthenticationSessionsChangeEvent>;
|
13816 |
|
13817 | /**
|
13818 | * Register an authentication provider.
|
13819 | *
|
13820 | * There can only be one provider per id and an error is being thrown when an id
|
13821 | * has already been used by another provider. Ids are case-sensitive.
|
13822 | *
|
13823 | * @param id The unique identifier of the provider.
|
13824 | * @param label The human-readable name of the provider.
|
13825 | * @param provider The authentication provider provider.
|
13826 | * @params options Additional options for the provider.
|
13827 | * @return A {@link Disposable} that unregisters this provider when being disposed.
|
13828 | */
|
13829 | export function registerAuthenticationProvider(id: string, label: string, provider: AuthenticationProvider, options?: AuthenticationProviderOptions): Disposable;
|
13830 | }
|
13831 |
|
13832 | /**
|
13833 | * Namespace for testing functionality. Tests are published by registering
|
13834 | * {@link TestController} instances, then adding {@link TestItem TestItems}.
|
13835 | * Controllers may also describe how to run tests by creating one or more
|
13836 | * {@link TestRunProfile} instances.
|
13837 | */
|
13838 | export namespace tests {
|
13839 | /**
|
13840 | * Creates a new test controller.
|
13841 | *
|
13842 | * @param id Identifier for the controller, must be globally unique.
|
13843 | * @param label A human-readable label for the controller.
|
13844 | * @returns An instance of the {@link TestController}.
|
13845 | */
|
13846 | export function createTestController(id: string, label: string): TestController;
|
13847 | }
|
13848 |
|
13849 | /**
|
13850 | * The kind of executions that {@link TestRunProfile TestRunProfiles} control.
|
13851 | */
|
13852 | export enum TestRunProfileKind {
|
13853 | Run = 1,
|
13854 | Debug = 2,
|
13855 | Coverage = 3,
|
13856 | }
|
13857 |
|
13858 | /**
|
13859 | * A TestRunProfile describes one way to execute tests in a {@link TestController}.
|
13860 | */
|
13861 | export interface TestRunProfile {
|
13862 | /**
|
13863 | * Label shown to the user in the UI.
|
13864 | *
|
13865 | * Note that the label has some significance if the user requests that
|
13866 | * tests be re-run in a certain way. For example, if tests were run
|
13867 | * normally and the user requests to re-run them in debug mode, the editor
|
13868 | * will attempt use a configuration with the same label of the `Debug`
|
13869 | * kind. If there is no such configuration, the default will be used.
|
13870 | */
|
13871 | label: string;
|
13872 |
|
13873 | /**
|
13874 | * Configures what kind of execution this profile controls. If there
|
13875 | * are no profiles for a kind, it will not be available in the UI.
|
13876 | */
|
13877 | readonly kind: TestRunProfileKind;
|
13878 |
|
13879 | /**
|
13880 | * Controls whether this profile is the default action that will
|
13881 | * be taken when its kind is actioned. For example, if the user clicks
|
13882 | * the generic "run all" button, then the default profile for
|
13883 | * {@link TestRunProfileKind.Run} will be executed, although the
|
13884 | * user can configure this.
|
13885 | */
|
13886 | isDefault: boolean;
|
13887 |
|
13888 | /**
|
13889 | * If this method is present, a configuration gear will be present in the
|
13890 | * UI, and this method will be invoked when it's clicked. When called,
|
13891 | * you can take other editor actions, such as showing a quick pick or
|
13892 | * opening a configuration file.
|
13893 | */
|
13894 | configureHandler?: () => void;
|
13895 |
|
13896 | /**
|
13897 | * Handler called to start a test run. When invoked, the function should call
|
13898 | * {@link TestController.createTestRun} at least once, and all test runs
|
13899 | * associated with the request should be created before the function returns
|
13900 | * or the returned promise is resolved.
|
13901 | *
|
13902 | * @param request Request information for the test run.
|
13903 | * @param cancellationToken Token that signals the used asked to abort the
|
13904 | * test run. If cancellation is requested on this token, all {@link TestRun}
|
13905 | * instances associated with the request will be
|
13906 | * automatically cancelled as well.
|
13907 | */
|
13908 | runHandler: (request: TestRunRequest, token: CancellationToken) => Thenable<void> | void;
|
13909 |
|
13910 | /**
|
13911 | * Deletes the run profile.
|
13912 | */
|
13913 | dispose(): void;
|
13914 | }
|
13915 |
|
13916 | /**
|
13917 | * Entry point to discover and execute tests. It contains {@link TestController.items} which
|
13918 | * are used to populate the editor UI, and is associated with
|
13919 | * {@link TestController.createRunProfile run profiles} to allow
|
13920 | * for tests to be executed.
|
13921 | */
|
13922 | export interface TestController {
|
13923 | /**
|
13924 | * The id of the controller passed in {@link vscode.tests.createTestController}.
|
13925 | * This must be globally unique.
|
13926 | */
|
13927 | readonly id: string;
|
13928 |
|
13929 | /**
|
13930 | * Human-readable label for the test controller.
|
13931 | */
|
13932 | label: string;
|
13933 |
|
13934 | /**
|
13935 | * A collection of "top-level" {@link TestItem} instances, which can in
|
13936 | * turn have their own {@link TestItem.children | children} to form the
|
13937 | * "test tree."
|
13938 | *
|
13939 | * The extension controls when to add tests. For example, extensions should
|
13940 | * add tests for a file when {@link vscode.workspace.onDidOpenTextDocument}
|
13941 | * fires in order for decorations for tests within a file to be visible.
|
13942 | *
|
13943 | * However, the editor may sometimes explicitly request children using the
|
13944 | * {@link resolveHandler} See the documentation on that method for more details.
|
13945 | */
|
13946 | readonly items: TestItemCollection;
|
13947 |
|
13948 | /**
|
13949 | * Creates a profile used for running tests. Extensions must create
|
13950 | * at least one profile in order for tests to be run.
|
13951 | * @param label A human-readable label for this profile.
|
13952 | * @param kind Configures what kind of execution this profile manages.
|
13953 | * @param runHandler Function called to start a test run.
|
13954 | * @param isDefault Whether this is the default action for its kind.
|
13955 | * @returns An instance of a {@link TestRunProfile}, which is automatically
|
13956 | * associated with this controller.
|
13957 | */
|
13958 | createRunProfile(label: string, kind: TestRunProfileKind, runHandler: (request: TestRunRequest, token: CancellationToken) => Thenable<void> | void, isDefault?: boolean): TestRunProfile;
|
13959 |
|
13960 | /**
|
13961 | * A function provided by the extension that the editor may call to request
|
13962 | * children of a test item, if the {@link TestItem.canResolveChildren} is
|
13963 | * `true`. When called, the item should discover children and call
|
13964 | * {@link vscode.tests.createTestItem} as children are discovered.
|
13965 | *
|
13966 | * Generally the extension manages the lifecycle of test items, but under
|
13967 | * certain conditions the editor may request the children of a specific
|
13968 | * item to be loaded. For example, if the user requests to re-run tests
|
13969 | * after reloading the editor, the editor may need to call this method
|
13970 | * to resolve the previously-run tests.
|
13971 | *
|
13972 | * The item in the explorer will automatically be marked as "busy" until
|
13973 | * the function returns or the returned thenable resolves.
|
13974 | *
|
13975 | * @param item An unresolved test item for which children are being
|
13976 | * requested, or `undefined` to resolve the controller's initial {@link items}.
|
13977 | */
|
13978 | resolveHandler?: (item: TestItem | undefined) => Thenable<void> | void;
|
13979 |
|
13980 | /**
|
13981 | * Creates a {@link TestRun}. This should be called by the
|
13982 | * {@link TestRunProfile} when a request is made to execute tests, and may
|
13983 | * also be called if a test run is detected externally. Once created, tests
|
13984 | * that are included in the request will be moved into the queued state.
|
13985 | *
|
13986 | * All runs created using the same `request` instance will be grouped
|
13987 | * together. This is useful if, for example, a single suite of tests is
|
13988 | * run on multiple platforms.
|
13989 | *
|
13990 | * @param request Test run request. Only tests inside the `include` may be
|
13991 | * modified, and tests in its `exclude` are ignored.
|
13992 | * @param name The human-readable name of the run. This can be used to
|
13993 | * disambiguate multiple sets of results in a test run. It is useful if
|
13994 | * tests are run across multiple platforms, for example.
|
13995 | * @param persist Whether the results created by the run should be
|
13996 | * persisted in the editor. This may be false if the results are coming from
|
13997 | * a file already saved externally, such as a coverage information file.
|
13998 | * @returns An instance of the {@link TestRun}. It will be considered "running"
|
13999 | * from the moment this method is invoked until {@link TestRun.end} is called.
|
14000 | */
|
14001 | createTestRun(request: TestRunRequest, name?: string, persist?: boolean): TestRun;
|
14002 |
|
14003 | /**
|
14004 | * Creates a new managed {@link TestItem} instance. It can be added into
|
14005 | * the {@link TestItem.children} of an existing item, or into the
|
14006 | * {@link TestController.items}.
|
14007 | *
|
14008 | * @param id Identifier for the TestItem. The test item's ID must be unique
|
14009 | * in the {@link TestItemCollection} it's added to.
|
14010 | * @param label Human-readable label of the test item.
|
14011 | * @param uri URI this TestItem is associated with. May be a file or directory.
|
14012 | */
|
14013 | createTestItem(id: string, label: string, uri?: Uri): TestItem;
|
14014 |
|
14015 | /**
|
14016 | * Unregisters the test controller, disposing of its associated tests
|
14017 | * and unpersisted results.
|
14018 | */
|
14019 | dispose(): void;
|
14020 | }
|
14021 |
|
14022 | /**
|
14023 | * A TestRunRequest is a precursor to a {@link TestRun}, which in turn is
|
14024 | * created by passing a request to {@link tests.runTests}. The TestRunRequest
|
14025 | * contains information about which tests should be run, which should not be
|
14026 | * run, and how they are run (via the {@link profile}).
|
14027 | *
|
14028 | * In general, TestRunRequests are created by the editor and pass to
|
14029 | * {@link TestRunProfile.runHandler}, however you can also create test
|
14030 | * requests and runs outside of the `runHandler`.
|
14031 | */
|
14032 | export class TestRunRequest {
|
14033 | /**
|
14034 | * A filter for specific tests to run. If given, the extension should run
|
14035 | * all of the included tests and all their children, excluding any tests
|
14036 | * that appear in {@link TestRunRequest.exclude}. If this property is
|
14037 | * undefined, then the extension should simply run all tests.
|
14038 | *
|
14039 | * The process of running tests should resolve the children of any test
|
14040 | * items who have not yet been resolved.
|
14041 | */
|
14042 | readonly include?: TestItem[];
|
14043 |
|
14044 | /**
|
14045 | * An array of tests the user has marked as excluded from the test included
|
14046 | * in this run; exclusions should apply after inclusions.
|
14047 | *
|
14048 | * May be omitted if no exclusions were requested. Test controllers should
|
14049 | * not run excluded tests or any children of excluded tests.
|
14050 | */
|
14051 | readonly exclude?: TestItem[];
|
14052 |
|
14053 | /**
|
14054 | * The profile used for this request. This will always be defined
|
14055 | * for requests issued from the editor UI, though extensions may
|
14056 | * programmatically create requests not associated with any profile.
|
14057 | */
|
14058 | readonly profile?: TestRunProfile;
|
14059 |
|
14060 | /**
|
14061 | * @param tests Array of specific tests to run, or undefined to run all tests
|
14062 | * @param exclude An array of tests to exclude from the run.
|
14063 | * @param profile The run profile used for this request.
|
14064 | */
|
14065 | constructor(include?: readonly TestItem[], exclude?: readonly TestItem[], profile?: TestRunProfile);
|
14066 | }
|
14067 |
|
14068 | /**
|
14069 | * Options given to { TestController.runTests}
|
14070 | */
|
14071 | export interface TestRun {
|
14072 | /**
|
14073 | * The human-readable name of the run. This can be used to
|
14074 | * disambiguate multiple sets of results in a test run. It is useful if
|
14075 | * tests are run across multiple platforms, for example.
|
14076 | */
|
14077 | readonly name?: string;
|
14078 |
|
14079 | /**
|
14080 | * A cancellation token which will be triggered when the test run is
|
14081 | * canceled from the UI.
|
14082 | */
|
14083 | readonly token: CancellationToken;
|
14084 |
|
14085 | /**
|
14086 | * Whether the test run will be persisted across reloads by the editor.
|
14087 | */
|
14088 | readonly isPersisted: boolean;
|
14089 |
|
14090 | /**
|
14091 | * Indicates a test is queued for later execution.
|
14092 | * @param test Test item to update.
|
14093 | */
|
14094 | enqueued(test: TestItem): void;
|
14095 |
|
14096 | /**
|
14097 | * Indicates a test has started running.
|
14098 | * @param test Test item to update.
|
14099 | */
|
14100 | started(test: TestItem): void;
|
14101 |
|
14102 | /**
|
14103 | * Indicates a test has been skipped.
|
14104 | * @param test Test item to update.
|
14105 | */
|
14106 | skipped(test: TestItem): void;
|
14107 |
|
14108 | /**
|
14109 | * Indicates a test has failed. You should pass one or more
|
14110 | * {@link TestMessage TestMessages} to describe the failure.
|
14111 | * @param test Test item to update.
|
14112 | * @param messages Messages associated with the test failure.
|
14113 | * @param duration How long the test took to execute, in milliseconds.
|
14114 | */
|
14115 | failed(test: TestItem, message: TestMessage | readonly TestMessage[], duration?: number): void;
|
14116 |
|
14117 | /**
|
14118 | * Indicates a test has errored. You should pass one or more
|
14119 | * {@link TestMessage TestMessages} to describe the failure. This differs
|
14120 | * from the "failed" state in that it indicates a test that couldn't be
|
14121 | * executed at all, from a compilation error for example.
|
14122 | * @param test Test item to update.
|
14123 | * @param messages Messages associated with the test failure.
|
14124 | * @param duration How long the test took to execute, in milliseconds.
|
14125 | */
|
14126 | errored(test: TestItem, message: TestMessage | readonly TestMessage[], duration?: number): void;
|
14127 |
|
14128 | /**
|
14129 | * Indicates a test has passed.
|
14130 | * @param test Test item to update.
|
14131 | * @param duration How long the test took to execute, in milliseconds.
|
14132 | */
|
14133 | passed(test: TestItem, duration?: number): void;
|
14134 |
|
14135 | /**
|
14136 | * Appends raw output from the test runner. On the user's request, the
|
14137 | * output will be displayed in a terminal. ANSI escape sequences,
|
14138 | * such as colors and text styles, are supported.
|
14139 | *
|
14140 | * @param output Output text to append.
|
14141 | */
|
14142 | appendOutput(output: string): void;
|
14143 |
|
14144 | /**
|
14145 | * Signals that the end of the test run. Any tests included in the run whose
|
14146 | * states have not been updated will have their state reset.
|
14147 | */
|
14148 | end(): void;
|
14149 | }
|
14150 |
|
14151 | /**
|
14152 | * Collection of test items, found in {@link TestItem.children} and
|
14153 | * {@link TestController.items}.
|
14154 | */
|
14155 | export interface TestItemCollection {
|
14156 | /**
|
14157 | * Gets the number of items in the collection.
|
14158 | */
|
14159 | readonly size: number;
|
14160 |
|
14161 | /**
|
14162 | * Replaces the items stored by the collection.
|
14163 | * @param items Items to store.
|
14164 | */
|
14165 | replace(items: readonly TestItem[]): void;
|
14166 |
|
14167 | /**
|
14168 | * Iterate over each entry in this collection.
|
14169 | *
|
14170 | * @param callback Function to execute for each entry.
|
14171 | * @param thisArg The `this` context used when invoking the handler function.
|
14172 | */
|
14173 | forEach(callback: (item: TestItem, collection: TestItemCollection) => unknown, thisArg?: unknown): void;
|
14174 |
|
14175 | /**
|
14176 | * Adds the test item to the children. If an item with the same ID already
|
14177 | * exists, it'll be replaced.
|
14178 | * @param items Item to add.
|
14179 | */
|
14180 | add(item: TestItem): void;
|
14181 |
|
14182 | /**
|
14183 | * Removes a single test item from the collection.
|
14184 | * @param itemId Item ID to delete.
|
14185 | */
|
14186 | delete(itemId: string): void;
|
14187 |
|
14188 | /**
|
14189 | * Efficiently gets a test item by ID, if it exists, in the children.
|
14190 | * @param itemId Item ID to get.
|
14191 | * @returns The found item or undefined if it does not exist.
|
14192 | */
|
14193 | get(itemId: string): TestItem | undefined;
|
14194 | }
|
14195 |
|
14196 | /**
|
14197 | * An item shown in the "test explorer" view.
|
14198 | *
|
14199 | * A `TestItem` can represent either a test suite or a test itself, since
|
14200 | * they both have similar capabilities.
|
14201 | */
|
14202 | export interface TestItem {
|
14203 | /**
|
14204 | * Identifier for the `TestItem`. This is used to correlate
|
14205 | * test results and tests in the document with those in the workspace
|
14206 | * (test explorer). This cannot change for the lifetime of the `TestItem`,
|
14207 | * and must be unique among its parent's direct children.
|
14208 | */
|
14209 | readonly id: string;
|
14210 |
|
14211 | /**
|
14212 | * URI this `TestItem` is associated with. May be a file or directory.
|
14213 | */
|
14214 | readonly uri?: Uri;
|
14215 |
|
14216 | /**
|
14217 | * The children of this test item. For a test suite, this may contain the
|
14218 | * individual test cases or nested suites.
|
14219 | */
|
14220 | readonly children: TestItemCollection;
|
14221 |
|
14222 | /**
|
14223 | * The parent of this item. It's set automatically, and is undefined
|
14224 | * top-level items in the {@link TestController.items} and for items that
|
14225 | * aren't yet included in another item's {@link children}.
|
14226 | */
|
14227 | readonly parent?: TestItem;
|
14228 |
|
14229 | /**
|
14230 | * Indicates whether this test item may have children discovered by resolving.
|
14231 | *
|
14232 | * If true, this item is shown as expandable in the Test Explorer view and
|
14233 | * expanding the item will cause {@link TestController.resolveHandler}
|
14234 | * to be invoked with the item.
|
14235 | *
|
14236 | * Default to `false`.
|
14237 | */
|
14238 | canResolveChildren: boolean;
|
14239 |
|
14240 | /**
|
14241 | * Controls whether the item is shown as "busy" in the Test Explorer view.
|
14242 | * This is useful for showing status while discovering children.
|
14243 | *
|
14244 | * Defaults to `false`.
|
14245 | */
|
14246 | busy: boolean;
|
14247 |
|
14248 | /**
|
14249 | * Display name describing the test case.
|
14250 | */
|
14251 | label: string;
|
14252 |
|
14253 | /**
|
14254 | * Optional description that appears next to the label.
|
14255 | */
|
14256 | description?: string;
|
14257 |
|
14258 | /**
|
14259 | * Location of the test item in its {@link uri}.
|
14260 | *
|
14261 | * This is only meaningful if the `uri` points to a file.
|
14262 | */
|
14263 | range?: Range;
|
14264 |
|
14265 | /**
|
14266 | * Optional error encountered while loading the test.
|
14267 | *
|
14268 | * Note that this is not a test result and should only be used to represent errors in
|
14269 | * test discovery, such as syntax errors.
|
14270 | */
|
14271 | error?: string | MarkdownString;
|
14272 | }
|
14273 |
|
14274 | /**
|
14275 | * Message associated with the test state. Can be linked to a specific
|
14276 | * source range -- useful for assertion failures, for example.
|
14277 | */
|
14278 | export class TestMessage {
|
14279 | /**
|
14280 | * Human-readable message text to display.
|
14281 | */
|
14282 | message: string | MarkdownString;
|
14283 |
|
14284 | /**
|
14285 | * Expected test output. If given with {@link actualOutput}, a diff view will be shown.
|
14286 | */
|
14287 | expectedOutput?: string;
|
14288 |
|
14289 | /**
|
14290 | * Actual test output. If given with {@link expectedOutput}, a diff view will be shown.
|
14291 | */
|
14292 | actualOutput?: string;
|
14293 |
|
14294 | /**
|
14295 | * Associated file location.
|
14296 | */
|
14297 | location?: Location;
|
14298 |
|
14299 | /**
|
14300 | * Creates a new TestMessage that will present as a diff in the editor.
|
14301 | * @param message Message to display to the user.
|
14302 | * @param expected Expected output.
|
14303 | * @param actual Actual output.
|
14304 | */
|
14305 | static diff(message: string | MarkdownString, expected: string, actual: string): TestMessage;
|
14306 |
|
14307 | /**
|
14308 | * Creates a new TestMessage instance.
|
14309 | * @param message The message to show to the user.
|
14310 | */
|
14311 | constructor(message: string | MarkdownString);
|
14312 | }
|
14313 | }
|
14314 |
|
14315 | /**
|
14316 | * Thenable is a common denominator between ES6 promises, Q, jquery.Deferred, WinJS.Promise,
|
14317 | * and others. This API makes no assumption about what promise library is being used which
|
14318 | * enables reusing existing code without migrating to a specific promise implementation. Still,
|
14319 | * we recommend the use of native promises which are available in this editor.
|
14320 | */
|
14321 | interface Thenable<T> {
|
14322 | /**
|
14323 | * Attaches callbacks for the resolution and/or rejection of the Promise.
|
14324 | * @param onfulfilled The callback to execute when the Promise is resolved.
|
14325 | * @param onrejected The callback to execute when the Promise is rejected.
|
14326 | * @returns A Promise for the completion of which ever callback is executed.
|
14327 | */
|
14328 | then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => TResult | Thenable<TResult>): Thenable<TResult>;
|
14329 | then<TResult>(onfulfilled?: (value: T) => TResult | Thenable<TResult>, onrejected?: (reason: any) => void): Thenable<TResult>;
|
14330 | }
|
14331 |
|
\ | No newline at end of file |