vscode.proposed.d.ts 97.5 KB
Newer Older
1 2 3 4 5
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/

6 7 8 9 10 11
/**
 * This is the place for API experiments and proposals.
 * These API are NOT stable and subject to change. They are only available in the Insiders
 * distribution and CANNOT be used in published extensions.
 *
 * To test these API in local environment:
M
Matt Bierner 已提交
12
 * - Use Insiders release of 'VS Code'.
13 14 15
 * - Add `"enableProposedApi": true` to your package.json.
 * - Copy this file to your project.
 */
16

17 18
declare module 'vscode' {

19
	// eslint-disable-next-line vscode-dts-region-comments
A
Alex Ross 已提交
20
	//#region @alexdima - resolvers
A
Alex Dima 已提交
21

22 23 24 25 26 27 28
	export interface MessageOptions {
		/**
		 * Do not render a native message box.
		 */
		useCustom?: boolean;
	}

A
Tweaks  
Alex Dima 已提交
29 30 31 32
	export interface RemoteAuthorityResolverContext {
		resolveAttempt: number;
	}

A
Alex Dima 已提交
33 34 35
	export class ResolvedAuthority {
		readonly host: string;
		readonly port: number;
36
		readonly connectionToken: string | undefined;
A
Alex Dima 已提交
37

38
		constructor(host: string, port: number, connectionToken?: string);
A
Alex Dima 已提交
39 40
	}

41
	export interface ResolvedOptions {
R
rebornix 已提交
42
		extensionHostEnv?: { [key: string]: string | null; };
A
Alexandru Dima 已提交
43

A
Alex Dima 已提交
44
		isTrusted?: boolean;
45 46
	}

47
	export interface TunnelOptions {
R
rebornix 已提交
48
		remoteAddress: { port: number, host: string; };
A
Alex Ross 已提交
49 50 51
		// The desired local port. If this port can't be used, then another will be chosen.
		localAddressPort?: number;
		label?: string;
52
		public?: boolean;
A
Alex Ross 已提交
53
		protocol?: string;
54 55
	}

A
Alex Ross 已提交
56
	export interface TunnelDescription {
R
rebornix 已提交
57
		remoteAddress: { port: number, host: string; };
A
Alex Ross 已提交
58
		//The complete local address(ex. localhost:1234)
R
rebornix 已提交
59
		localAddress: { port: number, host: string; } | string;
60
		public?: boolean;
A
Alex Ross 已提交
61 62
		// If protocol is not provided it is assumed to be http, regardless of the localAddress.
		protocol?: string;
A
Alex Ross 已提交
63 64 65
	}

	export interface Tunnel extends TunnelDescription {
A
Alex Ross 已提交
66 67
		// Implementers of Tunnel should fire onDidDispose when dispose is called.
		onDidDispose: Event<void>;
68
		dispose(): void | Thenable<void>;
69 70 71
	}

	/**
72 73
	 * Used as part of the ResolverResult if the extension has any candidate,
	 * published, or forwarded ports.
74 75 76 77
	 */
	export interface TunnelInformation {
		/**
		 * Tunnels that are detected by the extension. The remotePort is used for display purposes.
A
Alex Ross 已提交
78
		 * The localAddress should be the complete local address (ex. localhost:1234) for connecting to the port. Tunnels provided through
79 80
		 * detected are read-only from the forwarded ports UI.
		 */
A
Alex Ross 已提交
81
		environmentTunnels?: TunnelDescription[];
A
Alex Ross 已提交
82

83 84
	}

85
	export interface TunnelCreationOptions {
86 87 88 89 90 91
		/**
		 * True when the local operating system will require elevation to use the requested local port.
		 */
		elevationRequired?: boolean;
	}

92 93 94 95 96 97
	export enum CandidatePortSource {
		None = 0,
		Process = 1,
		Output = 2
	}

98
	export type ResolverResult = ResolvedAuthority & ResolvedOptions & TunnelInformation;
99

A
Tweaks  
Alex Dima 已提交
100 101 102 103 104 105 106
	export class RemoteAuthorityResolverError extends Error {
		static NotAvailable(message?: string, handled?: boolean): RemoteAuthorityResolverError;
		static TemporarilyNotAvailable(message?: string): RemoteAuthorityResolverError;

		constructor(message?: string);
	}

A
Alex Dima 已提交
107
	export interface RemoteAuthorityResolver {
108 109 110
		/**
		 * Resolve the authority part of the current opened `vscode-remote://` URI.
		 *
M
Matt Bierner 已提交
111 112
		 * This method will be invoked once during the startup of the editor and again each time
		 * the editor detects a disconnection.
113 114 115 116
		 *
		 * @param authority The authority part of the current opened `vscode-remote://` URI.
		 * @param context A context indicating if this is the first call or a subsequent call.
		 */
117
		resolve(authority: string, context: RemoteAuthorityResolverContext): ResolverResult | Thenable<ResolverResult>;
118 119 120 121 122 123 124 125

		/**
		 * Get the canonical URI (if applicable) for a `vscode-remote://` URI.
		 *
		 * @returns The canonical URI or undefined if the uri is already canonical.
		 */
		getCanonicalURI?(uri: Uri): ProviderResult<Uri>;

126 127 128 129
		/**
		 * Can be optionally implemented if the extension can forward ports better than the core.
		 * When not implemented, the core will use its default forwarding logic.
		 * When implemented, the core will use this to forward ports.
130 131 132
		 *
		 * To enable the "Change Local Port" action on forwarded ports, make sure to set the `localAddress` of
		 * the returned `Tunnel` to a `{ port: number, host: string; }` and not a string.
133
		 */
134
		tunnelFactory?: (tunnelOptions: TunnelOptions, tunnelCreationOptions: TunnelCreationOptions) => Thenable<Tunnel> | undefined;
135

136
		/**p
137 138 139
		 * Provides filtering for candidate ports.
		 */
		showCandidatePort?: (host: string, port: number, detail: string) => Thenable<boolean>;
140 141 142 143 144 145 146

		/**
		 * Lets the resolver declare which tunnel factory features it supports.
		 * UNDER DISCUSSION! MAY CHANGE SOON.
		 */
		tunnelFeatures?: {
			elevation: boolean;
147
			public: boolean;
148
		};
149 150

		candidatePortSource?: CandidatePortSource;
151 152 153 154
	}

	export namespace workspace {
		/**
155
		 * Forwards a port. If the current resolver implements RemoteAuthorityResolver:forwardPort then that will be used to make the tunnel.
A
Alex Ross 已提交
156
		 * By default, openTunnel only support localhost; however, RemoteAuthorityResolver:tunnelFactory can be used to support other ips.
157 158 159
		 *
		 * @throws When run in an environment without a remote.
		 *
A
Alex Ross 已提交
160
		 * @param tunnelOptions The `localPort` is a suggestion only. If that port is not available another will be chosen.
161
		 */
A
Alex Ross 已提交
162
		export function openTunnel(tunnelOptions: TunnelOptions): Thenable<Tunnel>;
163 164 165 166 167 168

		/**
		 * Gets an array of the currently available tunnels. This does not include environment tunnels, only tunnels that have been created by the user.
		 * Note that these are of type TunnelDescription and cannot be disposed.
		 */
		export let tunnels: Thenable<TunnelDescription[]>;
A
Alex Ross 已提交
169

170 171 172 173
		/**
		 * Fired when the list of tunnels has changed.
		 */
		export const onDidChangeTunnels: Event<void>;
A
Alex Dima 已提交
174 175
	}

176 177 178 179 180 181 182 183
	export interface ResourceLabelFormatter {
		scheme: string;
		authority?: string;
		formatting: ResourceLabelFormatting;
	}

	export interface ResourceLabelFormatting {
		label: string; // myLabel:/${path}
I
isidor 已提交
184
		// For historic reasons we use an or string here. Once we finalize this API we should start using enums instead and adopt it in extensions.
J
Johannes Rieken 已提交
185
		// eslint-disable-next-line vscode-dts-literal-or-types
186 187 188 189
		separator: '/' | '\\' | '';
		tildify?: boolean;
		normalizeDriveLetter?: boolean;
		workspaceSuffix?: string;
190
		workspaceTooltip?: string;
191
		authorityPrefix?: string;
192
		stripPathStartingSeparator?: boolean;
193 194
	}

A
Alex Dima 已提交
195 196
	export namespace workspace {
		export function registerRemoteAuthorityResolver(authorityPrefix: string, resolver: RemoteAuthorityResolver): Disposable;
197
		export function registerResourceLabelFormatter(formatter: ResourceLabelFormatter): Disposable;
198
	}
199

200 201
	//#endregion

J
Johannes Rieken 已提交
202
	//#region editor insets: https://github.com/microsoft/vscode/issues/85682
203

204 205
	export interface WebviewEditorInset {
		readonly editor: TextEditor;
206 207
		readonly line: number;
		readonly height: number;
208 209 210
		readonly webview: Webview;
		readonly onDidDispose: Event<void>;
		dispose(): void;
211 212
	}

213
	export namespace window {
214
		export function createWebviewTextEditorInset(editor: TextEditor, line: number, height: number, options?: WebviewOptions): WebviewEditorInset;
A
Alex Dima 已提交
215 216 217 218
	}

	//#endregion

J
Johannes Rieken 已提交
219
	//#region read/write in chunks: https://github.com/microsoft/vscode/issues/84515
220 221

	export interface FileSystemProvider {
R
rebornix 已提交
222
		open?(resource: Uri, options: { create: boolean; }): number | Thenable<number>;
223 224 225 226 227 228 229
		close?(fd: number): void | Thenable<void>;
		read?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): number | Thenable<number>;
		write?(fd: number, pos: number, data: Uint8Array, offset: number, length: number): number | Thenable<number>;
	}

	//#endregion

R
Rob Lourens 已提交
230
	//#region TextSearchProvider: https://github.com/microsoft/vscode/issues/59921
231

232 233 234
	/**
	 * The parameters of a query for text search.
	 */
235
	export interface TextSearchQuery {
236 237 238
		/**
		 * The text pattern to search for.
		 */
239
		pattern: string;
240

R
Rob Lourens 已提交
241 242 243 244 245
		/**
		 * Whether or not `pattern` should match multiple lines of text.
		 */
		isMultiline?: boolean;

246 247 248
		/**
		 * Whether or not `pattern` should be interpreted as a regular expression.
		 */
R
Rob Lourens 已提交
249
		isRegExp?: boolean;
250 251 252 253

		/**
		 * Whether or not the search should be case-sensitive.
		 */
R
Rob Lourens 已提交
254
		isCaseSensitive?: boolean;
255 256 257 258

		/**
		 * Whether or not to search for whole word matches only.
		 */
R
Rob Lourens 已提交
259
		isWordMatch?: boolean;
260 261
	}

262 263
	/**
	 * A file glob pattern to match file paths against.
264
	 * TODO@roblourens merge this with the GlobPattern docs/definition in vscode.d.ts.
M
Matt Bierner 已提交
265
	 * @see {@link GlobPattern}
266 267 268 269 270 271
	 */
	export type GlobString = string;

	/**
	 * Options common to file and text search
	 */
R
Rob Lourens 已提交
272
	export interface SearchOptions {
273 274 275
		/**
		 * The root folder to search within.
		 */
276
		folder: Uri;
277 278 279 280 281 282 283 284 285 286 287 288 289 290 291

		/**
		 * Files that match an `includes` glob pattern should be included in the search.
		 */
		includes: GlobString[];

		/**
		 * Files that match an `excludes` glob pattern should be excluded from the search.
		 */
		excludes: GlobString[];

		/**
		 * Whether external files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useIgnoreFiles"`.
		 */
R
Rob Lourens 已提交
292
		useIgnoreFiles: boolean;
293 294 295 296 297

		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
298
		followSymlinks: boolean;
P
pkoushik 已提交
299 300 301 302 303 304

		/**
		 * Whether global files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useGlobalIgnoreFiles"`.
		 */
		useGlobalIgnoreFiles: boolean;
305
	}
306

R
Rob Lourens 已提交
307 308
	/**
	 * Options to specify the size of the result text preview.
R
Rob Lourens 已提交
309
	 * These options don't affect the size of the match itself, just the amount of preview text.
R
Rob Lourens 已提交
310
	 */
311
	export interface TextSearchPreviewOptions {
312
		/**
R
Rob Lourens 已提交
313
		 * The maximum number of lines in the preview.
R
Rob Lourens 已提交
314
		 * Only search providers that support multiline search will ever return more than one line in the match.
315
		 */
R
Rob Lourens 已提交
316
		matchLines: number;
R
Rob Lourens 已提交
317 318 319 320

		/**
		 * The maximum number of characters included per line.
		 */
R
Rob Lourens 已提交
321
		charsPerLine: number;
322 323
	}

324 325 326
	/**
	 * Options that apply to text search.
	 */
R
Rob Lourens 已提交
327
	export interface TextSearchOptions extends SearchOptions {
328
		/**
329
		 * The maximum number of results to be returned.
330
		 */
331 332
		maxResults: number;

R
Rob Lourens 已提交
333 334 335
		/**
		 * Options to specify the size of the result text preview.
		 */
336
		previewOptions?: TextSearchPreviewOptions;
337 338 339 340

		/**
		 * Exclude files larger than `maxFileSize` in bytes.
		 */
341
		maxFileSize?: number;
342 343 344 345 346

		/**
		 * Interpret files using this encoding.
		 * See the vscode setting `"files.encoding"`
		 */
347
		encoding?: string;
348 349 350 351 352 353 354 355 356 357

		/**
		 * Number of lines of context to include before each match.
		 */
		beforeContext?: number;

		/**
		 * Number of lines of context to include after each match.
		 */
		afterContext?: number;
358 359
	}

360 361 362 363 364 365 366 367
	/**
	 * Represents the severiry of a TextSearchComplete message.
	 */
	export enum TextSearchCompleteMessageType {
		Information = 1,
		Warning = 2,
	}

368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386
	/**
	 * A message regarding a completed search.
	 */
	export interface TextSearchCompleteMessage {
		/**
		 * Markdown text of the message.
		 */
		text: string,
		/**
		 * Whether the source of the message is trusted, command links are disabled for untrusted message sources.
		 * Messaged are untrusted by default.
		 */
		trusted?: boolean,
		/**
		 * The message type, this affects how the message will be rendered.
		 */
		type: TextSearchCompleteMessageType,
	}

387 388 389 390 391 392
	/**
	 * Information collected when text search is complete.
	 */
	export interface TextSearchComplete {
		/**
		 * Whether the search hit the limit on the maximum number of search results.
M
Matt Bierner 已提交
393
		 * `maxResults` on {@link TextSearchOptions `TextSearchOptions`} specifies the max number of results.
394 395 396 397 398
		 * - If exactly that number of matches exist, this should be false.
		 * - If `maxResults` matches are returned and more exist, this should be true.
		 * - If search hits an internal limit which is less than `maxResults`, this should be true.
		 */
		limitHit?: boolean;
399 400 401 402

		/**
		 * Additional information regarding the state of the completed search.
		 *
M
Matt Bierner 已提交
403
		 * Messages with "Information" style support links in markdown syntax:
404 405
		 * - Click to [run a command](command:workbench.action.OpenQuickPick)
		 * - Click to [open a website](https://aka.ms)
406
		 *
M
Matt Bierner 已提交
407
		 * Commands may optionally return { triggerSearch: true } to signal to the editor that the original search should run be again.
408
		 */
409
		message?: TextSearchCompleteMessage | TextSearchCompleteMessage[];
410 411
	}

R
Rob Lourens 已提交
412 413 414
	/**
	 * A preview of the text result.
	 */
