vscode.proposed.d.ts 93.2 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 12 13 14 15
/**
 * 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:
 * - Use Insiders release of VS Code.
 * - Add `"enableProposedApi": true` to your package.json.
 * - Copy this file to your project.
 */
16

17 18
declare module 'vscode' {

19
	//#region auth provider: https://github.com/microsoft/vscode/issues/88309
J
Johannes Rieken 已提交
20

21 22 23 24 25 26 27
	/**
	 * An [event](#Event) which fires when an [AuthenticationProvider](#AuthenticationProvider) is added or removed.
	 */
	export interface AuthenticationProvidersChangeEvent {
		/**
		 * The ids of the [authenticationProvider](#AuthenticationProvider)s that have been added.
		 */
28
		readonly added: ReadonlyArray<AuthenticationProviderInformation>;
29 30

		/**
31
		 * The ids of the [authenticationProvider](#AuthenticationProvider)s that have been removed.
32
		 */
33
		readonly removed: ReadonlyArray<AuthenticationProviderInformation>;
34 35
	}

36
	export namespace authentication {
37
		/**
38
		 * @deprecated - getSession should now trigger extension activation.
39 40
		 * Fires with the provider id that was registered or unregistered.
		 */
41
		export const onDidChangeAuthenticationProviders: Event<AuthenticationProvidersChangeEvent>;
42

43
		/**
44
		 * @deprecated
45 46 47
		 * An array of the information of authentication providers that are currently registered.
		 */
		export const providers: ReadonlyArray<AuthenticationProviderInformation>;
48

49
		/**
50 51 52 53 54 55
		 * @deprecated
		 * Logout of a specific session.
		 * @param providerId The id of the provider to use
		 * @param sessionId The session id to remove
		 * provider
		 */
56
		export function logout(providerId: string, sessionId: string): Thenable<void>;
57 58
	}

J
Johannes Rieken 已提交
59 60
	//#endregion

61
	// eslint-disable-next-line vscode-dts-region-comments
A
Alex Ross 已提交
62
	//#region @alexdima - resolvers
A
Alex Dima 已提交
63

64 65 66 67 68 69 70
	export interface MessageOptions {
		/**
		 * Do not render a native message box.
		 */
		useCustom?: boolean;
	}

A
Tweaks  
Alex Dima 已提交
71 72 73 74
	export interface RemoteAuthorityResolverContext {
		resolveAttempt: number;
	}

A
Alex Dima 已提交
75 76 77
	export class ResolvedAuthority {
		readonly host: string;
		readonly port: number;
78
		readonly connectionToken: string | undefined;
A
Alex Dima 已提交
79

80
		constructor(host: string, port: number, connectionToken?: string);
A
Alex Dima 已提交
81 82
	}

83
	export interface ResolvedOptions {
R
rebornix 已提交
84
		extensionHostEnv?: { [key: string]: string | null; };
85 86
	}

87
	export interface TunnelOptions {
R
rebornix 已提交
88
		remoteAddress: { port: number, host: string; };
A
Alex Ross 已提交
89 90 91
		// The desired local port. If this port can't be used, then another will be chosen.
		localAddressPort?: number;
		label?: string;
92
		public?: boolean;
93 94
	}

A
Alex Ross 已提交
95
	export interface TunnelDescription {
R
rebornix 已提交
96
		remoteAddress: { port: number, host: string; };
A
Alex Ross 已提交
97
		//The complete local address(ex. localhost:1234)
R
rebornix 已提交
98
		localAddress: { port: number, host: string; } | string;
99
		public?: boolean;
A
Alex Ross 已提交
100 101 102
	}

	export interface Tunnel extends TunnelDescription {
A
Alex Ross 已提交
103 104
		// Implementers of Tunnel should fire onDidDispose when dispose is called.
		onDidDispose: Event<void>;
105
		dispose(): void | Thenable<void>;
106 107 108
	}

	/**
109 110
	 * Used as part of the ResolverResult if the extension has any candidate,
	 * published, or forwarded ports.
111 112 113 114
	 */
	export interface TunnelInformation {
		/**
		 * Tunnels that are detected by the extension. The remotePort is used for display purposes.
A
Alex Ross 已提交
115
		 * The localAddress should be the complete local address (ex. localhost:1234) for connecting to the port. Tunnels provided through
116 117
		 * detected are read-only from the forwarded ports UI.
		 */
A
Alex Ross 已提交
118
		environmentTunnels?: TunnelDescription[];
A
Alex Ross 已提交
119

120 121
	}

122
	export interface TunnelCreationOptions {
123 124 125 126 127 128
		/**
		 * True when the local operating system will require elevation to use the requested local port.
		 */
		elevationRequired?: boolean;
	}

129 130 131 132 133 134
	export enum CandidatePortSource {
		None = 0,
		Process = 1,
		Output = 2
	}

135
	export type ResolverResult = ResolvedAuthority & ResolvedOptions & TunnelInformation;
136

A
Tweaks  
Alex Dima 已提交
137 138 139 140 141 142 143
	export class RemoteAuthorityResolverError extends Error {
		static NotAvailable(message?: string, handled?: boolean): RemoteAuthorityResolverError;
		static TemporarilyNotAvailable(message?: string): RemoteAuthorityResolverError;

		constructor(message?: string);
	}

A
Alex Dima 已提交
144
	export interface RemoteAuthorityResolver {
145
		resolve(authority: string, context: RemoteAuthorityResolverContext): ResolverResult | Thenable<ResolverResult>;
146 147 148 149
		/**
		 * 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.
150 151 152
		 *
		 * 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.
153
		 */
154
		tunnelFactory?: (tunnelOptions: TunnelOptions, tunnelCreationOptions: TunnelCreationOptions) => Thenable<Tunnel> | undefined;
155

156
		/**p
157 158 159
		 * Provides filtering for candidate ports.
		 */
		showCandidatePort?: (host: string, port: number, detail: string) => Thenable<boolean>;
160 161 162 163 164 165 166

		/**
		 * Lets the resolver declare which tunnel factory features it supports.
		 * UNDER DISCUSSION! MAY CHANGE SOON.
		 */
		tunnelFeatures?: {
			elevation: boolean;
167
			public: boolean;
168
		};
169 170

		candidatePortSource?: CandidatePortSource;
171 172 173 174
	}

	export namespace workspace {
		/**
175
		 * Forwards a port. If the current resolver implements RemoteAuthorityResolver:forwardPort then that will be used to make the tunnel.
A
Alex Ross 已提交
176
		 * By default, openTunnel only support localhost; however, RemoteAuthorityResolver:tunnelFactory can be used to support other ips.
177 178 179
		 *
		 * @throws When run in an environment without a remote.
		 *
A
Alex Ross 已提交
180
		 * @param tunnelOptions The `localPort` is a suggestion only. If that port is not available another will be chosen.
181
		 */
A
Alex Ross 已提交
182
		export function openTunnel(tunnelOptions: TunnelOptions): Thenable<Tunnel>;
183 184 185 186 187 188

		/**
		 * 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 已提交
189

190 191 192 193
		/**
		 * Fired when the list of tunnels has changed.
		 */
		export const onDidChangeTunnels: Event<void>;
A
Alex Dima 已提交
194 195
	}

196 197 198 199 200 201 202 203
	export interface ResourceLabelFormatter {
		scheme: string;
		authority?: string;
		formatting: ResourceLabelFormatting;
	}

	export interface ResourceLabelFormatting {
		label: string; // myLabel:/${path}
I
isidor 已提交
204
		// 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 已提交
205
		// eslint-disable-next-line vscode-dts-literal-or-types
206 207 208 209 210
		separator: '/' | '\\' | '';
		tildify?: boolean;
		normalizeDriveLetter?: boolean;
		workspaceSuffix?: string;
		authorityPrefix?: string;
211
		stripPathStartingSeparator?: boolean;
212 213
	}

A
Alex Dima 已提交
214 215
	export namespace workspace {
		export function registerRemoteAuthorityResolver(authorityPrefix: string, resolver: RemoteAuthorityResolver): Disposable;
216
		export function registerResourceLabelFormatter(formatter: ResourceLabelFormatter): Disposable;
217
	}
218

219 220
	//#endregion

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

223 224
	export interface WebviewEditorInset {
		readonly editor: TextEditor;
225 226
		readonly line: number;
		readonly height: number;
227 228 229
		readonly webview: Webview;
		readonly onDidDispose: Event<void>;
		dispose(): void;
230 231
	}

232
	export namespace window {
233
		export function createWebviewTextEditorInset(editor: TextEditor, line: number, height: number, options?: WebviewOptions): WebviewEditorInset;
A
Alex Dima 已提交
234 235 236 237
	}

	//#endregion

J
Johannes Rieken 已提交
238
	//#region read/write in chunks: https://github.com/microsoft/vscode/issues/84515
239 240

	export interface FileSystemProvider {
R
rebornix 已提交
241
		open?(resource: Uri, options: { create: boolean; }): number | Thenable<number>;
242 243 244 245 246 247 248
		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 已提交
249
	//#region TextSearchProvider: https://github.com/microsoft/vscode/issues/59921
250

251 252 253
	/**
	 * The parameters of a query for text search.
	 */
254
	export interface TextSearchQuery {
255 256 257
		/**
		 * The text pattern to search for.
		 */
258
		pattern: string;
259

R
Rob Lourens 已提交
260 261 262 263 264
		/**
		 * Whether or not `pattern` should match multiple lines of text.
		 */
		isMultiline?: boolean;

265 266 267
		/**
		 * Whether or not `pattern` should be interpreted as a regular expression.
		 */
R
Rob Lourens 已提交
268
		isRegExp?: boolean;
269 270 271 272

		/**
		 * Whether or not the search should be case-sensitive.
		 */
R
Rob Lourens 已提交
273
		isCaseSensitive?: boolean;
274 275 276 277

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

281 282
	/**
	 * A file glob pattern to match file paths against.
283
	 * TODO@roblourens merge this with the GlobPattern docs/definition in vscode.d.ts.
284 285 286 287 288 289 290
	 * @see [GlobPattern](#GlobPattern)
	 */
	export type GlobString = string;

	/**
	 * Options common to file and text search
	 */
R
Rob Lourens 已提交
291
	export interface SearchOptions {
292 293 294
		/**
		 * The root folder to search within.
		 */
295
		folder: Uri;
296 297 298 299 300 301 302 303 304 305 306 307 308 309 310

		/**
		 * 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 已提交
311
		useIgnoreFiles: boolean;
312 313 314 315 316

		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
317
		followSymlinks: boolean;
P
pkoushik 已提交
318 319 320 321 322 323

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

R
Rob Lourens 已提交
326 327
	/**
	 * Options to specify the size of the result text preview.
R
Rob Lourens 已提交
328
	 * These options don't affect the size of the match itself, just the amount of preview text.
R
Rob Lourens 已提交
329
	 */
330
	export interface TextSearchPreviewOptions {
331
		/**
R
Rob Lourens 已提交
332
		 * The maximum number of lines in the preview.
R
Rob Lourens 已提交
333
		 * Only search providers that support multiline search will ever return more than one line in the match.
334
		 */
R
Rob Lourens 已提交
335
		matchLines: number;
R
Rob Lourens 已提交
336 337 338 339

		/**
		 * The maximum number of characters included per line.
		 */
R
Rob Lourens 已提交
340
		charsPerLine: number;
341 342
	}

343 344 345
	/**
	 * Options that apply to text search.
	 */
R
Rob Lourens 已提交
346
	export interface TextSearchOptions extends SearchOptions {
347
		/**
348
		 * The maximum number of results to be returned.
349
		 */
350 351
		maxResults: number;

R
Rob Lourens 已提交
352 353 354
		/**
		 * Options to specify the size of the result text preview.
		 */
355
		previewOptions?: TextSearchPreviewOptions;
356 357 358 359

		/**
		 * Exclude files larger than `maxFileSize` in bytes.
		 */
360
		maxFileSize?: number;
361 362 363 364 365

		/**
		 * Interpret files using this encoding.
		 * See the vscode setting `"files.encoding"`
		 */
366
		encoding?: string;
367 368 369 370 371 372 373 374 375 376

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

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

379 380 381 382 383 384 385 386 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.
		 * `maxResults` on [`TextSearchOptions`](#TextSearchOptions) specifies the max number of results.
		 * - 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;
	}

R
Rob Lourens 已提交
393 394 395
	/**
	 * A preview of the text result.
	 */
396
	export interface TextSearchMatchPreview {
397
		/**
R
Rob Lourens 已提交
398
		 * The matching lines of text, or a portion of the matching line that contains the match.
399 400 401 402 403
		 */
		text: string;

