vscode.proposed.d.ts 98.6 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 687 688 689 690 691 692 693 694 695 696 697 698
	// eslint-disable-next-line vscode-dts-region-comments
	//#region @weinand: new debug session option 'managedByParent' (see https://github.com/microsoft/vscode/issues/128058)

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

		/**
		 * Controls whether lifecycle requests like 'restart' are sent to the newly created session or its parent session.
		 * By default (if the property is false or missing), lifecycle requests are sent to the new session.
		 * This property is ignored if the session has no parent session.
		 */
699
		lifecycleManagedByParent?: 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 945 946 947
	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()))
		 * ```
		 */
		items: Map<string, TreeDataTransferItem>;
	}

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

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

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

970
	//#region Custom editor move https://github.com/microsoft/vscode/issues/86146
971

972
	// TODO: Also for custom editor
973

974
	export interface CustomTextEditorProvider {
M
Matt Bierner 已提交
975

976 977 978 979
		/**
		 * 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 已提交
980
		 * the editor will destroy the previous custom editor and create a replacement one.
981 982 983
		 *
		 * @param newDocument New text document to use for the custom editor.
		 * @param existingWebviewPanel Webview panel for the custom editor.
984
		 * @param token A cancellation token that indicates the result is no longer needed.
985 986 987
		 *
		 * @return Thenable indicating that the webview editor has been moved.
		 */
J
Johannes Rieken 已提交
988
		// eslint-disable-next-line vscode-dts-provider-naming
989
		moveCustomTextEditor?(newDocument: TextDocument, existingWebviewPanel: WebviewPanel, token: CancellationToken): Thenable<void>;
990 991 992
	}

	//#endregion
993

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

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

	//#endregion
M
Matt Bierner 已提交
1004

1005 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
	//#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;
	}

1040
	export namespace notebooks {
1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051

		/**
		 * 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

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

1054 1055 1056
	export interface NotebookCellOutput {
		id: string;
	}
1057 1058 1059

	//#endregion

1060 1061
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookEditor

J
Johannes Rieken 已提交
1062 1063 1064
	/**
	 * Represents a notebook editor that is attached to a {@link NotebookDocument notebook}.
	 */
1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087
	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 已提交
1088 1089 1090
	/**
	 * Represents a notebook editor that is attached to a {@link NotebookDocument notebook}.
	 */
1091 1092 1093 1094
	export interface NotebookEditor {
		/**
		 * The document associated with this notebook editor.
		 */
J
Johannes Rieken 已提交
1095
		//todo@api rename to notebook?
1096 1097 1098 1099 1100 1101 1102
		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 }`;
		 */
1103
		selections: NotebookRange[];
1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121

		/**
		 * 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 已提交
1122 1123
	}

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

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

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

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

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

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

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

R
rebornix 已提交
1187

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

1195
	export namespace notebooks {
1196

1197

1198 1199

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

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

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

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

1211 1212 1213 1214 1215 1216 1217
	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>;
1218

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

1223
	//#endregion
1224

1225
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookEditorEdit
1226

1227 1228 1229 1230 1231 1232 1233
	// 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 已提交
1234

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

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

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

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

1256
	export interface NotebookEditor {
1257
		/**
1258
		 * Perform an edit on the notebook associated with this notebook editor.
1259
		 *
1260 1261 1262
		 * 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.
1263
		 *
1264 1265
		 * @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.
1266
		 */
1267 1268
		// @jrieken REMOVE maybe
		edit(callback: (editBuilder: NotebookEditorEdit) => void): Thenable<boolean>;
1269 1270
	}

1271 1272
	//#endregion

J
Johannes Rieken 已提交
1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289
	//#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;
	}

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

	//#endregion

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

1298
	export namespace notebooks {
J
Johannes Rieken 已提交
1299 1300 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
		/**
		 * 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

1331 1332
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookContentProvider

1333

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

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

	interface NotebookDocumentBackupContext {
		readonly destination: Uri;
	}

	interface NotebookDocumentOpenContext {
		readonly backupId?: string;
1357
		readonly untitledDocumentData?: Uint8Array;
1358 1359
	}

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

1364 1365 1366
		readonly options?: NotebookDocumentContentOptions;
		readonly onDidChangeNotebookContentOptions?: Event<NotebookDocumentContentOptions>;

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

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

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

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

1383
	export namespace workspace {
J
Johannes Rieken 已提交
1384

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

1390 1391
	//#endregion

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

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

1400
	export namespace workspace {
J
Johannes Rieken 已提交
1401 1402 1403 1404
		// 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;
1405 1406
	}

1407 1408
	//#endregion

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

1411
	export interface NotebookRendererMessage<T> {
1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422
		/**
		 * Editor that sent the message.
		 */
		editor: NotebookEditor;

		/**
		 * Message sent from the webview.
		 */
		message: T;
	}

1423 1424
	/**
	 * Renderer messaging is used to communicate with a single renderer. It's
C
Connor Peet 已提交
1425
	 * returned from {@link notebooks.createRendererMessaging}.
1426
	 */
1427
	export interface NotebookRendererMessaging<TSend = any, TReceive = TSend> {
1428 1429 1430
		/**
		 * Events that fires when a message is received from a renderer.
		 */
1431
		onDidReceiveMessage: Event<NotebookRendererMessage<TReceive>>;
1432 1433 1434

		/**
		 * Sends a message to the renderer.
1435
		 * @param editor Editor to target with the message
1436 1437
		 * @param message Message to send
		 */
1438
		postMessage(editor: NotebookEditor, message: TSend): void;
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 1465
	/**
	 * 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[]);
	}

1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479 1480 1481 1482 1483 1484 1485 1486 1487 1488 1489 1490 1491 1492
	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;
	}

1493
	export namespace notebooks {
1494

1495
		export function createNotebookController(id: string, viewType: string, label: string, handler?: (cells: NotebookCell[], notebook: NotebookDocument, controller: NotebookController) => void | Thenable<void>, rendererScripts?: NotebookRendererScript[]): NotebookController;
1496

1497 1498 1499
		/**
		 * Creates a new messaging instance used to communicate with a specific
		 * renderer. The renderer only has access to messaging if `requiresMessaging`
C
Connor Peet 已提交
1500
		 * is set to `always` or `optional` in its `notebookRenderer ` contribution.
1501 1502 1503
		 *
		 * @see https://github.com/microsoft/vscode/issues/123601
		 * @param rendererId The renderer ID to communicate with
1504 1505 1506
		*/
		// todo@API can ANY extension talk to renderer or is there a check that the calling extension
		// declared the renderer in its package.json?
1507
		export function createRendererMessaging<TSend = any, TReceive = TSend>(rendererId: string): NotebookRendererMessaging<TSend, TReceive>;
1508 1509 1510 1511
	}

	//#endregion