415
	export interface TextSearchMatchPreview {
416
		/**
R
Rob Lourens 已提交
417
		 * The matching lines of text, or a portion of the matching line that contains the match.
418 419 420 421 422
		 */
		text: string;

		/**
		 * The Range within `text` corresponding to the text of the match.
423
		 * The number of matches must match the TextSearchMatch's range property.
424
		 */
425
		matches: Range | Range[];
426 427 428 429 430
	}

	/**
	 * A match from a text search
	 */
431
	export interface TextSearchMatch {
432 433 434
		/**
		 * The uri for the matching document.
		 */
435
		uri: Uri;
436 437

		/**
438
		 * The range of the match within the document, or multiple ranges for multiple matches.
439
		 */
440
		ranges: Range | Range[];
R
Rob Lourens 已提交
441

442
		/**
443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464
		 * A preview of the text match.
		 */
		preview: TextSearchMatchPreview;
	}

	/**
	 * A line of context surrounding a TextSearchMatch.
	 */
	export interface TextSearchContext {
		/**
		 * The uri for the matching document.
		 */
		uri: Uri;

		/**
		 * One line of text.
		 * previewOptions.charsPerLine applies to this
		 */
		text: string;

		/**
		 * The line number of this line of context.
465
		 */
466
		lineNumber: number;
467 468
	}

469 470
	export type TextSearchResult = TextSearchMatch | TextSearchContext;

R
Rob Lourens 已提交
471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514
	/**
	 * A TextSearchProvider provides search results for text results inside files in the workspace.
	 */
	export interface TextSearchProvider {
		/**
		 * Provide results that match the given text pattern.
		 * @param query The parameters for this query.
		 * @param options A set of options to consider while searching.
		 * @param progress A progress callback that must be invoked for all results.
		 * @param token A cancellation token.
		 */
		provideTextSearchResults(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): ProviderResult<TextSearchComplete>;
	}

	//#endregion

	//#region FileSearchProvider: https://github.com/microsoft/vscode/issues/73524

	/**
	 * The parameters of a query for file search.
	 */
	export interface FileSearchQuery {
		/**
		 * The search pattern to match against file paths.
		 */
		pattern: string;
	}

	/**
	 * Options that apply to file search.
	 */
	export interface FileSearchOptions extends SearchOptions {
		/**
		 * The maximum number of results to be returned.
		 */
		maxResults?: number;

		/**
		 * A CancellationToken that represents the session for this search query. If the provider chooses to, this object can be used as the key for a cache,
		 * and searches with the same session object can search the same cache. When the token is cancelled, the session is complete and the cache can be cleared.
		 */
		session?: CancellationToken;
	}

515
	/**
R
Rob Lourens 已提交
516 517
	 * A FileSearchProvider provides search results for files in the given folder that match a query string. It can be invoked by quickopen or other extensions.
	 *
M
Matt Bierner 已提交
518
	 * A FileSearchProvider is the more powerful of two ways to implement file search in the editor. Use a FileSearchProvider if you wish to search within a folder for
R
Rob Lourens 已提交
519 520 521 522
	 * all files that match the user's query.
	 *
	 * The FileSearchProvider will be invoked on every keypress in quickopen. When `workspace.findFiles` is called, it will be invoked with an empty query string,
	 * and in that case, every file in the folder should be returned.
523
	 */
524
	export interface FileSearchProvider {
525 526 527 528 529 530
		/**
		 * Provide the set of files that match a certain file path pattern.
		 * @param query The parameters for this query.
		 * @param options A set of options to consider while searching files.
		 * @param token A cancellation token.
		 */
531
		provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, token: CancellationToken): ProviderResult<Uri[]>;
532
	}
533

R
Rob Lourens 已提交
534
	export namespace workspace {
535
		/**
R
Rob Lourens 已提交
536 537 538 539 540 541
		 * Register a search provider.
		 *
		 * Only one provider can be registered per scheme.
		 *
		 * @param scheme The provider will be invoked for workspace folders that have this file scheme.
		 * @param provider The provider.
M
Matt Bierner 已提交
542
		 * @return A {@link Disposable} that unregisters this provider when being disposed.
543
		 */
R
Rob Lourens 已提交
544 545 546 547 548 549 550 551 552
		export function registerFileSearchProvider(scheme: string, provider: FileSearchProvider): Disposable;

		/**
		 * Register a text search provider.
		 *
		 * Only one provider can be registered per scheme.
		 *
		 * @param scheme The provider will be invoked for workspace folders that have this file scheme.
		 * @param provider The provider.
M
Matt Bierner 已提交
553
		 * @return A {@link Disposable} that unregisters this provider when being disposed.
R
Rob Lourens 已提交
554 555
		 */
		export function registerTextSearchProvider(scheme: string, provider: TextSearchProvider): Disposable;
556 557
	}

R
Rob Lourens 已提交
558 559 560 561
	//#endregion

	//#region findTextInFiles: https://github.com/microsoft/vscode/issues/59924

562 563 564
	/**
	 * Options that can be set on a findTextInFiles search.
	 */
R
Rob Lourens 已提交
565
	export interface FindTextInFilesOptions {
566
		/**
M
Matt Bierner 已提交
567 568 569
		 * A {@link GlobPattern glob pattern} that defines the files to search for. The glob pattern
		 * will be matched against the file paths of files relative to their workspace. Use a {@link RelativePattern relative pattern}
		 * to restrict the search results to a {@link WorkspaceFolder workspace folder}.
570
		 */
571
		include?: GlobPattern;
572 573

		/**
M
Matt Bierner 已提交
574
		 * A {@link GlobPattern glob pattern} that defines files and folders to exclude. The glob pattern
575 576
		 * will be matched against the file paths of resulting matches relative to their workspace. When `undefined`, default excludes will
		 * apply.
577
		 */
578 579 580 581
		exclude?: GlobPattern;

		/**
		 * Whether to use the default and user-configured excludes. Defaults to true.
582
		 */
583
		useDefaultExcludes?: boolean;
584 585 586 587

		/**
		 * The maximum number of results to search for
		 */
R
Rob Lourens 已提交
588
		maxResults?: number;
589 590 591 592 593

		/**
		 * Whether external files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useIgnoreFiles"`.
		 */
R
Rob Lourens 已提交
594
		useIgnoreFiles?: boolean;
595

P
pkoushik 已提交
596 597 598 599
		/**
		 * Whether global files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useGlobalIgnoreFiles"`.
		 */
600
		useGlobalIgnoreFiles?: boolean;
P
pkoushik 已提交
601

602 603 604 605
		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
606
		followSymlinks?: boolean;
607 608 609 610 611

		/**
		 * Interpret files using this encoding.
		 * See the vscode setting `"files.encoding"`
		 */
R
Rob Lourens 已提交
612
		encoding?: string;
613

R
Rob Lourens 已提交
614 615 616
		/**
		 * Options to specify the size of the result text preview.
		 */
617
		previewOptions?: TextSearchPreviewOptions;
618 619 620 621 622 623 624 625 626 627

		/**
		 * Number of lines of context to include before each match.
		 */
		beforeContext?: number;

		/**
		 * Number of lines of context to include after each match.
		 */
		afterContext?: number;
R
Rob Lourens 已提交
628 629
	}