		/**
		 * The Range within `text` corresponding to the text of the match.
404
		 * The number of matches must match the TextSearchMatch's range property.
405
		 */
406
		matches: Range | Range[];
407 408 409 410 411
	}

	/**
	 * A match from a text search
	 */
412
	export interface TextSearchMatch {
413 414 415
		/**
		 * The uri for the matching document.
		 */
416
		uri: Uri;
417 418

		/**
419
		 * The range of the match within the document, or multiple ranges for multiple matches.
420
		 */
421
		ranges: Range | Range[];
R
Rob Lourens 已提交
422

423
		/**
424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445
		 * 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.
446
		 */
447
		lineNumber: number;
448 449
	}

450 451
	export type TextSearchResult = TextSearchMatch | TextSearchContext;

R
Rob Lourens 已提交
452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 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
	/**
	 * 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;
	}

496
	/**
R
Rob Lourens 已提交
497 498 499 500 501 502 503
	 * 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.
	 *
	 * A FileSearchProvider is the more powerful of two ways to implement file search in VS Code. Use a FileSearchProvider if you wish to search within a folder for
	 * 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.
504
	 */
505
	export interface FileSearchProvider {
506 507 508 509 510 511
		/**
		 * 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.
		 */
512
		provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, token: CancellationToken): ProviderResult<Uri[]>;
513
	}
514

R
Rob Lourens 已提交
515
	export namespace workspace {
516
		/**
R
Rob Lourens 已提交
517 518 519 520 521 522 523
		 * 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.
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
524
		 */
R
Rob Lourens 已提交
525 526 527 528 529 530 531 532 533 534 535 536
		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.
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
		export function registerTextSearchProvider(scheme: string, provider: TextSearchProvider): Disposable;
537 538
	}

R
Rob Lourens 已提交
539 540 541 542
	//#endregion

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

543 544 545
	/**
	 * Options that can be set on a findTextInFiles search.
	 */
R
Rob Lourens 已提交
546
	export interface FindTextInFilesOptions {
547 548 549 550 551
		/**
		 * A [glob pattern](#GlobPattern) 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 [relative pattern](#RelativePattern)
		 * to restrict the search results to a [workspace folder](#WorkspaceFolder).
		 */
552
		include?: GlobPattern;
553 554 555

		/**
		 * A [glob pattern](#GlobPattern) that defines files and folders to exclude. The glob pattern
556 557
		 * will be matched against the file paths of resulting matches relative to their workspace. When `undefined`, default excludes will
		 * apply.
558
		 */
559 560 561 562
		exclude?: GlobPattern;

		/**
		 * Whether to use the default and user-configured excludes. Defaults to true.
563
		 */
564
		useDefaultExcludes?: boolean;
565 566 567 568

		/**
		 * The maximum number of results to search for
		 */
R
Rob Lourens 已提交
569
		maxResults?: number;
570 571 572 573 574

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

P
pkoushik 已提交
577 578 579 580
		/**
		 * Whether global files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useGlobalIgnoreFiles"`.
		 */
581
		useGlobalIgnoreFiles?: boolean;
P
pkoushik 已提交
582

583 584 585 586
		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
587
		followSymlinks?: boolean;
588 589 590 591 592

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

R
Rob Lourens 已提交
595 596 597
		/**
		 * Options to specify the size of the result text preview.
		 */
598
		previewOptions?: TextSearchPreviewOptions;
599 600 601 602 603 604 605 606 607 608

		/**
		 * 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 已提交
609 610
	}

611
	export namespace workspace {
612 613 614 615 616 617 618
		/**
		 * Search text in files across all [workspace folders](#workspace.workspaceFolders) in the workspace.
		 * @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.
		 */
619
		export function findTextInFiles(query: TextSearchQuery, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
620 621 622 623 624 625 626 627 628

		/**
		 * Search text in files across all [workspace folders](#workspace.workspaceFolders) in the workspace.
		 * @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.
		 */
629
		export function findTextInFiles(query: TextSearchQuery, options: FindTextInFilesOptions, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
630 631
	}

J
Johannes Rieken 已提交
632
	//#endregion
633

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

J
Joao Moreno 已提交
636 637 638
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
639 640 641 642 643 644 645
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663
	export namespace commands {

		/**
		 * Registers a diff information command that can be invoked via a keyboard shortcut,
		 * a menu item, an action, or directly.
		 *
		 * Diff information commands are different from ordinary [commands](#commands.registerCommand) as
		 * 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.
		 * @param callback A command handler function with access to the [diff information](#LineChange).
		 * @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;
	}
664

J
Johannes Rieken 已提交
665 666
	//#endregion

667
	// eslint-disable-next-line vscode-dts-region-comments
668
	//#region @weinand: variables view action contributions
669

670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685
	/**
	 * 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 已提交
686 687
	//#endregion

688
	// eslint-disable-next-line vscode-dts-region-comments
689
	//#region @joaomoreno: SCM validation
690

J
Joao Moreno 已提交
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729
	/**
	 * 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 {

730 731 732 733 734
		/**
		 * Shows a transient contextual message on the input.
		 */
		showValidationMessage(message: string, type: SourceControlInputBoxValidationType): void;

J
Joao Moreno 已提交
735 736 737 738
		/**
		 * A validation function for the input box. It's possible to change
		 * the validation provider simply by setting this property to a different function.
		 */
739
		validateInput?(value: string, cursorPosition: number): ProviderResult<SourceControlInputBoxValidation>;
J
Joao Moreno 已提交
740
	}
M
Matt Bierner 已提交
741

J
Johannes Rieken 已提交
742 743
	//#endregion

744
	// eslint-disable-next-line vscode-dts-region-comments
745
	//#region @joaomoreno: SCM selected provider
746 747 748 749 750 751 752 753 754 755 756 757

	export interface SourceControl {

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

		/**
		 * An event signaling when the selection state changes.
		 */
		readonly onDidChangeSelection: Event<boolean>;
758 759 760 761
	}

	//#endregion

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

764 765 766 767 768 769 770 771 772 773 774
	export interface TerminalDataWriteEvent {
		/**
		 * The [terminal](#Terminal) for which the data was written.
		 */
		readonly terminal: Terminal;
		/**
		 * The data being written.
		 */
		readonly data: string;
	}

D
Daniel Imms 已提交
775 776
	namespace window {
		/**
D
Daniel Imms 已提交
777 778 779
		 * 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 已提交
780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800
		 */
		export const onDidWriteTerminalData: Event<TerminalDataWriteEvent>;
	}

	//#endregion

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

	/**
	 * An [event](#Event) which fires when a [Terminal](#Terminal)'s dimensions change.
	 */
	export interface TerminalDimensionsChangeEvent {
		/**
		 * The [terminal](#Terminal) for which the dimensions have changed.
		 */
		readonly terminal: Terminal;
		/**
		 * The new value for the [terminal's dimensions](#Terminal.dimensions).
		 */
		readonly dimensions: TerminalDimensions;
	}
801

D
Daniel Imms 已提交
802
	export namespace window {
D
Daniel Imms 已提交
803 804 805 806 807 808 809
		/**
		 * An event which fires when the [dimensions](#Terminal.dimensions) of the terminal change.
		 */
		export const onDidChangeTerminalDimensions: Event<TerminalDimensionsChangeEvent>;
	}

	export interface Terminal {
810
		/**
811 812 813
		 * 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.
814
		 */
815
		readonly dimensions: TerminalDimensions | undefined;
D
Daniel Imms 已提交
816 817
	}

818 819
	//#endregion

D
Daniel Imms 已提交
820 821 822 823
	//#region Terminal initial text https://github.com/microsoft/vscode/issues/120368

	export interface TerminalOptions {
		/**
D
Daniel Imms 已提交
824 825 826
		 * A message to write to the terminal on first launch, note that this is not sent to the
		 * process but, rather written directly to the terminal. This supports escape sequences such
		 * a setting text style.
D
Daniel Imms 已提交
827
		 */
D
Daniel Imms 已提交
828
		readonly message?: string;
D
Daniel Imms 已提交
829 830 831 832
	}

	//#endregion

D
Daniel Imms 已提交
833 834 835 836 837 838 839 840 841 842 843
	//#region Terminal icon https://github.com/microsoft/vscode/issues/120538

	export interface TerminalOptions {
		/**
		 * A codicon ID to associate with this terminal.
		 */
		readonly icon?: string;
	}

	//#endregion

844
	// eslint-disable-next-line vscode-dts-region-comments
845
	//#region @jrieken -> exclusive document filters
846 847

	export interface DocumentFilter {
848
		readonly exclusive?: boolean;
849 850 851
	}

	//#endregion
C
Christof Marti 已提交
852

853
	//#region Tree View: https://github.com/microsoft/vscode/issues/61313 @alexr00
854
	export interface TreeView<T> extends Disposable {
855
		reveal(element: T | undefined, options?: { select?: boolean, focus?: boolean, expand?: boolean | number; }): Thenable<void>;
856
	}
857
	//#endregion
858

859
	//#region Task presentation group: https://github.com/microsoft/vscode/issues/47265
860 861 862 863 864 865 866
	export interface TaskPresentationOptions {
		/**
		 * Controls whether the task is executed in a specific terminal group using split panes.
		 */
		group?: string;
	}
	//#endregion
867

868
	//#region Status bar item with ID and Name: https://github.com/microsoft/vscode/issues/74972
869

B
Benjamin Pasero 已提交
870 871 872 873 874 875 876 877 878 879 880
	/**
	 * Options to configure the status bar item.
	 */
	export interface StatusBarItemOptions {

		/**
		 * A unique identifier of the status bar item. The identifier
		 * is for example used to allow a user to show or hide the
		 * status bar item in the UI.
		 */
		id: string;
881 882

		/**
B
Benjamin Pasero 已提交
883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906
		 * A human readable name of the status bar item. The name is
		 * for example used as a label in the UI to show or hide the
		 * status bar item.
		 */
		name: string;

		/**
		 * Accessibility information used when screen reader interacts with this status bar item.
		 */
		accessibilityInformation?: AccessibilityInformation;

		/**
		 * The alignment of the status bar item.
		 */
		alignment?: StatusBarAlignment;

		/**
		 * The priority of the status bar item. Higher value means the item should
		 * be shown more to the left.
		 */
		priority?: number;
	}

	export namespace window {
907 908 909 910 911 912 913 914 915 916 917 918 919

		/**
		 * Creates a status bar [item](#StatusBarItem).
		 *
		 * @param options The options of the item. If not provided, some default values
		 * will be assumed. For example, the `StatusBarItemOptions.id` will be the id
		 * of the extension and the `StatusBarItemOptions.name` will be the extension name.
		 * @return A new status bar item.
		 */
		export function createStatusBarItem(options?: StatusBarItemOptions): StatusBarItem;
	}

	//#endregion
920

921
	//#region Custom editor move https://github.com/microsoft/vscode/issues/86146
922

923
	// TODO: Also for custom editor
924

925
	export interface CustomTextEditorProvider {
M
Matt Bierner 已提交
926

927 928 929 930 931 932 933 934
		/**
		 * 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,
		 * VS Code will destory the previous custom editor and create a replacement one.
		 *
		 * @param newDocument New text document to use for the custom editor.
		 * @param existingWebviewPanel Webview panel for the custom editor.
935
		 * @param token A cancellation token that indicates the result is no longer needed.
936 937 938
		 *
		 * @return Thenable indicating that the webview editor has been moved.
		 */
J
Johannes Rieken 已提交
939
		// eslint-disable-next-line vscode-dts-provider-naming
940
		moveCustomTextEditor?(newDocument: TextDocument, existingWebviewPanel: WebviewPanel, token: CancellationToken): Thenable<void>;
941 942 943
	}

	//#endregion
944

J
Johannes Rieken 已提交
945
	//#region allow QuickPicks to skip sorting: https://github.com/microsoft/vscode/issues/73904
P
Peter Elmers 已提交
946 947 948

	export interface QuickPick<T extends QuickPickItem> extends QuickInput {
		/**
949 950
		 * An optional flag to sort the final results by index of first query match in label. Defaults to true.
		 */
P
Peter Elmers 已提交
951 952 953 954
		sortByLabel: boolean;
	}

	//#endregion
M
Matt Bierner 已提交
955

956
	//#region https://github.com/microsoft/vscode/issues/106744, Notebooks (misc)
R
rebornix 已提交
957

958
	export enum NotebookCellKind {
R
rebornix 已提交
959 960 961 962
		Markdown = 1,
		Code = 2
	}

963
	export class NotebookCellMetadata {
964
		/**
R
rebornix 已提交
965
		 * todo@API this can be renamed to `contentEditable`.
966
		 * Controls whether a cell's editor is editable/readonly.
967
		 */
968
		readonly editable?: boolean;
969
		/**
R
rebornix 已提交
970
		 * todo@API this can be removed and only kept internally? It's a UI thing and should be controlled by detecting wether there is a debugging session, or through a user setting (like line numbers)
971 972 973
		 * Controls if the cell has a margin to support the breakpoint UI.
		 * This metadata is ignored for markdown cell.
		 */
974
		readonly breakpointMargin?: boolean;
975 976 977
		/**
		 * Whether a code cell's editor is collapsed
		 */
978
		readonly outputCollapsed?: boolean;
979 980 981
		/**
		 * Whether a code cell's outputs are collapsed
		 */
982
		readonly inputCollapsed?: boolean;
R
rebornix 已提交
983 984 985
		/**
		 * Additional attributes of a cell metadata.
		 */
986 987 988 989 990
		readonly custom?: Record<string, any>;

		// todo@API duplicates status bar API
		readonly statusMessage?: string;

991
		constructor(editable?: boolean, breakpointMargin?: boolean, statusMessage?: string, lastRunDuration?: number, inputCollapsed?: boolean, outputCollapsed?: boolean, custom?: Record<string, any>)
992

993
		with(change: { editable?: boolean | null, breakpointMargin?: boolean | null, statusMessage?: string | null, lastRunDuration?: number | null, inputCollapsed?: boolean | null, outputCollapsed?: boolean | null, custom?: Record<string, any> | null, }): NotebookCellMetadata;
R
Rob Lourens 已提交
994
	}
995

R
Rob Lourens 已提交
996 997 998 999
	export interface NotebookCellExecutionSummary {
		executionOrder?: number;
		success?: boolean;
		duration?: number;
R
rebornix 已提交
1000 1001
	}

1002
	// todo@API support ids https://github.com/jupyter/enhancement-proposals/blob/master/62-cell-id/cell-id.md
R
rebornix 已提交
1003
	export interface NotebookCell {
1004
		readonly index: number;
1005
		readonly notebook: NotebookDocument;
J
Johannes Rieken 已提交
1006
		readonly kind: NotebookCellKind;
J
Johannes Rieken 已提交
1007
		readonly document: TextDocument;
1008
		readonly metadata: NotebookCellMetadata
J
Johannes Rieken 已提交
1009
		readonly outputs: ReadonlyArray<NotebookCellOutput>;
R
Rob Lourens 已提交
1010
		readonly latestExecutionSummary: NotebookCellExecutionSummary | undefined;
R
rebornix 已提交
1011 1012
	}

1013
	export class NotebookDocumentMetadata {
J
Johannes Rieken 已提交
1014

1015
		/**
R
rebornix 已提交
1016
		 * todo@API. If it's called `editable` then this should also control if a cell is edtiable or not (through UI at least).
1017
		 * Controls if users can add or delete cells
1018
		 * Defaults to true
1019
		 */
1020
		readonly editable: boolean;
1021
		/**
R
rebornix 已提交
1022
		 * todo@API maybe removed?
1023
		 * Default value for [cell editable metadata](#NotebookCellMetadata.editable).
1024
		 * Defaults to true.
1025
		 */
1026
		readonly cellEditable: boolean;
R
rebornix 已提交
1027
		/**
1028
		 * Additional attributes of the document metadata.
R
rebornix 已提交
1029
		 */
1030
		readonly custom: { [key: string]: any; };
R
rebornix 已提交
1031 1032 1033 1034
		/**
		 * Whether the document is trusted, default to true
		 * When false, insecure outputs like HTML, JavaScript, SVG will not be rendered.
		 */
1035 1036
		readonly trusted: boolean;

1037
		constructor(editable?: boolean, cellEditable?: boolean, custom?: { [key: string]: any; }, trusted?: boolean);
1038

1039
		with(change: { editable?: boolean | null, cellEditable?: boolean | null, custom?: { [key: string]: any; } | null, trusted?: boolean | null, }): NotebookDocumentMetadata
R
rebornix 已提交
1040 1041
	}

R
rebornix 已提交
1042 1043 1044 1045 1046
	export interface NotebookDocumentContentOptions {
		/**
		 * Controls if outputs change will trigger notebook document content change and if it will be used in the diff editor
		 * Default to false. If the content provider doesn't persisit the outputs in the file document, this should be set to true.
		 */
1047
		transientOutputs?: boolean;
R
rebornix 已提交
1048 1049 1050 1051 1052

		/**
		 * Controls if a meetadata property change will trigger notebook document content change and if it will be used in the diff editor
		 * Default to false. If the content provider doesn't persisit a metadata property in the file document, it should be set to true.
		 */
1053
		transientMetadata?: { [K in keyof NotebookCellMetadata]?: boolean };
R
rebornix 已提交
1054 1055
	}

R
rebornix 已提交
1056 1057
	export interface NotebookDocument {
		readonly uri: Uri;
1058
		readonly version: number;
1059

1060
		/** @deprecated Use `uri` instead */
J
Johannes Rieken 已提交
1061
		// todo@API don't have this...
R
rebornix 已提交
1062
		readonly fileName: string;
1063

R
rebornix 已提交
1064
		readonly isDirty: boolean;
R
rebornix 已提交
1065
		readonly isUntitled: boolean;
1066

1067 1068 1069 1070 1071
		/**
		 * `true` if the notebook has been closed. A closed notebook isn't synchronized anymore
		 * and won't be re-used when the same resource is opened again.
		 */
		readonly isClosed: boolean;
1072

R
rebornix 已提交
1073
		readonly metadata: NotebookDocumentMetadata;
R
rebornix 已提交
1074

1075 1076 1077
		// todo@API should we really expose this?
		readonly viewType: string;

1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090
		/**
		 * The number of cells in the notebook document.
		 */
		readonly cellCount: number;

		/**
		 * Return the cell at the specified index. The index will be adjusted to the notebook.
		 *
		 * @param index - The index of the cell to retrieve.
		 * @return A [cell](#NotebookCell).
		 */
		cellAt(index: number): NotebookCell;

1091 1092 1093 1094 1095 1096 1097
		/**
		 * Get the cells of this notebook. A subset can be retrieved by providing
		 * a range. The range will be adjuset to the notebook.
		 *
		 * @param range A notebook range.
		 * @returns The cells contained by the range or all cells.
		 */
1098
		getCells(range?: NotebookCellRange): NotebookCell[];
1099

R
rebornix 已提交
1100 1101 1102 1103 1104 1105 1106 1107
		/**
		 * Save the document. The saving will be handled by the corresponding content provider
		 *
		 * @return A promise that will resolve to true when the document
		 * has been saved. If the file was not dirty or the save failed,
		 * will return false.
		 */
		save(): Thenable<boolean>;
R
rebornix 已提交
1108 1109
	}

1110
	// todo@API RENAME to NotebookRange
1111
	// todo@API maybe have a NotebookCellPosition sibling
1112
	export class NotebookCellRange {
1113
		readonly start: number;
R
rebornix 已提交
1114 1115 1116
		/**
		 * exclusive
		 */
1117
		readonly end: number;
1118

J
Johannes Rieken 已提交
1119
		readonly isEmpty: boolean;
1120

1121
		constructor(start: number, end: number);
1122 1123

		with(change: { start?: number, end?: number }): NotebookCellRange;
1124 1125
	}

R
rebornix 已提交
1126 1127 1128 1129 1130 1131 1132 1133 1134
	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,
R
rebornix 已提交
1135

R
rebornix 已提交
1136 1137 1138 1139 1140
		/**
		 * 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,
R
rebornix 已提交
1141 1142 1143 1144 1145

		/**
		 * The range will always be revealed at the top of the viewport.
		 */
		AtTop = 3
R
rebornix 已提交
1146 1147
	}

R
rebornix 已提交
1148
	export interface NotebookEditor {
R
rebornix 已提交
1149 1150 1151
		/**
		 * The document associated with this notebook editor.
		 */
R
rebornix 已提交
1152
		readonly document: NotebookDocument;
R
rebornix 已提交
1153 1154