1512
	//#region @eamodio - timeline: https://github.com/microsoft/vscode/issues/84297
1513 1514 1515

	export class TimelineItem {
		/**
1516
		 * A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred.
1517
		 */
E
Eric Amodio 已提交
1518
		timestamp: number;
1519 1520

		/**
1521
		 * A human-readable string describing the timeline item.
1522 1523 1524 1525
		 */
		label: string;

		/**
1526
		 * Optional id for the timeline item. It must be unique across all the timeline items provided by this source.
1527
		 *
1528
		 * If not provided, an id is generated using the timeline item's timestamp.
1529 1530 1531 1532
		 */
		id?: string;

		/**
M
Matt Bierner 已提交
1533
		 * The icon path or {@link ThemeIcon} for the timeline item.
1534
		 */
R
rebornix 已提交
1535
		iconPath?: Uri | { light: Uri; dark: Uri; } | ThemeIcon;
1536 1537

		/**
1538
		 * A human readable string describing less prominent details of the timeline item.
1539 1540 1541 1542 1543 1544
		 */
		description?: string;

		/**
		 * The tooltip text when you hover over the timeline item.
		 */
1545
		detail?: string;
1546 1547

		/**
M
Matt Bierner 已提交
1548
		 * The {@link Command} that should be executed when the timeline item is selected.
1549 1550 1551 1552
		 */
		command?: Command;

		/**
1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568
		 * 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`.
1569 1570 1571
		 */
		contextValue?: string;

1572 1573 1574 1575 1576
		/**
		 * Accessibility information used when screen reader interacts with this timeline item.
		 */
		accessibilityInformation?: AccessibilityInformation;

1577 1578
		/**
		 * @param label A human-readable string describing the timeline item
E
Eric Amodio 已提交
1579
		 * @param timestamp A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred
1580
		 */
E
Eric Amodio 已提交
1581
		constructor(label: string, timestamp: number);
1582 1583
	}

1584
	export interface TimelineChangeEvent {
E
Eric Amodio 已提交
1585
		/**
M
Matt Bierner 已提交
1586
		 * The {@link Uri} of the resource for which the timeline changed.
E
Eric Amodio 已提交
1587
		 */
E
Eric Amodio 已提交
1588
		uri: Uri;
1589

E
Eric Amodio 已提交
1590
		/**
1591
		 * A flag which indicates whether the entire timeline should be reset.
E
Eric Amodio 已提交
1592
		 */
1593 1594
		reset?: boolean;
	}
E
Eric Amodio 已提交
1595

1596 1597 1598
	export interface Timeline {
		readonly paging?: {
			/**
E
Eric Amodio 已提交
1599
			 * A provider-defined cursor specifying the starting point of timeline items which are after the ones returned.
E
Eric Amodio 已提交
1600
			 * Use `undefined` to signal that there are no more items to be returned.
1601
			 */
E
Eric Amodio 已提交
1602
			readonly cursor: string | undefined;
R
rebornix 已提交
1603
		};
E
Eric Amodio 已提交
1604 1605

		/**
M
Matt Bierner 已提交
1606
		 * An array of {@link TimelineItem timeline items}.
E
Eric Amodio 已提交
1607
		 */
1608
		readonly items: readonly TimelineItem[];
E
Eric Amodio 已提交
1609 1610
	}

1611
	export interface TimelineOptions {
E
Eric Amodio 已提交
1612
		/**
E
Eric Amodio 已提交
1613
		 * A provider-defined cursor specifying the starting point of the timeline items that should be returned.
E
Eric Amodio 已提交
1614
		 */
1615
		cursor?: string;
E
Eric Amodio 已提交
1616 1617

		/**
1618 1619
		 * 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 已提交
1620
		 */
R
rebornix 已提交
1621
		limit?: number | { timestamp: number; id?: string; };
E
Eric Amodio 已提交
1622 1623
	}

1624
	export interface TimelineProvider {
1625
		/**
1626 1627
		 * 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`.
1628
		 */
E
Eric Amodio 已提交
1629
		onDidChange?: Event<TimelineChangeEvent | undefined>;
1630 1631

		/**
1632
		 * An identifier of the source of the timeline items. This can be used to filter sources.
1633
		 */
1634
		readonly id: string;
1635

E
Eric Amodio 已提交
1636
		/**
1637
		 * 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 已提交
1638
		 */
1639
		readonly label: string;
1640 1641

		/**
M
Matt Bierner 已提交
1642
		 * Provide {@link TimelineItem timeline items} for a {@link Uri}.
1643
		 *
M
Matt Bierner 已提交
1644
		 * @param uri The {@link Uri} of the file to provide the timeline for.
1645
		 * @param options A set of options to determine how results should be returned.
1646
		 * @param token A cancellation token.
M
Matt Bierner 已提交
1647
		 * @return The {@link TimelineResult timeline result} or a thenable that resolves to such. The lack of a result
1648 1649
		 * can be signaled by returning `undefined`, `null`, or an empty array.
		 */
1650
		provideTimeline(uri: Uri, options: TimelineOptions, token: CancellationToken): ProviderResult<Timeline>;
1651 1652 1653 1654 1655 1656 1657 1658 1659 1660
	}

	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.
		 *
1661
		 * @param scheme A scheme or schemes that defines which documents this provider is applicable to. Can be `*` to target all documents.
1662
		 * @param provider A timeline provider.
M
Matt Bierner 已提交
1663
		 * @return A {@link Disposable} that unregisters this provider when being disposed.
E
Eric Amodio 已提交
1664
		*/