630
	export namespace workspace {
631
		/**
M
Matt Bierner 已提交
632
		 * Search text in files across all {@link workspace.workspaceFolders workspace folders} in the workspace.
633 634 635 636 637
		 * @param query The query parameters for the search - the search string, whether it's case-sensitive, or a regex, or matches whole words.
		 * @param callback A callback, called for each result
		 * @param token A token that can be used to signal cancellation to the underlying search engine.
		 * @return A thenable that resolves when the search is complete.
		 */
638
		export function findTextInFiles(query: TextSearchQuery, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
639 640

		/**
M
Matt Bierner 已提交
641
		 * Search text in files across all {@link workspace.workspaceFolders workspace folders} in the workspace.
642 643 644 645 646 647
		 * @param query The query parameters for the search - the search string, whether it's case-sensitive, or a regex, or matches whole words.
		 * @param options An optional set of query options. Include and exclude patterns, maxResults, etc.
		 * @param callback A callback, called for each result
		 * @param token A token that can be used to signal cancellation to the underlying search engine.
		 * @return A thenable that resolves when the search is complete.
		 */
648
		export function findTextInFiles(query: TextSearchQuery, options: FindTextInFilesOptions, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
649 650
	}

J
Johannes Rieken 已提交
651
	//#endregion
652

J
Johannes Rieken 已提交
653
	//#region diff command: https://github.com/microsoft/vscode/issues/84899
P
Pine Wu 已提交
654

J
Joao Moreno 已提交
655 656 657
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
658 659 660 661 662 663 664
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

665 666 667 668 669 670
	export namespace commands {

		/**
		 * Registers a diff information command that can be invoked via a keyboard shortcut,
		 * a menu item, an action, or directly.
		 *
M
Matt Bierner 已提交
671
		 * Diff information commands are different from ordinary {@link commands.registerCommand commands} as
672 673 674 675 676
		 * they only execute when there is an active diff editor when the command is called, and the diff
		 * information has been computed. Also, the command handler of an editor command has access to
		 * the diff information.
		 *
		 * @param command A unique identifier for the command.
M
Matt Bierner 已提交
677
		 * @param callback A command handler function with access to the {@link LineChange diff information}.
678 679 680 681 682
		 * @param thisArg The `this` context used when invoking the handler function.
		 * @return Disposable which unregisters this command on disposal.
		 */
		export function registerDiffInformationCommand(command: string, callback: (diff: LineChange[], ...args: any[]) => any, thisArg?: any): Disposable;
	}
683

J
Johannes Rieken 已提交
684 685
	//#endregion

686
	// eslint-disable-next-line vscode-dts-region-comments
687
	//#region @roblourens: new debug session option for simple UI 'managedByParent' (see https://github.com/microsoft/vscode/issues/128588)
688 689 690 691 692 693

	/**
	 * Options for {@link debug.startDebugging starting a debug session}.
	 */
	export interface DebugSessionOptions {

694 695 696 697 698 699
		debugUI?: {
			/**
			 * When true, the debug toolbar will not be shown for this session, the window statusbar color will not be changed, and the debug viewlet will not be automatically revealed.
			 */
			simple?: boolean;
		}
700 701 702 703
	}

	//#endregion

704
	// eslint-disable-next-line vscode-dts-region-comments
705
	//#region @weinand: variables view action contributions
706

707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722
	/**
	 * A DebugProtocolVariableContainer is an opaque stand-in type for the intersection of the Scope and Variable types defined in the Debug Adapter Protocol.
	 * See https://microsoft.github.io/debug-adapter-protocol/specification#Types_Scope and https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable.
	 */
	export interface DebugProtocolVariableContainer {
		// Properties: the intersection of DAP's Scope and Variable types.
	}

	/**
	 * A DebugProtocolVariable is an opaque stand-in type for the Variable type defined in the Debug Adapter Protocol.
	 * See https://microsoft.github.io/debug-adapter-protocol/specification#Types_Variable.
	 */
	export interface DebugProtocolVariable {
		// Properties: see details [here](https://microsoft.github.io/debug-adapter-protocol/specification#Base_Protocol_Variable).
	}

J
Johannes Rieken 已提交
723 724
	//#endregion

725
	// eslint-disable-next-line vscode-dts-region-comments
726
	//#region @joaomoreno: SCM validation
727

J
Joao Moreno 已提交
728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766
	/**
	 * Represents the validation type of the Source Control input.
	 */
	export enum SourceControlInputBoxValidationType {

		/**
		 * Something not allowed by the rules of a language or other means.
		 */
		Error = 0,

		/**
		 * Something suspicious but allowed.
		 */
		Warning = 1,

		/**
		 * Something to inform about but not a problem.
		 */
		Information = 2
	}

	export interface SourceControlInputBoxValidation {

		/**
		 * The validation message to display.
		 */
		readonly message: string;

		/**
		 * The validation type.
		 */
		readonly type: SourceControlInputBoxValidationType;
	}

	/**
	 * Represents the input box in the Source Control viewlet.
	 */
	export interface SourceControlInputBox {

767 768 769 770 771
		/**
		 * Shows a transient contextual message on the input.
		 */
		showValidationMessage(message: string, type: SourceControlInputBoxValidationType): void;

J
Joao Moreno 已提交
772 773 774 775
		/**
		 * A validation function for the input box. It's possible to change
		 * the validation provider simply by setting this property to a different function.
		 */
776
		validateInput?(value: string, cursorPosition: number): ProviderResult<SourceControlInputBoxValidation>;
J
Joao Moreno 已提交
777
	}
M
Matt Bierner 已提交
778

J
Johannes Rieken 已提交
779 780
	//#endregion

781
	// eslint-disable-next-line vscode-dts-region-comments
782
	//#region @joaomoreno: SCM selected provider
783 784 785 786 787 788 789 790 791 792 793 794

	export interface SourceControl {

		/**
		 * Whether the source control is selected.
		 */
		readonly selected: boolean;

		/**
		 * An event signaling when the selection state changes.
		 */
		readonly onDidChangeSelection: Event<boolean>;
795 796 797 798
	}

	//#endregion

D
Daniel Imms 已提交
799
	//#region Terminal data write event https://github.com/microsoft/vscode/issues/78502
800

801 802
	export interface TerminalDataWriteEvent {
		/**
M
Matt Bierner 已提交
803
		 * The {@link Terminal} for which the data was written.
804 805 806 807 808 809 810 811
		 */
		readonly terminal: Terminal;
		/**
		 * The data being written.
		 */
		readonly data: string;
	}

D
Daniel Imms 已提交
812 813
	namespace window {
		/**
D
Daniel Imms 已提交
814 815 816
		 * An event which fires when the terminal's child pseudo-device is written to (the shell).
		 * In other words, this provides access to the raw data stream from the process running
		 * within the terminal, including VT sequences.
D
Daniel Imms 已提交
817 818 819 820 821 822 823 824 825
		 */
		export const onDidWriteTerminalData: Event<TerminalDataWriteEvent>;
	}

	//#endregion

	//#region Terminal dimensions property and change event https://github.com/microsoft/vscode/issues/55718

	/**
M
Matt Bierner 已提交
826
	 * An {@link Event} which fires when a {@link Terminal}'s dimensions change.
D
Daniel Imms 已提交
827 828 829
	 */
	export interface TerminalDimensionsChangeEvent {
		/**
M
Matt Bierner 已提交
830
		 * The {@link Terminal} for which the dimensions have changed.
D
Daniel Imms 已提交
831 832 833
		 */
		readonly terminal: Terminal;
		/**
M
Matt Bierner 已提交
834
		 * The new value for the {@link Terminal.dimensions terminal's dimensions}.
D
Daniel Imms 已提交
835 836 837
		 */
		readonly dimensions: TerminalDimensions;
	}
838

D
Daniel Imms 已提交
839
	export namespace window {
D
Daniel Imms 已提交
840
		/**
M
Matt Bierner 已提交
841
		 * An event which fires when the {@link Terminal.dimensions dimensions} of the terminal change.
D
Daniel Imms 已提交
842 843 844 845 846
		 */
		export const onDidChangeTerminalDimensions: Event<TerminalDimensionsChangeEvent>;
	}

	export interface Terminal {
847
		/**
848 849 850
		 * The current dimensions of the terminal. This will be `undefined` immediately after the
		 * terminal is created as the dimensions are not known until shortly after the terminal is
		 * created.
851
		 */
852
		readonly dimensions: TerminalDimensions | undefined;
D
Daniel Imms 已提交
853 854
	}

855 856
	//#endregion

857
	//#region Terminal name change event https://github.com/microsoft/vscode/issues/114898
D
Daniel Imms 已提交
858

859
	export interface Pseudoterminal {
D
Daniel Imms 已提交
860
		/**
861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876
		 * An event that when fired allows changing the name of the terminal.
		 *
		 * **Example:** Change the terminal name to "My new terminal".
		 * ```typescript
		 * const writeEmitter = new vscode.EventEmitter<string>();
		 * const changeNameEmitter = new vscode.EventEmitter<string>();
		 * const pty: vscode.Pseudoterminal = {
		 *   onDidWrite: writeEmitter.event,
		 *   onDidChangeName: changeNameEmitter.event,
		 *   open: () => changeNameEmitter.fire('My new terminal'),
		 *   close: () => {}
		 * };
		 * vscode.window.createTerminal({ name: 'My terminal', pty });
		 * ```
		 */
		onDidChangeName?: Event<string>;
877 878 879 880
	}

	//#endregion

881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896
	//#region Terminal color support https://github.com/microsoft/vscode/issues/128228
	export interface TerminalOptions {
		/**
		 * Supports all ThemeColor keys, terminal.ansi* is recommended for contrast/consistency
		 */
		color?: ThemeColor;
	}
	export interface ExtensionTerminalOptions {
		/**
		 * Supports all ThemeColor keys, terminal.ansi* is recommended for contrast/consistency
		 */
		color?: ThemeColor;
	}

	//#endregion

897
	// eslint-disable-next-line vscode-dts-region-comments
898
	//#region @jrieken -> exclusive document filters
899 900

	export interface DocumentFilter {
901
		readonly exclusive?: boolean;
902 903 904
	}

	//#endregion
C
Christof Marti 已提交
905

906
	//#region Tree View: https://github.com/microsoft/vscode/issues/61313 @alexr00
907
	export interface TreeView<T> extends Disposable {
908
		reveal(element: T | undefined, options?: { select?: boolean, focus?: boolean, expand?: boolean | number; }): Thenable<void>;
909
	}
910
	//#endregion
911

912
	//#region Custom Tree View Drag and Drop https://github.com/microsoft/vscode/issues/32592
913 914 915 916
	/**
	 * A data provider that provides tree data
	 */
	export interface TreeDataProvider<T> {
917
		/**
918
		 * An optional event to signal that an element or root has changed.
919 920 921
		 * This will trigger the view to update the changed element/root and its children recursively (if shown).
		 * To signal that root has changed, do not pass any argument or pass `undefined` or `null`.
		 */
922 923 924 925
		onDidChangeTreeData2?: Event<T | T[] | undefined | null | void>;
	}

	export interface TreeViewOptions<T> {
926 927 928
		/**
		* An optional interface to implement drag and drop in the tree view.
		*/
929
		dragAndDropController?: DragAndDropController<T>;
930 931
	}

A
Alex Ross 已提交
932 933 934 935 936 937 938 939 940 941 942 943 944
	export interface TreeDataTransferItem {
		asString(): Thenable<string>;
	}

	export interface TreeDataTransfer {
		/**
		 * A map containing a mapping of the mime type of the corresponding data.
		 * The type for tree elements is text/treeitem.
		 * For example, you can reconstruct the your tree elements:
		 * ```ts
		 * JSON.parse(await (items.get('text/treeitems')!.asString()))
		 * ```
		 */
945 946
		// todo@API no Map
		// @ts-ignore
A
Alex Ross 已提交
947 948 949
		items: Map<string, TreeDataTransferItem>;
	}

950
	export interface DragAndDropController<T> extends Disposable {
A
Alex Ross 已提交
951 952
		readonly supportedTypes: string[];

953
		/**
954
		 * Extensions should fire `TreeDataProvider.onDidChangeTreeData` for any elements that need to be refreshed.
955
		 *
956 957
		 * @param source
		 * @param target
958
		 */
A
Alex Ross 已提交
959
		onDrop(source: TreeDataTransfer, target: T): Thenable<void>;
960 961 962
	}
	//#endregion

963
	//#region Task presentation group: https://github.com/microsoft/vscode/issues/47265
964 965 966 967 968 969 970
	export interface TaskPresentationOptions {
		/**
		 * Controls whether the task is executed in a specific terminal group using split panes.
		 */
		group?: string;
	}
	//#endregion
971

972
	//#region Custom editor move https://github.com/microsoft/vscode/issues/86146
973

974
	// TODO: Also for custom editor
975

976
	export interface CustomTextEditorProvider {
M
Matt Bierner 已提交
977

978 979 980 981
		/**
		 * Handle when the underlying resource for a custom editor is renamed.
		 *
		 * This allows the webview for the editor be preserved throughout the rename. If this method is not implemented,
M
Matt Bierner 已提交
982
		 * the editor will destroy the previous custom editor and create a replacement one.
983 984 985
		 *
		 * @param newDocument New text document to use for the custom editor.
		 * @param existingWebviewPanel Webview panel for the custom editor.
986
		 * @param token A cancellation token that indicates the result is no longer needed.
987 988 989
		 *
		 * @return Thenable indicating that the webview editor has been moved.
		 */
J
Johannes Rieken 已提交
990
		// eslint-disable-next-line vscode-dts-provider-naming
991
		moveCustomTextEditor?(newDocument: TextDocument, existingWebviewPanel: WebviewPanel, token: CancellationToken): Thenable<void>;
992 993 994
	}

	//#endregion
995

J
Johannes Rieken 已提交
996
	//#region allow QuickPicks to skip sorting: https://github.com/microsoft/vscode/issues/73904
P
Peter Elmers 已提交
997 998 999

	export interface QuickPick<T extends QuickPickItem> extends QuickInput {
		/**
1000 1001
		 * An optional flag to sort the final results by index of first query match in label. Defaults to true.
		 */
P
Peter Elmers 已提交
1002 1003 1004 1005
		sortByLabel: boolean;
	}

	//#endregion
M
Matt Bierner 已提交
1006

1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041
	//#region https://github.com/microsoft/vscode/issues/124970, Cell Execution State

	/**
	 * The execution state of a notebook cell.
	 */
	export enum NotebookCellExecutionState {
		/**
		 * The cell is idle.
		 */
		Idle = 1,
		/**
		 * Execution for the cell is pending.
		 */
		Pending = 2,
		/**
		 * The cell is currently executing.
		 */
		Executing = 3,
	}

	/**
	 * An event describing a cell execution state change.
	 */
	export interface NotebookCellExecutionStateChangeEvent {
		/**
		 * The {@link NotebookCell cell} for which the execution state has changed.
		 */
		readonly cell: NotebookCell;

		/**
		 * The new execution state of the cell.
		 */
		readonly state: NotebookCellExecutionState;
	}

1042
	export namespace notebooks {
1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053

		/**
		 * An {@link Event} which fires when the execution state of a cell has changed.
		 */
		// todo@API this is an event that is fired for a property that cells don't have and that makes me wonder
		// how a correct consumer works, e.g the consumer could have been late and missed an event?
		export const onDidChangeNotebookCellExecutionState: Event<NotebookCellExecutionStateChangeEvent>;
	}

	//#endregion

1054
	//#region https://github.com/microsoft/vscode/issues/106744, Notebook, deprecated & misc
1055

1056 1057 1058
	export interface NotebookCellOutput {
		id: string;
	}
1059 1060 1061

	//#endregion

1062 1063
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookEditor

J
Johannes Rieken 已提交
1064 1065 1066
	/**
	 * Represents a notebook editor that is attached to a {@link NotebookDocument notebook}.
	 */
1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089
	export enum NotebookEditorRevealType {
		/**
		 * The range will be revealed with as little scrolling as possible.
		 */
		Default = 0,

		/**
		 * The range will always be revealed in the center of the viewport.
		 */
		InCenter = 1,

		/**
		 * If the range is outside the viewport, it will be revealed in the center of the viewport.
		 * Otherwise, it will be revealed with as little scrolling as possible.
		 */
		InCenterIfOutsideViewport = 2,

		/**
		 * The range will always be revealed at the top of the viewport.
		 */
		AtTop = 3
	}

J
Johannes Rieken 已提交
1090 1091 1092
	/**
	 * Represents a notebook editor that is attached to a {@link NotebookDocument notebook}.
	 */
1093 1094 1095 1096
	export interface NotebookEditor {
		/**
		 * The document associated with this notebook editor.
		 */
J
Johannes Rieken 已提交
1097
		//todo@api rename to notebook?
1098 1099 1100 1101 1102 1103 1104
		readonly document: NotebookDocument;

		/**
		 * The selections on this notebook editor.
		 *
		 * The primary selection (or focused range) is `selections[0]`. When the document has no cells, the primary selection is empty `{ start: 0, end: 0 }`;
		 */
1105
		selections: NotebookRange[];
1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123

		/**
		 * The current visible ranges in the editor (vertically).
		 */
		readonly visibleRanges: NotebookRange[];

		/**
		 * Scroll as indicated by `revealType` in order to reveal the given range.
		 *
		 * @param range A range.
		 * @param revealType The scrolling strategy for revealing `range`.
		 */
		revealRange(range: NotebookRange, revealType?: NotebookEditorRevealType): void;

		/**
		 * The column in which this editor shows.
		 */
		readonly viewColumn?: ViewColumn;
R
rebornix 已提交
1124 1125
	}

1126
	export interface NotebookDocumentMetadataChangeEvent {
R
rebornix 已提交
1127
		/**
M
Matt Bierner 已提交
1128
		 * The {@link NotebookDocument notebook document} for which the document metadata have changed.
R
rebornix 已提交
1129
		 */
J
Johannes Rieken 已提交
1130
		//todo@API rename to notebook?
1131 1132 1133
		readonly document: NotebookDocument;
	}

1134
	export interface NotebookCellsChangeData {
R
rebornix 已提交
1135
		readonly start: number;
J
Johannes Rieken 已提交
1136
		// todo@API end? Use NotebookCellRange instead?
R
rebornix 已提交
1137
		readonly deletedCount: number;
J
Johannes Rieken 已提交
1138
		// todo@API removedCells, deletedCells?
1139
		readonly deletedItems: NotebookCell[];
J
Johannes Rieken 已提交
1140
		// todo@API addedCells, insertedCells, newCells?
R
rebornix 已提交
1141
		readonly items: NotebookCell[];
R
rebornix 已提交
1142 1143
	}

R
rebornix 已提交
1144
	export interface NotebookCellsChangeEvent {
1145
		/**
M
Matt Bierner 已提交
1146
		 * The {@link NotebookDocument notebook document} for which the cells have changed.
1147
		 */
J
Johannes Rieken 已提交
1148
		//todo@API rename to notebook?
R
rebornix 已提交
1149
		readonly document: NotebookDocument;
1150
		readonly changes: ReadonlyArray<NotebookCellsChangeData>;
R
rebornix 已提交
1151 1152
	}

1153
	export interface NotebookCellOutputsChangeEvent {
1154
		/**
M
Matt Bierner 已提交
1155
		 * The {@link NotebookDocument notebook document} for which the cell outputs have changed.
1156
		 */
J
Johannes Rieken 已提交
1157
		//todo@API remove? use cell.notebook instead?
R
rebornix 已提交
1158
		readonly document: NotebookDocument;
J
Johannes Rieken 已提交
1159
		// NotebookCellOutputsChangeEvent.cells vs NotebookCellMetadataChangeEvent.cell
1160
		readonly cells: NotebookCell[];
R
rebornix 已提交
1161
	}
1162

1163
	export interface NotebookCellMetadataChangeEvent {
1164
		/**
M
Matt Bierner 已提交
1165
		 * The {@link NotebookDocument notebook document} for which the cell metadata have changed.
1166
		 */
J
Johannes Rieken 已提交
1167
		//todo@API remove? use cell.notebook instead?
R
rebornix 已提交
1168
		readonly document: NotebookDocument;
J
Johannes Rieken 已提交
1169
		// NotebookCellOutputsChangeEvent.cells vs NotebookCellMetadataChangeEvent.cell
R
rebornix 已提交
1170
		readonly cell: NotebookCell;
R
rebornix 已提交
1171 1172
	}

1173
	export interface NotebookEditorSelectionChangeEvent {
R
rebornix 已提交
1174
		/**
M
Matt Bierner 已提交
1175
		 * The {@link NotebookEditor notebook editor} for which the selections have changed.
R
rebornix 已提交
1176
		 */
1177
		readonly notebookEditor: NotebookEditor;
1178
		readonly selections: ReadonlyArray<NotebookRange>
R
rebornix 已提交
1179 1180
	}

1181
	export interface NotebookEditorVisibleRangesChangeEvent {
R
rebornix 已提交
1182
		/**
M
Matt Bierner 已提交
1183
		 * The {@link NotebookEditor notebook editor} for which the visible ranges have changed.
R
rebornix 已提交
1184
		 */
1185
		readonly notebookEditor: NotebookEditor;
1186
		readonly visibleRanges: ReadonlyArray<NotebookRange>;
R
rebornix 已提交
1187 1188
	}

R
rebornix 已提交
1189

1190 1191 1192 1193
	export interface NotebookDocumentShowOptions {
		viewColumn?: ViewColumn;
		preserveFocus?: boolean;
		preview?: boolean;
1194
		selections?: NotebookRange[];
R
rebornix 已提交
1195 1196
	}

1197
	export namespace notebooks {
1198

1199

1200 1201

		export const onDidSaveNotebookDocument: Event<NotebookDocument>;
R
rebornix 已提交
1202

1203 1204
		export const onDidChangeNotebookDocumentMetadata: Event<NotebookDocumentMetadataChangeEvent>;
		export const onDidChangeNotebookCells: Event<NotebookCellsChangeEvent>;
J
Johannes Rieken 已提交
1205 1206

		// todo@API add onDidChangeNotebookCellOutputs
1207
		export const onDidChangeCellOutputs: Event<NotebookCellOutputsChangeEvent>;
R
rebornix 已提交
1208

J
Johannes Rieken 已提交
1209
		// todo@API add onDidChangeNotebookCellMetadata
1210
		export const onDidChangeCellMetadata: Event<NotebookCellMetadataChangeEvent>;
R
rebornix 已提交
1211 1212
	}

1213 1214 1215 1216 1217 1218 1219
	export namespace window {
		export const visibleNotebookEditors: NotebookEditor[];
		export const onDidChangeVisibleNotebookEditors: Event<NotebookEditor[]>;
		export const activeNotebookEditor: NotebookEditor | undefined;
		export const onDidChangeActiveNotebookEditor: Event<NotebookEditor | undefined>;
		export const onDidChangeNotebookEditorSelection: Event<NotebookEditorSelectionChangeEvent>;
		export const onDidChangeNotebookEditorVisibleRanges: Event<NotebookEditorVisibleRangesChangeEvent>;
1220

1221 1222 1223
		export function showNotebookDocument(uri: Uri, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
		export function showNotebookDocument(document: NotebookDocument, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
	}
1224

1225
	//#endregion
1226

1227
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookEditorEdit
1228

1229 1230 1231 1232 1233 1234 1235
	// todo@API add NotebookEdit-type which handles all these cases?
	// export class NotebookEdit {
	// 	range: NotebookRange;
	// 	newCells: NotebookCellData[];
	// 	newMetadata?: NotebookDocumentMetadata;
	// 	constructor(range: NotebookRange, newCells: NotebookCellData)
	// }
J
Johannes Rieken 已提交
1236

1237 1238 1239
	// export class NotebookCellEdit {
	// 	newMetadata?: NotebookCellMetadata;
	// }
J
Johannes Rieken 已提交
1240

1241 1242 1243
	// export interface WorkspaceEdit {
	// 	set(uri: Uri, edits: TextEdit[] | NotebookEdit[]): void
	// }
1244

1245 1246
	export interface WorkspaceEdit {
		// todo@API add NotebookEdit-type which handles all these cases?
1247
		replaceNotebookMetadata(uri: Uri, value: { [key: string]: any }): void;
1248
		replaceNotebookCells(uri: Uri, range: NotebookRange, cells: NotebookCellData[], metadata?: WorkspaceEditEntryMetadata): void;
1249
		replaceNotebookCellMetadata(uri: Uri, index: number, cellMetadata: { [key: string]: any }, metadata?: WorkspaceEditEntryMetadata): void;
1250
	}
1251

1252
	export interface NotebookEditorEdit {
1253
		replaceMetadata(value: { [key: string]: any }): void;
1254
		replaceCells(start: number, end: number, cells: NotebookCellData[]): void;
1255
		replaceCellMetadata(index: number, metadata: { [key: string]: any }): void;
1256
	}
1257

1258
	export interface NotebookEditor {
1259
		/**
1260
		 * Perform an edit on the notebook associated with this notebook editor.
1261
		 *
1262 1263 1264
		 * The given callback-function is invoked with an {@link NotebookEditorEdit edit-builder} which must
		 * be used to make edits. Note that the edit-builder is only valid while the
		 * callback executes.
1265
		 *
1266 1267
		 * @param callback A function which can create edits using an {@link NotebookEditorEdit edit-builder}.
		 * @return A promise that resolves with a value indicating if the edits could be applied.
1268
		 */
1269 1270
		// @jrieken REMOVE maybe
		edit(callback: (editBuilder: NotebookEditorEdit) => void): Thenable<boolean>;
1271 1272
	}

1273 1274
	//#endregion

J
Johannes Rieken 已提交
1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookEditorDecorationType

	export interface NotebookEditor {
		setDecorations(decorationType: NotebookEditorDecorationType, range: NotebookRange): void;
	}

	export interface NotebookDecorationRenderOptions {
		backgroundColor?: string | ThemeColor;
		borderColor?: string | ThemeColor;
		top: ThemableDecorationAttachmentRenderOptions;
	}

	export interface NotebookEditorDecorationType {
		readonly key: string;
		dispose(): void;
	}

1292
	export namespace notebooks {
J
Johannes Rieken 已提交
1293 1294 1295 1296 1297 1298 1299
		export function createNotebookEditorDecorationType(options: NotebookDecorationRenderOptions): NotebookEditorDecorationType;
	}

	//#endregion

	//#region https://github.com/microsoft/vscode/issues/106744, NotebookConcatTextDocument

1300
	export namespace notebooks {
J
Johannes Rieken 已提交
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332
		/**
		 * Create a document that is the concatenation of all  notebook cells. By default all code-cells are included
		 * but a selector can be provided to narrow to down the set of cells.
		 *
		 * @param notebook
		 * @param selector
		 */
		// todo@API really needed? we didn't find a user here
		export function createConcatTextDocument(notebook: NotebookDocument, selector?: DocumentSelector): NotebookConcatTextDocument;
	}

	export interface NotebookConcatTextDocument {
		readonly uri: Uri;
		readonly isClosed: boolean;
		dispose(): void;
		readonly onDidChange: Event<void>;
		readonly version: number;
		getText(): string;
		getText(range: Range): string;

		offsetAt(position: Position): number;
		positionAt(offset: number): Position;
		validateRange(range: Range): Range;
		validatePosition(position: Position): Position;

		locationAt(positionOrRange: Position | Range): Location;
		positionAt(location: Location): Position;
		contains(uri: Uri): boolean;
	}

	//#endregion

1333 1334
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookContentProvider

1335

1336 1337 1338 1339
	interface NotebookDocumentBackup {
		/**
		 * Unique identifier for the backup.
		 *
R
Rob Lourens 已提交
1340
		 * This id is passed back to your extension in `openNotebook` when opening a notebook editor from a backup.
1341 1342 1343 1344 1345 1346
		 */
		readonly id: string;

		/**
		 * Delete the current backup.
		 *
M
Matt Bierner 已提交
1347
		 * This is called by the editor when it is clear the current backup is no longer needed, such as when a new backup
1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358
		 * is made or when the file is saved.
		 */
		delete(): void;
	}

	interface NotebookDocumentBackupContext {
		readonly destination: Uri;
	}

	interface NotebookDocumentOpenContext {
		readonly backupId?: string;
1359
		readonly untitledDocumentData?: Uint8Array;
1360 1361
	}

1362
	// todo@API use openNotebookDOCUMENT to align with openCustomDocument etc?
J
Johannes Rieken 已提交
1363
	// todo@API rename to NotebookDocumentContentProvider
R
rebornix 已提交
1364
	export interface NotebookContentProvider {
1365

1366 1367 1368
		readonly options?: NotebookDocumentContentOptions;
		readonly onDidChangeNotebookContentOptions?: Event<NotebookDocumentContentOptions>;

1369
		/**
M
Matt Bierner 已提交
1370
		 * Content providers should always use {@link FileSystemProvider file system providers} to
1371 1372
		 * resolve the raw content for `uri` as the resouce is not necessarily a file on disk.
		 */
1373 1374
		openNotebook(uri: Uri, openContext: NotebookDocumentOpenContext, token: CancellationToken): NotebookData | Thenable<NotebookData>;

J
Johannes Rieken 已提交
1375
		// todo@API use NotebookData instead
1376 1377
		saveNotebook(document: NotebookDocument, token: CancellationToken): Thenable<void>;

J
Johannes Rieken 已提交
1378
		// todo@API use NotebookData instead
1379
		saveNotebookAs(targetResource: Uri, document: NotebookDocument, token: CancellationToken): Thenable<void>;
J
Johannes Rieken 已提交
1380

J
Johannes Rieken 已提交
1381
		// todo@API use NotebookData instead
1382
		backupNotebook(document: NotebookDocument, context: NotebookDocumentBackupContext, token: CancellationToken): Thenable<NotebookDocumentBackup>;
R
rebornix 已提交
1383 1384
	}

1385
	export namespace workspace {
J
Johannes Rieken 已提交
1386

1387 1388
		// TODO@api use NotebookDocumentFilter instead of just notebookType:string?
		// TODO@API options duplicates the more powerful variant on NotebookContentProvider
1389
		export function registerNotebookContentProvider(notebookType: string, provider: NotebookContentProvider, options?: NotebookDocumentContentOptions): Disposable;
R
rebornix 已提交
1390 1391
	}

1392 1393
	//#endregion

J
Johannes Rieken 已提交
1394
	//#region https://github.com/microsoft/vscode/issues/106744, LiveShare
1395

J
Johannes Rieken 已提交
1396 1397 1398 1399
	export interface NotebookRegistrationData {
		displayName: string;
		filenamePattern: (GlobPattern | { include: GlobPattern; exclude: GlobPattern; })[];
		exclusive?: boolean;
1400 1401
	}

1402
	export namespace workspace {
J
Johannes Rieken 已提交
1403 1404 1405 1406
		// SPECIAL overload with NotebookRegistrationData
		export function registerNotebookContentProvider(notebookType: string, provider: NotebookContentProvider, options?: NotebookDocumentContentOptions, registrationData?: NotebookRegistrationData): Disposable;
		// SPECIAL overload with NotebookRegistrationData
		export function registerNotebookSerializer(notebookType: string, serializer: NotebookSerializer, options?: NotebookDocumentContentOptions, registration?: NotebookRegistrationData): Disposable;
1407 1408
	}

1409 1410
	//#endregion

1411
	//#region @https://github.com/microsoft/vscode/issues/123601, notebook messaging
1412

1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437
	/**
	 * Represents a script that is loaded into the notebook renderer before rendering output. This allows
	 * to provide and share functionality for notebook markup and notebook output renderers.
	 */
	export class NotebookRendererScript {

		/**
		 * APIs that the preload provides to the renderer. These are matched
		 * against the `dependencies` and `optionalDependencies` arrays in the
		 * notebook renderer contribution point.
		 */
		provides: string[];

		/**
		 * URI for the file to preload
		 */
		uri: Uri;

		/**
		 * @param uri URI for the file to preload
		 * @param provides Value for the `provides` property
		 */
		constructor(uri: Uri, provides?: string | string[]);
	}

1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461 1462 1463 1464
	export interface NotebookController {

		// todo@API allow add, not remove
		readonly rendererScripts: NotebookRendererScript[];

		/**
		 * An event that fires when a {@link NotebookController.rendererScripts renderer script} has send a message to
		 * the controller.
		 */
		readonly onDidReceiveMessage: Event<{ editor: NotebookEditor, message: any }>;

		/**
		 * Send a message to the renderer of notebook editors.
		 *
		 * Note that only editors showing documents that are bound to this controller
		 * are receiving the message.
		 *
		 * @param message The message to send.
		 * @param editor A specific editor to send the message to. When `undefined` all applicable editors are receiving the message.
		 * @returns A promise that resolves to a boolean indicating if the message has been send or not.
		 */
		postMessage(message: any, editor?: NotebookEditor): Thenable<boolean>;

		//todo@API validate this works
		asWebviewUri(localResource: Uri): Uri;
	}

1465
	export namespace notebooks {
1466

1467
		export function createNotebookController(id: string, viewType: string, label: string, handler?: (cells: NotebookCell[], notebook: NotebookDocument, controller: NotebookController) => void | Thenable<void>, rendererScripts?: NotebookRendererScript[]): NotebookController;
1468 1469 1470 1471
	}

	//#endregion

1472
	//#region @eamodio - timeline: https://github.com/microsoft/vscode/issues/84297
1473 1474 1475

	export class TimelineItem {
		/**
1476
		 * A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred.
1477
		 */
E
Eric Amodio 已提交
1478
		timestamp: number;
1479 1480

		/**
1481
		 * A human-readable string describing the timeline item.
1482 1483 1484 1485
		 */
		label: string;

		/**
1486
		 * Optional id for the timeline item. It must be unique across all the timeline items provided by this source.
1487
		 *
1488
		 * If not provided, an id is generated using the timeline item's timestamp.
1489 1490 1491 1492
		 */
		id?: string;

		/**
M
Matt Bierner 已提交
1493
		 * The icon path or {@link ThemeIcon} for the timeline item.
1494
		 */
R
rebornix 已提交
1495
		iconPath?: Uri | { light: Uri; dark: Uri; } | ThemeIcon;
1496 1497

		/**
1498
		 * A human readable string describing less prominent details of the timeline item.
1499 1500 1501 1502 1503 1504
		 */
		description?: string;

		/**
		 * The tooltip text when you hover over the timeline item.
		 */
1505
		detail?: string;
1506 1507

		/**
M
Matt Bierner 已提交
1508
		 * The {@link Command} that should be executed when the timeline item is selected.
1509 1510 1511 1512
		 */
		command?: Command;

		/**
1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 1528
		 * Context value of the timeline item. This can be used to contribute specific actions to the item.
		 * For example, a timeline item is given a context value as `commit`. When contributing actions to `timeline/item/context`
		 * using `menus` extension point, you can specify context value for key `timelineItem` in `when` expression like `timelineItem == commit`.
		 * ```
		 *	"contributes": {
		 *		"menus": {
		 *			"timeline/item/context": [
		 *				{
		 *					"command": "extension.copyCommitId",
		 *					"when": "timelineItem == commit"
		 *				}
		 *			]
		 *		}
		 *	}
		 * ```
		 * This will show the `extension.copyCommitId` action only for items where `contextValue` is `commit`.
1529 1530 1531
		 */
		contextValue?: string;

1532 1533 1534 1535 1536
		/**
		 * Accessibility information used when screen reader interacts with this timeline item.
		 */
		accessibilityInformation?: AccessibilityInformation;

1537 1538
		/**
		 * @param label A human-readable string describing the timeline item
E
Eric Amodio 已提交
1539
		 * @param timestamp A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred
1540
		 */
E
Eric Amodio 已提交
1541
		constructor(label: string, timestamp: number);
1542 1543
	}

1544
	export interface TimelineChangeEvent {
E
Eric Amodio 已提交
1545
		/**
M
Matt Bierner 已提交
1546
		 * The {@link Uri} of the resource for which the timeline changed.
E
Eric Amodio 已提交
1547
		 */
E
Eric Amodio 已提交
1548
		uri: Uri;
1549

E
Eric Amodio 已提交
1550
		/**
1551
		 * A flag which indicates whether the entire timeline should be reset.
E
Eric Amodio 已提交
1552
		 */
1553 1554
		reset?: boolean;
	}
E
Eric Amodio 已提交
1555

1556 1557 1558
	export interface Timeline {
		readonly paging?: {
			/**
E
Eric Amodio 已提交
1559
			 * A provider-defined cursor specifying the starting point of timeline items which are after the ones returned.
E
Eric Amodio 已提交
1560
			 * Use `undefined` to signal that there are no more items to be returned.
1561
			 */
E
Eric Amodio 已提交
1562
			readonly cursor: string | undefined;
R
rebornix 已提交
1563
		};
E
Eric Amodio 已提交
1564 1565

		/**
M
Matt Bierner 已提交
1566
		 * An array of {@link TimelineItem timeline items}.
E
Eric Amodio 已提交
1567
		 */
1568
		readonly items: readonly TimelineItem[];
E
Eric Amodio 已提交
1569 1570
	}

1571
	export interface TimelineOptions {
E
Eric Amodio 已提交
1572
		/**
E
Eric Amodio 已提交
1573
		 * A provider-defined cursor specifying the starting point of the timeline items that should be returned.
E
Eric Amodio 已提交
1574
		 */
1575
		cursor?: string;
E
Eric Amodio 已提交
1576 1577

		/**
1578 1579
		 * An optional maximum number timeline items or the all timeline items newer (inclusive) than the timestamp or id that should be returned.
		 * If `undefined` all timeline items should be returned.
E
Eric Amodio 已提交
1580
		 */
R
rebornix 已提交
1581
		limit?: number | { timestamp: number; id?: string; };
E
Eric Amodio 已提交
1582 1583
	}

1584
	export interface TimelineProvider {
1585
		/**
1586 1587
		 * An optional event to signal that the timeline for a source has changed.
		 * To signal that the timeline for all resources (uris) has changed, do not pass any argument or pass `undefined`.
1588
		 */
E
Eric Amodio 已提交
1589
		onDidChange?: Event<TimelineChangeEvent | undefined>;
1590 1591

		/**
1592
		 * An identifier of the source of the timeline items. This can be used to filter sources.
1593
		 */
1594
		readonly id: string;
1595

E
Eric Amodio 已提交
1596
		/**
1597
		 * A human-readable string describing the source of the timeline items. This can be used as the display label when filtering sources.
E
Eric Amodio 已提交
1598
		 */
1599
		readonly label: string;
1600 1601

		/**
M
Matt Bierner 已提交
1602
		 * Provide {@link TimelineItem timeline items} for a {@link Uri}.
1603
		 *
M
Matt Bierner 已提交
1604
		 * @param uri The {@link Uri} of the file to provide the timeline for.
1605
		 * @param options A set of options to determine how results should be returned.
1606
		 * @param token A cancellation token.
M
Matt Bierner 已提交
1607
		 * @return The {@link TimelineResult timeline result} or a thenable that resolves to such. The lack of a result
1608 1609
		 * can be signaled by returning `undefined`, `null`, or an empty array.
		 */
1610
		provideTimeline(uri: Uri, options: TimelineOptions, token: CancellationToken): ProviderResult<Timeline>;
1611 1612 1613 1614 1615 1616 1617 1618 1619 1620
	}

	export namespace workspace {
		/**
		 * Register a timeline provider.
		 *
		 * Multiple providers can be registered. In that case, providers are asked in
		 * parallel and the results are merged. A failing provider (rejected promise or exception) will
		 * not cause a failure of the whole operation.
		 *
1621
		 * @param scheme A scheme or schemes that defines which documents this provider is applicable to. Can be `*` to target all documents.
1622
		 * @param provider A timeline provider.
M
Matt Bierner 已提交
1623
		 * @return A {@link Disposable} that unregisters this provider when being disposed.
E
Eric Amodio 已提交
1624
		*/
1625
		export function registerTimelineProvider(scheme: string | string[], provider: TimelineProvider): Disposable;
1626 1627 1628
	}

	//#endregion
1629

1630
	//#region https://github.com/microsoft/vscode/issues/91555
1631

1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644
	export enum StandardTokenType {
		Other = 0,
		Comment = 1,
		String = 2,
		RegEx = 4
	}

	export interface TokenInformation {
		type: StandardTokenType;
		range: Range;
	}

	export namespace languages {
1645
		export function getTokenInformationAtPosition(document: TextDocument, position: Position): Thenable<TokenInformation>;
K
kingwl 已提交
1646 1647 1648 1649
	}

	//#endregion

J
Johannes Rieken 已提交
1650
	//#region https://github.com/microsoft/vscode/issues/16221
K
kingwl 已提交
1651

1652
	// todo@API Split between Inlay- and OverlayHints (InlayHint are for a position, OverlayHints for a non-empty range)
J
Johannes Rieken 已提交
1653
	// todo@API add "mini-markdown" for links and styles
1654 1655 1656
	// (done) remove description
	// (done) rename to InlayHint
	// (done)  add InlayHintKind with type, argument, etc
J
Johannes Rieken 已提交
1657

K
kingwl 已提交
1658
	export namespace languages {
K
kingwl 已提交
1659
		/**
1660
		 * Register a inlay hints provider.
K
kingwl 已提交
1661
		 *
J
Johannes Rieken 已提交
1662 1663 1664
		 * Multiple providers can be registered for a language. In that case providers are asked in
		 * parallel and the results are merged. A failing provider (rejected promise or exception) will
		 * not cause a failure of the whole operation.
K
kingwl 已提交
1665 1666
		 *
		 * @param selector A selector that defines the documents this provider is applicable to.
J
Johannes Rieken 已提交
1667
		 * @param provider An inlay hints provider.
M
Matt Bierner 已提交
1668
		 * @return A {@link Disposable} that unregisters this provider when being disposed.
K
kingwl 已提交
1669
		 */
1670
		export function registerInlayHintsProvider(selector: DocumentSelector, provider: InlayHintsProvider): Disposable;
1671 1672
	}

1673
	export enum InlayHintKind {
1674 1675 1676 1677 1678
		Other = 0,
		Type = 1,
		Parameter = 2,
	}

K
kingwl 已提交
1679
	/**
J
Johannes Rieken 已提交
1680
	 * Inlay hint information.
K
kingwl 已提交
1681
	 */
1682
	export class InlayHint {
K
kingwl 已提交
1683 1684 1685 1686 1687
		/**
		 * The text of the hint.
		 */
		text: string;
		/**
1688
		 * The position of this hint.
K
kingwl 已提交
1689
		 */
1690 1691 1692 1693 1694
		position: Position;
		/**
		 * The kind of this hint.
		 */
		kind?: InlayHintKind;
K
kingwl 已提交
1695 1696 1697 1698 1699 1700 1701 1702 1703
		/**
		 * Whitespace before the hint.
		 */
		whitespaceBefore?: boolean;
		/**
		 * Whitespace after the hint.
		 */
		whitespaceAfter?: boolean;

1704
		// todo@API make range first argument
1705
		constructor(text: string, position: Position, kind?: InlayHintKind);
K
kingwl 已提交
1706 1707 1708
	}

	/**
J
Johannes Rieken 已提交
1709 1710
	 * The inlay hints provider interface defines the contract between extensions and
	 * the inlay hints feature.
K
kingwl 已提交
1711
	 */
1712
	export interface InlayHintsProvider {
W
Wenlu Wang 已提交
1713 1714

		/**
J
Johannes Rieken 已提交
1715
		 * An optional event to signal that inlay hints have changed.
M
Matt Bierner 已提交
1716
		 * @see {@link EventEmitter}
W
Wenlu Wang 已提交
1717
		 */
1718
		onDidChangeInlayHints?: Event<void>;
J
Johannes Rieken 已提交
1719

K
kingwl 已提交
1720
		/**
J
Johannes Rieken 已提交
1721
		 *
K
kingwl 已提交
1722
		 * @param model The document in which the command was invoked.
J
Johannes Rieken 已提交
1723
		 * @param range The range for which inlay hints should be computed.
K
kingwl 已提交
1724
		 * @param token A cancellation token.
J
Johannes Rieken 已提交
1725
		 * @return A list of inlay hints or a thenable that resolves to such.
K
kingwl 已提交
1726
		 */
1727
		provideInlayHints(model: TextDocument, range: Range, token: CancellationToken): ProviderResult<InlayHint[]>;
K
kingwl 已提交
1728
	}
1729
	//#endregion
1730

1731 1732 1733 1734 1735 1736 1737 1738 1739 1740 1741 1742 1743 1744 1745 1746 1747 1748
	//#region https://github.com/microsoft/vscode/issues/104436

	export enum ExtensionRuntime {
		/**
		 * The extension is running in a NodeJS extension host. Runtime access to NodeJS APIs is available.
		 */
		Node = 1,
		/**
		 * The extension is running in a Webworker extension host. Runtime access is limited to Webworker APIs.
		 */
		Webworker = 2
	}

	export interface ExtensionContext {
		readonly extensionRuntime: ExtensionRuntime;
	}

	//#endregion
1749 1750 1751 1752

	//#region https://github.com/microsoft/vscode/issues/102091

	export interface TextDocument {
1753 1754

		/**
M
Matt Bierner 已提交
1755
		 * The {@link NotebookDocument notebook} that contains this document as a notebook cell or `undefined` when
1756 1757
		 * the document is not contained by a notebook (this should be the more frequent case).
		 */
1758 1759 1760
		notebook: NotebookDocument | undefined;
	}
	//#endregion
C
Connor Peet 已提交
1761 1762

	//#region https://github.com/microsoft/vscode/issues/107467
J
Johannes Rieken 已提交
1763
	// todo@API test or tests?
C
Connor Peet 已提交
1764
	export namespace tests {
C
Connor Peet 已提交
1765
		/**
1766 1767 1768
		 * Creates a new test controller.
		 *
		 * @param id Identifier for the controller, must be globally unique.
J
Johannes Rieken 已提交
1769
		*/
1770
		export function createTestController(id: string, label: string): TestController;
C
Connor Peet 已提交
1771 1772 1773

		/**
		 * Requests that tests be run by their controller.
1774
		 * @param run Run options to use.
C
Connor Peet 已提交
1775
		 * @param token Cancellation token for the test run
1776
		 * @stability experimental
C
Connor Peet 已提交
1777
		 */
1778
		export function runTests(run: TestRunRequest, token?: CancellationToken): Thenable<void>;
C
Connor Peet 已提交
1779

C
Connor Peet 已提交
1780
		/**
1781
		 * Returns an observer that watches and can request tests.
1782
		 * @stability experimental
C
Connor Peet 已提交
1783
		 */
1784
		export function createTestObserver(): TestObserver;
1785
		/**
M
Matt Bierner 已提交
1786
		 * List of test results stored by the editor, sorted in descending
1787 1788 1789
		 * order by their `completedAt` time.
		 * @stability experimental
		 */
C
Connor Peet 已提交
1790
		export const testResults: ReadonlyArray<TestRunResult>;
1791 1792

		/**
1793 1794 1795
		 * Event that fires when the {@link testResults} array is updated.
		 * @stability experimental
		 */
1796
		export const onDidChangeTestResults: Event<void>;
C
Connor Peet 已提交
1797 1798
	}

1799 1800 1801
	/**
	 * @stability experimental
	 */
C
Connor Peet 已提交
1802 1803 1804 1805
	export interface TestObserver {
		/**
		 * List of tests returned by test provider for files in the workspace.
		 */
1806
		readonly tests: ReadonlyArray<TestItem>;
C
Connor Peet 已提交
1807 1808 1809 1810 1811 1812

		/**
		 * An event that fires when an existing test in the collection changes, or
		 * null if a top-level test was added or removed. When fired, the consumer
		 * should check the test item and all its children for changes.
		 */
C
Connor Peet 已提交
1813
		readonly onDidChangeTest: Event<TestsChangeEvent>;
C
Connor Peet 已提交
1814 1815

		/**
M
Matt Bierner 已提交
1816
		 * Dispose of the observer, allowing the editor to eventually tell test
C
Connor Peet 已提交
1817 1818 1819 1820 1821
		 * providers that they no longer need to update tests.
		 */
		dispose(): void;
	}

1822 1823 1824
	/**
	 * @stability experimental
	 */
C
Connor Peet 已提交
1825
	export interface TestsChangeEvent {
C
Connor Peet 已提交
1826 1827 1828
		/**
		 * List of all tests that are newly added.
		 */
1829
		readonly added: ReadonlyArray<TestItem>;
C
Connor Peet 已提交
1830 1831 1832 1833

		/**
		 * List of existing tests that have updated.
		 */
1834
		readonly updated: ReadonlyArray<TestItem>;
C
Connor Peet 已提交
1835 1836 1837 1838

		/**
		 * List of existing tests that have been removed.
		 */
1839
		readonly removed: ReadonlyArray<TestItem>;
C
Connor Peet 已提交
1840 1841
	}

C
Connor Peet 已提交
1842
	/**
C
Connor Peet 已提交
1843
	 * The kind of executions that {@link TestRunProfile | TestRunProfiles} control.
C
Connor Peet 已提交
1844
	 */
C
Connor Peet 已提交
1845
	export enum TestRunProfileKind {
1846 1847 1848 1849 1850
		Run = 1,
		Debug = 2,
		Coverage = 3,
	}

C
Connor Peet 已提交
1851 1852 1853 1854
	/**
	 * A TestRunProfile describes one way to execute tests in a {@link TestController}.
	 */
	export interface TestRunProfile {
1855 1856 1857 1858 1859 1860 1861 1862 1863 1864 1865 1866
		/**
		 * Label shown to the user in the UI.
		 *
		 * Note that the label has some significance if the user requests that
		 * tests be re-run in a certain way. For example, if tests were run
		 * normally and the user requests to re-run them in debug mode, the editor
		 * will attempt use a configuration with the same label in the `Debug`
		 * group. If there is no such configuration, the default will be used.
		 */
		label: string;

		/**
C
Connor Peet 已提交
1867 1868
		 * Configures what kind of execution this profile controls. If there
		 * are no profiles for a kind, it will not be available in the UI.
1869
		 */
C
Connor Peet 已提交
1870
		readonly kind: TestRunProfileKind;
1871 1872

		/**
C
Connor Peet 已提交
1873
		 * Controls whether this profile is the default action that will
1874
		 * be taken when its group is actions. For example, if the user clicks
C
Connor Peet 已提交
1875
		 * the generic "run all" button, then the default profile for
C
Connor Peet 已提交
1876
		 * {@link TestRunProfileKind.Run} will be executed.
1877 1878 1879 1880
		 */
		isDefault: boolean;

		/**
C
Connor Peet 已提交
1881
		 * If this method is present, a configuration gear will be present in the
1882 1883 1884 1885 1886 1887 1888
		 * UI, and this method will be invoked when it's clicked. When called,
		 * you can take other editor actions, such as showing a quick pick or
		 * opening a configuration file.
		 */
		configureHandler?: () => void;

		/**
1889 1890 1891 1892
		 * Handler called to start a test run. When invoked, the function should
		 * {@link TestController.createTestRun} at least once, and all tasks
		 * associated with the run should be created before the function returns
		 * or the reutrned promise is resolved.
1893 1894 1895 1896 1897 1898 1899
		 *
		 * @param request Request information for the test run
		 * @param cancellationToken Token that signals the used asked to abort the
		 * test run. If cancellation is requested on this token, all {@link TestRun}
		 * instances associated with the request will be
		 * automatically cancelled as well.
		 */
1900
		runHandler: (request: TestRunRequest, token: CancellationToken) => Thenable<void> | void;
1901 1902

		/**
C
Connor Peet 已提交
1903
		 * Deletes the run profile.
1904 1905 1906 1907
		 */
		dispose(): void;
	}

C
Connor Peet 已提交
1908
	/**
C
Connor Peet 已提交
1909 1910
	 * Entry point to discover and execute tests. It contains {@link items} which
	 * are used to populate the editor UI, and is associated with
J
Johannes Rieken 已提交
1911
	 * {@link createRunProfile run profiles} to allow
C
Connor Peet 已提交
1912
	 * for tests to be executed.
C
Connor Peet 已提交
1913
	 */
1914 1915
	export interface TestController {
		/**
C
Connor Peet 已提交
1916 1917
		 * The ID of the controller, passed in {@link vscode.tests.createTestController}.
		 * This must be globally unique,
1918 1919
		 */
		readonly id: string;
1920

1921 1922 1923 1924 1925
		/**
		 * Human-readable label for the test controller.
		 */
		label: string;

1926
		/**
C
Connor Peet 已提交
1927 1928
		 * Available test items. Tests in the workspace should be added in this
		 * collection. The extension controls when to add these, although the
1929 1930 1931 1932
		 * editor may request children using the {@link resolveChildrenHandler},
		 * and the extension should add tests for a file when
		 * {@link vscode.workspace.onDidOpenTextDocument} fires in order for
		 * decorations for tests within the file to be visible.
C
Connor Peet 已提交
1933
		 *
1934
		 * Tests in this collection should be watched and updated by the extension
J
Johannes Rieken 已提交
1935
		 * as files change. See {@link resolveChildrenHandler} for details around
1936
		 * for the lifecycle of watches.
C
Connor Peet 已提交
1937
		 */
C
Connor Peet 已提交
1938
		readonly items: TestItemCollection;
C
Connor Peet 已提交
1939

1940
		/**
C
Connor Peet 已提交
1941 1942 1943 1944
		 * Creates a profile used for running tests. Extensions must create
		 * at least one profile in order for tests to be run.
		 * @param label Human-readable label for this profile
		 * @param group Configures where this profile is grouped in the UI.
1945 1946 1947
		 * @param runHandler Function called to start a test run
		 * @param isDefault Whether this is the default action for the group
		 */
C
Connor Peet 已提交
1948
		createRunProfile(label: string, group: TestRunProfileKind, runHandler: (request: TestRunRequest, token: CancellationToken) => Thenable<void> | void, isDefault?: boolean): TestRunProfile;
1949

1950 1951
		/**
		 * A function provided by the extension that the editor may call to request
1952 1953
		 * children of a test item, if the {@link TestItem.canResolveChildren} is
		 * `true`. When called, the item should discover children and call
C
Connor Peet 已提交
1954
		 * {@link vscode.tests.createTestItem} as children are discovered.
C
Connor Peet 已提交
1955
		 *
1956 1957
		 * The item in the explorer will automatically be marked as "busy" until
		 * the function returns or the returned thenable resolves.
C
Connor Peet 已提交
1958
		 *
1959 1960
		 * The handler will be called `undefined` to resolve the controller's
		 * initial children.
C
Connor Peet 已提交
1961
		 *
1962 1963
		 * @param item An unresolved test item for which
		 * children are being requested
C
Connor Peet 已提交
1964
		 */
1965
		resolveChildrenHandler?: (item: TestItem | undefined) => Thenable<void> | void;
C
Connor Peet 已提交
1966

1967 1968 1969 1970 1971
		/**
		 * Creates a {@link TestRun<T>}. This should be called by the
		 * {@link TestRunner} when a request is made to execute tests, and may also
		 * be called if a test run is detected externally. Once created, tests
		 * that are included in the results will be moved into the
C
Connor Peet 已提交
1972
		 * {@link TestResultState.Queued} state.
1973
		 *
1974 1975 1976 1977
		 * All runs created using the same `request` instance will be grouped
		 * together. This is useful if, for example, a single suite of tests is
		 * run on multiple platforms.
		 *
1978 1979 1980 1981 1982 1983 1984 1985 1986
		 * @param request Test run request. Only tests inside the `include` may be
		 * modified, and tests in its `exclude` are ignored.
		 * @param name The human-readable name of the run. This can be used to
		 * disambiguate multiple sets of results in a test run. It is useful if
		 * tests are run across multiple platforms, for example.
		 * @param persist Whether the results created by the run should be
		 * persisted in the editor. This may be false if the results are coming from
		 * a file already saved externally, such as a coverage information file.
		 */
1987
		createTestRun(request: TestRunRequest, name?: string, persist?: boolean): TestRun;
1988

C
Connor Peet 已提交
1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999
		/**
		 * Creates a new managed {@link TestItem} instance. It can be added into
		 * the {@link TestItem.children} of an existing item, or into the
		 * {@link TestController.items}.
		 * @param id Identifier for the TestItem. The test item's ID must be unique
		 * in the {@link TestItemCollection} it's added to.
		 * @param label Human-readable label of the test item.
		 * @param uri URI this TestItem is associated with. May be a file or directory.
		 */
		createTestItem(id: string, label: string, uri?: Uri): TestItem;

2000 2001 2002 2003 2004
		/**
		 * Unregisters the test controller, disposing of its associated tests
		 * and unpersisted results.
		 */
		dispose(): void;
C
Connor Peet 已提交
2005 2006 2007
	}

	/**
C
Connor Peet 已提交
2008
	 * Options given to {@link tests.runTests}.
C
Connor Peet 已提交
2009
	 */
2010
	export class TestRunRequest {
C
Connor Peet 已提交
2011
		/**
C
Connor Peet 已提交
2012 2013 2014 2015
		 * Filter for specific tests to run. If given, the extension should run all
		 * of the given tests and all children of the given tests, excluding
		 * any tests that appear in {@link TestRunRequest.exclude}. If this is
		 * not given, then the extension should simply run all tests.
C
Connor Peet 已提交
2016 2017 2018
		 *
		 * The process of running tests should resolve the children of any test
		 * items who have not yet been resolved.
C
Connor Peet 已提交
2019
		 */
C
Connor Peet 已提交
2020
		include?: TestItem[];
C
Connor Peet 已提交
2021 2022

		/**
C
Connor Peet 已提交
2023 2024 2025 2026 2027
		 * An array of tests the user has marked as excluded from the test included
		 * in this run; exclusions should apply after inclusions.
		 *
		 * May be omitted if no exclusions were requested. Test controllers should
		 * not run excluded tests or any children of excluded tests.
C
Connor Peet 已提交
2028
		 */
2029
		exclude?: TestItem[];
C
Connor Peet 已提交
2030 2031

		/**
C
Connor Peet 已提交
2032
		 * The profile used for this request. This will always be defined
2033
		 * for requests issued from the editor UI, though extensions may
C
Connor Peet 已提交
2034
		 * programmatically create requests not associated with any profile.
C
Connor Peet 已提交
2035
		 */
C
Connor Peet 已提交
2036
		profile?: TestRunProfile;
2037 2038

		/**
C
Connor Peet 已提交
2039
		 * @param tests Array of specific tests to run, or undefined to run all tests
2040
		 * @param exclude Tests to exclude from the run
C
Connor Peet 已提交
2041
		 * @param profile The run profile used for this request.
2042
		 */
C
Connor Peet 已提交
2043
		constructor(include?: readonly TestItem[], exclude?: readonly TestItem[], profile?: TestRunProfile);
C
Connor Peet 已提交
2044 2045 2046 2047 2048
	}

	/**
	 * Options given to {@link TestController.runTests}
	 */
2049
	export interface TestRun {
C
Connor Peet 已提交
2050 2051 2052 2053 2054 2055 2056
		/**
		 * The human-readable name of the run. This can be used to
		 * disambiguate multiple sets of results in a test run. It is useful if
		 * tests are run across multiple platforms, for example.
		 */
		readonly name?: string;

2057 2058 2059 2060 2061 2062
		/**
		 * A cancellation token which will be triggered when the test run is
		 * canceled from the UI.
		 */
		readonly token: CancellationToken;

C
Connor Peet 已提交
2063 2064 2065 2066 2067
		/**
		 * Whether the test run will be persisteded across reloads by the editor UI.
		 */
		readonly isPersisted: boolean;

C
Connor Peet 已提交
2068 2069
		/**
		 * Updates the state of the test in the run. Calling with method with nodes
C
Connor Peet 已提交
2070 2071 2072
		 * outside the {@link TestRunRequest.tests} or in the {@link TestRunRequest.exclude}
		 * array will no-op. This will usually be called multiple times for a test
		 * as it is queued, enters the running state, and then passes or fails.
C
Connor Peet 已提交
2073 2074 2075
		 *
		 * @param test The test to update
		 * @param state The state to assign to the test
C
Connor Peet 已提交
2076 2077 2078 2079 2080 2081 2082 2083 2084 2085 2086
		 */
		setState(test: TestItem, state: TestResultState): void;

		/**
		 * Updates the state of the test in the run. Calling with method with nodes
		 * outside the {@link TestRunRequest.tests} or in the {@link TestRunRequest.exclude}
		 * array will no-op. This override moves the test into a terminal state and
		 * indicates how long it ran for.
		 *
		 * @param test The terminal test state
		 * @param state The state to assign to the test
2087
		 * @param duration Optionally sets how long the test took to run, in milliseconds
C
Connor Peet 已提交
2088
		 */
C
Connor Peet 已提交
2089
		setState(test: TestItem, state: TestResultState.Passed | TestResultState.Failed | TestResultState.Errored, duration: number): void;
C
Connor Peet 已提交
2090 2091 2092 2093 2094 2095 2096 2097

		/**
		 * Appends a message, such as an assertion error, to the test item.
		 *
		 * Calling with method with nodes outside the {@link TestRunRequest.tests}
		 * or in the {@link TestRunRequest.exclude} array will no-op.
		 *
		 * @param test The test to update
2098
		 * @param message The message to add
C
Connor Peet 已提交
2099
		 */
2100
		appendMessage(test: TestItem, message: TestMessage): void;
C
Connor Peet 已提交
2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111

		/**
		 * Appends raw output from the test runner. On the user's request, the
		 * output will be displayed in a terminal. ANSI escape sequences,
		 * such as colors and text styles, are supported.
		 *
		 * @param output Output text to append
		 */
		appendOutput(output: string): void;

		/**
C
Connor Peet 已提交
2112
		 * Signals that the end of the test run. Any tests included in the run whose
C
Connor Peet 已提交
2113
		 * states have not been updated will have their state reset.
C
Connor Peet 已提交
2114 2115 2116 2117
		 */
		end(): void;
	}

C
Connor Peet 已提交
2118 2119 2120 2121
	/**
	 * Collection of test items, found in {@link TestItem.children} and
	 * {@link TestController.items}.
	 */
2122
	export interface TestItemCollection {
C
Connor Peet 已提交
2123
		/**
C
Connor Peet 已提交
2124
		 * Replaces the items stored by the collection.
C
Connor Peet 已提交
2125
		 * @param items Items to store, can be an array or other iterable.
C
Connor Peet 已提交
2126
		 */
C
Connor Peet 已提交
2127
		replace(items: readonly TestItem[]): void;
C
Connor Peet 已提交
2128 2129 2130 2131 2132 2133 2134 2135

		/**
		 * Iterate over each entry in this collection.
		 *
		 * @param callback Function to execute for each entry.
		 * @param thisArg The `this` context used when invoking the handler function.
		 */
		forEach(callback: (item: TestItem, collection: TestItemCollection) => unknown, thisArg?: unknown): void;
C
Connor Peet 已提交
2136 2137 2138 2139

		/**
		 * Adds the test item to the children. If an item with the same ID already
		 * exists, it'll be replaced.
C
Connor Peet 已提交
2140
		 * @param items Item to add.
C
Connor Peet 已提交
2141 2142 2143 2144 2145
		 */
		add(item: TestItem): void;

		/**
		 * Removes the a single test item from the collection.
C
Connor Peet 已提交
2146
		 * @param itemId Item ID to delete.
C
Connor Peet 已提交
2147
		 */
C
Connor Peet 已提交
2148
		delete(itemId: string): void;
C
Connor Peet 已提交
2149 2150 2151

		/**
		 * Efficiently gets a test item by ID, if it exists, in the children.
C
Connor Peet 已提交
2152
		 * @param itemId Item ID to get.
C
Connor Peet 已提交
2153 2154 2155 2156
		 */
		get(itemId: string): TestItem | undefined;
	}

C
Connor Peet 已提交
2157 2158 2159 2160
	/**
	 * A test item is an item shown in the "test explorer" view. It encompasses
	 * both a suite and a test, since they have almost or identical capabilities.
	 */
2161
	export interface TestItem {
C
Connor Peet 已提交
2162
		/**
2163
		 * Identifier for the TestItem. This is used to correlate
C
Connor Peet 已提交
2164
		 * test results and tests in the document with those in the workspace
2165 2166
		 * (test explorer). This cannot change for the lifetime of the TestItem,
		 * and must be unique among its parent's direct children.
C
Connor Peet 已提交
2167 2168 2169 2170 2171 2172 2173 2174 2175 2176 2177
		 */
		readonly id: string;

		/**
		 * URI this TestItem is associated with. May be a file or directory.
		 */
		readonly uri?: Uri;

		/**
		 * A mapping of children by ID to the associated TestItem instances.
		 */
C
Connor Peet 已提交
2178
		readonly children: TestItemCollection;
C
Connor Peet 已提交
2179 2180

		/**
C
Connor Peet 已提交
2181
		 * The parent of this item, given in {@link vscode.tests.createTestItem}.
C
Connor Peet 已提交
2182 2183
		 * This is undefined top-level items in the `TestController` and for
		 * items that aren't yet included in another item's {@link children}.
C
Connor Peet 已提交
2184
		 */
2185
		readonly parent?: TestItem;
C
Connor Peet 已提交
2186 2187

		/**
2188
		 * Indicates whether this test item may have children discovered by resolving.
J
Johannes Rieken 已提交
2189
		 * If so, it will be shown as expandable in the Test Explorer view, and
2190 2191
		 * expanding the item will cause {@link TestController.resolveChildrenHandler}
		 * to be invoked with the item.
C
Connor Peet 已提交
2192
		 *
2193 2194
		 * Default to false.
		 */
J
Johannes Rieken 已提交
2195
		// todo@API better names: isLeaf, isLeaf{Type|Node}, canHaveChildren
2196 2197 2198 2199 2200 2201
		canResolveChildren: boolean;

		/**
		 * Controls whether the item is shown as "busy" in the Test Explorer view.
		 * This is useful for showing status while discovering children. Defaults
		 * to false.
C
Connor Peet 已提交
2202
		 */
2203
		busy: boolean;
C
Connor Peet 已提交
2204 2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234 2235

		/**
		 * Display name describing the test case.
		 */
		label: string;

		/**
		 * Optional description that appears next to the label.
		 */
		description?: string;

		/**
		 * Location of the test item in its `uri`. This is only meaningful if the
		 * `uri` points to a file.
		 */
		range?: Range;

		/**
		 * May be set to an error associated with loading the test. Note that this
		 * is not a test result and should only be used to represent errors in
		 * discovery, such as syntax errors.
		 */
		error?: string | MarkdownString;

		/**
		 * Marks the test as outdated. This can happen as a result of file changes,
		 * for example. In "auto run" mode, tests that are outdated will be
		 * automatically rerun after a short delay. Invoking this on a
		 * test with children will mark the entire subtree as outdated.
		 *
		 * Extensions should generally not override this method.
		 */
J
Johannes Rieken 已提交
2236
		// todo@api still unsure about this
2237
		invalidateResults(): void;
C
Connor Peet 已提交
2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296
	}

	/**
	 * Possible states of tests in a test run.
	 */
	export enum TestResultState {
		// Test will be run, but is not currently running.
		Queued = 1,
		// Test is currently running
		Running = 2,
		// Test run has passed
		Passed = 3,
		// Test run has failed (on an assertion)
		Failed = 4,
		// Test run has been skipped
		Skipped = 5,
		// Test run failed for some other reason (compilation error, timeout, etc)
		Errored = 6
	}
	/**
	 * Message associated with the test state. Can be linked to a specific
	 * source range -- useful for assertion failures, for example.
	 */
	export class TestMessage {
		/**
		 * Human-readable message text to display.
		 */
		message: string | MarkdownString;

		/**
		 * Expected test output. If given with `actualOutput`, a diff view will be shown.
		 */
		expectedOutput?: string;

		/**
		 * Actual test output. If given with `expectedOutput`, a diff view will be shown.
		 */
		actualOutput?: string;

		/**
		 * Associated file location.
		 */
		location?: Location;

		/**
		 * Creates a new TestMessage that will present as a diff in the editor.
		 * @param message Message to display to the user.
		 * @param expected Expected output.
		 * @param actual Actual output.
		 */
		static diff(message: string | MarkdownString, expected: string, actual: string): TestMessage;

		/**
		 * Creates a new TestMessage instance.
		 * @param message The message to show to the user.
		 */
		constructor(message: string | MarkdownString);
	}

2297
	/**
C
Connor Peet 已提交
2298 2299
	 * TestResults can be provided to the editor in {@link tests.publishTestResult},
	 * or read from it in {@link tests.testResults}.
2300 2301
	 *
	 * The results contain a 'snapshot' of the tests at the point when the test
C
Connor Peet 已提交
2302 2303 2304
	 * run is complete. Therefore, information such as its {@link Range} may be
	 * out of date. If the test still exists in the workspace, consumers can use
	 * its `id` to correlate the result instance with the living test.
2305
	 */
C
Connor Peet 已提交
2306
	export interface TestRunResult {
2307
		/**
C
Connor Peet 已提交
2308
		 * Unix milliseconds timestamp at which the test run was completed.
2309 2310 2311
		 */
		completedAt: number;

2312 2313 2314 2315 2316
		/**
		 * Optional raw output from the test run.
		 */
		output?: string;

2317 2318
		/**
		 * List of test results. The items in this array are the items that
C
Connor Peet 已提交
2319
		 * were passed in the {@link tests.runTests} method.
2320
		 */
2321
		results: ReadonlyArray<Readonly<TestResultSnapshot>>;
2322 2323 2324
	}

	/**
2325 2326
	 * A {@link TestItem}-like interface with an associated result, which appear
	 * or can be provided in {@link TestResult} interfaces.
2327
	 */
2328 2329 2330 2331 2332 2333 2334 2335
	export interface TestResultSnapshot {
		/**
		 * Unique identifier that matches that of the associated TestItem.
		 * This is used to correlate test results and tests in the document with
		 * those in the workspace (test explorer).
		 */
		readonly id: string;

2336 2337 2338 2339 2340
		/**
		 * Parent of this item.
		 */
		readonly parent?: TestResultSnapshot;

2341 2342 2343
		/**
		 * URI this TestItem is associated with. May be a file or file.
		 */
C
Connor Peet 已提交
2344
		readonly uri?: Uri;
2345

2346 2347 2348 2349 2350 2351 2352 2353 2354 2355 2356
		/**
		 * Display name describing the test case.
		 */
		readonly label: string;

		/**
		 * Optional description that appears next to the label.
		 */
		readonly description?: string;

		/**
2357 2358
		 * Location of the test item in its `uri`. This is only meaningful if the
		 * `uri` points to a file.
2359
		 */
2360
		readonly range?: Range;
2361

2362
		/**
2363 2364
		 * State of the test in each task. In the common case, a test will only
		 * be executed in a single task and the length of this array will be 1.
2365
		 */
2366
		readonly taskStates: ReadonlyArray<TestSnapshoptTaskState>;
2367 2368 2369 2370

		/**
		 * Optional list of nested tests for this item.
		 */
2371
		readonly children: Readonly<TestResultSnapshot>[];
C
Connor Peet 已提交
2372
	}
2373

2374
	export interface TestSnapshoptTaskState {
2375 2376 2377
		/**
		 * Current result of the test.
		 */
C
Connor Peet 已提交
2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390
		readonly state: TestResultState;

		/**
		 * The number of milliseconds the test took to run. This is set once the
		 * `state` is `Passed`, `Failed`, or `Errored`.
		 */
		readonly duration?: number;

		/**
		 * Associated test run message. Can, for example, contain assertion
		 * failure information if the test fails.
		 */
		readonly messages: ReadonlyArray<TestMessage>;
2391 2392
	}

C
Connor Peet 已提交
2393
	//#endregion
2394 2395 2396

	//#region Opener service (https://github.com/microsoft/vscode/issues/109277)

2397 2398 2399
	/**
	 * Details if an `ExternalUriOpener` can open a uri.
	 *
2400 2401 2402 2403
	 * The priority is also used to rank multiple openers against each other and determine
	 * if an opener should be selected automatically or if the user should be prompted to
	 * select an opener.
	 *
M
Matt Bierner 已提交
2404
	 * The editor will try to use the best available opener, as sorted by `ExternalUriOpenerPriority`.
2405 2406
	 * If there are multiple potential "best" openers for a URI, then the user will be prompted
	 * to select an opener.
2407
	 */
M
Matt Bierner 已提交
2408
	export enum ExternalUriOpenerPriority {
2409
		/**
2410
		 * The opener is disabled and will never be shown to users.
M
Matt Bierner 已提交
2411
		 *
2412 2413
		 * Note that the opener can still be used if the user specifically
		 * configures it in their settings.
2414
		 */
M
Matt Bierner 已提交
2415
		None = 0,
2416 2417

		/**
2418
		 * The opener can open the uri but will not cause a prompt on its own
M
Matt Bierner 已提交
2419
		 * since the editor always contributes a built-in `Default` opener.
2420
		 */
M
Matt Bierner 已提交
2421
		Option = 1,
2422 2423

		/**
M
Matt Bierner 已提交
2424 2425
		 * The opener can open the uri.
		 *
M
Matt Bierner 已提交
2426
		 * The editor's built-in opener has `Default` priority. This means that any additional `Default`
2427
		 * openers will cause the user to be prompted to select from a list of all potential openers.
2428
		 */
M
Matt Bierner 已提交
2429 2430 2431
		Default = 2,

		/**
2432
		 * The opener can open the uri and should be automatically selected over any
M
Matt Bierner 已提交
2433
		 * default openers, include the built-in one from the editor.
M
Matt Bierner 已提交
2434
		 *
2435
		 * A preferred opener will be automatically selected if no other preferred openers
2436
		 * are available. If multiple preferred openers are available, then the user
2437
		 * is shown a prompt with all potential openers (not just preferred openers).
M
Matt Bierner 已提交
2438 2439
		 */
		Preferred = 3,
2440 2441
	}

2442
	/**
M
Matt Bierner 已提交
2443
	 * Handles opening uris to external resources, such as http(s) links.
2444
	 *
M
Matt Bierner 已提交
2445
	 * Extensions can implement an `ExternalUriOpener` to open `http` links to a webserver
M
Matt Bierner 已提交
2446
	 * inside of the editor instead of having the link be opened by the web browser.
2447 2448 2449 2450 2451 2452
	 *
	 * Currently openers may only be registered for `http` and `https` uris.
	 */
	export interface ExternalUriOpener {

		/**
2453
		 * Check if the opener can open a uri.
2454
		 *
M
Matt Bierner 已提交
2455 2456 2457
		 * @param uri The uri being opened. This is the uri that the user clicked on. It has
		 * not yet gone through port forwarding.
		 * @param token Cancellation token indicating that the result is no longer needed.
2458
		 *
2459
		 * @return Priority indicating if the opener can open the external uri.
M
Matt Bierner 已提交
2460
		 */
M
Matt Bierner 已提交
2461
		canOpenExternalUri(uri: Uri, token: CancellationToken): ExternalUriOpenerPriority | Thenable<ExternalUriOpenerPriority>;
M
Matt Bierner 已提交
2462 2463

		/**
2464
		 * Open a uri.
2465
		 *
M
Matt Bierner 已提交
2466
		 * This is invoked when:
2467
		 *
M
Matt Bierner 已提交
2468 2469 2470
		 * - The user clicks a link which does not have an assigned opener. In this case, first `canOpenExternalUri`
		 *   is called and if the user selects this opener, then `openExternalUri` is called.
		 * - The user sets the default opener for a link in their settings and then visits a link.
2471
		 *
M
Matt Bierner 已提交
2472 2473 2474 2475 2476 2477
		 * @param resolvedUri The uri to open. This uri may have been transformed by port forwarding, so it
		 * may not match the original uri passed to `canOpenExternalUri`. Use `ctx.originalUri` to check the
		 * original uri.
		 * @param ctx Additional information about the uri being opened.
		 * @param token Cancellation token indicating that opening has been canceled.
		 *
2478
		 * @return Thenable indicating that the opening has completed.
M
Matt Bierner 已提交
2479 2480 2481 2482 2483 2484 2485 2486 2487 2488
		 */
		openExternalUri(resolvedUri: Uri, ctx: OpenExternalUriContext, token: CancellationToken): Thenable<void> | void;
	}

	/**
	 * Additional information about the uri being opened.
	 */
	interface OpenExternalUriContext {
		/**
		 * The uri that triggered the open.
2489
		 *
2490
		 * This is the original uri that the user clicked on or that was passed to `openExternal.`
M
Matt Bierner 已提交
2491
		 * Due to port forwarding, this may not match the `resolvedUri` passed to `openExternalUri`.
2492
		 */
M
Matt Bierner 已提交
2493 2494 2495
		readonly sourceUri: Uri;
	}

M
Matt Bierner 已提交
2496
	/**
2497
	 * Additional metadata about a registered `ExternalUriOpener`.
M
Matt Bierner 已提交
2498
	 */
M
Matt Bierner 已提交
2499
	interface ExternalUriOpenerMetadata {
M
Matt Bierner 已提交
2500

M
Matt Bierner 已提交
2501 2502 2503 2504 2505 2506 2507
		/**
		 * List of uri schemes the opener is triggered for.
		 *
		 * Currently only `http` and `https` are supported.
		 */
		readonly schemes: readonly string[]

M
Matt Bierner 已提交
2508 2509
		/**
		 * Text displayed to the user that explains what the opener does.
2510
		 *
M
Matt Bierner 已提交
2511
		 * For example, 'Open in browser preview'
2512
		 */
M
Matt Bierner 已提交
2513
		readonly label: string;
2514 2515 2516 2517 2518 2519
	}

	namespace window {
		/**
		 * Register a new `ExternalUriOpener`.
		 *
2520
		 * When a uri is about to be opened, an `onOpenExternalUri:SCHEME` activation event is fired.
2521
		 *
M
Matt Bierner 已提交
2522 2523
		 * @param id Unique id of the opener, such as `myExtension.browserPreview`. This is used in settings
		 *   and commands to identify the opener.
2524
		 * @param opener Opener to register.
M
Matt Bierner 已提交
2525
		 * @param metadata Additional information about the opener.
2526 2527
		 *
		* @returns Disposable that unregisters the opener.
M
Matt Bierner 已提交
2528 2529
		*/
		export function registerExternalUriOpener(id: string, opener: ExternalUriOpener, metadata: ExternalUriOpenerMetadata): Disposable;
2530 2531
	}

2532 2533
	interface OpenExternalOptions {
		/**
2534 2535
		 * Allows using openers contributed by extensions through  `registerExternalUriOpener`
		 * when opening the resource.
2536
		 *
M
Matt Bierner 已提交
2537
		 * If `true`, the editor will check if any contributed openers can handle the
2538 2539
		 * uri, and fallback to the default opener behavior.
		 *
2540
		 * If it is string, this specifies the id of the `ExternalUriOpener`
M
Matt Bierner 已提交
2541
		 * that should be used if it is available. Use `'default'` to force the editor's
2542 2543 2544 2545 2546 2547 2548 2549 2550
		 * standard external opener to be used.
		 */
		readonly allowContributedOpeners?: boolean | string;
	}

	namespace env {
		export function openExternal(target: Uri, options?: OpenExternalOptions): Thenable<boolean>;
	}

J
Johannes Rieken 已提交
2551
	//#endregion
2552 2553 2554 2555 2556 2557 2558

	//#region https://github.com/Microsoft/vscode/issues/15178

	// TODO@API must be a class
	export interface OpenEditorInfo {
		name: string;
		resource: Uri;
2559
		isActive: boolean;
2560 2561 2562 2563 2564 2565 2566 2567 2568 2569
	}

	export namespace window {
		export const openEditors: ReadonlyArray<OpenEditorInfo>;

		// todo@API proper event type
		export const onDidChangeOpenEditors: Event<void>;
	}

	//#endregion
2570

2571
	//#region https://github.com/microsoft/vscode/issues/120173
L
Ladislau Szomoru 已提交
2572 2573 2574
	/**
	 * The object describing the properties of the workspace trust request
	 */
2575
	export interface WorkspaceTrustRequestOptions {
L
Ladislau Szomoru 已提交
2576
		/**
2577 2578 2579
		 * Custom message describing the user action that requires workspace
		 * trust. If omitted, a generic message will be displayed in the workspace
		 * trust request dialog.
L
Ladislau Szomoru 已提交
2580
		 */
2581
		readonly message?: string;
L
Ladislau Szomoru 已提交
2582 2583
	}

2584 2585 2586
	export namespace workspace {
		/**
		 * Prompt the user to chose whether to trust the current workspace
2587
		 * @param options Optional object describing the properties of the
2588
		 * workspace trust request.
2589
		 */
2590
		export function requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Thenable<boolean | undefined>;
2591 2592
	}

2593
	//#endregion
2594 2595 2596 2597 2598 2599 2600

	//#region https://github.com/microsoft/vscode/issues/115616 @alexr00
	export enum PortAutoForwardAction {
		Notify = 1,
		OpenBrowser = 2,
		OpenPreview = 3,
		Silent = 4,
2601 2602
		Ignore = 5,
		OpenBrowserOnce = 6
2603 2604
	}

A
Alex Ross 已提交
2605 2606 2607 2608
	export class PortAttributes {
		/**
		 * The port number associated with this this set of attributes.
		 */
2609
		port: number;
A
Alex Ross 已提交
2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621

		/**
		 * The action to be taken when this port is detected for auto forwarding.
		 */
		autoForwardAction: PortAutoForwardAction;

		/**
		 * Creates a new PortAttributes object
		 * @param port the port number
		 * @param autoForwardAction the action to take when this port is detected
		 */
		constructor(port: number, autoForwardAction: PortAutoForwardAction);
2622 2623 2624
	}

	export interface PortAttributesProvider {
2625
		/**
2626 2627 2628
		 * Provides attributes for the given port. For ports that your extension doesn't know about, simply
		 * return undefined. For example, if `providePortAttributes` is called with ports 3000 but your
		 * extension doesn't know anything about 3000 you should return undefined.
2629
		 */
2630
		providePortAttributes(port: number, pid: number | undefined, commandLine: string | undefined, token: CancellationToken): ProviderResult<PortAttributes>;
2631 2632 2633 2634 2635 2636
	}

	export namespace workspace {
		/**
		 * If your extension listens on ports, consider registering a PortAttributesProvider to provide information
		 * about the ports. For example, a debug extension may know about debug ports in it's debuggee. By providing
M
Matt Bierner 已提交
2637
		 * this information with a PortAttributesProvider the extension can tell the editor that these ports should be
2638 2639 2640
		 * ignored, since they don't need to be user facing.
		 *
		 * @param portSelector If registerPortAttributesProvider is called after you start your process then you may already
2641 2642
		 * know the range of ports or the pid of your process. All properties of a the portSelector must be true for your
		 * provider to get called.
2643
		 * The `portRange` is start inclusive and end exclusive.
2644 2645
		 * @param provider The PortAttributesProvider
		 */
2646
		export function registerPortAttributesProvider(portSelector: { pid?: number, portRange?: [number, number], commandMatcher?: RegExp }, provider: PortAttributesProvider): Disposable;
2647 2648
	}
	//#endregion
2649

J
Johannes Rieken 已提交
2650
	//#region https://github.com/microsoft/vscode/issues/119904 @eamodio
2651 2652 2653 2654 2655 2656 2657 2658 2659 2660

	export interface SourceControlInputBox {

		/**
		 * Sets focus to the input.
		 */
		focus(): void;
	}

	//#endregion
2661

A
Alex Dima 已提交
2662 2663
	//#region https://github.com/microsoft/vscode/issues/124024 @hediet @alexdima

2664
	export namespace languages {
2665 2666 2667
		/**
		 * Registers an inline completion provider.
		 */
2668
		export function registerInlineCompletionItemProvider(selector: DocumentSelector, provider: InlineCompletionItemProvider): Disposable;
A
Alex Dima 已提交
2669 2670
	}

2671
	export interface InlineCompletionItemProvider<T extends InlineCompletionItem = InlineCompletionItem> {
2672 2673 2674 2675 2676 2677
		/**
		 * Provides inline completion items for the given position and document.
		 * If inline completions are enabled, this method will be called whenever the user stopped typing.
		 * It will also be called when the user explicitly triggers inline completions or asks for the next or previous inline completion.
		 * Use `context.triggerKind` to distinguish between these scenarios.
		*/
2678
		provideInlineCompletionItems(document: TextDocument, position: Position, context: InlineCompletionContext, token: CancellationToken): ProviderResult<InlineCompletionList<T> | T[]>;
2679
	}
H
wip  
Henning Dieterichs 已提交
2680

2681 2682 2683 2684 2685
	export interface InlineCompletionContext {
		/**
		 * How the completion was triggered.
		 */
		readonly triggerKind: InlineCompletionTriggerKind;
H
wip  
Henning Dieterichs 已提交
2686 2687
	}

2688 2689 2690 2691 2692 2693 2694 2695 2696 2697
	/**
	 * How an {@link InlineCompletionItemProvider inline completion provider} was triggered.
	 */
	export enum InlineCompletionTriggerKind {
		/**
		 * Completion was triggered automatically while editing.
		 * It is sufficient to return a single completion item in this case.
		 */
		Automatic = 0,

H
wip  
Henning Dieterichs 已提交
2698
		/**
2699 2700 2701 2702 2703
		 * Completion was triggered explicitly by a user gesture.
		 * Return multiple completion items to enable cycling through them.
		 */
		Explicit = 1,
	}
2704 2705 2706 2707 2708 2709 2710 2711

	export class InlineCompletionList<T extends InlineCompletionItem = InlineCompletionItem> {
		items: T[];

		constructor(items: T[]);
	}

	export class InlineCompletionItem {
2712
		/**
2713 2714 2715 2716 2717 2718 2719 2720 2721
		 * The text to insert.
		 * If the text contains a line break, the range must end at the end of a line.
		 * If existing text should be replaced, the existing text must be a prefix of the text to insert.
		*/
		text: string;

		/**
		 * The range to replace.
		 * Must begin and end on the same line.
2722 2723 2724 2725
		 *
		 * Prefer replacements over insertions to avoid cache invalidation.
		 * Instead of reporting a completion that extends a word,
		 * the whole word should be replaced with the extended word.
2726 2727 2728 2729 2730
		*/
		range?: Range;

		/**
		 * An optional {@link Command} that is executed *after* inserting this completion.
2731
		 */
2732 2733 2734
		command?: Command;

		constructor(text: string, range?: Range, command?: Command);
H
wip  
Henning Dieterichs 已提交
2735 2736
	}

2737 2738 2739 2740 2741 2742

	/**
	 * Be aware that this API will not ever be finalized.
	 */
	export namespace window {
		export function getInlineCompletionItemController<T extends InlineCompletionItem>(provider: InlineCompletionItemProvider<T>): InlineCompletionController<T>;
A
Alex Dima 已提交
2743 2744
	}

2745 2746 2747 2748
	/**
	 * Be aware that this API will not ever be finalized.
	 */
	export interface InlineCompletionController<T extends InlineCompletionItem> {
2749 2750 2751
		/**
		 * Is fired when an inline completion item is shown to the user.
		 */
2752 2753 2754 2755 2756 2757 2758 2759 2760
		// eslint-disable-next-line vscode-dts-event-naming
		readonly onDidShowCompletionItem: Event<InlineCompletionItemDidShowEvent<T>>;
	}

	/**
	 * Be aware that this API will not ever be finalized.
	 */
	export interface InlineCompletionItemDidShowEvent<T extends InlineCompletionItem> {
		completionItem: T;
A
Alex Dima 已提交
2761 2762 2763 2764
	}

	//#endregion

2765 2766 2767 2768 2769
	//#region FileSystemProvider stat readonly - https://github.com/microsoft/vscode/issues/73122

	export enum FilePermission {
		/**
		 * The file is readonly.
2770 2771 2772 2773 2774
		 *
		 * *Note:* All `FileStat` from a `FileSystemProvider` that is registered  with
		 * the option `isReadonly: true` will be implicitly handled as if `FilePermission.Readonly`
		 * is set. As a consequence, it is not possible to have a readonly file system provider
		 * registered where some `FileStat` are not readonly.
2775 2776 2777 2778 2779 2780 2781 2782 2783 2784 2785 2786 2787 2788 2789 2790 2791 2792
		 */
		Readonly = 1
	}

	/**
	 * The `FileStat`-type represents metadata about a file
	 */
	export interface FileStat {

		/**
		 * The permissions of the file, e.g. whether the file is readonly.
		 *
		 * *Note:* This value might be a bitmask, e.g. `FilePermission.Readonly | FilePermission.Other`.
		 */
		permissions?: FilePermission;
	}

	//#endregion
2793

2794 2795 2796 2797 2798 2799 2800 2801 2802 2803 2804 2805 2806 2807 2808 2809 2810 2811 2812 2813 2814 2815 2816 2817 2818 2819 2820
	//#region https://github.com/microsoft/vscode/issues/126280 @mjbvz

	export interface NotebookCellData {
		/**
		 * Mime type determines how the cell's `value` is interpreted.
		 *
		 * The mime selects which notebook renders is used to render the cell.
		 *
		 * If not set, internally the cell is treated as having a mime type of `text/plain`.
		 * Cells that set `language` to `markdown` instead are treated as `text/markdown`.
		 */
		mime?: string;
	}

	export interface NotebookCell {
		/**
		 * Mime type determines how the markup cell's `value` is interpreted.
		 *
		 * The mime selects which notebook renders is used to render the cell.
		 *
		 * If not set, internally the cell is treated as having a mime type of `text/plain`.
		 * Cells that set `language` to `markdown` instead are treated as `text/markdown`.
		 */
		mime: string | undefined;
	}

	//#endregion
2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831 2832 2833 2834 2835 2836 2837 2838 2839 2840 2841 2842 2843 2844 2845 2846 2847 2848 2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865 2866 2867 2868 2869 2870 2871 2872 2873 2874 2875 2876 2877 2878 2879 2880 2881 2882 2883 2884 2885 2886 2887 2888 2889 2890 2891 2892 2893 2894 2895 2896 2897 2898 2899 2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910 2911 2912 2913 2914 2915 2916 2917 2918 2919 2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935 2936 2937 2938 2939 2940 2941 2942 2943 2944 2945 2946 2947 2948 2949 2950 2951 2952 2953 2954 2955 2956 2957 2958 2959 2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971 2972 2973 2974 2975 2976 2977 2978 2979 2980 2981 2982 2983 2984 2985 2986 2987 2988 2989 2990 2991 2992 2993 2994 2995 2996 2997 2998 2999 3000 3001 3002 3003 3004 3005 3006 3007 3008 3009 3010 3011

	//#region https://github.com/microsoft/vscode/issues/123713 @connor4312
	export interface TestRun {
		/**
		 * Test coverage provider for this result. An extension can defer setting
		 * this until after a run is complete and coverage is available.
		 */
		coverageProvider?: TestCoverageProvider
		// ...
	}

	/**
	 * Provides information about test coverage for a test result.
	 * Methods on the provider will not be called until the test run is complete
	 */
	export interface TestCoverageProvider<T extends FileCoverage = FileCoverage> {
		/**
		 * Returns coverage information for all files involved in the test run.
		 * @param token A cancellation token.
		 * @return Coverage metadata for all files involved in the test.
		 */
		provideFileCoverage(token: CancellationToken): ProviderResult<T[]>;

		/**
		 * Give a FileCoverage to fill in more data, namely {@link FileCoverage.detailedCoverage}.
		 * The editor will only resolve a FileCoverage once, and onyl if detailedCoverage
		 * is undefined.
		 *
		 * @param coverage A coverage object obtained from {@link provideFileCoverage}
		 * @param token A cancellation token.
		 * @return The resolved file coverage, or a thenable that resolves to one. It
		 * is OK to return the given `coverage`. When no result is returned, the
		 * given `coverage` will be used.
		 */
		resolveFileCoverage?(coverage: T, token: CancellationToken): ProviderResult<T>;
	}

	/**
	 * A class that contains information about a covered resource. A count can
	 * be give for lines, branches, and functions in a file.
	 */
	export class CoveredCount {
		/**
		 * Number of items covered in the file.
		 */
		covered: number;
		/**
		 * Total number of covered items in the file.
		 */
		total: number;

		/**
		 * @param covered Value for {@link CovereredCount.covered}
		 * @param total Value for {@link CovereredCount.total}
		 */
		constructor(covered: number, total: number);
	}

	/**
	 * Contains coverage metadata for a file.
	 */
	export class FileCoverage {
		/**
		 * File URI.
		 */
		readonly uri: Uri;

		/**
		 * Statement coverage information. If the reporter does not provide statement
		 * coverage information, this can instead be used to represent line coverage.
		 */
		statementCoverage: CoveredCount;

		/**
		 * Branch coverage information.
		 */
		branchCoverage?: CoveredCount;

		/**
		 * Function coverage information.
		 */
		functionCoverage?: CoveredCount;

		/**
		 * Detailed, per-statement coverage. If this is undefined, the editor will
		 * call {@link TestCoverageProvider.resolveFileCoverage} when necessary.
		 */
		detailedCoverage?: DetailedCoverage[];

		/**
		 * Creates a {@link FileCoverage} instance with counts filled in from
		 * the coverage details.
		 * @param uri Covered file URI
		 * @param detailed Detailed coverage information
		 */
		static fromDetails(uri: Uri, details: readonly DetailedCoverage[]): FileCoverage;

		/**
		 * @param uri Covered file URI
		 * @param statementCoverage Statement coverage information. If the reporter
		 * does not provide statement coverage information, this can instead be
		 * used to represent line coverage.
		 * @param branchCoverage Branch coverage information
		 * @param functionCoverage Function coverage information
		 */
		constructor(
			uri: Uri,
			statementCoverage: CoveredCount,
			branchCoverage?: CoveredCount,
			functionCoverage?: CoveredCount,
		);
	}

	/**
	 * Contains coverage information for a single statement or line.
	 */
	export class StatementCoverage {
		/**
		 * The number of times this statement was executed. If zero, the
		 * statement will be marked as un-covered.
		 */
		executionCount: number;

		/**
		 * Statement location.
		 */
		location: Position | Range;

		/**
		 * Coverage from branches of this line or statement. If it's not a
		 * conditional, this will be empty.
		 */
		branches: BranchCoverage[];

		/**
		 * @param location The statement position.
		 * @param executionCount The number of times this statement was
		 * executed. If zero, the statement will be marked as un-covered.
		 * @param branches Coverage from branches of this line.  If it's not a
		 * conditional, this should be omitted.
		 */
		constructor(executionCount: number, location: Position | Range, branches?: BranchCoverage[]);
	}

	/**
	 * Contains coverage information for a branch of a {@link StatementCoverage}.
	 */
	export class BranchCoverage {
		/**
		 * The number of times this branch was executed. If zero, the
		 * branch will be marked as un-covered.
		 */
		executionCount: number;

		/**
		 * Branch location.
		 */
		location?: Position | Range;

		/**
		 * @param executionCount The number of times this branch was executed.
		 * @param location The branch position.
		 */
		constructor(executionCount: number, location?: Position | Range);
	}

	/**
	 * Contains coverage information for a function or method.
	 */
	export class FunctionCoverage {
		/**
		 * The number of times this function was executed. If zero, the
		 * function will be marked as un-covered.
		 */
		executionCount: number;

		/**
		 * Function location.
		 */
		location: Position | Range;

		/**
		 * @param executionCount The number of times this function was executed.
		 * @param location The function position.
		 */
		constructor(executionCount: number, location: Position | Range);
	}

	export type DetailedCoverage = StatementCoverage | FunctionCoverage;

	//#endregion
Y
Yan Zhang 已提交
3012 3013


3014
	//#region https://github.com/microsoft/vscode/issues/15533 --- Type hierarchy --- @eskibear
3015 3016 3017 3018

	/**
	 * Represents an item of a type hierarchy, like a class or an interface.
	 */
Y
Yan Zhang 已提交
3019 3020 3021 3022 3023
	export class TypeHierarchyItem {
		/**
		 * The name of this item.
		 */
		name: string;
3024

Y
Yan Zhang 已提交
3025 3026 3027 3028
		/**
		 * The kind of this item.
		 */
		kind: SymbolKind;
3029

Y
Yan Zhang 已提交
3030 3031 3032 3033
		/**
		 * Tags for this item.
		 */
		tags?: ReadonlyArray<SymbolTag>;
3034

Y
Yan Zhang 已提交
3035 3036 3037 3038
		/**
		 * More detail for this item, e.g. the signature of a function.
		 */
		detail?: string;
3039

Y
Yan Zhang 已提交
3040 3041 3042 3043
		/**
		 * The resource identifier of this item.
		 */
		uri: Uri;
3044

Y
Yan Zhang 已提交
3045 3046 3047 3048 3049
		/**
		 * The range enclosing this symbol not including leading/trailing whitespace
		 * but everything else, e.g. comments and code.
		 */
		range: Range;
3050

Y
Yan Zhang 已提交
3051 3052
		/**
		 * The range that should be selected and revealed when this symbol is being
J
Johannes Rieken 已提交
3053
		 * picked, e.g. the name of a class. Must be contained by the {@link TypeHierarchyItem.range range}-property.
Y
Yan Zhang 已提交
3054 3055 3056
		 */
		selectionRange: Range;

3057 3058 3059 3060 3061 3062 3063 3064 3065 3066
		/**
		 * Creates a new type hierarchy item.
		 *
		 * @param kind The kind of the item.
		 * @param name The name of the item.
		 * @param detail The details of the item.
		 * @param uri The Uri of the item.
		 * @param range The whole range of the item.
		 * @param selectionRange The selection range of the item.
		 */
Y
Yan Zhang 已提交
3067 3068 3069
		constructor(kind: SymbolKind, name: string, detail: string, uri: Uri, range: Range, selectionRange: Range);
	}

3070 3071 3072 3073
	/**
	 * The type hierarchy provider interface describes the contract between extensions
	 * and the type hierarchy feature.
	 */
Y
Yan Zhang 已提交
3074 3075 3076 3077 3078 3079 3080 3081 3082 3083 3084 3085 3086 3087 3088 3089 3090 3091 3092 3093 3094 3095 3096 3097 3098 3099 3100 3101 3102 3103 3104 3105 3106 3107 3108 3109 3110 3111 3112 3113 3114 3115 3116 3117 3118 3119 3120 3121 3122 3123 3124 3125
	export interface TypeHierarchyProvider {

		/**
		 * Bootstraps type hierarchy by returning the item that is denoted by the given document
		 * and position. This item will be used as entry into the type graph. Providers should
		 * return `undefined` or `null` when there is no item at the given location.
		 *
		 * @param document The document in which the command was invoked.
		 * @param position The position at which the command was invoked.
		 * @param token A cancellation token.
		 * @returns A type hierarchy item or a thenable that resolves to such. The lack of a result can be
		 * signaled by returning `undefined` or `null`.
		 */
		prepareTypeHierarchy(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<TypeHierarchyItem[]>;

		/**
		 * Provide all supertypes for an item, e.g all types from which a type is derived/inherited. In graph terms this describes directed
		 * and annotated edges inside the type graph, e.g the given item is the starting node and the result is the nodes
		 * that can be reached.
		 *
		 * @param item The hierarchy item for which super types should be computed.
		 * @param token A cancellation token.
		 * @returns A set of supertypes or a thenable that resolves to such. The lack of a result can be
		 * signaled by returning `undefined` or `null`.
		 */
		provideTypeHierarchySupertypes(item: TypeHierarchyItem, token: CancellationToken): ProviderResult<TypeHierarchyItem[]>;

		/**
		 * Provide all subtypes for an item, e.g all types which are derived/inherited from the given item. In
		 * graph terms this describes directed and annotated edges inside the type graph, e.g the given item is the starting
		 * node and the result is the nodes that can be reached.
		 *
		 * @param item The hierarchy item for which subtypes should be computed.
		 * @param token A cancellation token.
		 * @returns A set of subtypes or a thenable that resolves to such. The lack of a result can be
		 * signaled by returning `undefined` or `null`.
		 */
		provideTypeHierarchySubtypes(item: TypeHierarchyItem, token: CancellationToken): ProviderResult<TypeHierarchyItem[]>;
	}

	export namespace languages {
		/**
		 * Register a type hierarchy provider.
		 *
		 * @param selector A selector that defines the documents this provider is applicable to.
		 * @param provider A type hierarchy provider.
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
		export function registerTypeHierarchyProvider(selector: DocumentSelector, provider: TypeHierarchyProvider): Disposable;
	}
	//#endregion

J
Johannes Rieken 已提交
3126
}