		/**
R
rebornix 已提交
1155 1156 1157 1158
		 * 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 }`;
		 */
R
rebornix 已提交
1159
		readonly selections: NotebookCellRange[];
J
Johannes Rieken 已提交
1160

1161 1162 1163 1164 1165
		/**
		 * The current visible ranges in the editor (vertically).
		 */
		readonly visibleRanges: NotebookCellRange[];

1166 1167
		revealRange(range: NotebookCellRange, revealType?: NotebookEditorRevealType): void;

R
rebornix 已提交
1168 1169 1170
		/**
		 * The column in which this editor shows.
		 */
J
Johannes Rieken 已提交
1171
		readonly viewColumn?: ViewColumn;
R
rebornix 已提交
1172 1173
	}

1174 1175 1176 1177
	export interface NotebookDocumentMetadataChangeEvent {
		readonly document: NotebookDocument;
	}

1178
	export interface NotebookCellsChangeData {
R
rebornix 已提交
1179
		readonly start: number;
J
Johannes Rieken 已提交
1180
		// todo@API end? Use NotebookCellRange instead?
R
rebornix 已提交
1181
		readonly deletedCount: number;
J
Johannes Rieken 已提交
1182
		// todo@API removedCells, deletedCells?
1183
		readonly deletedItems: NotebookCell[];
J
Johannes Rieken 已提交
1184
		// todo@API addedCells, insertedCells, newCells?
R
rebornix 已提交
1185
		readonly items: NotebookCell[];
R
rebornix 已提交
1186 1187
	}

R
rebornix 已提交
1188
	export interface NotebookCellsChangeEvent {
R
rebornix 已提交
1189 1190 1191 1192 1193

		/**
		 * The affected document.
		 */
		readonly document: NotebookDocument;
1194
		readonly changes: ReadonlyArray<NotebookCellsChangeData>;
R
rebornix 已提交
1195 1196
	}

1197
	export interface NotebookCellOutputsChangeEvent {
R
rebornix 已提交
1198 1199 1200 1201 1202

		/**
		 * The affected document.
		 */
		readonly document: NotebookDocument;
1203
		readonly cells: NotebookCell[];
R
rebornix 已提交
1204 1205
	}

1206 1207 1208
	export interface NotebookCellMetadataChangeEvent {
		readonly document: NotebookDocument;
		readonly cell: NotebookCell;
R
rebornix 已提交
1209 1210
	}

1211 1212
	export interface NotebookEditorSelectionChangeEvent {
		readonly notebookEditor: NotebookEditor;
1213
		readonly selections: ReadonlyArray<NotebookCellRange>
1214 1215
	}

1216 1217 1218 1219 1220
	export interface NotebookEditorVisibleRangesChangeEvent {
		readonly notebookEditor: NotebookEditor;
		readonly visibleRanges: ReadonlyArray<NotebookCellRange>;
	}

R
Rob Lourens 已提交
1221 1222 1223 1224 1225 1226
	export interface NotebookCellExecutionStateChangeEvent {
		readonly document: NotebookDocument;
		readonly cell: NotebookCell;
		readonly executionState: NotebookCellExecutionState;
	}

1227
	// todo@API support ids https://github.com/jupyter/enhancement-proposals/blob/master/62-cell-id/cell-id.md
1228
	export class NotebookCellData {
R
rebornix 已提交
1229
		// todo@API should they all be readonly?
1230 1231 1232 1233 1234
		kind: NotebookCellKind;
		// todo@API better names: value? text?
		source: string;
		// todo@API how does language and MD relate?
		language: string;
R
rebornix 已提交
1235
		// todo@API ReadonlyArray?
1236 1237
		outputs?: NotebookCellOutput[];
		metadata?: NotebookCellMetadata;
R
Rob Lourens 已提交
1238 1239
		latestExecutionSummary?: NotebookCellExecutionSummary;
		constructor(kind: NotebookCellKind, source: string, language: string, outputs?: NotebookCellOutput[], metadata?: NotebookCellMetadata, latestExecutionSummary?: NotebookCellExecutionSummary);
1240 1241 1242
	}

	export class NotebookData {
R
rebornix 已提交
1243
		// todo@API should they all be readonly?
1244
		cells: NotebookCellData[];
1245
		metadata: NotebookDocumentMetadata;
1246
		constructor(cells: NotebookCellData[], metadata?: NotebookDocumentMetadata);
R
rebornix 已提交
1247 1248
	}

1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270
	/**
	 * Communication object passed to the {@link NotebookContentProvider} and
	 * {@link NotebookOutputRenderer} to communicate with the webview.
	 */
	export interface NotebookCommunication {
		/**
		 * ID of the editor this object communicates with. A single notebook
		 * document can have multiple attached webviews and editors, when the
		 * notebook is split for instance. The editor ID lets you differentiate
		 * between them.
		 */
		readonly editorId: string;