1665
		export function registerTimelineProvider(scheme: string | string[], provider: TimelineProvider): Disposable;
1666 1667 1668
	}

	//#endregion
1669

1670
	//#region https://github.com/microsoft/vscode/issues/91555
1671

1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684
	export enum StandardTokenType {
		Other = 0,
		Comment = 1,
		String = 2,
		RegEx = 4
	}

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

	export namespace languages {
1685
		export function getTokenInformationAtPosition(document: TextDocument, position: Position): Thenable<TokenInformation>;
K
kingwl 已提交
1686 1687 1688 1689
	}

	//#endregion

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

1692
	// todo@API Split between Inlay- and OverlayHints (InlayHint are for a position, OverlayHints for a non-empty range)
J
Johannes Rieken 已提交
1693
	// todo@API add "mini-markdown" for links and styles
1694 1695 1696
	// (done) remove description
	// (done) rename to InlayHint
	// (done)  add InlayHintKind with type, argument, etc
J
Johannes Rieken 已提交
1697

K
kingwl 已提交
1698
	export namespace languages {
K
kingwl 已提交
1699
		/**
1700
		 * Register a inlay hints provider.
K
kingwl 已提交
1701
		 *
J
Johannes Rieken 已提交
1702 1703 1704
		 * 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 已提交
1705 1706
		 *
		 * @param selector A selector that defines the documents this provider is applicable to.
J
Johannes Rieken 已提交
1707
		 * @param provider An inlay hints provider.
M
Matt Bierner 已提交
1708
		 * @return A {@link Disposable} that unregisters this provider when being disposed.
K
kingwl 已提交
1709
		 */
1710
		export function registerInlayHintsProvider(selector: DocumentSelector, provider: InlayHintsProvider): Disposable;
1711 1712
	}

1713
	export enum InlayHintKind {
1714 1715 1716 1717 1718
		Other = 0,
		Type = 1,
		Parameter = 2,
	}

K
kingwl 已提交
1719
	/**
J
Johannes Rieken 已提交
1720
	 * Inlay hint information.
K
kingwl 已提交
1721
	 */
1722
	export class InlayHint {
K
kingwl 已提交
1723 1724 1725 1726 1727
		/**
		 * The text of the hint.
		 */
		text: string;
		/**
1728
		 * The position of this hint.
K
kingwl 已提交
1729
		 */
1730 1731 1732 1733 1734
		position: Position;
		/**
		 * The kind of this hint.
		 */
		kind?: InlayHintKind;
K
kingwl 已提交
1735 1736 1737 1738 1739 1740 1741 1742 1743
		/**
		 * Whitespace before the hint.
		 */
		whitespaceBefore?: boolean;
		/**
		 * Whitespace after the hint.
		 */
		whitespaceAfter?: boolean;

1744
		// todo@API make range first argument
1745
		constructor(text: string, position: Position, kind?: InlayHintKind);
K
kingwl 已提交
1746 1747 1748
	}

	/**
J
Johannes Rieken 已提交
1749 1750
	 * The inlay hints provider interface defines the contract between extensions and
	 * the inlay hints feature.
K
kingwl 已提交
1751
	 */
1752
	export interface InlayHintsProvider {
W
Wenlu Wang 已提交
1753 1754

		/**
J
Johannes Rieken 已提交
1755
		 * An optional event to signal that inlay hints have changed.
M
Matt Bierner 已提交
1756
		 * @see {@link EventEmitter}
W
Wenlu Wang 已提交
1757
		 */
1758
		onDidChangeInlayHints?: Event<void>;
J
Johannes Rieken 已提交
1759

K
kingwl 已提交
1760
		/**
J
Johannes Rieken 已提交
1761
		 *
K
kingwl 已提交
1762
		 * @param model The document in which the command was invoked.
J
Johannes Rieken 已提交
1763
		 * @param range The range for which inlay hints should be computed.
K
kingwl 已提交
1764
		 * @param token A cancellation token.
J
Johannes Rieken 已提交
1765
		 * @return A list of inlay hints or a thenable that resolves to such.
K
kingwl 已提交
1766
		 */
1767
		provideInlayHints(model: TextDocument, range: Range, token: CancellationToken): ProviderResult<InlayHint[]>;
K
kingwl 已提交
1768
	}
1769
	//#endregion
1770

1771 1772 1773 1774 1775 1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788
	//#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
1789 1790 1791 1792

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

	export interface TextDocument {
1793 1794

		/**
M
Matt Bierner 已提交
1795
		 * The {@link NotebookDocument notebook} that contains this document as a notebook cell or `undefined` when
1796 1797
		 * the document is not contained by a notebook (this should be the more frequent case).
		 */
1798 1799 1800
		notebook: NotebookDocument | undefined;
	}
	//#endregion
C
Connor Peet 已提交
1801 1802 1803

	//#region https://github.com/microsoft/vscode/issues/107467
	export namespace test {
C
Connor Peet 已提交
1804
		/**
1805 1806 1807
		 * Creates a new test controller.
		 *
		 * @param id Identifier for the controller, must be globally unique.
J
Johannes Rieken 已提交
1808
		*/
1809
		export function createTestController(id: string, label: string): TestController;
C
Connor Peet 已提交
1810 1811 1812

		/**
		 * Requests that tests be run by their controller.
1813
		 * @param run Run options to use.
C
Connor Peet 已提交
1814
		 * @param token Cancellation token for the test run
1815
		 * @stability experimental
C
Connor Peet 已提交
1816
		 */
1817
		export function runTests(run: TestRunRequest, token?: CancellationToken): Thenable<void>;
C
Connor Peet 已提交
1818

C
Connor Peet 已提交
1819
		/**
1820
		 * Returns an observer that watches and can request tests.
1821
		 * @stability experimental
C
Connor Peet 已提交
1822
		 */
1823
		export function createTestObserver(): TestObserver;
C
Connor Peet 已提交
1824

C
Connor Peet 已提交
1825 1826 1827 1828 1829 1830 1831 1832 1833 1834
		/**
		 * 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 Unique identifier for the TestItem.
		 * @param label Human-readable label of the test item.
		 * @param uri URI this TestItem is associated with. May be a file or directory.
		 */
		export function createTestItem(id: string, label: string, uri?: Uri): TestItem;

1835
		/**
M
Matt Bierner 已提交
1836
		 * List of test results stored by the editor, sorted in descending
1837 1838 1839
		 * order by their `completedAt` time.
		 * @stability experimental
		 */
C
Connor Peet 已提交
1840
		export const testResults: ReadonlyArray<TestRunResult>;
1841 1842

		/**
1843 1844 1845
		 * Event that fires when the {@link testResults} array is updated.
		 * @stability experimental
		 */
1846
		export const onDidChangeTestResults: Event<void>;
C
Connor Peet 已提交
1847 1848
	}

