vscode.proposed.d.ts 80.8 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 37 38
	/**
	* An [event](#Event) which fires when an [AuthenticationSession](#AuthenticationSession) is added, removed, or changed.
	*/
39
	export interface AuthenticationProviderAuthenticationSessionsChangeEvent {
40 41 42
		/**
		 * The ids of the [AuthenticationSession](#AuthenticationSession)s that have been added.
		*/
43
		readonly added: ReadonlyArray<string>;
44 45 46 47

		/**
		 * The ids of the [AuthenticationSession](#AuthenticationSession)s that have been removed.
		 */
48
		readonly removed: ReadonlyArray<string>;
49 50 51 52

		/**
		 * The ids of the [AuthenticationSession](#AuthenticationSession)s that have been changed.
		 */
53
		readonly changed: ReadonlyArray<string>;
54 55
	}

56
	/**
57
	 * A provider for performing authentication to a service.
58
	 */
59
	export interface AuthenticationProvider {
60
		/**
61
		 * An [event](#Event) which fires when the array of sessions has changed, or data
62 63
		 * within a session has changed.
		 */
64
		readonly onDidChangeSessions: Event<AuthenticationProviderAuthenticationSessionsChangeEvent>;
65

66 67 68
		/**
		 * Returns an array of current sessions.
		 */
J
Johannes Rieken 已提交
69
		// eslint-disable-next-line vscode-dts-provider-naming
70
		getSessions(): Thenable<ReadonlyArray<AuthenticationSession>>;
71

72 73 74
		/**
		 * Prompts a user to login.
		 */
J
Johannes Rieken 已提交
75
		// eslint-disable-next-line vscode-dts-provider-naming
76
		login(scopes: string[]): Thenable<AuthenticationSession>;
77 78 79 80 81

		/**
		 * Removes the session corresponding to session id.
		 * @param sessionId The session id to log out of
		 */
J
Johannes Rieken 已提交
82
		// eslint-disable-next-line vscode-dts-provider-naming
83
		logout(sessionId: string): Thenable<void>;
84 85
	}

86 87 88 89 90 91 92 93 94 95 96
	/**
	 * Options for creating an [AuthenticationProvider](#AuthentcationProvider).
	 */
	export interface AuthenticationProviderOptions {
		/**
		 * Whether it is possible to be signed into multiple accounts at once with this provider.
		 * If not specified, will default to false.
		*/
		readonly supportsMultipleAccounts?: boolean;
	}

97
	export namespace authentication {
98 99 100 101
		/**
		 * Register an authentication provider.
		 *
		 * There can only be one provider per id and an error is being thrown when an id
102
		 * has already been used by another provider. Ids are case-sensitive.
103
		 *
104 105
		 * @param id The unique identifier of the provider.
		 * @param label The human-readable name of the provider.
106
		 * @param provider The authentication provider provider.
107
		 * @params options Additional options for the provider.
108 109
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
110
		export function registerAuthenticationProvider(id: string, label: string, provider: AuthenticationProvider, options?: AuthenticationProviderOptions): Disposable;
111 112

		/**
113
		 * @deprecated - getSession should now trigger extension activation.
114 115
		 * Fires with the provider id that was registered or unregistered.
		 */
116
		export const onDidChangeAuthenticationProviders: Event<AuthenticationProvidersChangeEvent>;
117

118
		/**
119 120 121
		 * An array of the information of authentication providers that are currently registered.
		 */
		export const providers: ReadonlyArray<AuthenticationProviderInformation>;
122

123 124 125 126 127 128 129
		/**
		* Logout of a specific session.
		* @param providerId The id of the provider to use
		* @param sessionId The session id to remove
		* provider
		*/
		export function logout(providerId: string, sessionId: string): Thenable<void>;
130 131
	}

J
Johannes Rieken 已提交
132 133
	//#endregion

134
	// eslint-disable-next-line vscode-dts-region-comments
A
Alex Ross 已提交
135
	//#region @alexdima - resolvers
A
Alex Dima 已提交
136

137 138 139 140 141 142 143
	export interface MessageOptions {
		/**
		 * Do not render a native message box.
		 */
		useCustom?: boolean;
	}

A
Tweaks  
Alex Dima 已提交
144 145 146 147
	export interface RemoteAuthorityResolverContext {
		resolveAttempt: number;
	}

A
Alex Dima 已提交
148 149 150
	export class ResolvedAuthority {
		readonly host: string;
		readonly port: number;
151
		readonly connectionToken: string | undefined;
A
Alex Dima 已提交
152

153
		constructor(host: string, port: number, connectionToken?: string);
A
Alex Dima 已提交
154 155
	}

156
	export interface ResolvedOptions {
R
rebornix 已提交
157
		extensionHostEnv?: { [key: string]: string | null; };
158 159
	}

160
	export interface TunnelOptions {
R
rebornix 已提交
161
		remoteAddress: { port: number, host: string; };
A
Alex Ross 已提交
162 163 164
		// The desired local port. If this port can't be used, then another will be chosen.
		localAddressPort?: number;
		label?: string;
165
		public?: boolean;
166 167
	}

A
Alex Ross 已提交
168
	export interface TunnelDescription {
R
rebornix 已提交
169
		remoteAddress: { port: number, host: string; };
A
Alex Ross 已提交
170
		//The complete local address(ex. localhost:1234)
R
rebornix 已提交
171
		localAddress: { port: number, host: string; } | string;
172
		public?: boolean;
A
Alex Ross 已提交
173 174 175
	}

	export interface Tunnel extends TunnelDescription {
A
Alex Ross 已提交
176 177
		// Implementers of Tunnel should fire onDidDispose when dispose is called.
		onDidDispose: Event<void>;
178
		dispose(): void | Thenable<void>;
179 180 181
	}

	/**
182 183
	 * Used as part of the ResolverResult if the extension has any candidate,
	 * published, or forwarded ports.
184 185 186 187
	 */
	export interface TunnelInformation {
		/**
		 * Tunnels that are detected by the extension. The remotePort is used for display purposes.
A
Alex Ross 已提交
188
		 * The localAddress should be the complete local address (ex. localhost:1234) for connecting to the port. Tunnels provided through
189 190
		 * detected are read-only from the forwarded ports UI.
		 */
A
Alex Ross 已提交
191
		environmentTunnels?: TunnelDescription[];
A
Alex Ross 已提交
192

193 194
	}

195
	export interface TunnelCreationOptions {
196 197 198 199 200 201
		/**
		 * True when the local operating system will require elevation to use the requested local port.
		 */
		elevationRequired?: boolean;
	}

202
	export type ResolverResult = ResolvedAuthority & ResolvedOptions & TunnelInformation;
203

A
Tweaks  
Alex Dima 已提交
204 205 206 207 208 209 210
	export class RemoteAuthorityResolverError extends Error {
		static NotAvailable(message?: string, handled?: boolean): RemoteAuthorityResolverError;
		static TemporarilyNotAvailable(message?: string): RemoteAuthorityResolverError;

		constructor(message?: string);
	}

A
Alex Dima 已提交
211
	export interface RemoteAuthorityResolver {
212
		resolve(authority: string, context: RemoteAuthorityResolverContext): ResolverResult | Thenable<ResolverResult>;
213 214 215 216
		/**
		 * 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.
217 218 219
		 *
		 * 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.
220
		 */
221
		tunnelFactory?: (tunnelOptions: TunnelOptions, tunnelCreationOptions: TunnelCreationOptions) => Thenable<Tunnel> | undefined;
222

223
		/**p
224 225 226
		 * Provides filtering for candidate ports.
		 */
		showCandidatePort?: (host: string, port: number, detail: string) => Thenable<boolean>;
227 228 229 230 231 232 233

		/**
		 * Lets the resolver declare which tunnel factory features it supports.
		 * UNDER DISCUSSION! MAY CHANGE SOON.
		 */
		tunnelFeatures?: {
			elevation: boolean;
234
			public: boolean;
235
		};
236 237 238 239
	}

	export namespace workspace {
		/**
240
		 * Forwards a port. If the current resolver implements RemoteAuthorityResolver:forwardPort then that will be used to make the tunnel.
A
Alex Ross 已提交
241
		 * By default, openTunnel only support localhost; however, RemoteAuthorityResolver:tunnelFactory can be used to support other ips.
242 243 244
		 *
		 * @throws When run in an environment without a remote.
		 *
A
Alex Ross 已提交
245
		 * @param tunnelOptions The `localPort` is a suggestion only. If that port is not available another will be chosen.
246
		 */
A
Alex Ross 已提交
247
		export function openTunnel(tunnelOptions: TunnelOptions): Thenable<Tunnel>;
248 249 250 251 252 253

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

255 256 257 258
		/**
		 * Fired when the list of tunnels has changed.
		 */
		export const onDidChangeTunnels: Event<void>;
A
Alex Dima 已提交
259 260
	}

261 262 263 264 265 266 267 268
	export interface ResourceLabelFormatter {
		scheme: string;
		authority?: string;
		formatting: ResourceLabelFormatting;
	}

	export interface ResourceLabelFormatting {
		label: string; // myLabel:/${path}
I
isidor 已提交
269
		// 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 已提交
270
		// eslint-disable-next-line vscode-dts-literal-or-types
271 272 273 274 275
		separator: '/' | '\\' | '';
		tildify?: boolean;
		normalizeDriveLetter?: boolean;
		workspaceSuffix?: string;
		authorityPrefix?: string;
276
		stripPathStartingSeparator?: boolean;
277 278
	}