		/**
		 * Fired when the output hosting webview posts a message.
		 */
		readonly onDidReceiveMessage: Event<any>;
		/**
		 * Post a message to the output hosting webview.
		 *
		 * Messages are only delivered if the editor is live.
		 *
T
Toan Nguyen 已提交
1271
		 * @param message Body of the message. This must be a string or other json serializable object.
1272 1273 1274 1275 1276 1277 1278
		 */
		postMessage(message: any): Thenable<boolean>;

		/**
		 * Convert a uri for the local file system to one that can be used inside outputs webview.
		 */
		asWebviewUri(localResource: Uri): Uri;
J
Johannes Rieken 已提交
1279 1280 1281

		// @rebornix
		// readonly onDidDispose: Event<void>;
R
rebornix 已提交
1282 1283
	}

1284 1285 1286 1287 1288 1289 1290
	// export function registerNotebookKernel(selector: string, kernel: NotebookKernel): Disposable;


	export interface NotebookDocumentShowOptions {
		viewColumn?: ViewColumn;
		preserveFocus?: boolean;
		preview?: boolean;
1291
		selections?: NotebookCellRange[];
1292 1293 1294 1295
	}

	export namespace notebook {

1296 1297
		export function openNotebookDocument(uri: Uri): Thenable<NotebookDocument>;

1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309
		export const onDidOpenNotebookDocument: Event<NotebookDocument>;
		export const onDidCloseNotebookDocument: Event<NotebookDocument>;

		export const onDidSaveNotebookDocument: Event<NotebookDocument>;

		/**
		 * All currently known notebook documents.
		 */
		export const notebookDocuments: ReadonlyArray<NotebookDocument>;
		export const onDidChangeNotebookDocumentMetadata: Event<NotebookDocumentMetadataChangeEvent>;
		export const onDidChangeNotebookCells: Event<NotebookCellsChangeEvent>;
		export const onDidChangeCellOutputs: Event<NotebookCellOutputsChangeEvent>;
J
Johannes Rieken 已提交
1310

1311 1312 1313 1314 1315 1316 1317 1318 1319 1320
		export const onDidChangeCellMetadata: Event<NotebookCellMetadataChangeEvent>;
	}

	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>;
1321 1322