1849 1850 1851
	/**
	 * @stability experimental
	 */
C
Connor Peet 已提交
1852 1853 1854 1855
	export interface TestObserver {
		/**
		 * List of tests returned by test provider for files in the workspace.
		 */
1856
		readonly tests: ReadonlyArray<TestItem>;
C
Connor Peet 已提交
1857 1858 1859 1860 1861 1862

		/**
		 * 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 已提交
1863
		readonly onDidChangeTest: Event<TestsChangeEvent>;
C
Connor Peet 已提交
1864 1865

		/**
M
Matt Bierner 已提交
1866
		 * Dispose of the observer, allowing the editor to eventually tell test
C
Connor Peet 已提交
1867 1868 1869 1870 1871
		 * providers that they no longer need to update tests.
		 */
		dispose(): void;
	}

1872 1873 1874
	/**
	 * @stability experimental
	 */
C
Connor Peet 已提交
1875
	export interface TestsChangeEvent {
C
Connor Peet 已提交
1876 1877 1878
		/**
		 * List of all tests that are newly added.
		 */
1879
		readonly added: ReadonlyArray<TestItem>;
C
Connor Peet 已提交
1880 1881 1882 1883

		/**
		 * List of existing tests that have updated.
		 */
1884
		readonly updated: ReadonlyArray<TestItem>;
C
Connor Peet 已提交
1885 1886 1887 1888

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

J
Johannes Rieken 已提交
1892
	// Todo@api: this is basically the same as the TaskGroup, which is a class that
1893 1894 1895 1896 1897 1898 1899 1900 1901 1902 1903 1904 1905 1906 1907 1908 1909 1910 1911 1912
	// allows custom groups to be created. However I don't anticipate having any
	// UI for that, so enum for now?
	export enum TestRunConfigurationGroup {
		Run = 1,
		Debug = 2,
		Coverage = 3,
	}

	/**
	 * 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.
	 *
	 * @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.
	 */
J
Johannes Rieken 已提交
1913 1914
	// todo@api We have been there with NotebookCtrl#executeHandler and I believe the recommendation is still not to inline.
	// At least with that we can still do it later
1915 1916 1917 1918 1919 1920 1921 1922 1923 1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947 1948 1949 1950 1951 1952 1953 1954 1955 1956 1957 1958 1959 1960 1961 1962 1963 1964 1965 1966 1967 1968 1969 1970
	export type TestRunHandler = (request: TestRunRequest, token: CancellationToken) => Thenable<void> | void;

	export interface TestRunConfiguration {
		/**
		 * 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;

		/**
		 * Configures where this configuration is grouped in the UI. If there
		 * are no configurations for a group, it will not be available in the UI.
		 */
		readonly group: TestRunConfigurationGroup;

		/**
		 * Controls whether this configuration is the default action that will
		 * be taken when its group is actions. For example, if the user clicks
		 * the generic "run all" button, then the default configuration for
		 * {@link TestRunConfigurationGroup.Run} will be executed.
		 */
		isDefault: boolean;

		/**
		 * If this method is present a configuration gear will be present in the
		 * 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;

		/**
		 * Starts a test run. When called, the controller should call
		 * {@link TestController.createTestRun}. All tasks associated with the
		 * run should be created before the function returns or the reutrned
		 * promise is resolved.
		 *
		 * @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.
		 */
		runHandler: TestRunHandler;

		/**
		 * Deletes the run configuration.
		 */
		dispose(): void;
	}

C
Connor Peet 已提交
1971 1972 1973
	/**
	 * Interface to discover and execute tests.
	 */
J
Johannes Rieken 已提交
1974
	// todo@api maybe some words on this being the "entry point"
1975 1976 1977 1978
	export interface TestController {
		/**
		 * The ID of the controller, passed in {@link vscode.test.createTestController}
		 */
J
Johannes Rieken 已提交
1979
		// todo@api maybe explain what the id is used for and iff it must be globally unique or only unique within the extension
1980
		readonly id: string;
1981

1982 1983 1984 1985 1986
		/**
		 * Human-readable label for the test controller.
		 */
		label: string;

1987
		/**
C
Connor Peet 已提交
1988 1989
		 * Available test items. Tests in the workspace should be added in this
		 * collection. The extension controls when to add these, although the
1990 1991 1992 1993
		 * 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 已提交
1994
		 *
1995
		 * Tests in this collection should be watched and updated by the extension
J
Johannes Rieken 已提交
1996
		 * as files change. See {@link resolveChildrenHandler} for details around
1997
		 * for the lifecycle of watches.
C
Connor Peet 已提交
1998
		 */
C
Connor Peet 已提交
1999
		readonly items: TestItemCollection;
C
Connor Peet 已提交
2000

2001 2002 2003 2004 2005 2006 2007 2008 2009 2010
		/**
		 * Creates a configuration used for running tests. Extensions must create
		 * at least one configuration in order for tests to be run.
		 * @param label Human-readable label for this configuration
		 * @param group Configures where this configuration is grouped in the UI.
		 * @param runHandler Function called to start a test run
		 * @param isDefault Whether this is the default action for the group
		 */
		createRunConfiguration(label: string, group: TestRunConfigurationGroup, runHandler: TestRunHandler, isDefault?: boolean): TestRunConfiguration;

2011 2012
		/**
		 * A function provided by the extension that the editor may call to request
2013 2014
		 * children of a test item, if the {@link TestItem.canExpand} is `true`.
		 * When called, the item should discover children and call
C
Connor Peet 已提交
2015
		 * {@link vscode.test.createTestItem} as children are discovered.
C
Connor Peet 已提交
2016
		 *
2017 2018
		 * The item in the explorer will automatically be marked as "busy" until
		 * the function returns or the returned thenable resolves.
C
Connor Peet 已提交
2019
		 *
2020 2021
		 * The controller may wish to set up listeners or watchers to update the
		 * children as files and documents change.
C
Connor Peet 已提交
2022
		 *
2023 2024
		 * @param item An unresolved test item for which
		 * children are being requested
C
Connor Peet 已提交
2025
		 */
J
Johannes Rieken 已提交
2026
		// todo@API maybe just `resolveHandler` so that we could extends its usage in the future?
2027
		resolveChildrenHandler?: (item: TestItem) => Thenable<void> | void;
C
Connor Peet 已提交
2028

2029 2030 2031 2032 2033 2034 2035
		/**
		 * 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
		 * {@link TestResultState.Pending} state.
		 *
2036 2037 2038 2039
		 * 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.
		 *
2040 2041 2042 2043 2044 2045 2046 2047 2048
		 * @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.
		 */
2049
		createTestRun(request: TestRunRequest, name?: string, persist?: boolean): TestRun;
2050 2051 2052 2053 2054 2055

		/**
		 * Unregisters the test controller, disposing of its associated tests
		 * and unpersisted results.
		 */
		dispose(): void;
C
Connor Peet 已提交
2056 2057 2058 2059 2060
	}

	/**
	 * Options given to {@link test.runTests}.
	 */
2061
	export class TestRunRequest {
C
Connor Peet 已提交
2062
		/**
C
Connor Peet 已提交
2063 2064 2065 2066
		 * 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 已提交
2067
		 */
C
Connor Peet 已提交
2068
		include?: TestItem[];
C
Connor Peet 已提交
2069 2070

		/**
M
Matt Bierner 已提交
2071
		 * An array of tests the user has marked as excluded in the editor. May be
C
Connor Peet 已提交
2072 2073 2074
		 * omitted if no exclusions were requested. Test controllers should not run
		 * excluded tests or any children of excluded tests.
		 */
2075
		exclude?: TestItem[];
C
Connor Peet 已提交
2076 2077

		/**
2078 2079 2080
		 * The configuration used for this request. This will always be defined
		 * for requests issued from the editor UI, though extensions may
		 * programmatically create requests not associated with any configuration.
C
Connor Peet 已提交
2081
		 */
2082
		configuration?: TestRunConfiguration;
2083 2084

		/**
C
Connor Peet 已提交
2085
		 * @param tests Array of specific tests to run, or undefined to run all tests
2086
		 * @param exclude Tests to exclude from the run
2087
		 * @param configuration The run configuration used for this request.
2088
		 */
C
Connor Peet 已提交
2089
		constructor(include?: readonly TestItem[], exclude?: readonly TestItem[], configuration?: TestRunConfiguration);
C
Connor Peet 已提交
2090 2091 2092 2093 2094
	}

	/**
	 * Options given to {@link TestController.runTests}
	 */
2095
	export interface TestRun {
C
Connor Peet 已提交
2096 2097 2098 2099 2100 2101 2102
		/**
		 * 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;

2103 2104 2105 2106 2107 2108
		/**
		 * A cancellation token which will be triggered when the test run is
		 * canceled from the UI.
		 */
		readonly token: CancellationToken;

C
Connor Peet 已提交
2109 2110 2111 2112 2113 2114 2115
		/**
		 * 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.
		 *
		 * @param test The test to update
		 * @param state The state to assign to the test
2116
		 * @param duration Optionally sets how long the test took to run, in milliseconds
C
Connor Peet 已提交
2117
		 */
2118
		//todo@API is this "update" state or set final state? should this be called setTestResult?
2119
		setState(test: TestItem, state: TestResultState, duration?: number): void;
C
Connor Peet 已提交
2120 2121 2122 2123 2124 2125 2126 2127

		/**
		 * 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
2128
		 * @param message The message to add
C
Connor Peet 已提交
2129
		 */
2130
		appendMessage(test: TestItem, message: TestMessage): void;
C
Connor Peet 已提交
2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145

		/**
		 * 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
		 * @param associateTo Optionally, associate the given segment of output
		 */
		appendOutput(output: string): void;

		/**
		 * Signals that the end of the test run. Any tests whose states have not
		 * been updated will be moved into the {@link TestResultState.Unset} state.
		 */
J
Johannes Rieken 已提交
2146
		// todo@api is the Unset logic smart and only considering those tests that are included?
C
Connor Peet 已提交
2147 2148 2149
		end(): void;
	}

C
Connor Peet 已提交
2150 2151 2152 2153 2154 2155 2156 2157 2158
	/**
	 * Collection of test items, found in {@link TestItem.children} and
	 * {@link TestController.items}.
	 */
	export interface TestItemCollection {
		/**
		 * A read-only array of all the test items children. Can be retrieved, or
		 * set in order to replace children in the collection.
		 */
J
Johannes Rieken 已提交
2159
		// todo@API unsure if this should readonly and have a separate replaceAll-like function
C
Connor Peet 已提交
2160 2161 2162 2163 2164 2165 2166 2167 2168 2169 2170
		all: readonly TestItem[];

		/**
		 * Adds the test item to the children. If an item with the same ID already
		 * exists, it'll be replaced.
		 */
		add(item: TestItem): void;

		/**
		 * Removes the a single test item from the collection.
		 */
J
Johannes Rieken 已提交
2171
		//todo@API `delete` as Map, EnvironmentVariableCollection, DiagnosticCollection
C
Connor Peet 已提交
2172 2173 2174 2175 2176 2177 2178 2179
		remove(itemId: string): void;

		/**
		 * Efficiently gets a test item by ID, if it exists, in the children.
		 */
		get(itemId: string): TestItem | undefined;
	}

C
Connor Peet 已提交
2180 2181 2182 2183
	/**
	 * 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.
	 */
2184
	export interface TestItem {
C
Connor Peet 已提交
2185 2186 2187 2188 2189
		/**
		 * Unique identifier for the TestItem. This is used to correlate
		 * test results and tests in the document with those in the workspace
		 * (test explorer). This must not change for the lifetime of the TestItem.
		 */
J
Johannes Rieken 已提交
2190
		// todo@API globally vs extension vs controller unique. I would strongly recommend non-global
C
Connor Peet 已提交
2191 2192 2193 2194 2195 2196 2197 2198 2199 2200
		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 已提交
2201
		readonly children: TestItemCollection;
C
Connor Peet 已提交
2202 2203

		/**
C
Connor Peet 已提交
2204 2205 2206
		 * The parent of this item, given in {@link vscode.test.createTestItem}.
		 * This is undefined top-level items in the `TestController`, and for
		 * items that aren't yet assigned to a parent.
C
Connor Peet 已提交
2207
		 */
J
Johannes Rieken 已提交
2208
		// todo@api obsolete? doc is outdated at least
2209
		readonly parent?: TestItem;
C
Connor Peet 已提交
2210 2211

		/**
2212 2213 2214 2215
		 * Indicates whether this test item may have children discovered by resolving.
		 * If so, it will be shown as expandable in the Test Explorer  view, and
		 * expanding the item will cause {@link TestController.resolveChildrenHandler}
		 * to be invoked with the item.
C
Connor Peet 已提交
2216
		 *
2217 2218 2219 2220 2221 2222 2223 2224
		 * Default to false.
		 */
		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 已提交
2225
		 */
2226
		busy: boolean;
C
Connor Peet 已提交
2227 2228 2229 2230 2231 2232 2233 2234 2235 2236 2237 2238 2239 2240 2241 2242 2243 2244 2245 2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258

		/**
		 * 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 已提交
2259
		// todo@api still unsure about this
2260
		invalidateResults(): void;
C
Connor Peet 已提交
2261 2262 2263 2264 2265 2266 2267 2268 2269 2270 2271 2272 2273 2274 2275 2276 2277 2278 2279
	}

	/**
	 * Possible states of tests in a test run.
	 */
	export enum TestResultState {
		// Initial state
		Unset = 0,
		// 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)
J
Johannes Rieken 已提交
2280
		// todo@api could I just use `Skipped` and TestItem#error?
C
Connor Peet 已提交
2281 2282 2283 2284 2285 2286 2287 2288 2289 2290 2291 2292 2293 2294 2295 2296 2297 2298 2299 2300 2301 2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 2333 2334 2335 2336 2337 2338
		Errored = 6
	}

	/**
	 * Represents the severity of test messages.
	 */
	export enum TestMessageSeverity {
		Error = 0,
		Warning = 1,
		Information = 2,
		Hint = 3
	}

	/**
	 * 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;

		/**
		 * Message severity. Defaults to "Error".
		 */
		severity: TestMessageSeverity;

		/**
		 * 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);
	}

2339
	/**
M
Matt Bierner 已提交
2340
	 * TestResults can be provided to the editor in {@link test.publishTestResult},
C
Connor Peet 已提交
2341
	 * or read from it in {@link test.testResults}.
2342 2343
	 *
	 * The results contain a 'snapshot' of the tests at the point when the test
C
Connor Peet 已提交
2344 2345 2346
	 * 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.
2347
	 *
2348
	 * @todo coverage and other info may eventually be provided here
2349
	 */
C
Connor Peet 已提交
2350
	export interface TestRunResult {
2351
		/**
C
Connor Peet 已提交
2352
		 * Unix milliseconds timestamp at which the test run was completed.
2353 2354 2355
		 */
		completedAt: number;

2356 2357 2358 2359 2360
		/**
		 * Optional raw output from the test run.
		 */
		output?: string;

2361 2362 2363 2364
		/**
		 * List of test results. The items in this array are the items that
		 * were passed in the {@link test.runTests} method.
		 */
2365
		results: ReadonlyArray<Readonly<TestResultSnapshot>>;
2366 2367 2368
	}

	/**
2369 2370
	 * A {@link TestItem}-like interface with an associated result, which appear
	 * or can be provided in {@link TestResult} interfaces.
2371
	 */
2372 2373 2374 2375 2376 2377 2378 2379
	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;

2380 2381 2382
		/**
		 * URI this TestItem is associated with. May be a file or file.
		 */
C
Connor Peet 已提交
2383
		readonly uri?: Uri;
2384

2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395
		/**
		 * Display name describing the test case.
		 */
		readonly label: string;

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

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

2401
		/**
2402 2403
		 * 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.
2404
		 */
2405
		readonly taskStates: ReadonlyArray<TestSnapshoptTaskState>;
2406 2407 2408 2409

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

2413
	export interface TestSnapshoptTaskState {
2414 2415 2416
		/**
		 * Current result of the test.
		 */
C
Connor Peet 已提交
2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429
		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>;
2430 2431
	}

C
Connor Peet 已提交
2432
	//#endregion
2433 2434 2435

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

2436 2437 2438
	/**
	 * Details if an `ExternalUriOpener` can open a uri.
	 *
2439 2440 2441 2442
	 * 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 已提交
2443
	 * The editor will try to use the best available opener, as sorted by `ExternalUriOpenerPriority`.
2444 2445
	 * If there are multiple potential "best" openers for a URI, then the user will be prompted
	 * to select an opener.
2446
	 */
M
Matt Bierner 已提交
2447
	export enum ExternalUriOpenerPriority {
2448
		/**
2449
		 * The opener is disabled and will never be shown to users.
M
Matt Bierner 已提交
2450
		 *
2451 2452
		 * Note that the opener can still be used if the user specifically
		 * configures it in their settings.
2453
		 */
M
Matt Bierner 已提交
2454
		None = 0,
2455 2456

		/**
2457
		 * The opener can open the uri but will not cause a prompt on its own
M
Matt Bierner 已提交
2458
		 * since the editor always contributes a built-in `Default` opener.
2459
		 */
M
Matt Bierner 已提交
2460
		Option = 1,
2461 2462

		/**
M
Matt Bierner 已提交
2463 2464
		 * The opener can open the uri.
		 *
M
Matt Bierner 已提交
2465
		 * The editor's built-in opener has `Default` priority. This means that any additional `Default`
2466
		 * openers will cause the user to be prompted to select from a list of all potential openers.
2467
		 */
M
Matt Bierner 已提交
2468 2469 2470
		Default = 2,

		/**
2471
		 * The opener can open the uri and should be automatically selected over any
M
Matt Bierner 已提交
2472
		 * default openers, include the built-in one from the editor.
M
Matt Bierner 已提交
2473
		 *
2474
		 * A preferred opener will be automatically selected if no other preferred openers
2475
		 * are available. If multiple preferred openers are available, then the user
2476
		 * is shown a prompt with all potential openers (not just preferred openers).
M
Matt Bierner 已提交
2477 2478
		 */
		Preferred = 3,
2479 2480
	}

2481
	/**
M
Matt Bierner 已提交
2482
	 * Handles opening uris to external resources, such as http(s) links.
2483
	 *
M
Matt Bierner 已提交
2484
	 * Extensions can implement an `ExternalUriOpener` to open `http` links to a webserver
M
Matt Bierner 已提交
2485
	 * inside of the editor instead of having the link be opened by the web browser.
2486 2487 2488 2489 2490 2491
	 *
	 * Currently openers may only be registered for `http` and `https` uris.
	 */
	export interface ExternalUriOpener {

		/**
2492
		 * Check if the opener can open a uri.
2493
		 *
M
Matt Bierner 已提交
2494 2495 2496
		 * @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.
2497
		 *
2498
		 * @return Priority indicating if the opener can open the external uri.
M
Matt Bierner 已提交
2499
		 */
M
Matt Bierner 已提交
2500
		canOpenExternalUri(uri: Uri, token: CancellationToken): ExternalUriOpenerPriority | Thenable<ExternalUriOpenerPriority>;
M
Matt Bierner 已提交
2501 2502

		/**
2503
		 * Open a uri.
2504
		 *
M
Matt Bierner 已提交
2505
		 * This is invoked when:
2506
		 *
M
Matt Bierner 已提交
2507 2508 2509
		 * - 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.
2510
		 *
M
Matt Bierner 已提交
2511 2512 2513 2514 2515 2516
		 * @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.
		 *
2517
		 * @return Thenable indicating that the opening has completed.
M
Matt Bierner 已提交
2518 2519 2520 2521 2522 2523 2524 2525 2526 2527
		 */
		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.
2528
		 *
2529
		 * This is the original uri that the user clicked on or that was passed to `openExternal.`
M
Matt Bierner 已提交
2530
		 * Due to port forwarding, this may not match the `resolvedUri` passed to `openExternalUri`.
2531
		 */
M
Matt Bierner 已提交
2532 2533 2534
		readonly sourceUri: Uri;
	}

M
Matt Bierner 已提交
2535
	/**
2536
	 * Additional metadata about a registered `ExternalUriOpener`.
M
Matt Bierner 已提交
2537
	 */
M
Matt Bierner 已提交
2538
	interface ExternalUriOpenerMetadata {
M
Matt Bierner 已提交
2539

M
Matt Bierner 已提交
2540 2541 2542 2543 2544 2545 2546
		/**
		 * List of uri schemes the opener is triggered for.
		 *
		 * Currently only `http` and `https` are supported.
		 */
		readonly schemes: readonly string[]

M
Matt Bierner 已提交
2547 2548
		/**
		 * Text displayed to the user that explains what the opener does.
2549
		 *
M
Matt Bierner 已提交
2550
		 * For example, 'Open in browser preview'
2551
		 */
M
Matt Bierner 已提交
2552
		readonly label: string;
2553 2554 2555 2556 2557 2558
	}

	namespace window {
		/**
		 * Register a new `ExternalUriOpener`.
		 *
2559
		 * When a uri is about to be opened, an `onOpenExternalUri:SCHEME` activation event is fired.
2560
		 *
M
Matt Bierner 已提交
2561 2562
		 * @param id Unique id of the opener, such as `myExtension.browserPreview`. This is used in settings
		 *   and commands to identify the opener.
2563
		 * @param opener Opener to register.
M
Matt Bierner 已提交
2564
		 * @param metadata Additional information about the opener.
2565 2566
		 *
		* @returns Disposable that unregisters the opener.
M
Matt Bierner 已提交
2567 2568
		*/
		export function registerExternalUriOpener(id: string, opener: ExternalUriOpener, metadata: ExternalUriOpenerMetadata): Disposable;
2569 2570
	}

2571 2572
	interface OpenExternalOptions {
		/**
2573 2574
		 * Allows using openers contributed by extensions through  `registerExternalUriOpener`
		 * when opening the resource.
2575
		 *
M
Matt Bierner 已提交
2576
		 * If `true`, the editor will check if any contributed openers can handle the
2577 2578
		 * uri, and fallback to the default opener behavior.
		 *
2579
		 * If it is string, this specifies the id of the `ExternalUriOpener`
M
Matt Bierner 已提交
2580
		 * that should be used if it is available. Use `'default'` to force the editor's
2581 2582 2583 2584 2585 2586 2587 2588 2589
		 * standard external opener to be used.
		 */
		readonly allowContributedOpeners?: boolean | string;
	}

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

J
Johannes Rieken 已提交
2590
	//#endregion
2591 2592 2593 2594 2595 2596 2597

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

	// TODO@API must be a class
	export interface OpenEditorInfo {
		name: string;
		resource: Uri;
2598
		isActive: boolean;
2599 2600 2601 2602 2603 2604 2605 2606 2607 2608
	}

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

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

	//#endregion
2609

2610
	//#region https://github.com/microsoft/vscode/issues/120173
L
Ladislau Szomoru 已提交
2611 2612 2613
	/**
	 * The object describing the properties of the workspace trust request
	 */
2614
	export interface WorkspaceTrustRequestOptions {
L
Ladislau Szomoru 已提交
2615
		/**
2616 2617 2618
		 * 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 已提交
2619
		 */
2620
		readonly message?: string;
L
Ladislau Szomoru 已提交
2621 2622
	}

2623 2624 2625
	export namespace workspace {
		/**
		 * Prompt the user to chose whether to trust the current workspace
2626
		 * @param options Optional object describing the properties of the
2627
		 * workspace trust request.
2628
		 */
2629
		export function requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Thenable<boolean | undefined>;
2630 2631
	}

2632
	//#endregion
2633 2634 2635 2636 2637 2638 2639

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

A
Alex Ross 已提交
2644 2645 2646 2647
	export class PortAttributes {
		/**
		 * The port number associated with this this set of attributes.
		 */
2648
		port: number;
A
Alex Ross 已提交
2649 2650 2651 2652 2653 2654 2655 2656 2657 2658 2659 2660

		/**
		 * 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);
2661 2662 2663
	}

	export interface PortAttributesProvider {
2664
		/**
2665 2666 2667
		 * 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.
2668
		 */
2669
		providePortAttributes(port: number, pid: number | undefined, commandLine: string | undefined, token: CancellationToken): ProviderResult<PortAttributes>;
2670 2671 2672 2673 2674 2675
	}

	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 已提交
2676
		 * this information with a PortAttributesProvider the extension can tell the editor that these ports should be
2677 2678 2679
		 * 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
2680 2681
		 * 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.
2682
		 * The `portRange` is start inclusive and end exclusive.
2683 2684
		 * @param provider The PortAttributesProvider
		 */
2685
		export function registerPortAttributesProvider(portSelector: { pid?: number, portRange?: [number, number], commandMatcher?: RegExp }, provider: PortAttributesProvider): Disposable;
2686 2687
	}
	//#endregion
2688

J
Johannes Rieken 已提交
2689
	//#region https://github.com/microsoft/vscode/issues/119904 @eamodio
2690 2691 2692 2693 2694 2695 2696 2697 2698 2699

	export interface SourceControlInputBox {

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

	//#endregion
2700

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

2703
	export namespace languages {
2704 2705 2706
		/**
		 * Registers an inline completion provider.
		 */
2707
		export function registerInlineCompletionItemProvider(selector: DocumentSelector, provider: InlineCompletionItemProvider): Disposable;
A
Alex Dima 已提交
2708 2709
	}

2710
	export interface InlineCompletionItemProvider<T extends InlineCompletionItem = InlineCompletionItem> {
2711 2712 2713 2714 2715 2716
		/**
		 * 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.
		*/
2717
		provideInlineCompletionItems(document: TextDocument, position: Position, context: InlineCompletionContext, token: CancellationToken): ProviderResult<InlineCompletionList<T> | T[]>;
2718
	}
H
wip  
Henning Dieterichs 已提交
2719

2720 2721 2722 2723 2724
	export interface InlineCompletionContext {
		/**
		 * How the completion was triggered.
		 */
		readonly triggerKind: InlineCompletionTriggerKind;
H
wip  
Henning Dieterichs 已提交
2725 2726
	}

2727 2728 2729 2730 2731 2732 2733 2734 2735 2736
	/**
	 * 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 已提交
2737
		/**
2738 2739 2740 2741 2742
		 * Completion was triggered explicitly by a user gesture.
		 * Return multiple completion items to enable cycling through them.
		 */
		Explicit = 1,
	}
2743 2744 2745 2746 2747 2748 2749 2750

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

		constructor(items: T[]);
	}

	export class InlineCompletionItem {
2751
		/**
2752 2753 2754 2755 2756 2757 2758 2759 2760
		 * 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.
2761 2762 2763 2764
		 *
		 * 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.
2765 2766 2767 2768 2769
		*/
		range?: Range;

		/**
		 * An optional {@link Command} that is executed *after* inserting this completion.
2770
		 */
2771 2772 2773
		command?: Command;

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

2776 2777 2778 2779 2780 2781

	/**
	 * 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 已提交
2782 2783
	}

2784 2785 2786 2787
	/**
	 * Be aware that this API will not ever be finalized.
	 */
	export interface InlineCompletionController<T extends InlineCompletionItem> {
2788 2789 2790
		/**
		 * Is fired when an inline completion item is shown to the user.
		 */
2791 2792 2793 2794 2795 2796 2797 2798 2799
		// 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 已提交
2800 2801 2802 2803
	}

	//#endregion

2804 2805 2806 2807 2808
	//#region FileSystemProvider stat readonly - https://github.com/microsoft/vscode/issues/73122

	export enum FilePermission {
		/**
		 * The file is readonly.
2809 2810 2811 2812 2813
		 *
		 * *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.
2814 2815 2816 2817 2818 2819 2820 2821 2822 2823 2824 2825 2826 2827 2828 2829 2830 2831
		 */
		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
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
	//#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
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 3012 3013 3014 3015 3016 3017 3018 3019 3020 3021 3022 3023 3024 3025 3026 3027 3028 3029 3030 3031 3032 3033 3034 3035 3036 3037 3038 3039 3040 3041 3042 3043 3044 3045 3046 3047 3048 3049 3050

	//#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 已提交
3051 3052


3053
	//#region https://github.com/microsoft/vscode/issues/15533 --- Type hierarchy --- @eskibear
Y
Yan Zhang 已提交
3054 3055 3056 3057 3058 3059 3060 3061 3062 3063 3064 3065 3066 3067 3068 3069 3070 3071 3072 3073 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 3126 3127 3128 3129 3130 3131 3132 3133 3134 3135 3136 3137 3138 3139 3140 3141
	export class TypeHierarchyItem {
		/**
		 * The name of this item.
		 */
		name: string;
		/**
		 * The kind of this item.
		 */
		kind: SymbolKind;
		/**
		 * Tags for this item.
		 */
		tags?: ReadonlyArray<SymbolTag>;
		/**
		 * More detail for this item, e.g. the signature of a function.
		 */
		detail?: string;
		/**
		 * The resource identifier of this item.
		 */
		uri: Uri;
		/**
		 * The range enclosing this symbol not including leading/trailing whitespace
		 * but everything else, e.g. comments and code.
		 */
		range: Range;
		/**
		 * The range that should be selected and revealed when this symbol is being
		 * picked, e.g. the name of a function. Must be contained by the
		 * [`range`](#TypeHierarchyItem.range).
		 */
		selectionRange: Range;

		constructor(kind: SymbolKind, name: string, detail: string, uri: Uri, range: Range, selectionRange: Range);
	}

	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 已提交
3142
}