A
Alex Dima 已提交
279 280
	export namespace workspace {
		export function registerRemoteAuthorityResolver(authorityPrefix: string, resolver: RemoteAuthorityResolver): Disposable;
281
		export function registerResourceLabelFormatter(formatter: ResourceLabelFormatter): Disposable;
282
	}
283

284 285
	//#endregion

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

288 289
	export interface WebviewEditorInset {
		readonly editor: TextEditor;
290 291
		readonly line: number;
		readonly height: number;
292 293 294
		readonly webview: Webview;
		readonly onDidDispose: Event<void>;
		dispose(): void;
295 296
	}

297
	export namespace window {
298
		export function createWebviewTextEditorInset(editor: TextEditor, line: number, height: number, options?: WebviewOptions): WebviewEditorInset;
A
Alex Dima 已提交
299 300 301 302
	}

	//#endregion

J
Johannes Rieken 已提交
303
	//#region read/write in chunks: https://github.com/microsoft/vscode/issues/84515
304 305

	export interface FileSystemProvider {
R
rebornix 已提交
306
		open?(resource: Uri, options: { create: boolean; }): number | Thenable<number>;
307 308 309 310 311 312 313
		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 已提交
314
	//#region TextSearchProvider: https://github.com/microsoft/vscode/issues/59921
315

316 317 318
	/**
	 * The parameters of a query for text search.
	 */
319
	export interface TextSearchQuery {
320 321 322
		/**
		 * The text pattern to search for.
		 */
323
		pattern: string;
324

R
Rob Lourens 已提交
325 326 327 328 329
		/**
		 * Whether or not `pattern` should match multiple lines of text.
		 */
		isMultiline?: boolean;

330 331 332
		/**
		 * Whether or not `pattern` should be interpreted as a regular expression.
		 */
R
Rob Lourens 已提交
333
		isRegExp?: boolean;
334 335 336 337

		/**
		 * Whether or not the search should be case-sensitive.
		 */
R
Rob Lourens 已提交
338
		isCaseSensitive?: boolean;
339 340 341 342

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

346 347
	/**
	 * A file glob pattern to match file paths against.
348
	 * TODO@roblourens merge this with the GlobPattern docs/definition in vscode.d.ts.
349 350 351 352 353 354 355
	 * @see [GlobPattern](#GlobPattern)
	 */
	export type GlobString = string;

	/**
	 * Options common to file and text search
	 */
R
Rob Lourens 已提交
356
	export interface SearchOptions {
357 358 359
		/**
		 * The root folder to search within.
		 */
360
		folder: Uri;
361 362 363 364 365 366 367 368 369 370 371 372 373 374 375

		/**
		 * 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 已提交
376
		useIgnoreFiles: boolean;
377 378 379 380 381

		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
382
		followSymlinks: boolean;
P
pkoushik 已提交
383 384 385 386 387 388

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

R
Rob Lourens 已提交
391 392
	/**
	 * Options to specify the size of the result text preview.
R
Rob Lourens 已提交
393
	 * These options don't affect the size of the match itself, just the amount of preview text.
R
Rob Lourens 已提交
394
	 */
395
	export interface TextSearchPreviewOptions {
396
		/**
R
Rob Lourens 已提交
397
		 * The maximum number of lines in the preview.
R
Rob Lourens 已提交
398
		 * Only search providers that support multiline search will ever return more than one line in the match.
399
		 */
R
Rob Lourens 已提交
400
		matchLines: number;
R
Rob Lourens 已提交
401 402 403 404

		/**
		 * The maximum number of characters included per line.
		 */
R
Rob Lourens 已提交
405
		charsPerLine: number;
406 407
	}

408 409 410
	/**
	 * Options that apply to text search.
	 */
R
Rob Lourens 已提交
411
	export interface TextSearchOptions extends SearchOptions {
412
		/**
413
		 * The maximum number of results to be returned.
414
		 */
415 416
		maxResults: number;

R
Rob Lourens 已提交
417 418 419
		/**
		 * Options to specify the size of the result text preview.
		 */
420
		previewOptions?: TextSearchPreviewOptions;
421 422 423 424

		/**
		 * Exclude files larger than `maxFileSize` in bytes.
		 */
425
		maxFileSize?: number;
426 427 428 429 430

		/**
		 * Interpret files using this encoding.
		 * See the vscode setting `"files.encoding"`
		 */
431
		encoding?: string;
432 433 434 435 436 437 438 439 440 441

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

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

444 445 446 447 448 449 450 451 452 453 454 455 456 457
	/**
	 * 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 已提交
458 459 460
	/**
	 * A preview of the text result.
	 */
461
	export interface TextSearchMatchPreview {
462
		/**
R
Rob Lourens 已提交
463
		 * The matching lines of text, or a portion of the matching line that contains the match.
464 465 466 467 468
		 */
		text: string;

		/**
		 * The Range within `text` corresponding to the text of the match.
469
		 * The number of matches must match the TextSearchMatch's range property.
470
		 */
471
		matches: Range | Range[];
472 473 474 475 476
	}

	/**
	 * A match from a text search
	 */
477
	export interface TextSearchMatch {
478 479 480
		/**
		 * The uri for the matching document.
		 */
481
		uri: Uri;
482 483

		/**
484
		 * The range of the match within the document, or multiple ranges for multiple matches.
485
		 */
486
		ranges: Range | Range[];
R
Rob Lourens 已提交
487

488
		/**
489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510
		 * 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.
511
		 */
512
		lineNumber: number;
513 514
	}

515 516
	export type TextSearchResult = TextSearchMatch | TextSearchContext;

R
Rob Lourens 已提交
517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560
	/**
	 * 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;
	}

561
	/**
R
Rob Lourens 已提交
562 563 564 565 566 567 568
	 * 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.
569
	 */
570
	export interface FileSearchProvider {
571 572 573 574 575 576
		/**
		 * 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.
		 */
577
		provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, token: CancellationToken): ProviderResult<Uri[]>;
578
	}
579

R
Rob Lourens 已提交
580
	export namespace workspace {
581
		/**
R
Rob Lourens 已提交
582 583 584 585 586 587 588
		 * 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.
589
		 */
R
Rob Lourens 已提交
590 591 592 593 594 595 596 597 598 599 600 601
		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;
602 603
	}

R
Rob Lourens 已提交
604 605 606 607
	//#endregion

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

608 609 610
	/**
	 * Options that can be set on a findTextInFiles search.
	 */
R
Rob Lourens 已提交
611
	export interface FindTextInFilesOptions {
612 613 614 615 616
		/**
		 * 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).
		 */
617
		include?: GlobPattern;
618 619 620

		/**
		 * A [glob pattern](#GlobPattern) that defines files and folders to exclude. The glob pattern
621 622
		 * will be matched against the file paths of resulting matches relative to their workspace. When `undefined`, default excludes will
		 * apply.
623
		 */
624 625 626 627
		exclude?: GlobPattern;

		/**
		 * Whether to use the default and user-configured excludes. Defaults to true.
628
		 */
629
		useDefaultExcludes?: boolean;
630 631 632 633

		/**
		 * The maximum number of results to search for
		 */
R
Rob Lourens 已提交
634
		maxResults?: number;
635 636 637 638 639

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

P
pkoushik 已提交
642 643 644 645
		/**
		 * Whether global files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useGlobalIgnoreFiles"`.
		 */
646
		useGlobalIgnoreFiles?: boolean;
P
pkoushik 已提交
647

648 649 650 651
		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
652
		followSymlinks?: boolean;
653 654 655 656 657

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

R
Rob Lourens 已提交
660 661 662
		/**
		 * Options to specify the size of the result text preview.
		 */
663
		previewOptions?: TextSearchPreviewOptions;
664 665 666 667 668 669 670 671 672 673

		/**
		 * 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 已提交
674 675
	}

676
	export namespace workspace {
677 678 679 680 681 682 683
		/**
		 * 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.
		 */
684
		export function findTextInFiles(query: TextSearchQuery, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
685 686 687 688 689 690 691 692 693

		/**
		 * 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.
		 */
694
		export function findTextInFiles(query: TextSearchQuery, options: FindTextInFilesOptions, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
695 696
	}

J
Johannes Rieken 已提交
697
	//#endregion
698

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

J
Joao Moreno 已提交
701 702 703
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
704 705 706 707 708 709 710
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728
	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;
	}
729

J
Johannes Rieken 已提交
730 731
	//#endregion

732
	// eslint-disable-next-line vscode-dts-region-comments
733
	//#region debug
734

735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750
	/**
	 * 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 已提交
751 752
	//#endregion

753
	// eslint-disable-next-line vscode-dts-region-comments
754
	//#region @joaomoreno: SCM validation
755

J
Joao Moreno 已提交
756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800
	/**
	 * 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 {

		/**
		 * A validation function for the input box. It's possible to change
		 * the validation provider simply by setting this property to a different function.
		 */
		validateInput?(value: string, cursorPosition: number): ProviderResult<SourceControlInputBoxValidation | undefined | null>;
	}
M
Matt Bierner 已提交
801

J
Johannes Rieken 已提交
802 803
	//#endregion

804
	// eslint-disable-next-line vscode-dts-region-comments
805
	//#region @joaomoreno: SCM selected provider
806 807 808 809 810 811 812 813 814 815 816 817

	export interface SourceControl {

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

		/**
		 * An event signaling when the selection state changes.
		 */
		readonly onDidChangeSelection: Event<boolean>;
818 819 820 821
	}

	//#endregion

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

824 825 826 827 828 829 830 831 832 833 834
	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 已提交
835 836
	namespace window {
		/**
D
Daniel Imms 已提交
837 838 839
		 * 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 已提交
840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860
		 */
		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;
	}
861

D
Daniel Imms 已提交
862
	export namespace window {
D
Daniel Imms 已提交
863 864 865 866 867 868 869
		/**
		 * An event which fires when the [dimensions](#Terminal.dimensions) of the terminal change.
		 */
		export const onDidChangeTerminalDimensions: Event<TerminalDimensionsChangeEvent>;
	}

	export interface Terminal {
870
		/**
871 872 873
		 * 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.
874
		 */
875
		readonly dimensions: TerminalDimensions | undefined;
D
Daniel Imms 已提交
876 877
	}

878 879
	//#endregion

880
	// eslint-disable-next-line vscode-dts-region-comments
881
	//#region @jrieken -> exclusive document filters
882 883

	export interface DocumentFilter {
884
		readonly exclusive?: boolean;
885 886 887
	}

	//#endregion
C
Christof Marti 已提交
888

889
	//#region Tree View: https://github.com/microsoft/vscode/issues/61313 @alexr00
890
	export interface TreeView<T> extends Disposable {
891
		reveal(element: T | undefined, options?: { select?: boolean, focus?: boolean, expand?: boolean | number; }): Thenable<void>;
892
	}
893
	//#endregion
894

895
	//#region Task presentation group: https://github.com/microsoft/vscode/issues/47265
896 897 898 899 900 901 902
	export interface TaskPresentationOptions {
		/**
		 * Controls whether the task is executed in a specific terminal group using split panes.
		 */
		group?: string;
	}
	//#endregion
903

904
	//#region Status bar item with ID and Name: https://github.com/microsoft/vscode/issues/74972
905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926

	export namespace window {

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

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

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

932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955
			/**
			 * 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;
		}

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

957
	//#region Custom editor move https://github.com/microsoft/vscode/issues/86146
958

959
	// TODO: Also for custom editor
960

961
	export interface CustomTextEditorProvider {
M
Matt Bierner 已提交
962

963 964 965 966 967 968 969 970
		/**
		 * 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.
971
		 * @param token A cancellation token that indicates the result is no longer needed.
972 973 974
		 *
		 * @return Thenable indicating that the webview editor has been moved.
		 */
J
Johannes Rieken 已提交
975
		// eslint-disable-next-line vscode-dts-provider-naming
976
		moveCustomTextEditor?(newDocument: TextDocument, existingWebviewPanel: WebviewPanel, token: CancellationToken): Thenable<void>;
977 978 979
	}

	//#endregion
980

J
Johannes Rieken 已提交
981
	//#region allow QuickPicks to skip sorting: https://github.com/microsoft/vscode/issues/73904
P
Peter Elmers 已提交
982 983 984

	export interface QuickPick<T extends QuickPickItem> extends QuickInput {
		/**
985 986
		 * An optional flag to sort the final results by index of first query match in label. Defaults to true.
		 */
P
Peter Elmers 已提交
987 988 989 990
		sortByLabel: boolean;
	}

	//#endregion
M
Matt Bierner 已提交
991

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

R
rebornix 已提交
994 995 996 997 998
	export enum CellKind {
		Markdown = 1,
		Code = 2
	}

R
Rob Lourens 已提交
999 1000 1001 1002 1003 1004 1005
	export enum NotebookCellRunState {
		Running = 1,
		Idle = 2,
		Success = 3,
		Error = 4
	}

R
Rob Lourens 已提交
1006 1007 1008 1009 1010
	export enum NotebookRunState {
		Running = 1,
		Idle = 2
	}

J
Johannes Rieken 已提交
1011 1012
	// TODO@API
	// make this a class, allow modified using with-pattern
R
rebornix 已提交
1013
	export interface NotebookCellMetadata {
1014
		/**
1015
		 * Controls whether a cell's editor is editable/readonly.
1016
		 */
R
rebornix 已提交
1017
		editable?: boolean;
R
rebornix 已提交
1018

1019 1020 1021 1022 1023 1024
		/**
		 * Controls if the cell has a margin to support the breakpoint UI.
		 * This metadata is ignored for markdown cell.
		 */
		breakpointMargin?: boolean;

1025 1026 1027 1028 1029 1030 1031 1032 1033 1034
		/**
		 * Whether a code cell's editor is collapsed
		 */
		inputCollapsed?: boolean;

		/**
		 * Whether a code cell's outputs are collapsed
		 */
		outputCollapsed?: boolean;

R
rebornix 已提交
1035 1036 1037
		/**
		 * Additional attributes of a cell metadata.
		 */
1038
		custom?: { [key: string]: any; };
R
rebornix 已提交
1039 1040
	}

1041
	// todo@API support ids https://github.com/jupyter/enhancement-proposals/blob/master/62-cell-id/cell-id.md
R
rebornix 已提交
1042
	export interface NotebookCell {
1043
		readonly index: number;
1044
		readonly notebook: NotebookDocument;
1045
		readonly uri: Uri;
R
rebornix 已提交
1046
		readonly cellKind: CellKind;
1047
		readonly document: TextDocument;
1048
		readonly language: string;
R
rebornix 已提交
1049
		readonly outputs: readonly NotebookCellOutput[];
1050
		readonly metadata: NotebookCellMetadata;
J
Johannes Rieken 已提交
1051
		/** @deprecated use WorkspaceEdit.replaceCellOutput */
1052
		// outputs: CellOutput[];
J
Johannes Rieken 已提交
1053
		// readonly outputs2: NotebookCellOutput[];
J
Johannes Rieken 已提交
1054
		/** @deprecated use WorkspaceEdit.replaceCellMetadata */
1055
		// metadata: NotebookCellMetadata;
R
rebornix 已提交
1056 1057
	}

J
Johannes Rieken 已提交
1058

R
rebornix 已提交
1059
	export interface NotebookDocumentMetadata {
1060 1061
		/**
		 * Controls if users can add or delete cells
1062
		 * Defaults to true
1063
		 */
1064
		editable?: boolean;
R
rebornix 已提交
1065

1066 1067
		/**
		 * Default value for [cell editable metadata](#NotebookCellMetadata.editable).
1068
		 * Defaults to true.
1069
		 */
1070
		cellEditable?: boolean;
R
rebornix 已提交
1071
		displayOrder?: GlobPattern[];
R
rebornix 已提交
1072 1073

		/**
1074
		 * Additional attributes of the document metadata.
R
rebornix 已提交
1075
		 */
1076
		custom?: { [key: string]: any; };
R
Rob Lourens 已提交
1077

R
rebornix 已提交
1078 1079 1080 1081 1082
		/**
		 * Whether the document is trusted, default to true
		 * When false, insecure outputs like HTML, JavaScript, SVG will not be rendered.
		 */
		trusted?: boolean;
1083 1084 1085 1086 1087

		/**
		 * Languages the document supports
		 */
		languages?: string[];
R
rebornix 已提交
1088 1089
	}

R
rebornix 已提交
1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103
	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.
		 */
		transientOutputs: boolean;

		/**
		 * 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.
		 */
		transientMetadata: { [K in keyof NotebookCellMetadata]?: boolean };
	}

R
rebornix 已提交
1104 1105
	export interface NotebookDocument {
		readonly uri: Uri;
1106
		readonly version: number;
R
rebornix 已提交
1107
		readonly fileName: string;
R
rebornix 已提交
1108
		readonly viewType: string;
R
rebornix 已提交
1109
		readonly isDirty: boolean;
R
rebornix 已提交
1110
		readonly isUntitled: boolean;
1111
		readonly cells: ReadonlyArray<NotebookCell>;
R
rebornix 已提交
1112
		readonly contentOptions: NotebookDocumentContentOptions;
1113
		// todo@API
J
Johannes Rieken 已提交
1114 1115
		// - move to kernel -> control runnable state of a cell
		// - remove from this type
R
rebornix 已提交
1116
		languages: string[];
R
rebornix 已提交
1117
		readonly metadata: NotebookDocumentMetadata;
R
rebornix 已提交
1118 1119
	}

1120 1121
	// todo@API maybe have a NotebookCellPosition sibling
	// todo@API should be a class
1122 1123
	export interface NotebookCellRange {
		readonly start: number;
R
rebornix 已提交
1124 1125 1126
		/**
		 * exclusive
		 */
1127 1128 1129
		readonly end: number;
	}

R
rebornix 已提交
1130 1131 1132 1133 1134 1135 1136 1137 1138
	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 已提交
1139

R
rebornix 已提交
1140 1141 1142 1143 1144
		/**
		 * 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 已提交
1145 1146 1147 1148 1149

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

R
rebornix 已提交
1152
	export interface NotebookEditor {
R
rebornix 已提交
1153 1154 1155
		/**
		 * The document associated with this notebook editor.
		 */
R
rebornix 已提交
1156
		readonly document: NotebookDocument;
R
rebornix 已提交
1157 1158 1159 1160

		/**
		 * The primary selected cell on this notebook editor.
		 */
J
Johannes Rieken 已提交
1161
		// todo@API should not be undefined, rather a default
R
rebornix 已提交
1162
		readonly selection?: NotebookCell;
1163

J
Johannes Rieken 已提交
1164 1165 1166 1167 1168 1169
		// @rebornix
		// todo@API should replace selection
		// never empty!
		// primary/secondary selections
		// readonly selections: NotebookCellRange[];

1170 1171 1172 1173 1174
		/**
		 * The current visible ranges in the editor (vertically).
		 */
		readonly visibleRanges: NotebookCellRange[];

1175 1176
		revealRange(range: NotebookCellRange, revealType?: NotebookEditorRevealType): void;

R
rebornix 已提交
1177 1178 1179
		/**
		 * The column in which this editor shows.
		 */
J
Johannes Rieken 已提交
1180
		// @jrieken
J
Johannes Rieken 已提交
1181
		// todo@API maybe never undefined because notebooks always show in the editor area (unlike text editors)
J
Johannes Rieken 已提交
1182
		// maybe for notebook diff editor
J
Johannes Rieken 已提交
1183
		readonly viewColumn?: ViewColumn;
1184

R
rebornix 已提交
1185 1186 1187
		/**
		 * Fired when the panel is disposed.
		 */
J
Johannes Rieken 已提交
1188
		// @rebornix REMOVE/REplace NotebookCommunication
J
Johannes Rieken 已提交
1189
		// todo@API fishy? notebooks are public objects, there should be a "global" events for this
R
rebornix 已提交
1190
		readonly onDidDispose: Event<void>;
R
rebornix 已提交
1191 1192
	}

1193 1194 1195 1196
	export interface NotebookDocumentMetadataChangeEvent {
		readonly document: NotebookDocument;
	}

1197
	export interface NotebookCellsChangeData {
R
rebornix 已提交
1198 1199
		readonly start: number;
		readonly deletedCount: number;
1200
		readonly deletedItems: NotebookCell[];
R
rebornix 已提交
1201
		readonly items: NotebookCell[];
R
rebornix 已提交
1202 1203
	}

R
rebornix 已提交
1204
	export interface NotebookCellsChangeEvent {
R
rebornix 已提交
1205 1206 1207 1208 1209

		/**
		 * The affected document.
		 */
		readonly document: NotebookDocument;
1210
		readonly changes: ReadonlyArray<NotebookCellsChangeData>;
R
rebornix 已提交
1211 1212
	}

1213
	export interface NotebookCellOutputsChangeEvent {
R
rebornix 已提交
1214 1215 1216 1217 1218

		/**
		 * The affected document.
		 */
		readonly document: NotebookDocument;
1219
		readonly cells: NotebookCell[];
R
rebornix 已提交
1220 1221 1222
	}

	export interface NotebookCellLanguageChangeEvent {
R
rebornix 已提交
1223 1224

		/**
R
rebornix 已提交
1225
		 * The affected document.
R
rebornix 已提交
1226
		 */
R
rebornix 已提交
1227 1228 1229
		readonly document: NotebookDocument;
		readonly cell: NotebookCell;
		readonly language: string;
R
rebornix 已提交
1230 1231
	}

1232 1233 1234
	export interface NotebookCellMetadataChangeEvent {
		readonly document: NotebookDocument;
		readonly cell: NotebookCell;
R
rebornix 已提交
1235 1236
	}

1237 1238
	export interface NotebookEditorSelectionChangeEvent {
		readonly notebookEditor: NotebookEditor;
1239 1240
		// @rebornix
		// todo@API show NotebookCellRange[] instead
1241 1242 1243
		readonly selection?: NotebookCell;
	}

1244 1245 1246 1247 1248
	export interface NotebookEditorVisibleRangesChangeEvent {
		readonly notebookEditor: NotebookEditor;
		readonly visibleRanges: ReadonlyArray<NotebookCellRange>;
	}

1249
	// todo@API support ids https://github.com/jupyter/enhancement-proposals/blob/master/62-cell-id/cell-id.md
R
rebornix 已提交
1250 1251 1252
	export interface NotebookCellData {
		readonly cellKind: CellKind;
		readonly source: string;
1253
		readonly language: string;
J
Johannes Rieken 已提交
1254
		// todo@API maybe use a separate data type?
R
rebornix 已提交
1255
		readonly outputs: NotebookCellOutput[];
1256
		readonly metadata: NotebookCellMetadata | undefined;
R
rebornix 已提交
1257 1258 1259 1260 1261 1262 1263 1264
	}

	export interface NotebookData {
		readonly cells: NotebookCellData[];
		readonly languages: string[];
		readonly metadata: NotebookDocumentMetadata;
	}

R
rebornix 已提交
1265

1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287
	/**
	 * 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 已提交
1288
		 * @param message Body of the message. This must be a string or other json serializable object.
1289 1290 1291 1292 1293 1294 1295
		 */
		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 已提交
1296 1297 1298

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

1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344
	// export function registerNotebookKernel(selector: string, kernel: NotebookKernel): Disposable;


	export interface NotebookDocumentShowOptions {
		viewColumn?: ViewColumn;
		preserveFocus?: boolean;
		preview?: boolean;
		selection?: NotebookCellRange;
	}

	export namespace notebook {

		export function openNotebookDocument(uri: Uri, viewType?: string): Thenable<NotebookDocument>;
		export const onDidOpenNotebookDocument: Event<NotebookDocument>;
		export const onDidCloseNotebookDocument: Event<NotebookDocument>;

		// todo@API really needed?
		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>;
		export const onDidChangeCellLanguage: Event<NotebookCellLanguageChangeEvent>;
		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>;
		export function showNotebookDocument(document: NotebookDocument, options?: NotebookDocumentShowOptions): Thenable<NotebookEditor>;
	}

	//#endregion

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

1345 1346 1347
	// code specific mime types
	// application/x.notebook.error-traceback
	// application/x.notebook.stream
1348 1349
	export class NotebookCellOutputItem {

1350 1351 1352 1353 1354
		// todo@API
		// add factory functions for common mime types
		// static textplain(value:string): NotebookCellOutputItem;
		// static errortrace(value:any): NotebookCellOutputItem;

1355 1356
		readonly mime: string;
		readonly value: unknown;
R
rebornix 已提交
1357
		readonly metadata?: Record<string, string | number | boolean | unknown>;
1358

R
rebornix 已提交
1359
		constructor(mime: string, value: unknown, metadata?: Record<string, string | number | boolean | unknown>);
1360 1361
	}

1362 1363
	// @jrieken
	//TODO@API add execution count to cell output?
1364
	export class NotebookCellOutput {
1365
		readonly id: string;
1366
		readonly outputs: NotebookCellOutputItem[];
1367
		constructor(outputs: NotebookCellOutputItem[], id?: string);
1368 1369 1370 1371 1372 1373 1374 1375
	}

	//#endregion

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

	export interface WorkspaceEdit {
		replaceNotebookMetadata(uri: Uri, value: NotebookDocumentMetadata): void;
1376 1377

		// todo@API use NotebookCellRange
1378 1379
		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 已提交
1380

R
rebornix 已提交
1381 1382
		replaceNotebookCellOutput(uri: Uri, index: number, outputs: NotebookCellOutput[], metadata?: WorkspaceEditEntryMetadata): void;
		appendNotebookCellOutput(uri: Uri, index: number, outputs: NotebookCellOutput[], metadata?: WorkspaceEditEntryMetadata): void;
1383 1384 1385

		// TODO@api
		// https://jupyter-protocol.readthedocs.io/en/latest/messaging.html#update-display-data
R
rebornix 已提交
1386 1387
		replaceNotebookCellOutputItems(uri: Uri, index: number, outputId: string, items: NotebookCellOutputItem[], metadata?: WorkspaceEditEntryMetadata): void;
		appendNotebookCellOutputItems(uri: Uri, index: number, outputId: string, items: NotebookCellOutputItem[], metadata?: WorkspaceEditEntryMetadata): void;
1388 1389 1390 1391 1392
	}

	export interface NotebookEditorEdit {
		replaceMetadata(value: NotebookDocumentMetadata): void;
		replaceCells(start: number, end: number, cells: NotebookCellData[]): void;
R
rebornix 已提交
1393
		replaceCellOutput(index: number, outputs: NotebookCellOutput[]): void;
1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440
		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

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

	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;
	}

R
rebornix 已提交
1441
	export interface NotebookContentProvider {
1442 1443
		readonly options?: NotebookDocumentContentOptions;
		readonly onDidChangeNotebookContentOptions?: Event<NotebookDocumentContentOptions>;
1444 1445 1446 1447
		/**
		 * 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.
		 */
J
Johannes Rieken 已提交
1448
		// eslint-disable-next-line vscode-dts-provider-naming
1449
		openNotebook(uri: Uri, openContext: NotebookDocumentOpenContext): NotebookData | Thenable<NotebookData>;
J
Johannes Rieken 已提交
1450
		// eslint-disable-next-line vscode-dts-provider-naming
1451
		// eslint-disable-next-line vscode-dts-cancellation
1452
		resolveNotebook(document: NotebookDocument, webview: NotebookCommunication): Thenable<void>;
J
Johannes Rieken 已提交
1453
		// eslint-disable-next-line vscode-dts-provider-naming
1454
		saveNotebook(document: NotebookDocument, cancellation: CancellationToken): Thenable<void>;
J
Johannes Rieken 已提交
1455
		// eslint-disable-next-line vscode-dts-provider-naming
1456
		saveNotebookAs(targetResource: Uri, document: NotebookDocument, cancellation: CancellationToken): Thenable<void>;
J
Johannes Rieken 已提交
1457
		// eslint-disable-next-line vscode-dts-provider-naming
1458
		backupNotebook(document: NotebookDocument, context: NotebookDocumentBackupContext, cancellation: CancellationToken): Thenable<NotebookDocumentBackup>;
J
Johannes Rieken 已提交
1459

1460
		// ???
J
Johannes Rieken 已提交
1461
		// provideKernels(document: NotebookDocument, token: CancellationToken): ProviderResult<T[]>;
1462 1463 1464
	}

	export namespace notebook {
J
Johannes Rieken 已提交
1465

1466 1467 1468 1469 1470 1471 1472 1473 1474 1475 1476 1477 1478 1479
		// 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 已提交
1480 1481
	}

1482 1483 1484 1485
	//#endregion

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

J
Johannes Rieken 已提交
1486 1487 1488 1489 1490 1491 1492 1493 1494 1495 1496 1497 1498 1499 1500 1501 1502 1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525
	export interface NotebookDocumentMetadata {

		/**
		 * Controls whether the full notebook can be run at once.
		 * Defaults to true
		 */
		// todo@API infer from kernel
		// todo@API remove
		runnable?: boolean;

		/**
		 * Default value for [cell runnable metadata](#NotebookCellMetadata.runnable).
		 * Defaults to true.
		 */
		cellRunnable?: boolean;

		/**
		 * Default value for [cell hasExecutionOrder metadata](#NotebookCellMetadata.hasExecutionOrder).
		 * Defaults to true.
		 */
		cellHasExecutionOrder?: boolean;

		/**
		 * The document's current run state
		 */
		runState?: NotebookRunState;
	}

	// todo@API use the NotebookCellExecution-object as a container to model and enforce
	// the flow of a cell execution

	// kernel -> execute_info
	// ext -> createNotebookCellExecution(cell)
	// kernel -> done
	// exec.dispose();

	// export interface NotebookCellExecution {
	// 	dispose(): void;
	// 	clearOutput(): void;
	// 	appendOutput(out: NotebookCellOutput): void;
J
Johannes Rieken 已提交
1526
	// 	replaceOutput(out: NotebookCellOutput): void;
1527 1528
	//  appendOutputItems(output:string, items: NotebookCellOutputItem[]):void;
	//  replaceOutputItems(output:string, items: NotebookCellOutputItem[]):void;
J
Johannes Rieken 已提交
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 1552 1553 1554 1555 1556 1557 1558 1559 1560 1561 1562 1563 1564 1565 1566 1567 1568 1569 1570 1571 1572 1573 1574 1575 1576 1577
	// }

	// export function createNotebookCellExecution(cell: NotebookCell, startTime?: number): NotebookCellExecution;
	// export const onDidStartNotebookCellExecution: Event<any>;
	// export const onDidStopNotebookCellExecution: Event<any>;

	export interface NotebookCellMetadata {

		/**
		 * Controls if the cell is executable.
		 * This metadata is ignored for markdown cell.
		 */
		// todo@API infer from kernel
		runnable?: boolean;

		/**
		 * Whether the [execution order](#NotebookCellMetadata.executionOrder) indicator will be displayed.
		 * Defaults to true.
		 */
		hasExecutionOrder?: boolean;

		/**
		 * The order in which this cell was executed.
		 */
		executionOrder?: number;

		/**
		 * A status message to be shown in the cell's status bar
		 */
		// todo@API duplicates status bar API
		statusMessage?: string;

		/**
		 * The cell's current run state
		 */
		runState?: NotebookCellRunState;

		/**
		 * If the cell is running, the time at which the cell started running
		 */
		runStartTime?: number;

		/**
		 * The total duration of the cell's last run
		 */
		// todo@API depends on having output
		lastRunDuration?: number;
	}

R
rebornix 已提交
1578
	export interface NotebookKernel {
R
rebornix 已提交
1579
		readonly id?: string;
R
rebornix 已提交
1580
		label: string;
R
rebornix 已提交
1581
		description?: string;
R
rebornix 已提交
1582
		detail?: string;
R
rebornix 已提交
1583
		isPreferred?: boolean;
R
rebornix 已提交
1584
		preloads?: Uri[];
J
Johannes Rieken 已提交
1585 1586 1587 1588

		// todo@API
		// languages supported by kernel
		// first is preferred
1589 1590
		// `undefined` means all languages available in the editor
		supportedLanguages?: string[];
J
Johannes Rieken 已提交
1591

J
Johannes Rieken 已提交
1592 1593
		// @roblourens
		// todo@API change to `executeCells(document: NotebookDocument, cells: NotebookCellRange[], context:{isWholeNotebooke: boolean}, token: CancelationToken): void;`
J
Johannes Rieken 已提交
1594
		// todo@API interrupt vs cancellation, https://github.com/microsoft/vscode/issues/106741
J
Johannes Rieken 已提交
1595
		// interrupt?():void;
R
Rob Lourens 已提交
1596 1597 1598 1599
		executeCell(document: NotebookDocument, cell: NotebookCell): void;
		cancelCellExecution(document: NotebookDocument, cell: NotebookCell): void;
		executeAllCells(document: NotebookDocument): void;
		cancelAllCellsExecution(document: NotebookDocument): void;
R
rebornix 已提交
1600 1601
	}

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

J
Johannes Rieken 已提交
1604
	// todo@API why not for NotebookContentProvider?
R
rebornix 已提交
1605
	export interface NotebookDocumentFilter {
R
rebornix 已提交
1606
		viewType?: string | string[];
R
rebornix 已提交
1607
		filenamePattern?: NotebookFilenamePattern;
R
rebornix 已提交
1608 1609
	}

J
Johannes Rieken 已提交
1610 1611
	// todo@API very unclear, provider MUST not return alive object but only data object
	// todo@API unclear how the flow goes
R
rebornix 已提交
1612
	export interface NotebookKernelProvider<T extends NotebookKernel = NotebookKernel> {
R
rebornix 已提交
1613
		onDidChangeKernels?: Event<NotebookDocument | undefined>;
R
rebornix 已提交
1614 1615
		provideKernels(document: NotebookDocument, token: CancellationToken): ProviderResult<T[]>;
		resolveKernel?(kernel: T, document: NotebookDocument, webview: NotebookCommunication, token: CancellationToken): ProviderResult<void>;
R
rebornix 已提交
1616 1617
	}

1618 1619 1620 1621 1622 1623 1624 1625 1626 1627 1628 1629 1630 1631 1632 1633 1634 1635 1636 1637 1638 1639 1640 1641 1642 1643 1644 1645 1646 1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658
	export interface NotebookEditor {
		/**
		 * Active kernel used in the editor
		 */
		// todo@API unsure about that
		// kernel, kernel selection, kernel provider
		readonly kernel?: NotebookKernel;
	}

	export namespace notebook {
		export const onDidChangeActiveNotebookKernel: Event<{ document: NotebookDocument, kernel: NotebookKernel | undefined; }>;

		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 已提交
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
	/**
	 * Represents the alignment of status bar items.
	 */
	export enum NotebookCellStatusBarAlignment {

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

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

	export interface NotebookCellStatusBarItem {
		readonly cell: NotebookCell;
		readonly alignment: NotebookCellStatusBarAlignment;
		readonly priority?: number;
		text: string;
		tooltip: string | undefined;
		command: string | Command | undefined;
		accessibilityInformation?: AccessibilityInformation;
		show(): void;
		hide(): void;
		dispose(): void;
	}

1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701
	export namespace notebook {
		/**
		 * Creates a notebook cell status bar [item](#NotebookCellStatusBarItem).
		 * It will be disposed automatically when the notebook document is closed or the cell is deleted.
		 *
		 * @param cell The cell on which this item should be shown.
		 * @param alignment The alignment of the item.
		 * @param priority The priority of the item. Higher values mean the item should be shown more to the left.
		 * @return A new status bar item.
		 */
		// @roblourens
		// todo@API this should be a provider, https://github.com/microsoft/vscode/issues/105809
		export function createCellStatusBarItem(cell: NotebookCell, alignment?: NotebookCellStatusBarAlignment, priority?: number): NotebookCellStatusBarItem;
R
rebornix 已提交
1702 1703
	}

1704
	//#endregion
R
rebornix 已提交
1705

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

R
rebornix 已提交
1708
	export namespace notebook {
1709
		/**
J
Johannes Rieken 已提交
1710 1711
		 * 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.
1712 1713 1714 1715
		 *
		 * @param notebook
		 * @param selector
		 */
J
Johannes Rieken 已提交
1716
		// @jrieken REMOVE. p_never
J
Johannes Rieken 已提交
1717
		// todo@API really needed? we didn't find a user here
1718
		export function createConcatTextDocument(notebook: NotebookDocument, selector?: DocumentSelector): NotebookConcatTextDocument;
1719
	}
M
Martin Aeschlimann 已提交
1720

1721 1722 1723 1724 1725 1726 1727 1728
	export interface NotebookConcatTextDocument {
		uri: Uri;
		isClosed: boolean;
		dispose(): void;
		onDidChange: Event<void>;
		version: number;
		getText(): string;
		getText(range: Range): string;
1729

1730 1731 1732 1733
		offsetAt(position: Position): number;
		positionAt(offset: number): Position;
		validateRange(range: Range): Range;
		validatePosition(position: Position): Position;
M
Martin Aeschlimann 已提交
1734

1735 1736 1737
		locationAt(positionOrRange: Position | Range): Location;
		positionAt(location: Location): Position;
		contains(uri: Uri): boolean;
1738 1739
	}

1740 1741 1742 1743
	//#endregion

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

P
label2  
Pine Wu 已提交
1744 1745 1746 1747
	export interface CompletionItem {
		/**
		 * Will be merged into CompletionItem#label
		 */
P
Pine Wu 已提交
1748
		label2?: CompletionItemLabel;
P
label2  
Pine Wu 已提交
1749 1750
	}

1751 1752
	export interface CompletionItemLabel {
		/**
P
Pine Wu 已提交
1753
		 * The function or variable. Rendered leftmost.
1754
		 */
P
Pine Wu 已提交
1755
		name: string;
1756

P
Pine Wu 已提交
1757
		/**
1758
		 * The parameters without the return type. Render after `name`.
P
Pine Wu 已提交
1759
		 */
1760
		parameters?: string;
P
Pine Wu 已提交
1761 1762

		/**
P
Pine Wu 已提交
1763
		 * The fully qualified name, like package name or file path. Rendered after `signature`.
P
Pine Wu 已提交
1764 1765
		 */
		qualifier?: string;
1766

P
Pine Wu 已提交
1767
		/**
P
Pine Wu 已提交
1768
		 * The return-type of a function or type of a property/variable. Rendered rightmost.
P
Pine Wu 已提交
1769
		 */
P
Pine Wu 已提交
1770
		type?: string;
1771 1772 1773 1774
	}

	//#endregion

1775
	//#region @eamodio - timeline: https://github.com/microsoft/vscode/issues/84297
1776 1777 1778

	export class TimelineItem {
		/**
1779
		 * A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred.
1780
		 */
E
Eric Amodio 已提交
1781
		timestamp: number;
1782 1783

		/**
1784
		 * A human-readable string describing the timeline item.
1785 1786 1787 1788
		 */
		label: string;

		/**
1789
		 * Optional id for the timeline item. It must be unique across all the timeline items provided by this source.
1790
		 *
1791
		 * If not provided, an id is generated using the timeline item's timestamp.
1792 1793 1794 1795
		 */
		id?: string;

		/**
1796
		 * The icon path or [ThemeIcon](#ThemeIcon) for the timeline item.
1797
		 */
R
rebornix 已提交
1798
		iconPath?: Uri | { light: Uri; dark: Uri; } | ThemeIcon;
1799 1800

		/**
1801
		 * A human readable string describing less prominent details of the timeline item.
1802 1803 1804 1805 1806 1807
		 */
		description?: string;

		/**
		 * The tooltip text when you hover over the timeline item.
		 */
1808
		detail?: string;
1809 1810 1811 1812 1813 1814 1815

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

		/**
1816 1817 1818 1819 1820 1821 1822 1823 1824 1825 1826 1827 1828 1829 1830 1831
		 * 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`.
1832 1833 1834
		 */
		contextValue?: string;

1835 1836 1837 1838 1839
		/**
		 * Accessibility information used when screen reader interacts with this timeline item.
		 */
		accessibilityInformation?: AccessibilityInformation;

1840 1841
		/**
		 * @param label A human-readable string describing the timeline item
E
Eric Amodio 已提交
1842
		 * @param timestamp A timestamp (in milliseconds since 1 January 1970 00:00:00) for when the timeline item occurred
1843
		 */
E
Eric Amodio 已提交
1844
		constructor(label: string, timestamp: number);
1845 1846
	}

1847
	export interface TimelineChangeEvent {
E
Eric Amodio 已提交
1848
		/**
1849
		 * The [uri](#Uri) of the resource for which the timeline changed.
E
Eric Amodio 已提交
1850
		 */
E
Eric Amodio 已提交
1851
		uri: Uri;
1852

E
Eric Amodio 已提交
1853
		/**
1854
		 * A flag which indicates whether the entire timeline should be reset.
E
Eric Amodio 已提交
1855
		 */
1856 1857
		reset?: boolean;
	}
E
Eric Amodio 已提交
1858

1859 1860 1861
	export interface Timeline {
		readonly paging?: {
			/**
E
Eric Amodio 已提交
1862
			 * A provider-defined cursor specifying the starting point of timeline items which are after the ones returned.
E
Eric Amodio 已提交
1863
			 * Use `undefined` to signal that there are no more items to be returned.
1864
			 */
E
Eric Amodio 已提交
1865
			readonly cursor: string | undefined;
R
rebornix 已提交
1866
		};
E
Eric Amodio 已提交
1867 1868

		/**
1869
		 * An array of [timeline items](#TimelineItem).
E
Eric Amodio 已提交
1870
		 */
1871
		readonly items: readonly TimelineItem[];
E
Eric Amodio 已提交
1872 1873
	}

1874
	export interface TimelineOptions {
E
Eric Amodio 已提交
1875
		/**
E
Eric Amodio 已提交
1876
		 * A provider-defined cursor specifying the starting point of the timeline items that should be returned.
E
Eric Amodio 已提交
1877
		 */
1878
		cursor?: string;
E
Eric Amodio 已提交
1879 1880

		/**
1881 1882
		 * 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 已提交
1883
		 */
R
rebornix 已提交
1884
		limit?: number | { timestamp: number; id?: string; };
E
Eric Amodio 已提交
1885 1886
	}

1887
	export interface TimelineProvider {
1888
		/**
1889 1890
		 * 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`.
1891
		 */
E
Eric Amodio 已提交
1892
		onDidChange?: Event<TimelineChangeEvent | undefined>;
1893 1894

		/**
1895
		 * An identifier of the source of the timeline items. This can be used to filter sources.
1896
		 */
1897
		readonly id: string;
1898

E
Eric Amodio 已提交
1899
		/**
1900
		 * 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 已提交
1901
		 */
1902
		readonly label: string;
1903 1904

		/**
E
Eric Amodio 已提交
1905
		 * Provide [timeline items](#TimelineItem) for a [Uri](#Uri).
1906
		 *
1907
		 * @param uri The [uri](#Uri) of the file to provide the timeline for.
1908
		 * @param options A set of options to determine how results should be returned.
1909
		 * @param token A cancellation token.
E
Eric Amodio 已提交
1910
		 * @return The [timeline result](#TimelineResult) or a thenable that resolves to such. The lack of a result
1911 1912
		 * can be signaled by returning `undefined`, `null`, or an empty array.
		 */
1913
		provideTimeline(uri: Uri, options: TimelineOptions, token: CancellationToken): ProviderResult<Timeline>;
1914 1915 1916 1917 1918 1919 1920 1921 1922 1923
	}

	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.
		 *
1924
		 * @param scheme A scheme or schemes that defines which documents this provider is applicable to. Can be `*` to target all documents.
1925 1926
		 * @param provider A timeline provider.
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
E
Eric Amodio 已提交
1927
		*/
1928
		export function registerTimelineProvider(scheme: string | string[], provider: TimelineProvider): Disposable;
1929 1930 1931
	}

	//#endregion
1932

1933
	//#region https://github.com/microsoft/vscode/issues/91555
1934

1935 1936 1937 1938 1939 1940 1941 1942 1943 1944 1945 1946 1947
	export enum StandardTokenType {
		Other = 0,
		Comment = 1,
		String = 2,
		RegEx = 4
	}

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

	export namespace languages {
1948
		export function getTokenInformationAtPosition(document: TextDocument, position: Position): Thenable<TokenInformation>;
K
kingwl 已提交
1949 1950 1951 1952
	}

	//#endregion

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

J
Johannes Rieken 已提交
1955 1956
	// todo@API rename to InlayHint
	// todo@API add "mini-markdown" for links and styles
1957 1958
	// todo@API remove description
	// (done:)  add InlayHintKind with type, argument, etc
J
Johannes Rieken 已提交
1959

K
kingwl 已提交
1960
	export namespace languages {
K
kingwl 已提交
1961 1962 1963
		/**
		 * Register a inline hints provider.
		 *
J
Johannes Rieken 已提交
1964 1965 1966
		 * 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 已提交
1967 1968
		 *
		 * @param selector A selector that defines the documents this provider is applicable to.
J
Johannes Rieken 已提交
1969
		 * @param provider An inline hints provider.
K
kingwl 已提交
1970 1971 1972
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
		export function registerInlineHintsProvider(selector: DocumentSelector, provider: InlineHintsProvider): Disposable;
1973 1974
	}

1975 1976 1977 1978 1979 1980
	export enum InlineHintKind {
		Other = 0,
		Type = 1,
		Parameter = 2,
	}

K
kingwl 已提交
1981 1982 1983 1984 1985 1986 1987 1988 1989
	/**
	 * Inline hint information.
	 */
	export class InlineHint {
		/**
		 * The text of the hint.
		 */
		text: string;
		/**
K
kingwl 已提交
1990
		 * The range of the hint.
K
kingwl 已提交
1991 1992
		 */
		range: Range;
1993 1994 1995 1996

		kind?: InlineHintKind;

		// todo@API remove this
1997
		description?: string | MarkdownString;
K
kingwl 已提交
1998 1999 2000 2001 2002 2003 2004 2005 2006
		/**
		 * Whitespace before the hint.
		 */
		whitespaceBefore?: boolean;
		/**
		 * Whitespace after the hint.
		 */
		whitespaceAfter?: boolean;

2007
		constructor(text: string, range: Range, kind?: InlineHintKind);
K
kingwl 已提交
2008 2009 2010
	}

	/**
J
Johannes Rieken 已提交
2011
	 * The inline hints provider interface defines the contract between extensions and
K
kingwl 已提交
2012 2013 2014
	 * the inline hints feature.
	 */
	export interface InlineHintsProvider {
W
Wenlu Wang 已提交
2015 2016 2017 2018 2019 2020

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

K
kingwl 已提交
2022 2023
		/**
		 * @param model The document in which the command was invoked.
J
Johannes Rieken 已提交
2024
		 * @param range The range for which line hints should be computed.
K
kingwl 已提交
2025 2026 2027 2028 2029 2030
		 * @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[]>;
	}
2031
	//#endregion
2032

2033 2034 2035 2036 2037 2038 2039 2040 2041 2042 2043 2044 2045 2046 2047 2048 2049 2050
	//#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
2051 2052 2053 2054

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

	export interface TextDocument {
2055 2056 2057 2058 2059

		/**
		 * 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).
		 */
2060 2061 2062
		notebook: NotebookDocument | undefined;
	}
	//#endregion
C
Connor Peet 已提交
2063 2064 2065 2066 2067 2068 2069 2070 2071 2072 2073 2074 2075 2076 2077 2078 2079 2080

	//#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 {
		/**
		 * Registers a provider that discovers tests for the given document
		 * selectors. It is activated when either tests need to be enumerated, or
		 * a document matching the selector is opened.
		 */
		export function registerTestProvider<T extends TestItem>(testProvider: TestProvider<T>): Disposable;

		/**
2081 2082 2083 2084
		 * 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 已提交
2085
		 */
2086
		export function runTests<T extends TestItem>(run: TestRunOptions<T>, cancellationToken?: CancellationToken): Thenable<void>;
C
Connor Peet 已提交
2087 2088 2089 2090 2091 2092 2093 2094 2095 2096

		/**
		 * 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;
2097 2098 2099 2100 2101 2102 2103 2104 2105 2106 2107 2108 2109 2110 2111 2112 2113 2114

		/**
		 * The last or selected test run. Cleared when a new test run starts.
		 */
		export const testResults: TestResults | undefined;

		/**
		 * Event that fires when the testResults are updated.
		 */
		export const onDidChangeTestResults: Event<void>;
	}

	export interface TestResults {
		/**
		 * The results from the latest test run. The array contains a snapshot of
		 * all tests involved in the run at the moment when it completed.
		 */
		readonly tests: ReadonlyArray<RequiredTestItem> | undefined;
C
Connor Peet 已提交
2115 2116 2117 2118 2119 2120
	}

	export interface TestObserver {
		/**
		 * List of tests returned by test provider for files in the workspace.
		 */
2121
		readonly tests: ReadonlyArray<RequiredTestItem>;
C
Connor Peet 已提交
2122 2123 2124 2125 2126 2127

		/**
		 * 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 已提交
2128
		readonly onDidChangeTest: Event<TestChangeEvent>;
C
Connor Peet 已提交
2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146

		/**
		 * An event the fires when all test providers have signalled that the tests
		 * 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 已提交
2147 2148 2149 2150
	export interface TestChangeEvent {
		/**
		 * List of all tests that are newly added.
		 */
2151
		readonly added: ReadonlyArray<RequiredTestItem>;
C
Connor Peet 已提交
2152 2153 2154 2155

		/**
		 * List of existing tests that have updated.
		 */
2156
		readonly updated: ReadonlyArray<RequiredTestItem>;
C
Connor Peet 已提交
2157 2158 2159 2160

		/**
		 * List of existing tests that have been removed.
		 */
2161
		readonly removed: ReadonlyArray<RequiredTestItem>;
C
Connor Peet 已提交
2162 2163 2164 2165 2166

		/**
		 * Highest node in the test tree under which changes were made. This can
		 * be easily plugged into events like the TreeDataProvider update event.
		 */
2167
		readonly commonChangeAncestor: RequiredTestItem | null;
C
Connor Peet 已提交
2168 2169
	}

C
Connor Peet 已提交
2170 2171 2172 2173 2174 2175 2176 2177 2178 2179 2180 2181 2182 2183 2184 2185 2186 2187 2188 2189 2190 2191 2192 2193
	/**
	 * Tree of tests returned from the provide methods in the {@link TestProvider}.
	 */
	export interface TestHierarchy<T extends TestItem> {
		/**
		 * Root node for tests. The `testRoot` instance must not be replaced over
		 * the lifespan of the TestHierarchy, since you will need to reference it
		 * in `onDidChangeTest` when a test is added or removed.
		 */
		readonly root: T;

		/**
		 * An event that fires when an existing test under the `root` changes.
		 * This can be a result of a state change in a test run, a property update,
		 * or an update to its children. Changes made to tests will not be visible
		 * to {@link TestObserver} instances until this event is fired.
		 *
		 * This will signal a change recursively to all children of the given node.
		 * For example, firing the event with the {@link testRoot} will refresh
		 * all tests.
		 */
		readonly onDidChangeTest: Event<T>;

		/**
C
Connor Peet 已提交
2194 2195 2196
		 * Promise that should be resolved when all tests that are initially
		 * defined have been discovered. The provider should continue to watch for
		 * changes and fire `onDidChangeTest` until the hierarchy is disposed.
C
Connor Peet 已提交
2197
		 */
C
Connor Peet 已提交
2198
		readonly discoveredInitialTests?: Thenable<unknown>;
C
Connor Peet 已提交
2199

2200 2201 2202 2203 2204 2205 2206 2207
		/**
		 * An event that fires when a test becomes outdated, as a result of
		 * file changes, for example. In "watch" mode, tests that are outdated
		 * will be automatically re-run after a short delay. Firing a test
		 * with children will mark the entire subtree as outdated.
		 */
		readonly onDidInvalidateTest?: Event<T>;

C
Connor Peet 已提交
2208 2209 2210 2211 2212 2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 2223 2224 2225 2226 2227 2228 2229 2230 2231 2232 2233 2234
		/**
		 * Dispose will be called when there are no longer observers interested
		 * in the hierarchy.
		 */
		dispose(): void;
	}

	/**
	 * Discovers and provides tests. It's expected that the TestProvider will
	 * ambiently listen to {@link vscode.window.onDidChangeVisibleTextEditors} to
	 * provide test information about the open files for use in code lenses and
	 * other file-specific UI.
	 *
	 * 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
		 * generally be called when tests need to be enumerated for the
		 * workspace.
		 *
		 * It's guaranteed that this method will not be called again while
		 * there is a previous undisposed watcher for the given workspace folder.
		 */
J
Johannes Rieken 已提交
2235
		// eslint-disable-next-line vscode-dts-provider-naming
C
Connor Peet 已提交
2236
		createWorkspaceTestHierarchy?(workspace: WorkspaceFolder): TestHierarchy<T> | undefined;
C
Connor Peet 已提交
2237 2238 2239 2240 2241 2242

		/**
		 * 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.
		 */
J
Johannes Rieken 已提交
2243
		// eslint-disable-next-line vscode-dts-provider-naming
C
Connor Peet 已提交
2244
		createDocumentTestHierarchy?(document: TextDocument): TestHierarchy<T> | undefined;
C
Connor Peet 已提交
2245 2246 2247 2248 2249 2250

		/**
		 * Starts a test run. This should cause {@link onDidChangeTest} to
		 * fire with update test states during the run.
		 * @todo this will eventually need to be able to return a summary report, coverage for example.
		 */
J
Johannes Rieken 已提交
2251
		// eslint-disable-next-line vscode-dts-provider-naming
2252
		runTests?(options: TestRun<T>, cancellationToken: CancellationToken): ProviderResult<void>;
C
Connor Peet 已提交
2253 2254 2255
	}

	/**
2256
	 * Options given to {@link test.runTests}
C
Connor Peet 已提交
2257 2258 2259 2260 2261 2262 2263 2264 2265 2266 2267 2268 2269 2270
	 */
	export interface TestRunOptions<T extends TestItem = TestItem> {
		/**
		 * Array of specific tests to run. The {@link TestProvider.testRoot} may
		 * be provided as an indication to run all tests.
		 */
		tests: T[];

		/**
		 * Whether or not tests in this run should be debugged.
		 */
		debug: boolean;
	}

2271 2272 2273 2274 2275 2276 2277 2278 2279 2280 2281
	/**
	 * Options given to `TestProvider.runTests`
	 */
	export interface TestRun<T extends TestItem = TestItem> extends TestRunOptions<T> {
		/**
		 * 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.
		 */
		setState(test: T, state: TestState): void;
	}

C
Connor Peet 已提交
2282 2283 2284 2285 2286 2287 2288 2289 2290 2291
	/**
	 * 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.
	 */
	export interface TestItem {
		/**
		 * Display name describing the test case.
		 */
		label: string;

2292 2293 2294 2295 2296 2297 2298 2299 2300 2301
		/**
		 * Optional unique identifier for the TestItem. This is used to correlate
		 * test results and tests in the document with those in the workspace
		 * (test explorer). This must not change for the lifetime of a test item.
		 *
		 * If the ID is not provided, it defaults to the concatenation of the
		 * item's label and its parent's ID, if any.
		 */
		readonly id?: string;

C
Connor Peet 已提交
2302 2303 2304 2305 2306 2307 2308 2309 2310 2311 2312 2313 2314 2315 2316
		/**
		 * Optional description that appears next to the label.
		 */
		description?: string;

		/**
		 * Whether this test item can be run individually, defaults to `true`
		 * if not provided.
		 *
		 * In some cases, like Go's tests, test can have children but these
		 * children cannot be run independently.
		 */
		runnable?: boolean;

		/**
2317
		 * Whether this test item can be debugged. Defaults to `false` if not provided.
C
Connor Peet 已提交
2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331
		 */
		debuggable?: boolean;

		/**
		 * VS Code location.
		 */
		location?: Location;

		/**
		 * Optional list of nested tests for this item.
		 */
		children?: TestItem[];
	}

2332 2333 2334 2335 2336 2337 2338 2339 2340
	/**
	 * A {@link TestItem} with its defaults filled in.
	 */
	export type RequiredTestItem = {
		[K in keyof Required<TestItem>]: K extends 'children'
		? RequiredTestItem[]
		: (K extends 'description' | 'location' ? TestItem[K] : Required<TestItem>[K])
	};

C
Connor Peet 已提交
2341 2342 2343
	export enum TestRunState {
		// Initial state
		Unset = 0,
C
Connor Peet 已提交
2344 2345
		// Test will be run, but is not currently running.
		Queued = 1,
C
Connor Peet 已提交
2346
		// Test is currently running
C
Connor Peet 已提交
2347
		Running = 2,
C
Connor Peet 已提交
2348
		// Test run has passed
C
Connor Peet 已提交
2349
		Passed = 3,
C
Connor Peet 已提交
2350
		// Test run has failed (on an assertion)
C
Connor Peet 已提交
2351
		Failed = 4,
C
Connor Peet 已提交
2352
		// Test run has been skipped
C
Connor Peet 已提交
2353
		Skipped = 5,
C
Connor Peet 已提交
2354
		// Test run failed for some other reason (compilation error, timeout, etc)
C
Connor Peet 已提交
2355
		Errored = 6
C
Connor Peet 已提交
2356 2357 2358 2359 2360 2361 2362 2363
	}

	/**
	 * TestState includes a test and its run state. This is included in the
	 * {@link TestItem} and is immutable; it should be replaced in th TestItem
	 * in order to update it. This allows consumers to quickly and easily check
	 * for changes via object identity.
	 */
2364
	export interface TestState {
C
Connor Peet 已提交
2365 2366 2367
		/**
		 * Current state of the test.
		 */
2368
		readonly state: TestRunState;
C
Connor Peet 已提交
2369 2370 2371 2372 2373 2374 2375 2376 2377 2378

		/**
		 * Optional duration of the test run, in milliseconds.
		 */
		readonly duration?: number;

		/**
		 * Associated test run message. Can, for example, contain assertion
		 * failure information if the test fails.
		 */
2379
		readonly messages?: ReadonlyArray<Readonly<TestMessage>>;
C
Connor Peet 已提交
2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 2391 2392 2393 2394 2395 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
	}

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

	/**
	 * Message associated with the test state. Can be linked to a specific
	 * source range -- useful for assertion failures, for example.
	 */
	export interface TestMessage {
		/**
		 * Human-readable message text to display.
		 */
		message: string | MarkdownString;

		/**
		 * Message severity. Defaults to "Error", if not provided.
		 */
		severity?: TestMessageSeverity;

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

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

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

C
Connor Peet 已提交
2423
	//#endregion
2424 2425 2426

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

2427 2428 2429
	/**
	 * Details if an `ExternalUriOpener` can open a uri.
	 *
2430 2431 2432 2433 2434 2435 2436
	 * 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.
2437
	 */
M
Matt Bierner 已提交
2438
	export enum ExternalUriOpenerPriority {
2439
		/**
2440
		 * The opener is disabled and will never be shown to users.
M
Matt Bierner 已提交
2441
		 *
2442 2443
		 * Note that the opener can still be used if the user specifically
		 * configures it in their settings.
2444
		 */
M
Matt Bierner 已提交
2445
		None = 0,
2446 2447

		/**
2448 2449
		 * 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.
2450
		 */
M
Matt Bierner 已提交
2451
		Option = 1,
2452 2453

		/**
M
Matt Bierner 已提交
2454 2455
		 * The opener can open the uri.
		 *
2456 2457
		 * 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.
2458
		 */
M
Matt Bierner 已提交
2459 2460 2461
		Default = 2,

		/**
2462 2463
		 * 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 已提交
2464
		 *
2465
		 * A preferred opener will be automatically selected if no other preferred openers
2466
		 * are available. If multiple preferred openers are available, then the user
2467
		 * is shown a prompt with all potential openers (not just preferred openers).
M
Matt Bierner 已提交
2468 2469
		 */
		Preferred = 3,
2470 2471
	}

2472
	/**
M
Matt Bierner 已提交
2473
	 * Handles opening uris to external resources, such as http(s) links.
2474
	 *
M
Matt Bierner 已提交
2475
	 * Extensions can implement an `ExternalUriOpener` to open `http` links to a webserver
M
Matt Bierner 已提交
2476
	 * inside of VS Code instead of having the link be opened by the web browser.
2477 2478 2479 2480 2481 2482
	 *
	 * Currently openers may only be registered for `http` and `https` uris.
	 */
	export interface ExternalUriOpener {

		/**
2483
		 * Check if the opener can open a uri.
2484
		 *
M
Matt Bierner 已提交
2485 2486 2487
		 * @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.
2488
		 *
2489
		 * @return Priority indicating if the opener can open the external uri.
M
Matt Bierner 已提交
2490
		 */
M
Matt Bierner 已提交
2491
		canOpenExternalUri(uri: Uri, token: CancellationToken): ExternalUriOpenerPriority | Thenable<ExternalUriOpenerPriority>;
M
Matt Bierner 已提交
2492 2493

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

M
Matt Bierner 已提交
2526
	/**
2527
	 * Additional metadata about a registered `ExternalUriOpener`.
M
Matt Bierner 已提交
2528
	 */
M
Matt Bierner 已提交
2529
	interface ExternalUriOpenerMetadata {
M
Matt Bierner 已提交
2530

M
Matt Bierner 已提交
2531 2532 2533 2534 2535 2536 2537
		/**
		 * List of uri schemes the opener is triggered for.
		 *
		 * Currently only `http` and `https` are supported.
		 */
		readonly schemes: readonly string[]

M
Matt Bierner 已提交
2538 2539
		/**
		 * Text displayed to the user that explains what the opener does.
2540
		 *
M
Matt Bierner 已提交
2541
		 * For example, 'Open in browser preview'
2542
		 */
M
Matt Bierner 已提交
2543
		readonly label: string;
2544 2545 2546 2547 2548 2549
	}

	namespace window {
		/**
		 * Register a new `ExternalUriOpener`.
		 *
2550
		 * When a uri is about to be opened, an `onOpenExternalUri:SCHEME` activation event is fired.
2551
		 *
M
Matt Bierner 已提交
2552 2553
		 * @param id Unique id of the opener, such as `myExtension.browserPreview`. This is used in settings
		 *   and commands to identify the opener.
2554
		 * @param opener Opener to register.
M
Matt Bierner 已提交
2555
		 * @param metadata Additional information about the opener.
2556 2557
		 *
		* @returns Disposable that unregisters the opener.
M
Matt Bierner 已提交
2558 2559
		*/
		export function registerExternalUriOpener(id: string, opener: ExternalUriOpener, metadata: ExternalUriOpenerMetadata): Disposable;
2560 2561
	}

2562 2563
	interface OpenExternalOptions {
		/**
2564 2565
		 * Allows using openers contributed by extensions through  `registerExternalUriOpener`
		 * when opening the resource.
2566
		 *
2567
		 * If `true`, VS Code will check if any contributed openers can handle the
2568 2569
		 * uri, and fallback to the default opener behavior.
		 *
2570
		 * If it is string, this specifies the id of the `ExternalUriOpener`
2571 2572 2573 2574 2575 2576 2577 2578 2579 2580
		 * 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 已提交
2581
	//#endregion
2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 2592 2593 2594 2595 2596 2597 2598

	//#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
2599 2600 2601 2602 2603 2604 2605 2606 2607 2608 2609 2610 2611 2612 2613 2614 2615 2616 2617 2618 2619 2620 2621 2622 2623 2624 2625 2626 2627 2628 2629 2630 2631 2632 2633 2634 2635 2636 2637 2638 2639 2640 2641 2642 2643 2644 2645 2646 2647 2648 2649 2650 2651 2652 2653 2654

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

	export enum WorkspaceTrustState {
		/**
		 * The workspace is untrusted, and it will have limited functionality.
		 */
		Untrusted = 0,

		/**
		 * The workspace is trusted, and all functionality will be available.
		 */
		Trusted = 1,

		/**
		 * The initial state of the workspace.
		 *
		 * If trust will be required, users will be prompted to make a choice.
		 */
		Unknown = 2
	}

	/**
	 * The event data that is fired when the trust state of the workspace changes
	 */
	export interface WorkspaceTrustStateChangeEvent {
		/**
		 * Previous trust state of the workspace
		 */
		previousTrustState: WorkspaceTrustState;

		/**
		 * Current trust state of the workspace
		 */
		currentTrustState: WorkspaceTrustState;
	}

	export namespace workspace {
		/**
		 * The trust state of the current workspace
		 */
		export const trustState: WorkspaceTrustState;

		/**
		 * Prompt the user to chose whether to trust the current workspace
		 * @param message Optional message which would be displayed in the prompt
		 */
		export function requireWorkspaceTrust(message?: string): Thenable<WorkspaceTrustState>;

		/**
		 * Event that fires when the trust state of the current workspace changes
		 */
		export const onDidChangeWorkspaceTrustState: Event<WorkspaceTrustStateChangeEvent>;
	}

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