		export function showNotebookDocument(uri: Uri, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
1323 1324 1325 1326 1327 1328 1329
		export function showNotebookDocument(document: NotebookDocument, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
	}

	//#endregion

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

1330 1331
	// code specific mime types
	// application/x.notebook.error-traceback
1332 1333
	// application/x.notebook.stdout
	// application/x.notebook.stderr
1334
	// application/x.notebook.stream
1335 1336
	export class NotebookCellOutputItem {

1337 1338 1339 1340 1341
		// todo@API
		// add factory functions for common mime types
		// static textplain(value:string): NotebookCellOutputItem;
		// static errortrace(value:any): NotebookCellOutputItem;

1342 1343
		readonly mime: string;
		readonly value: unknown;
1344
		readonly metadata?: Record<string, any>;
1345

1346
		constructor(mime: string, value: unknown, metadata?: Record<string, any>);
1347 1348
	}

1349
	// @jrieken
J
Johannes Rieken 已提交
1350
	// todo@API think about readonly...
1351
	//TODO@API add execution count to cell output?
1352
	export class NotebookCellOutput {
1353
		readonly id: string;
1354
		readonly outputs: NotebookCellOutputItem[];
1355 1356 1357 1358 1359
		readonly metadata?: Record<string, any>;

		constructor(outputs: NotebookCellOutputItem[], metadata?: Record<string, any>);

		constructor(outputs: NotebookCellOutputItem[], id: string, metadata?: Record<string, any>);
1360 1361 1362 1363 1364 1365 1366 1367
	}

	//#endregion

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

	export interface WorkspaceEdit {
		replaceNotebookMetadata(uri: Uri, value: NotebookDocumentMetadata): void;
1368 1369

		// todo@API use NotebookCellRange
1370 1371
		replaceNotebookCells(uri: Uri, start: number, end: number, cells: NotebookCellData[], metadata?: WorkspaceEditEntryMetadata): void;
		replaceNotebookCellMetadata(uri: Uri, index: number, cellMetadata: NotebookCellMetadata, metadata?: WorkspaceEditEntryMetadata): void;
J
Johannes Rieken 已提交
1372

R
rebornix 已提交
1373 1374
		replaceNotebookCellOutput(uri: Uri, index: number, outputs: NotebookCellOutput[], metadata?: WorkspaceEditEntryMetadata): void;
		appendNotebookCellOutput(uri: Uri, index: number, outputs: NotebookCellOutput[], metadata?: WorkspaceEditEntryMetadata): void;
1375 1376 1377

		// TODO@api
		// https://jupyter-protocol.readthedocs.io/en/latest/messaging.html#update-display-data
R
rebornix 已提交
1378 1379
		replaceNotebookCellOutputItems(uri: Uri, index: number, outputId: string, items: NotebookCellOutputItem[], metadata?: WorkspaceEditEntryMetadata): void;
		appendNotebookCellOutputItems(uri: Uri, index: number, outputId: string, items: NotebookCellOutputItem[], metadata?: WorkspaceEditEntryMetadata): void;
1380 1381 1382 1383 1384
	}

	export interface NotebookEditorEdit {
		replaceMetadata(value: NotebookDocumentMetadata): void;
		replaceCells(start: number, end: number, cells: NotebookCellData[]): void;
R
rebornix 已提交
1385
		replaceCellOutput(index: number, outputs: NotebookCellOutput[]): void;
1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405
		replaceCellMetadata(index: number, metadata: NotebookCellMetadata): void;
	}

	export interface NotebookEditor {
		/**
		 * Perform an edit on the notebook associated with this notebook editor.
		 *
		 * The given callback-function is invoked with an [edit-builder](#NotebookEditorEdit) which must
		 * be used to make edits. Note that the edit-builder is only valid while the
		 * callback executes.
		 *
		 * @param callback A function which can create edits using an [edit-builder](#NotebookEditorEdit).
		 * @return A promise that resolves with a value indicating if the edits could be applied.
		 */
		// @jrieken REMOVE maybe
		edit(callback: (editBuilder: NotebookEditorEdit) => void): Thenable<boolean>;
	}

	//#endregion

1406 1407 1408 1409 1410 1411 1412 1413 1414
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookSerializer

	export interface NotebookSerializer {
		dataToNotebook(data: Uint8Array): NotebookData | Thenable<NotebookData>;
		notebookToData(data: NotebookData): Uint8Array | Thenable<Uint8Array>;
	}

	export namespace notebook {

J
Johannes Rieken 已提交
1415
		// todo@API remove output when notebook marks that as transient, same for metadata
1416 1417 1418 1419 1420
		export function registerNotebookSerializer(notebookType: string, provider: NotebookSerializer, options?: NotebookDocumentContentOptions): Disposable;
	}

	//#endregion

1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431
	//#region https://github.com/microsoft/vscode/issues/119949


	export interface NotebookFilter {
		readonly viewType?: string;
		readonly scheme?: string;
		readonly pattern?: GlobPattern;
	}

	export type NotebookSelector = NotebookFilter | string | ReadonlyArray<NotebookFilter | string>;

1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446
	export interface NotebookRendererCommunication {

		/**
		 *
		 */
		dispose(): void;

		/**
		 *
		 */
		readonly rendererId: string;

		/**
		 * Fired when the output hosting webview posts a message.
		 */
1447
		readonly onDidReceiveMessage: Event<{ editor: NotebookEditor, message: any }>;
1448 1449 1450 1451 1452 1453 1454
		/**
		 * Post a message to the output hosting webview.
		 *
		 * Messages are only delivered if the editor is live.
		 *
		 * @param message Body of the message. This must be a string or other json serializable object.
		 */
1455
		postMessage(message: any, editor?: NotebookEditor): Thenable<boolean>;
1456 1457 1458 1459

		/**
		 * Convert a uri for the local file system to one that can be used inside outputs webview.
		 */
1460
		asWebviewUri(localResource: Uri, editor: NotebookEditor): Uri;
1461 1462
	}

1463 1464 1465 1466 1467 1468 1469 1470 1471 1472
	export namespace notebook {

		/**
		 *
		 * @param rendererId
		 */
		export function createNotebookRendererCommunication(rendererId: string): NotebookRendererCommunication;
	}


1473
	export interface NotebookController {
1474 1475 1476 1477 1478 1479

		readonly id: string;

		// select notebook of a type and/or by file-pattern
		readonly selector: NotebookSelector;

1480 1481 1482 1483 1484 1485
		/**
		 * A kernel can apply to one or many notebook documents but a notebook has only one active
		 * kernel. This event fires whenever a notebook has been associated to a kernel or when
		 * that association has been removed.
		 */
		readonly onDidChangeNotebookAssociation: Event<{ notebook: NotebookDocument, selected: boolean }>;
1486

1487 1488 1489 1490 1491 1492
		// UI properties (get/set)
		label: string;
		description: string;
		supportedLanguages: string[];
		hasExecutionOrder: boolean;

J
Johannes Rieken 已提交
1493 1494 1495 1496
		/**
		 * The execute handler is invoked when the run gestures in the UI are selected, e.g Run Cell, Run All,
		 * Run Selection etc.
		 */
J
Johannes Rieken 已提交
1497
		readonly executeHandler: (executions: NotebookCellExecutionTask[]) => void;
1498 1499

		// optional kernel interrupt command
1500
		interruptHandler?: (notebook: NotebookDocument) => void
1501 1502 1503

		// remove kernel
		dispose(): void;
J
Johannes Rieken 已提交
1504 1505 1506 1507 1508 1509 1510 1511 1512 1513

		/**
		 * Manually create an execution task. This should only be used when cell execution
		 * has started before creating the kernel instance or when execution can be triggered
		 * from another source.
		 *
		 * @param cell The notebook cell for which to create the execution
		 * @returns A notebook cell execution.
		 */
		createNotebookCellExecutionTask(cell: NotebookCell): NotebookCellExecutionTask;
1514 1515
	}

1516 1517 1518 1519 1520
	export interface NotebookKernelOptions {
		id: string;
		label: string;
		description?: string;
		selector: NotebookSelector;
1521
		supportedLanguages?: string[];
1522 1523 1524 1525 1526
		hasExecutionOrder?: boolean;
		executeHandler: (executions: NotebookCellExecutionTask[]) => void;
		interruptHandler?: (notebook: NotebookDocument) => void
	}

1527
	export namespace notebook {
1528
		export function createNotebookController(options: NotebookKernelOptions): NotebookController;
1529 1530 1531 1532
	}

	//#endregion

1533 1534
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookContentProvider

1535

1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558
	interface NotebookDocumentBackup {
		/**
		 * Unique identifier for the backup.
		 *
		 * This id is passed back to your extension in `openNotebook` when opening a notebook editor from a backup.
		 */
		readonly id: string;

		/**
		 * Delete the current backup.
		 *
		 * This is called by VS Code when it is clear the current backup is no longer needed, such as when a new backup
		 * is made or when the file is saved.
		 */
		delete(): void;
	}

	interface NotebookDocumentBackupContext {
		readonly destination: Uri;
	}

	interface NotebookDocumentOpenContext {
		readonly backupId?: string;
1559
		readonly untitledDocumentData?: Uint8Array;
1560 1561
	}

1562
	// todo@API use openNotebookDOCUMENT to align with openCustomDocument etc?
J
Johannes Rieken 已提交
1563
	// todo@API rename to NotebookDocumentContentProvider
R
rebornix 已提交
1564
	export interface NotebookContentProvider {
1565

1566 1567
		readonly options?: NotebookDocumentContentOptions;
		readonly onDidChangeNotebookContentOptions?: Event<NotebookDocumentContentOptions>;
1568

1569 1570 1571 1572
		/**
		 * Content providers should always use [file system providers](#FileSystemProvider) to
		 * resolve the raw content for `uri` as the resouce is not necessarily a file on disk.
		 */
1573 1574
		openNotebook(uri: Uri, openContext: NotebookDocumentOpenContext, token: CancellationToken): NotebookData | Thenable<NotebookData>;

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

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

J
Johannes Rieken 已提交
1581
		// todo@API use NotebookData instead
1582
		backupNotebook(document: NotebookDocument, context: NotebookDocumentBackupContext, token: CancellationToken): Thenable<NotebookDocumentBackup>;
1583 1584 1585
	}

	export namespace notebook {
J
Johannes Rieken 已提交
1586

1587 1588 1589 1590 1591 1592 1593 1594 1595 1596 1597 1598 1599 1600
		// TODO@api use NotebookDocumentFilter instead of just notebookType:string?
		// TODO@API options duplicates the more powerful variant on NotebookContentProvider
		export function registerNotebookContentProvider(notebookType: string, provider: NotebookContentProvider,
			options?: NotebookDocumentContentOptions & {
				/**
				 * Not ready for production or development use yet.
				 */
				viewOptions?: {
					displayName: string;
					filenamePattern: NotebookFilenamePattern[];
					exclusive?: boolean;
				};
			}
		): Disposable;
R
rebornix 已提交
1601 1602
	}

1603 1604 1605 1606
	//#endregion

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

1607 1608 1609 1610 1611
	export interface NotebookKernelPreload {
		provides?: string | string[];
		uri: Uri;
	}

R
rebornix 已提交
1612
	export interface NotebookKernel {
1613 1614

		// todo@API make this mandatory?
R
rebornix 已提交
1615
		readonly id?: string;
1616

R
rebornix 已提交
1617
		label: string;
R
rebornix 已提交
1618
		description?: string;
R
rebornix 已提交
1619
		detail?: string;
R
rebornix 已提交
1620
		isPreferred?: boolean;
1621

1622 1623
		// todo@API do we need an preload change event?
		preloads?: NotebookKernelPreload[];
J
Johannes Rieken 已提交
1624

J
Johannes Rieken 已提交
1625 1626 1627 1628 1629
		/**
		 * languages supported by kernel
		 * - first is preferred
		 * - `undefined` means all languages available in the editor
		 */
1630
		supportedLanguages?: string[];
J
Johannes Rieken 已提交
1631

1632 1633 1634 1635
		// todo@API kernel updating itself
		// fired when properties like the supported languages etc change
		// onDidChangeProperties?: Event<void>

R
Rob Lourens 已提交
1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693
		/**
		 * A kernel can optionally implement this which will be called when any "cancel" button is clicked in the document.
		 */
		interrupt?(document: NotebookDocument): void;

		/**
		 * Called when the user triggers execution of a cell by clicking the run button for a cell, multiple cells,
		 * or full notebook. The cell will be put into the Pending state when this method is called. If
		 * createNotebookCellExecutionTask has not been called by the time the promise returned by this method is
		 * resolved, the cell will be put back into the Idle state.
		 */
		executeCellsRequest(document: NotebookDocument, ranges: NotebookCellRange[]): Thenable<void>;
	}

	export interface NotebookCellExecuteStartContext {
		// TODO@roblou are we concerned about clock issues with this absolute time?
		/**
		 * The time that execution began, in milliseconds in the Unix epoch. Used to drive the clock
		 * that shows for how long a cell has been running. If not given, the clock won't be shown.
		 */
		startTime?: number;
	}

	export interface NotebookCellExecuteEndContext {
		/**
		 * If true, a green check is shown on the cell status bar.
		 * If false, a red X is shown.
		 */
		success?: boolean;

		/**
		 * The total execution time in milliseconds.
		 */
		duration?: number;
	}

	/**
	 * A NotebookCellExecutionTask is how the kernel modifies a notebook cell as it is executing. When
	 * [`createNotebookCellExecutionTask`](#notebook.createNotebookCellExecutionTask) is called, the cell
	 * enters the Pending state. When `start()` is called on the execution task, it enters the Executing state. When
	 * `end()` is called, it enters the Idle state. While in the Executing state, cell outputs can be
	 * modified with the methods on the run task.
	 *
	 * All outputs methods operate on this NotebookCellExecutionTask's cell by default. They optionally take
	 * a cellIndex parameter that allows them to modify the outputs of other cells. `appendOutputItems` and
	 * `replaceOutputItems` operate on the output with the given ID, which can be an output on any cell. They
	 * all resolve once the output edit has been applied.
	 */
	export interface NotebookCellExecutionTask {
		readonly document: NotebookDocument;
		readonly cell: NotebookCell;

		start(context?: NotebookCellExecuteStartContext): void;
		executionOrder: number | undefined;
		end(result?: NotebookCellExecuteEndContext): void;
		readonly token: CancellationToken;

		clearOutput(cellIndex?: number): Thenable<void>;
1694 1695
		appendOutput(out: NotebookCellOutput | NotebookCellOutput[], cellIndex?: number): Thenable<void>;
		replaceOutput(out: NotebookCellOutput | NotebookCellOutput[], cellIndex?: number): Thenable<void>;
1696 1697
		appendOutputItems(items: NotebookCellOutputItem | NotebookCellOutputItem[], outputId: string): Thenable<void>;
		replaceOutputItems(items: NotebookCellOutputItem | NotebookCellOutputItem[], outputId: string): Thenable<void>;
R
Rob Lourens 已提交
1698 1699 1700 1701 1702 1703 1704 1705 1706 1707 1708 1709 1710 1711 1712 1713 1714 1715
	}

	export enum NotebookCellExecutionState {
		Idle = 1,
		Pending = 2,
		Executing = 3,
	}

	export namespace notebook {
		/**
		 * Creates a [`NotebookCellExecutionTask`](#NotebookCellExecutionTask). Should only be called by a kernel. Returns undefined unless requested by the active kernel.
		 * @param uri The [uri](#Uri) of the notebook document.
		 * @param index The index of the cell.
		 * @param kernelId The id of the kernel requesting this run task. If this kernel is not the current active kernel, `undefined` is returned.
		 */
		export function createNotebookCellExecutionTask(uri: Uri, index: number, kernelId: string): NotebookCellExecutionTask | undefined;

		export const onDidChangeCellExecutionState: Event<NotebookCellExecutionStateChangeEvent>;
R
rebornix 已提交
1716 1717
	}

1718
	export type NotebookFilenamePattern = GlobPattern | { include: GlobPattern; exclude: GlobPattern; };
R
rebornix 已提交
1719

J
Johannes Rieken 已提交
1720
	// todo@API why not for NotebookContentProvider?
R
rebornix 已提交
1721
	export interface NotebookDocumentFilter {
R
rebornix 已提交
1722
		viewType?: string | string[];
R
rebornix 已提交
1723
		filenamePattern?: NotebookFilenamePattern;
R
rebornix 已提交
1724 1725
	}

J
Johannes Rieken 已提交
1726 1727
	// todo@API very unclear, provider MUST not return alive object but only data object
	// todo@API unclear how the flow goes
R
rebornix 已提交
1728
	export interface NotebookKernelProvider<T extends NotebookKernel = NotebookKernel> {
R
rebornix 已提交
1729
		onDidChangeKernels?: Event<NotebookDocument | undefined>;
R
rebornix 已提交
1730 1731
		provideKernels(document: NotebookDocument, token: CancellationToken): ProviderResult<T[]>;
		resolveKernel?(kernel: T, document: NotebookDocument, webview: NotebookCommunication, token: CancellationToken): ProviderResult<void>;
R
rebornix 已提交
1732 1733
	}

1734
	export interface NotebookEditor {
J
Johannes Rieken 已提交
1735

1736 1737
		// todo@API unsure about that
		// kernel, kernel selection, kernel provider
J
Johannes Rieken 已提交
1738
		/** @deprecated kernels are private object*/
1739 1740 1741 1742
		readonly kernel?: NotebookKernel;
	}

	export namespace notebook {
J
Johannes Rieken 已提交
1743
		/** @deprecated */
1744
		export const onDidChangeActiveNotebookKernel: Event<{ document: NotebookDocument, kernel: NotebookKernel | undefined; }>;
J
Johannes Rieken 已提交
1745
		/** @deprecated use createNotebookKernel */
1746 1747 1748 1749 1750 1751 1752 1753 1754 1755 1756 1757 1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 1774
		export function registerNotebookKernelProvider(selector: NotebookDocumentFilter, provider: NotebookKernelProvider): Disposable;
	}

	//#endregion

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

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

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

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

	export namespace notebook {
		export function createNotebookEditorDecorationType(options: NotebookDecorationRenderOptions): NotebookEditorDecorationType;
	}

	//#endregion

	//#region https://github.com/microsoft/vscode/issues/106744, NotebookCellStatusBarItem
J
Johannes Rieken 已提交
1775

1776 1777 1778 1779 1780 1781 1782 1783 1784 1785 1786 1787 1788 1789 1790 1791
	/**
	 * Represents the alignment of status bar items.
	 */
	export enum NotebookCellStatusBarAlignment {

		/**
		 * Aligned to the left side.
		 */
		Left = 1,

		/**
		 * Aligned to the right side.
		 */
		Right = 2
	}

R
Rob Lourens 已提交
1792 1793
	export class NotebookCellStatusBarItem {
		readonly text: string;
1794
		readonly alignment: NotebookCellStatusBarAlignment;
R
Rob Lourens 已提交
1795 1796
		readonly command?: string | Command;
		readonly tooltip?: string;
1797
		readonly priority?: number;
R
Rob Lourens 已提交
1798 1799 1800 1801 1802 1803 1804 1805
		readonly accessibilityInformation?: AccessibilityInformation;

		constructor(text: string, alignment: NotebookCellStatusBarAlignment, command?: string | Command, tooltip?: string, priority?: number, accessibilityInformation?: AccessibilityInformation);
	}

	interface NotebookCellStatusBarItemProvider {
		onDidChangeCellStatusBarItems?: Event<void>;
		provideCellStatusBarItems(cell: NotebookCell, token: CancellationToken): ProviderResult<NotebookCellStatusBarItem[]>;
1806 1807
	}

1808
	export namespace notebook {
R
Rob Lourens 已提交
1809
		export function registerNotebookCellStatusBarItemProvider(selector: NotebookDocumentFilter, provider: NotebookCellStatusBarItemProvider): Disposable;
R
rebornix 已提交
1810 1811
	}

1812
	//#endregion
R
rebornix 已提交
1813

1814
	//#region https://github.com/microsoft/vscode/issues/106744, NotebookConcatTextDocument
R
rebornix 已提交
1815

R
rebornix 已提交
1816
	export namespace notebook {
1817
		/**
J
Johannes Rieken 已提交
1818 1819
		 * 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.
1820 1821 1822 1823
		 *
		 * @param notebook
		 * @param selector
		 */
J
Johannes Rieken 已提交
1824
		// @jrieken REMOVE. p_never
J
Johannes Rieken 已提交
1825
		// todo@API really needed? we didn't find a user here
1826
		export function createConcatTextDocument(notebook: NotebookDocument, selector?: DocumentSelector): NotebookConcatTextDocument;
1827
	}
M
Martin Aeschlimann 已提交
1828

1829 1830 1831 1832 1833 1834 1835 1836
	export interface NotebookConcatTextDocument {
		uri: Uri;
		isClosed: boolean;
		dispose(): void;
		onDidChange: Event<void>;
		version: number;
		getText(): string;
		getText(range: Range): string;
1837

1838 1839 1840 1841
		offsetAt(position: Position): number;
		positionAt(offset: number): Position;
		validateRange(range: Range): Range;
		validatePosition(position: Position): Position;
M
Martin Aeschlimann 已提交
1842

1843 1844 1845
		locationAt(positionOrRange: Position | Range): Location;
		positionAt(location: Location): Position;
		contains(uri: Uri): boolean;
1846 1847
	}

1848 1849 1850 1851
	//#endregion

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

P
label2  
Pine Wu 已提交
1852 1853 1854 1855
	export interface CompletionItem {
		/**
		 * Will be merged into CompletionItem#label
		 */
P
Pine Wu 已提交
1856
		label2?: CompletionItemLabel;
P
label2  
Pine Wu 已提交
1857 1858
	}

1859 1860
	export interface CompletionItemLabel {
		/**
P
Pine Wu 已提交
1861
		 * The function or variable. Rendered leftmost.
1862
		 */
P
Pine Wu 已提交
1863
		name: string;
1864

P
Pine Wu 已提交
1865
		/**
1866
		 * The parameters without the return type. Render after `name`.
P
Pine Wu 已提交
1867
		 */
1868
		parameters?: string;
P
Pine Wu 已提交
1869 1870

		/**
P
Pine Wu 已提交
1871
		 * The fully qualified name, like package name or file path. Rendered after `signature`.
P
Pine Wu 已提交
1872 1873
		 */
		qualifier?: string;
1874

P
Pine Wu 已提交
1875
		/**
P
Pine Wu 已提交
1876
		 * The return-type of a function or type of a property/variable. Rendered rightmost.
P
Pine Wu 已提交
1877
		 */
P
Pine Wu 已提交
1878
		type?: string;
1879 1880 1881 1882
	}

	//#endregion

1883
	//#region @eamodio - timeline: https://github.com/microsoft/vscode/issues/84297
1884 1885 1886

	export class TimelineItem {
		/**
1887
		 * A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred.
1888
		 */
E
Eric Amodio 已提交
1889
		timestamp: number;
1890 1891

		/**
1892
		 * A human-readable string describing the timeline item.
1893 1894 1895 1896
		 */
		label: string;

		/**
1897
		 * Optional id for the timeline item. It must be unique across all the timeline items provided by this source.
1898
		 *
1899
		 * If not provided, an id is generated using the timeline item's timestamp.
1900 1901 1902 1903
		 */
		id?: string;

		/**
1904
		 * The icon path or [ThemeIcon](#ThemeIcon) for the timeline item.
1905
		 */
R
rebornix 已提交
1906
		iconPath?: Uri | { light: Uri; dark: Uri; } | ThemeIcon;
1907 1908

		/**
1909
		 * A human readable string describing less prominent details of the timeline item.
1910 1911 1912 1913 1914 1915
		 */
		description?: string;

		/**
		 * The tooltip text when you hover over the timeline item.
		 */
1916
		detail?: string;
1917 1918 1919 1920 1921 1922 1923

		/**
		 * The [command](#Command) that should be executed when the timeline item is selected.
		 */
		command?: Command;

		/**
1924 1925 1926 1927 1928 1929 1930 1931 1932 1933 1934 1935 1936 1937 1938 1939
		 * 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`.
1940 1941 1942
		 */
		contextValue?: string;

1943 1944 1945 1946 1947
		/**
		 * Accessibility information used when screen reader interacts with this timeline item.
		 */
		accessibilityInformation?: AccessibilityInformation;

1948 1949
		/**
		 * @param label A human-readable string describing the timeline item
E
Eric Amodio 已提交
1950
		 * @param timestamp A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred
1951
		 */
E
Eric Amodio 已提交
1952
		constructor(label: string, timestamp: number);
1953 1954
	}

1955
	export interface TimelineChangeEvent {
E
Eric Amodio 已提交
1956
		/**
1957
		 * The [uri](#Uri) of the resource for which the timeline changed.
E
Eric Amodio 已提交
1958
		 */
E
Eric Amodio 已提交
1959
		uri: Uri;
1960

E
Eric Amodio 已提交
1961
		/**
1962
		 * A flag which indicates whether the entire timeline should be reset.
E
Eric Amodio 已提交
1963
		 */
1964 1965
		reset?: boolean;
	}
E
Eric Amodio 已提交
1966

1967 1968 1969
	export interface Timeline {
		readonly paging?: {
			/**
E
Eric Amodio 已提交
1970
			 * A provider-defined cursor specifying the starting point of timeline items which are after the ones returned.
E
Eric Amodio 已提交
1971
			 * Use `undefined` to signal that there are no more items to be returned.
1972
			 */
E
Eric Amodio 已提交
1973
			readonly cursor: string | undefined;
R
rebornix 已提交
1974
		};
E
Eric Amodio 已提交
1975 1976

		/**
1977
		 * An array of [timeline items](#TimelineItem).
E
Eric Amodio 已提交
1978
		 */
1979
		readonly items: readonly TimelineItem[];
E
Eric Amodio 已提交
1980 1981
	}

1982
	export interface TimelineOptions {
E
Eric Amodio 已提交
1983
		/**
E
Eric Amodio 已提交
1984
		 * A provider-defined cursor specifying the starting point of the timeline items that should be returned.
E
Eric Amodio 已提交
1985
		 */
1986
		cursor?: string;
E
Eric Amodio 已提交
1987 1988

		/**
1989 1990
		 * 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 已提交
1991
		 */
R
rebornix 已提交
1992
		limit?: number | { timestamp: number; id?: string; };
E
Eric Amodio 已提交
1993 1994
	}

1995
	export interface TimelineProvider {
1996
		/**
1997 1998
		 * 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`.
1999
		 */
E
Eric Amodio 已提交
2000
		onDidChange?: Event<TimelineChangeEvent | undefined>;
2001 2002

		/**
2003
		 * An identifier of the source of the timeline items. This can be used to filter sources.
2004
		 */
2005
		readonly id: string;
2006

E
Eric Amodio 已提交
2007
		/**
2008
		 * 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 已提交
2009
		 */
2010
		readonly label: string;
2011 2012

		/**
E
Eric Amodio 已提交
2013
		 * Provide [timeline items](#TimelineItem) for a [Uri](#Uri).
2014
		 *
2015
		 * @param uri The [uri](#Uri) of the file to provide the timeline for.
2016
		 * @param options A set of options to determine how results should be returned.
2017
		 * @param token A cancellation token.
E
Eric Amodio 已提交
2018
		 * @return The [timeline result](#TimelineResult) or a thenable that resolves to such. The lack of a result
2019 2020
		 * can be signaled by returning `undefined`, `null`, or an empty array.
		 */
2021
		provideTimeline(uri: Uri, options: TimelineOptions, token: CancellationToken): ProviderResult<Timeline>;
2022 2023 2024 2025 2026 2027 2028 2029 2030 2031
	}

	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.
		 *
2032
		 * @param scheme A scheme or schemes that defines which documents this provider is applicable to. Can be `*` to target all documents.
2033 2034
		 * @param provider A timeline provider.
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
E
Eric Amodio 已提交
2035
		*/
2036
		export function registerTimelineProvider(scheme: string | string[], provider: TimelineProvider): Disposable;
2037 2038 2039
	}

	//#endregion
2040

2041
	//#region https://github.com/microsoft/vscode/issues/91555
2042

2043 2044 2045 2046 2047 2048 2049 2050 2051 2052 2053 2054 2055
	export enum StandardTokenType {
		Other = 0,
		Comment = 1,
		String = 2,
		RegEx = 4
	}

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

	export namespace languages {
2056
		export function getTokenInformationAtPosition(document: TextDocument, position: Position): Thenable<TokenInformation>;
K
kingwl 已提交
2057 2058 2059 2060
	}

	//#endregion

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

J
Johannes Rieken 已提交
2063 2064
	// todo@API rename to InlayHint
	// todo@API add "mini-markdown" for links and styles
2065 2066
	// todo@API remove description
	// (done:)  add InlayHintKind with type, argument, etc
J
Johannes Rieken 已提交
2067

K
kingwl 已提交
2068
	export namespace languages {
K
kingwl 已提交
2069 2070 2071
		/**
		 * Register a inline hints provider.
		 *
J
Johannes Rieken 已提交
2072 2073 2074
		 * 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 已提交
2075 2076
		 *
		 * @param selector A selector that defines the documents this provider is applicable to.
J
Johannes Rieken 已提交
2077
		 * @param provider An inline hints provider.
K
kingwl 已提交
2078 2079 2080
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
		export function registerInlineHintsProvider(selector: DocumentSelector, provider: InlineHintsProvider): Disposable;
2081 2082
	}

2083 2084 2085 2086 2087 2088
	export enum InlineHintKind {
		Other = 0,
		Type = 1,
		Parameter = 2,
	}

K
kingwl 已提交
2089 2090 2091 2092 2093 2094 2095 2096 2097
	/**
	 * Inline hint information.
	 */
	export class InlineHint {
		/**
		 * The text of the hint.
		 */
		text: string;
		/**
K
kingwl 已提交
2098
		 * The range of the hint.
K
kingwl 已提交
2099 2100
		 */
		range: Range;
2101 2102 2103 2104

		kind?: InlineHintKind;

		// todo@API remove this
2105
		description?: string | MarkdownString;
K
kingwl 已提交
2106 2107 2108 2109 2110 2111 2112 2113 2114
		/**
		 * Whitespace before the hint.
		 */
		whitespaceBefore?: boolean;
		/**
		 * Whitespace after the hint.
		 */
		whitespaceAfter?: boolean;

2115
		// todo@API make range first argument
2116
		constructor(text: string, range: Range, kind?: InlineHintKind);
K
kingwl 已提交
2117 2118 2119
	}

	/**
J
Johannes Rieken 已提交
2120
	 * The inline hints provider interface defines the contract between extensions and
K
kingwl 已提交
2121 2122 2123
	 * the inline hints feature.
	 */
	export interface InlineHintsProvider {
W
Wenlu Wang 已提交
2124 2125 2126 2127 2128 2129

		/**
		 * An optional event to signal that inline hints have changed.
		 * @see [EventEmitter](#EventEmitter)
		 */
		onDidChangeInlineHints?: Event<void>;
J
Johannes Rieken 已提交
2130

K
kingwl 已提交
2131 2132
		/**
		 * @param model The document in which the command was invoked.
J
Johannes Rieken 已提交
2133
		 * @param range The range for which line hints should be computed.
K
kingwl 已提交
2134 2135 2136 2137 2138 2139
		 * @param token A cancellation token.
		 *
		 * @return A list of arguments labels or a thenable that resolves to such.
		 */
		provideInlineHints(model: TextDocument, range: Range, token: CancellationToken): ProviderResult<InlineHint[]>;
	}
2140
	//#endregion
2141

2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159
	//#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
2160 2161 2162 2163

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

	export interface TextDocument {
2164 2165 2166 2167 2168

		/**
		 * The [notebook](#NotebookDocument) that contains this document as a notebook cell or `undefined` when
		 * the document is not contained by a notebook (this should be the more frequent case).
		 */
2169 2170 2171
		notebook: NotebookDocument | undefined;
	}
	//#endregion
C
Connor Peet 已提交
2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182

	//#region https://github.com/microsoft/vscode/issues/107467
	/*
		General activation events:
			- `onLanguage:*` most test extensions will want to activate when their
				language is opened to provide code lenses.
			- `onTests:*` new activation event very simiular to `workspaceContains`,
				but only fired when the user wants to run tests or opens the test explorer.
	*/
	export namespace test {
		/**
C
Connor Peet 已提交
2183
		 * Registers a provider that discovers tests in workspaces and documents.
C
Connor Peet 已提交
2184 2185 2186 2187
		 */
		export function registerTestProvider<T extends TestItem>(testProvider: TestProvider<T>): Disposable;

		/**
2188 2189 2190 2191
		 * Runs tests. The "run" contains the list of tests to run as well as a
		 * method that can be used to update their state. At the point in time
		 * that "run" is called, all tests given in the run have their state
		 * automatically set to {@link TestRunState.Queued}.
C
Connor Peet 已提交
2192
		 */
C
Connor Peet 已提交
2193
		export function runTests<T extends TestItem>(run: TestRunRequest<T>, token?: CancellationToken): Thenable<void>;
C
Connor Peet 已提交
2194 2195 2196 2197 2198 2199 2200 2201 2202 2203

		/**
		 * Returns an observer that retrieves tests in the given workspace folder.
		 */
		export function createWorkspaceTestObserver(workspaceFolder: WorkspaceFolder): TestObserver;

		/**
		 * Returns an observer that retrieves tests in the given text document.
		 */
		export function createDocumentTestObserver(document: TextDocument): TestObserver;
2204

2205 2206 2207 2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218
		/**
		 * Inserts custom test results into the VS Code UI. The results are
		 * inserted and sorted based off the `completedAt` timestamp. If the
		 * results are being read from a file, for example, the `completedAt`
		 * time should generally be the modified time of the file if not more
		 * specific time is available.
		 *
		 * This will no-op if the inserted results are deeply equal to an
		 * existing result.
		 *
		 * @param results test results
		 * @param persist whether the test results should be saved by VS Code
		 * and persisted across reloads. Defaults to true.
		 */
C
Connor Peet 已提交
2219
		export function publishTestResult(results: TestRunResult, persist?: boolean): void;
2220

2221
		/**
2222 2223 2224
		* List of test results stored by VS Code, sorted in descnding
		* order by their `completedAt` time.
		*/
C
Connor Peet 已提交
2225
		export const testResults: ReadonlyArray<TestRunResult>;
2226 2227

		/**
2228 2229
		* Event that fires when the {@link testResults} array is updated.
		*/
2230 2231 2232
		export const onDidChangeTestResults: Event<void>;
	}

C
Connor Peet 已提交
2233 2234 2235 2236
	export interface TestObserver {
		/**
		 * List of tests returned by test provider for files in the workspace.
		 */
2237
		readonly tests: ReadonlyArray<TestItem>;
C
Connor Peet 已提交
2238 2239 2240 2241 2242 2243

		/**
		 * 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 已提交
2244
		readonly onDidChangeTest: Event<TestsChangeEvent>;
C
Connor Peet 已提交
2245 2246

		/**
C
Connor Peet 已提交
2247
		 * An event that fires when all test providers have signalled that the tests
C
Connor Peet 已提交
2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 2258 2259 2260 2261 2262
		 * the observer references have been discovered. Providers may continue to
		 * watch for changes and cause {@link onDidChangeTest} to fire as files
		 * change, until the observer is disposed.
		 *
		 * @todo as below
		 */
		readonly onDidDiscoverInitialTests: Event<void>;

		/**
		 * Dispose of the observer, allowing VS Code to eventually tell test
		 * providers that they no longer need to update tests.
		 */
		dispose(): void;
	}

C
Connor Peet 已提交
2263
	export interface TestsChangeEvent {
C
Connor Peet 已提交
2264 2265 2266
		/**
		 * List of all tests that are newly added.
		 */
2267
		readonly added: ReadonlyArray<TestItem>;
C
Connor Peet 已提交
2268 2269 2270 2271

		/**
		 * List of existing tests that have updated.
		 */
2272
		readonly updated: ReadonlyArray<TestItem>;
C
Connor Peet 已提交
2273 2274 2275 2276

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

C
Connor Peet 已提交
2280
	/**
2281
	 * Discovers and provides tests.
C
Connor Peet 已提交
2282 2283 2284 2285 2286 2287 2288 2289 2290
	 *
	 * Additionally, the UI may request it to discover tests for the workspace
	 * via `addWorkspaceTests`.
	 *
	 * @todo rename from provider
	 */
	export interface TestProvider<T extends TestItem = TestItem> {
		/**
		 * Requests that tests be provided for the given workspace. This will
2291 2292
		 * be called when tests need to be enumerated for the workspace, such as
		 * when the user opens the test explorer.
C
Connor Peet 已提交
2293 2294
		 *
		 * It's guaranteed that this method will not be called again while
C
Connor Peet 已提交
2295
		 * there is a previous uncancelled call for the given workspace folder.
2296 2297
		 *
		 * @param workspace The workspace in which to observe tests
2298
		 * @param cancellationToken Token that signals the used asked to abort the test run.
2299
		 * @returns the root test item for the workspace
C
Connor Peet 已提交
2300
		 */
2301
		provideWorkspaceTestRoot(workspace: WorkspaceFolder, token: CancellationToken): ProviderResult<T>;
C
Connor Peet 已提交
2302 2303

		/**
2304 2305 2306 2307 2308 2309 2310 2311 2312
		 * Requests that tests be provided for the given document. This will be
		 * called when tests need to be enumerated for a single open file, for
		 * instance by code lens UI.
		 *
		 * It's suggested that the provider listen to change events for the text
		 * document to provide information for test that might not yet be
		 * saved, if possible.
		 *
		 * If the test system is not able to provide or estimate for tests on a
2313 2314
		 * per-file basis, this method may not be implemented. In that case, the
		 * editor will request and use the information from the workspace tree.
2315 2316
		 *
		 * @param document The document in which to observe tests
2317
		 * @param cancellationToken Token that signals the used asked to abort the test run.
2318
		 * @returns the root test item for the workspace
C
Connor Peet 已提交
2319
		 */
2320
		provideDocumentTestRoot?(document: TextDocument, token: CancellationToken): ProviderResult<T>;
C
Connor Peet 已提交
2321 2322

		/**
2323 2324 2325
		 * @todo this will move out of the provider soon
		 * @todo this will eventually need to be able to return a summary report, coverage for example.
		 *
C
Connor Peet 已提交
2326 2327
		 * Starts a test run. This should cause {@link onDidChangeTest} to
		 * fire with update test states during the run.
2328 2329
		 * @param options Options for this test run
		 * @param cancellationToken Token that signals the used asked to abort the test run.
C
Connor Peet 已提交
2330
		 */
J
Johannes Rieken 已提交
2331
		// eslint-disable-next-line vscode-dts-provider-naming
C
Connor Peet 已提交
2332
		runTests(options: TestRunOptions<T>, token: CancellationToken): ProviderResult<void>;
C
Connor Peet 已提交
2333 2334 2335
	}

	/**
2336
	 * Options given to {@link test.runTests}.
C
Connor Peet 已提交
2337
	 */
C
Connor Peet 已提交
2338
	export interface TestRunRequest<T extends TestItem = TestItem> {
C
Connor Peet 已提交
2339 2340 2341 2342 2343 2344
		/**
		 * Array of specific tests to run. The {@link TestProvider.testRoot} may
		 * be provided as an indication to run all tests.
		 */
		tests: T[];

2345
		/**
2346 2347 2348
		 * An array of tests the user has marked as excluded in VS Code. May be
		 * omitted if no exclusions were requested. Test providers should not run
		 * excluded tests or any children of excluded tests.
2349 2350 2351
		 */
		exclude?: T[];

C
Connor Peet 已提交
2352 2353 2354 2355 2356 2357
		/**
		 * Whether or not tests in this run should be debugged.
		 */
		debug: boolean;
	}

2358
	/**
C
Connor Peet 已提交
2359
	 * Options given to {@link TestProvider.runTests}
2360
	 */
C
Connor Peet 已提交
2361
	export interface TestRunOptions<T extends TestItem = TestItem> extends TestRunRequest<T> {
2362 2363 2364
		/**
		 * Updates the state of the test in the run. By default, all tests involved
		 * in the run will have a "queued" state until they are updated by this method.
2365
		 *
C
Connor Peet 已提交
2366 2367
		 * Calling with method with nodes outside the {@link TestRunRequesttests}
		 * or in the {@link TestRunRequestexclude} array will no-op.
2368 2369 2370
		 *
		 * @param test The test to update
		 * @param state The state to assign to the test
C
Connor Peet 已提交
2371
		 * @param duration Optionally sets how long the test took to run
2372
		 */
C
Connor Peet 已提交
2373 2374 2375 2376 2377 2378 2379 2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390
		setState(test: T, state: TestResultState, duration?: number): void;

		/**
		 * Appends a message, such as an assertion error, to the test item.
		 *
		 * Calling with method with nodes outside the {@link TestRunRequesttests}
		 * or in the {@link TestRunRequestexclude} array will no-op.
		 *
		 * @param test The test to update
		 * @param state The state to assign to the test
		 *
		 */
		appendMessage(test: T, message: TestMessage): void;

		/**
		 * 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.
C
wip  
Connor Peet 已提交
2391 2392 2393
		 *
		 * @param output Output text to append
		 * @param associateTo Optionally, associate the given segment of output
C
Connor Peet 已提交
2394 2395
		 */
		appendOutput(output: string): void;
2396 2397
	}

2398 2399 2400 2401 2402 2403 2404 2405 2406 2407 2408 2409 2410 2411 2412 2413 2414 2415 2416 2417 2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428
	export interface TestChildrenCollection<T> extends Iterable<T> {
		/**
		 * Gets the number of children in the collection.
		 */
		readonly size: number;

		/**
		 * Gets an existing TestItem by its ID, if it exists.
		 * @param id ID of the test.
		 * @returns the TestItem instance if it exists.
		 */
		get(id: string): T | undefined;

		/**
		 * Adds a new child test item. No-ops if the test was already a child.
		 * @param child The test item to add.
		 */
		add(child: T): void;

		/**
		 * Removes the child test item by reference or ID from the collection.
		 * @param child Child ID or instance to remove.
		 */
		delete(child: T | string): void;

		/**
		 * Removes all children from the collection.
		 */
		clear(): void;
	}

C
Connor Peet 已提交
2429 2430 2431 2432
	/**
	 * 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.
	 */
2433
	export class TestItem<TChildren = any> {
C
Connor Peet 已提交
2434
		/**
2435 2436
		 * Unique identifier for the TestItem. This is used to correlate
		 * test results and tests in the document with those in the workspace
C
Connor Peet 已提交
2437
		 * (test explorer). This must not change for the lifetime of the TestItem.
C
Connor Peet 已提交
2438
		 */
2439
		readonly id: string;
C
Connor Peet 已提交
2440

2441
		/**
C
Connor Peet 已提交
2442
		 * URI this TestItem is associated with. May be a file or directory.
2443 2444 2445
		 */
		readonly uri: Uri;

2446 2447 2448 2449 2450 2451
		/**
		 * A set of children this item has. You can add new children to it, which
		 * will propagate to the editor UI.
		 */
		readonly children: TestChildrenCollection<TChildren>;

2452
		/**
2453
		 * Display name describing the test case.
2454
		 */
2455
		label: string;
2456

C
Connor Peet 已提交
2457 2458 2459 2460 2461
		/**
		 * Optional description that appears next to the label.
		 */
		description?: string;

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

C
Connor Peet 已提交
2468
		/**
C
Connor Peet 已提交
2469 2470
		 * Whether this test item can be run by providing it in the
		 * {@link TestRunRequest.tests} array. Defaults to `true`.
C
Connor Peet 已提交
2471
		 */
2472
		runnable: boolean;
C
Connor Peet 已提交
2473 2474

		/**
C
Connor Peet 已提交
2475 2476
		 * Whether this test item can be debugged by providing it in the
		 * {@link TestRunRequest.tests} array. Defaults to `false`.
C
Connor Peet 已提交
2477
		 */
2478
		debuggable: boolean;
C
Connor Peet 已提交
2479 2480

		/**
2481
		 * Whether this test item can be expanded in the tree view, implying it
C
Connor Peet 已提交
2482 2483
		 * has (or may have) children. If this is true, VS Code may call
		 * the {@link TestItem.discoverChildren} method.
C
Connor Peet 已提交
2484
		 */
2485
		expandable: boolean;
2486 2487

		/**
2488 2489 2490
		 * Creates a new TestItem instance.
		 * @param id Value of the "id" property
		 * @param label Value of the "label" property.
2491
		 * @param uri Value of the "uri" property.
C
Connor Peet 已提交
2492
		 * @param expandable Value of the "expandable" property.
2493
		 */
2494
		constructor(id: string, label: string, uri: Uri, expandable: boolean);
2495 2496 2497 2498

		/**
		 * 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
C
Connor Peet 已提交
2499
		 * automatically rerun after a short delay. Invoking this on a
2500 2501 2502 2503 2504 2505 2506 2507 2508 2509 2510 2511 2512 2513 2514 2515 2516 2517 2518 2519 2520 2521 2522 2523 2524 2525
		 * test with children will mark the entire subtree as outdated.
		 *
		 * Extensions should generally not override this method.
		 */
		invalidate(): void;

		/**
		 * Requests the children of the test item. Extensions should override this
		 * method for any test that can discover children.
		 *
		 * When called, the item should discover tests and update its's `children`.
		 * The provider will be marked as 'busy' when this method is called, and
		 * the provider should report `{ busy: false }` to {@link Progress.report}
		 * once discovery is complete.
		 *
		 * The item should continue watching for changes to the children and
		 * firing updates until the token is cancelled. The process of watching
		 * the tests may involve creating a file watcher, for example.
		 *
		 * The editor will only call this method when it's interested in refreshing
		 * the children of the item, and will not call it again while there's an
		 * existing, uncancelled discovery for an item.
		 *
		 * @param token Cancellation for the request. Cancellation will be
		 * requested if the test changes before the previous call completes.
		 * @returns a provider result of child test items
2526
		 */
2527
		discoverChildren(progress: Progress<{ busy: boolean }>, token: CancellationToken): void;
2528
	}
2529

2530 2531 2532
	/**
	 * Possible states of tests in a test run.
	 */
C
Connor Peet 已提交
2533
	export enum TestResultState {
C
Connor Peet 已提交
2534 2535
		// Initial state
		Unset = 0,
C
Connor Peet 已提交
2536 2537
		// Test will be run, but is not currently running.
		Queued = 1,
C
Connor Peet 已提交
2538
		// Test is currently running
C
Connor Peet 已提交
2539
		Running = 2,
C
Connor Peet 已提交
2540
		// Test run has passed
C
Connor Peet 已提交
2541
		Passed = 3,
C
Connor Peet 已提交
2542
		// Test run has failed (on an assertion)
C
Connor Peet 已提交
2543
		Failed = 4,
C
Connor Peet 已提交
2544
		// Test run has been skipped
C
Connor Peet 已提交
2545
		Skipped = 5,
C
Connor Peet 已提交
2546
		// Test run failed for some other reason (compilation error, timeout, etc)
C
Connor Peet 已提交
2547
		Errored = 6
C
Connor Peet 已提交
2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 2560 2561 2562 2563
	}

	/**
	 * 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.
	 */
2564
	export class TestMessage {
C
Connor Peet 已提交
2565 2566 2567 2568 2569 2570
		/**
		 * Human-readable message text to display.
		 */
		message: string | MarkdownString;

		/**
2571
		 * Message severity. Defaults to "Error".
C
Connor Peet 已提交
2572
		 */
2573
		severity: TestMessageSeverity;
C
Connor Peet 已提交
2574 2575

		/**
C
Connor Peet 已提交
2576
		 * Expected test output. If given with `actualOutput`, a diff view will be shown.
C
Connor Peet 已提交
2577 2578 2579 2580
		 */
		expectedOutput?: string;

		/**
C
Connor Peet 已提交
2581
		 * Actual test output. If given with `expectedOutput`, a diff view will be shown.
C
Connor Peet 已提交
2582 2583 2584 2585 2586 2587 2588
		 */
		actualOutput?: string;

		/**
		 * Associated file location.
		 */
		location?: Location;
2589 2590 2591 2592 2593 2594 2595 2596 2597 2598 2599 2600 2601 2602

		/**
		 * 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);
C
Connor Peet 已提交
2603
	}
2604

2605
	/**
C
Connor Peet 已提交
2606 2607
	 * TestResults can be provided to VS Code in {@link test.publishTestResult},
	 * or read from it in {@link test.testResults}.
2608 2609
	 *
	 * The results contain a 'snapshot' of the tests at the point when the test
C
Connor Peet 已提交
2610 2611 2612
	 * 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.
2613
	 *
2614
	 * @todo coverage and other info may eventually be provided here
2615
	 */
C
Connor Peet 已提交
2616
	export interface TestRunResult {
2617
		/**
C
Connor Peet 已提交
2618
		 * Unix milliseconds timestamp at which the test run was completed.
2619 2620 2621
		 */
		completedAt: number;

2622 2623 2624 2625 2626
		/**
		 * Optional raw output from the test run.
		 */
		output?: string;

2627 2628 2629 2630
		/**
		 * List of test results. The items in this array are the items that
		 * were passed in the {@link test.runTests} method.
		 */
2631
		results: ReadonlyArray<Readonly<TestResultSnapshot>>;
2632 2633 2634
	}

	/**
2635 2636
	 * A {@link TestItem}-like interface with an associated result, which appear
	 * or can be provided in {@link TestResult} interfaces.
2637
	 */
2638 2639 2640 2641 2642 2643 2644 2645
	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;

2646 2647 2648 2649 2650
		/**
		 * URI this TestItem is associated with. May be a file or file.
		 */
		readonly uri: Uri;

2651 2652 2653 2654 2655 2656 2657 2658 2659 2660 2661
		/**
		 * Display name describing the test case.
		 */
		readonly label: string;

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

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

2667 2668 2669
		/**
		 * Current result of the test.
		 */
C
Connor Peet 已提交
2670 2671 2672 2673 2674 2675 2676 2677 2678 2679 2680 2681 2682
		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>;
2683 2684 2685 2686

		/**
		 * Optional list of nested tests for this item.
		 */
2687
		readonly children: Readonly<TestResultSnapshot>[];
2688 2689
	}

C
Connor Peet 已提交
2690
	//#endregion
2691 2692 2693

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

2694 2695 2696
	/**
	 * Details if an `ExternalUriOpener` can open a uri.
	 *
2697 2698 2699 2700 2701 2702 2703
	 * 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.
	 *
	 * VS Code will try to use the best available opener, as sorted by `ExternalUriOpenerPriority`.
	 * If there are multiple potential "best" openers for a URI, then the user will be prompted
	 * to select an opener.
2704
	 */
M
Matt Bierner 已提交
2705
	export enum ExternalUriOpenerPriority {
2706
		/**
2707
		 * The opener is disabled and will never be shown to users.
M
Matt Bierner 已提交
2708
		 *
2709 2710
		 * Note that the opener can still be used if the user specifically
		 * configures it in their settings.
2711
		 */
M
Matt Bierner 已提交
2712
		None = 0,
2713 2714

		/**
2715 2716
		 * The opener can open the uri but will not cause a prompt on its own
		 * since VS Code always contributes a built-in `Default` opener.
2717
		 */
M
Matt Bierner 已提交
2718
		Option = 1,
2719 2720

		/**
M
Matt Bierner 已提交
2721 2722
		 * The opener can open the uri.
		 *
2723 2724
		 * VS Code's built-in opener has `Default` priority. This means that any additional `Default`
		 * openers will cause the user to be prompted to select from a list of all potential openers.
2725
		 */
M
Matt Bierner 已提交
2726 2727 2728
		Default = 2,

		/**
2729 2730
		 * The opener can open the uri and should be automatically selected over any
		 * default openers, include the built-in one from VS Code.
M
Matt Bierner 已提交
2731
		 *
2732
		 * A preferred opener will be automatically selected if no other preferred openers
2733
		 * are available. If multiple preferred openers are available, then the user
2734
		 * is shown a prompt with all potential openers (not just preferred openers).
M
Matt Bierner 已提交
2735 2736
		 */
		Preferred = 3,
2737 2738
	}

2739
	/**
M
Matt Bierner 已提交
2740
	 * Handles opening uris to external resources, such as http(s) links.
2741
	 *
M
Matt Bierner 已提交
2742
	 * Extensions can implement an `ExternalUriOpener` to open `http` links to a webserver
M
Matt Bierner 已提交
2743
	 * inside of VS Code instead of having the link be opened by the web browser.
2744 2745 2746 2747 2748 2749
	 *
	 * Currently openers may only be registered for `http` and `https` uris.
	 */
	export interface ExternalUriOpener {

		/**
2750
		 * Check if the opener can open a uri.
2751
		 *
M
Matt Bierner 已提交
2752 2753 2754
		 * @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.
2755
		 *
2756
		 * @return Priority indicating if the opener can open the external uri.
M
Matt Bierner 已提交
2757
		 */
M
Matt Bierner 已提交
2758
		canOpenExternalUri(uri: Uri, token: CancellationToken): ExternalUriOpenerPriority | Thenable<ExternalUriOpenerPriority>;
M
Matt Bierner 已提交
2759 2760

		/**
2761
		 * Open a uri.
2762
		 *
M
Matt Bierner 已提交
2763
		 * This is invoked when:
2764
		 *
M
Matt Bierner 已提交
2765 2766 2767
		 * - 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.
2768
		 *
M
Matt Bierner 已提交
2769 2770 2771 2772 2773 2774
		 * @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.
		 *
2775
		 * @return Thenable indicating that the opening has completed.
M
Matt Bierner 已提交
2776 2777 2778 2779 2780 2781 2782 2783 2784 2785
		 */
		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.
2786
		 *
2787
		 * This is the original uri that the user clicked on or that was passed to `openExternal.`
M
Matt Bierner 已提交
2788
		 * Due to port forwarding, this may not match the `resolvedUri` passed to `openExternalUri`.
2789
		 */
M
Matt Bierner 已提交
2790 2791 2792
		readonly sourceUri: Uri;
	}

M
Matt Bierner 已提交
2793
	/**
2794
	 * Additional metadata about a registered `ExternalUriOpener`.
M
Matt Bierner 已提交
2795
	 */
M
Matt Bierner 已提交
2796
	interface ExternalUriOpenerMetadata {
M
Matt Bierner 已提交
2797

M
Matt Bierner 已提交
2798 2799 2800 2801 2802 2803 2804
		/**
		 * List of uri schemes the opener is triggered for.
		 *
		 * Currently only `http` and `https` are supported.
		 */
		readonly schemes: readonly string[]

M
Matt Bierner 已提交
2805 2806
		/**
		 * Text displayed to the user that explains what the opener does.
2807
		 *
M
Matt Bierner 已提交
2808
		 * For example, 'Open in browser preview'
2809
		 */
M
Matt Bierner 已提交
2810
		readonly label: string;
2811 2812 2813 2814 2815 2816
	}

	namespace window {
		/**
		 * Register a new `ExternalUriOpener`.
		 *
2817
		 * When a uri is about to be opened, an `onOpenExternalUri:SCHEME` activation event is fired.
2818
		 *
M
Matt Bierner 已提交
2819 2820
		 * @param id Unique id of the opener, such as `myExtension.browserPreview`. This is used in settings
		 *   and commands to identify the opener.
2821
		 * @param opener Opener to register.
M
Matt Bierner 已提交
2822
		 * @param metadata Additional information about the opener.
2823 2824
		 *
		* @returns Disposable that unregisters the opener.
M
Matt Bierner 已提交
2825 2826
		*/
		export function registerExternalUriOpener(id: string, opener: ExternalUriOpener, metadata: ExternalUriOpenerMetadata): Disposable;
2827 2828
	}

2829 2830
	interface OpenExternalOptions {
		/**
2831 2832
		 * Allows using openers contributed by extensions through  `registerExternalUriOpener`
		 * when opening the resource.
2833
		 *
2834
		 * If `true`, VS Code will check if any contributed openers can handle the
2835 2836
		 * uri, and fallback to the default opener behavior.
		 *
2837
		 * If it is string, this specifies the id of the `ExternalUriOpener`
2838 2839 2840 2841 2842 2843 2844 2845 2846 2847
		 * that should be used if it is available. Use `'default'` to force VS Code's
		 * standard external opener to be used.
		 */
		readonly allowContributedOpeners?: boolean | string;
	}

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

J
Johannes Rieken 已提交
2848
	//#endregion
2849 2850 2851 2852 2853 2854 2855 2856 2857 2858 2859 2860 2861 2862 2863 2864 2865

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

	// TODO@API must be a class
	export interface OpenEditorInfo {
		name: string;
		resource: Uri;
	}

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

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

	//#endregion
2866

2867
	//#region https://github.com/microsoft/vscode/issues/120173
L
Ladislau Szomoru 已提交
2868 2869 2870
	/**
	 * The object describing the properties of the workspace trust request
	 */
2871
	export interface WorkspaceTrustRequestOptions {
L
Ladislau Szomoru 已提交
2872 2873
		/**
		 * When true, a modal dialog will be used to request workspace trust.
S
SteVen Batten 已提交
2874
		 * When false, a badge will be displayed on the settings gear activity bar item.
L
Ladislau Szomoru 已提交
2875
		 */
L
Ladislau Szomoru 已提交
2876
		readonly modal: boolean;
L
Ladislau Szomoru 已提交
2877 2878
	}

2879 2880
	export namespace workspace {
		/**
S
SteVen Batten 已提交
2881
		 * When true, the user has explicitly trusted the contents of the workspace.
2882
		 */
S
SteVen Batten 已提交
2883
		export const isTrusted: boolean;
2884 2885 2886

		/**
		 * Prompt the user to chose whether to trust the current workspace
2887
		 * @param options Optional object describing the properties of the
S
SteVen Batten 已提交
2888
		 * workspace trust request. Defaults to { modal: false }
2889
		 */
S
SteVen Batten 已提交
2890
		export function requestWorkspaceTrust(options?: WorkspaceTrustRequestOptions): Thenable<boolean>;
2891 2892

		/**
S
SteVen Batten 已提交
2893
		 * Event that fires when the current workspace has been trusted.
2894
		 */
S
SteVen Batten 已提交
2895
		export const onDidReceiveWorkspaceTrust: Event<void>;
2896 2897 2898
	}

	//#endregion
2899

2900 2901 2902 2903 2904 2905 2906 2907 2908 2909 2910
	//#region https://github.com/microsoft/vscode/issues/115807

	export interface Webview {
		/**
		 * @param message A json serializable message to send to the webview.
		 *
		 *   For older versions of vscode, if an `ArrayBuffer` is included in `message`,
		 *   it will not be serialized properly and will not be received by the webview.
		 *   Similarly any TypedArrays, such as a `Uint8Array`, will be very inefficiently
		 *   serialized and will also not be recreated as a typed array inside the webview.
		 *
2911
		 *   However if your extension targets vscode 1.56+ in the `engines` field of its
2912 2913 2914 2915 2916 2917 2918
		 *   `package.json` any `ArrayBuffer` values that appear in `message` will be more
		 *   efficiently transferred to the webview and will also be recreated inside of
		 *   the webview.
		 */
		postMessage(message: any): Thenable<boolean>;
	}

2919
	//#endregion
2920 2921 2922 2923 2924 2925 2926 2927 2928 2929 2930 2931 2932 2933 2934 2935

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

	export interface PortAttributes {
		port: number;
		autoForwardAction: PortAutoForwardAction
	}

	export interface PortAttributesProvider {
2936
		/**
2937 2938 2939
		 * 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.
2940
		 */
2941
		providePortAttributes(port: number, pid: number | undefined, commandLine: string | undefined, token: CancellationToken): ProviderResult<PortAttributes>;
2942 2943 2944 2945 2946 2947 2948 2949 2950 2951
	}

	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
		 * this information with a PortAttributesProvider the extension can tell VS Code that these ports should be
		 * 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
2952 2953
		 * 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.
2954
		 * The `portRange` is start inclusive and end exclusive.
2955 2956
		 * @param provider The PortAttributesProvider
		 */
2957
		export function registerPortAttributesProvider(portSelector: { pid?: number, portRange?: [number, number], commandMatcher?: RegExp }, provider: PortAttributesProvider): Disposable;
2958 2959
	}
	//#endregion
2960 2961 2962 2963 2964 2965 2966 2967 2968 2969 2970 2971

	// region https://github.com/microsoft/vscode/issues/119904 @eamodio

	export interface SourceControlInputBox {

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

	//#endregion
J
Johannes Rieken 已提交
2972
}