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

// This is the place for API experiments and proposal.

declare module 'vscode' {

J
Johannes Rieken 已提交
10 11 12 13 14 15
	export namespace window {
		export function sampleFunction(): Thenable<any>;
	}

	//#region Aeschli: folding

16 17 18 19 20 21 22 23
	export class FoldingRangeList {

		/**
		 * The folding ranges.
		 */
		ranges: FoldingRange[];

		/**
Y
Yemi Bedu @ P&amp;R 已提交
24
		 * Creates new folding range list.
25 26 27 28 29 30 31 32 33 34
		 *
		 * @param ranges The folding ranges
		 */
		constructor(ranges: FoldingRange[]);
	}


	export class FoldingRange {

		/**
M
Martin Aeschlimann 已提交
35
		 * The start line number (zero-based) of the range to fold. The hidden area starts after the last character of that line.
36 37 38 39
		 */
		startLine: number;

		/**
M
Martin Aeschlimann 已提交
40
		 * The end line number (0-based) of the range to fold. The hidden area ends at the last character of that line.
41 42 43 44 45 46 47 48 49 50 51 52 53 54
		 */
		endLine: number;

		/**
		 * The actual color value for this color range.
		 */
		type?: FoldingRangeType | string;

		/**
		 * Creates a new folding range.
		 *
		 * @param startLineNumber The first line of the fold
		 * @param type The last line of the fold
		 */
55
		constructor(startLineNumber: number, endLineNumber: number, type?: FoldingRangeType | string);
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72
	}

	export enum FoldingRangeType {
		/**
		 * Folding range for a comment
		 */
		Comment = 'comment',
		/**
		 * Folding range for a imports or includes
		 */
		Imports = 'imports',
		/**
		 * Folding range for a region (e.g. `#region`)
		 */
		Region = 'region'
	}

J
Johannes Rieken 已提交
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103
	export namespace languages {

		/**
		 * Register a folding provider.
		 *
		 * Multiple folding can be registered for a language. In that case providers are sorted
		 * by their [score](#languages.match) and the best-matching provider is used. Failure
		 * of the selected provider will cause a failure of the whole operation.
		 *
		 * @param selector A selector that defines the documents this provider is applicable to.
		 * @param provider A folding provider.
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
		export function registerFoldingProvider(selector: DocumentSelector, provider: FoldingProvider): Disposable;
	}

	export interface FoldingContext {
		maxRanges?: number;
	}

	export interface FoldingProvider {
		/**
		 * Returns a list of folding ranges or null if the provider does not want to participate or was cancelled.
		 */
		provideFoldingRanges(document: TextDocument, context: FoldingContext, token: CancellationToken): ProviderResult<FoldingRangeList>;
	}

	//#endregion

	//#region Joh: file system provider

104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
	export enum FileChangeType {
		Updated = 0,
		Added = 1,
		Deleted = 2
	}

	export interface FileChange {
		type: FileChangeType;
		resource: Uri;
	}

	export enum FileType {
		File = 0,
		Dir = 1,
		Symlink = 2
	}

	export interface FileStat {
122
		id: number | string;
123
		mtime: number;
J
Johannes Rieken 已提交
124
		// atime: number;
125 126 127 128
		size: number;
		type: FileType;
	}

J
Johannes Rieken 已提交
129
	// todo@joh discover files etc
J
Johannes Rieken 已提交
130
	// todo@joh CancellationToken everywhere
J
Johannes Rieken 已提交
131
	// todo@joh add open/close calls?
J
Johannes Rieken 已提交
132
	export interface FileSystemProvider {
D
Dirk Baeumer 已提交
133

J
Johannes Rieken 已提交
134
		readonly onDidChange?: Event<FileChange[]>;
135 136

		// more...
137
		// @deprecated - will go away
J
Johannes Rieken 已提交
138
		utimes(resource: Uri, mtime: number, atime: number): Thenable<FileStat>;
139

140
		stat(resource: Uri): Thenable<FileStat>;
141

142
		read(resource: Uri, offset: number, length: number, progress: Progress<Uint8Array>): Thenable<number>;
143

J
Johannes Rieken 已提交
144
		// todo@joh - have an option to create iff not exist
145 146 147 148
		// todo@remote
		// offset - byte offset to start
		// count - number of bytes to write
		// Thenable<number> - number of bytes actually written
149
		write(resource: Uri, content: Uint8Array): Thenable<void>;
150 151 152

		// todo@remote
		// Thenable<FileStat>
153 154 155 156 157
		move(resource: Uri, target: Uri): Thenable<FileStat>;

		// todo@remote
		// helps with performance bigly
		// copy?(from: Uri, to: Uri): Thenable<void>;
158 159 160

		// todo@remote
		// Thenable<FileStat>
161
		mkdir(resource: Uri): Thenable<FileStat>;
162

163 164 165 166 167
		readdir(resource: Uri): Thenable<[Uri, FileStat][]>;

		// todo@remote
		// ? merge both
		// ? recursive del
168
		rmdir(resource: Uri): Thenable<void>;
169 170 171 172
		unlink(resource: Uri): Thenable<void>;

		// todo@remote
		// create(resource: Uri): Thenable<FileStat>;
173 174
	}

175
	// export class FileError extends Error {
176

177 178 179 180
	// 	/**
	// 	 * Entry already exists, e.g. when creating a file or folder.
	// 	 */
	// 	static readonly EntryExists: FileError;
J
Johannes Rieken 已提交
181

182 183 184 185
	// 	/**
	// 	 * Entry does not exist.
	// 	 */
	// 	static readonly EntryNotFound: FileError;
J
Johannes Rieken 已提交
186

187 188 189 190
	// 	/**
	// 	 * Entry is not a directory.
	// 	 */
	// 	static readonly EntryNotADirectory: FileError;
J
Johannes Rieken 已提交
191

192 193 194 195
	// 	/**
	// 	 * Entry is a directory.
	// 	 */
	// 	static readonly EntryIsADirectory: FileError;
196

197
	// 	readonly code: string;
198

199 200
	// 	constructor(code: string, message?: string);
	// }
201

202 203 204 205 206 207 208 209
	export enum FileChangeType2 {
		Changed = 1,
		Created = 2,
		Deleted = 3,
	}

	export interface FileChange2 {
		type: FileChangeType2;
210
		uri: Uri;
211 212 213 214 215 216 217 218 219 220 221 222 223 224
	}

	export enum FileType2 {
		File = 0b001,
		Directory = 0b010,
		SymbolicLink = 0b100,
	}

	export interface FileStat2 {
		type: FileType2;
		mtime: number;
		size: number;
	}

225 226 227 228 229 230
	export enum FileOpenFlags {
		Read = 0b0001,
		Write = 0b0010,
		Create = 0b0100,
		Exclusive = 0b1000
	}
231

232 233 234
	/**
	 *
	 */
235 236
	export interface FileSystemProvider2 {

237
		_version: 7;
238

J
Johannes Rieken 已提交
239
		/**
240 241 242
		 * An event to signal that a resource has been created, changed, or deleted. This
		 * event should fire for resources that are being [watched](#FileSystemProvider2.watch)
		 * by clients of this provider.
J
Johannes Rieken 已提交
243
		 */
244 245 246
		readonly onDidChangeFile: Event<FileChange2[]>;

		/**
247 248 249
		 * Subscribe to events in the file or folder denoted by `uri`.
		 * @param uri
		 * @param options
250 251
		 */
		watch(uri: Uri, options: { recursive?: boolean; excludes?: string[] }): Disposable;
252

J
Johannes Rieken 已提交
253
		/**
254
		 * Retrieve metadata about a file.
J
Johannes Rieken 已提交
255 256 257
		 *
		 * @param uri The uri of the file to retrieve meta data about.
		 * @param token A cancellation token.
J
Johannes Rieken 已提交
258
		 * @return The file metadata about the file.
J
Johannes Rieken 已提交
259
		 */
260
		stat(uri: Uri, token: CancellationToken): FileStat2 | Thenable<FileStat2>;
261

J
Johannes Rieken 已提交
262 263 264 265 266
		/**
		 * Retrieve the meta data of all entries of a [directory](#FileType2.Directory)
		 *
		 * @param uri The uri of the folder.
		 * @param token A cancellation token.
267
		 * @return A thenable that resolves to an array of tuples of file names and files stats.
J
Johannes Rieken 已提交
268
		 */
269
		readDirectory(uri: Uri, token: CancellationToken): [string, FileStat2][] | Thenable<[string, FileStat2][]>;
270

271 272
		/**
		 * Create a new directory. *Note* that new files are created via `write`-calls.
273
		 *
274 275 276 277 278
		 * @param uri The uri of the *new* folder.
		 * @param token A cancellation token.
		 */
		createDirectory(uri: Uri, token: CancellationToken): FileStat2 | Thenable<FileStat2>;

J
Johannes Rieken 已提交
279 280 281 282 283 284 285
		/**
		 * Read the entire contents of a file.
		 *
		 * @param uri The uri of the file.
		 * @param token A cancellation token.
		 * @return A thenable that resolves to an array of bytes.
		 */
286
		readFile(uri: Uri, options: { flags: FileOpenFlags }, token: CancellationToken): Uint8Array | Thenable<Uint8Array>;
287

J
Johannes Rieken 已提交
288 289 290 291 292 293 294
		/**
		 * Write data to a file, replacing its entire contents.
		 *
		 * @param uri The uri of the file.
		 * @param content The new content of the file.
		 * @param token A cancellation token.
		 */
295
		writeFile(uri: Uri, content: Uint8Array, options: { flags: FileOpenFlags }, token: CancellationToken): void | Thenable<void>;
296

J
Johannes Rieken 已提交
297 298 299
		/**
		 * Rename a file or folder.
		 *
300 301
		 * @param oldUri The existing file or folder.
		 * @param newUri The target location.
J
Johannes Rieken 已提交
302 303
		 * @param token A cancellation token.
		 */
304
		rename(oldUri: Uri, newUri: Uri, options: { flags: FileOpenFlags }, token: CancellationToken): FileStat2 | Thenable<FileStat2>;
305

306 307 308 309 310 311 312 313 314
		/**
		 * Copy files or folders. Implementing this function is optional but it will speedup
		 * the copy operation.
		 *
		 * @param uri The existing file or folder.
		 * @param target The target location.
		 * @param token A cancellation token.
		 */
		copy?(uri: Uri, target: Uri, options: { flags: FileOpenFlags }, token: CancellationToken): FileStat2 | Thenable<FileStat2>;
315 316 317

		// todo@remote
		// ? useTrash, expose trash
318
		delete(uri: Uri, token: CancellationToken): void | Thenable<void>;
319 320
	}

321
	export namespace workspace {
322
		export function registerFileSystemProvider(scheme: string, provider: FileSystemProvider, newProvider?: FileSystemProvider2): Disposable;
323
		export function registerDeprecatedFileSystemProvider(scheme: string, provider: FileSystemProvider): Disposable;
324
	}
J
Johannes Rieken 已提交
325

326 327 328 329 330 331
	//#endregion

	//#region Joh: remote, search provider

	export interface TextSearchQuery {
		pattern: string;
332
		isRegExp?: boolean;
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
		isCaseSensitive?: boolean;
		isWordMatch?: boolean;
	}

	export interface TextSearchOptions {
		includes: GlobPattern[];
		excludes: GlobPattern[];
	}

	export interface TextSearchResult {
		uri: Uri;
		range: Range;
		preview: { leading: string, matching: string, trailing: string };
	}

	export interface SearchProvider {
		provideFileSearchResults?(query: string, progress: Progress<Uri>, token: CancellationToken): Thenable<void>;
350
		provideTextSearchResults?(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): Thenable<void>;
351 352
	}

353
	export namespace workspace {
354
		export function registerSearchProvider(scheme: string, provider: SearchProvider): Disposable;
355 356
	}

J
Johannes Rieken 已提交
357
	//#endregion
358

J
Johannes Rieken 已提交
359
	//#region Joao: diff command
P
Pine Wu 已提交
360

J
Joao Moreno 已提交
361 362 363
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
364 365 366 367 368 369 370
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388
	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;
	}
389

J
Johannes Rieken 已提交
390 391 392
	//#endregion

	//#region Joh: decorations
393 394 395 396 397

	//todo@joh -> make class
	export interface DecorationData {
		priority?: number;
		title?: string;
398
		bubble?: boolean;
399 400
		abbreviation?: string;
		color?: ThemeColor;
401
		source?: string;
402 403
	}

404 405 406 407 408 409
	export interface SourceControlResourceDecorations {
		source?: string;
		letter?: string;
		color?: ThemeColor;
	}

410
	export interface DecorationProvider {
411
		onDidChangeDecorations: Event<undefined | Uri | Uri[]>;
412 413 414 415
		provideDecoration(uri: Uri, token: CancellationToken): ProviderResult<DecorationData>;
	}

	export namespace window {
416
		export function registerDecorationProvider(provider: DecorationProvider): Disposable;
417 418 419
	}

	//#endregion
420

J
Johannes Rieken 已提交
421 422
	//#region André: debug

423 424 425 426 427 428
	/**
	 * Represents a debug adapter executable and optional arguments passed to it.
	 */
	export class DebugAdapterExecutable {
		/**
		 * The command path of the debug adapter executable.
A
Andre Weinand 已提交
429
		 * A command must be either an absolute path or the name of an executable looked up via the PATH environment variable.
430 431 432 433 434
		 * The special value 'node' will be mapped to VS Code's built-in node runtime.
		 */
		readonly command: string;

		/**
A
Andre Weinand 已提交
435
		 * Optional arguments passed to the debug adapter executable.
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
		 */
		readonly args: string[];

		/**
		 * Create a new debug adapter specification.
		 */
		constructor(command: string, args?: string[]);
	}

	export interface DebugConfigurationProvider {
		/**
		 * This optional method is called just before a debug adapter is started to determine its excutable path and arguments.
		 * Registering more than one debugAdapterExecutable for a type results in an error.
		 * @param folder The workspace folder from which the configuration originates from or undefined for a folderless setup.
		 * @param token A cancellation token.
		 * @return a [debug adapter's executable and optional arguments](#DebugAdapterExecutable) or undefined.
		 */
		debugAdapterExecutable?(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult<DebugAdapterExecutable>;
	}

J
Johannes Rieken 已提交
456 457 458 459
	//#endregion

	//#region Rob, Matt: logging

460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486
	/**
	 * The severity level of a log message
	 */
	export enum LogLevel {
		Trace = 1,
		Debug = 2,
		Info = 3,
		Warning = 4,
		Error = 5,
		Critical = 6,
		Off = 7
	}

	/**
	 * A logger for writing to an extension's log file, and accessing its dedicated log directory.
	 */
	export interface Logger {
		trace(message: string, ...args: any[]): void;
		debug(message: string, ...args: any[]): void;
		info(message: string, ...args: any[]): void;
		warn(message: string, ...args: any[]): void;
		error(message: string | Error, ...args: any[]): void;
		critical(message: string | Error, ...args: any[]): void;
	}

	export interface ExtensionContext {
		/**
R
Rob Lourens 已提交
487
		 * This extension's logger
488 489
		 */
		logger: Logger;
490 491 492 493 494 495 496

		/**
		 * Path where an extension can write log files.
		 *
		 * Extensions must create this directory before writing to it. The parent directory will always exist.
		 */
		readonly logDirectory: string;
497
	}
498

M
Matt Bierner 已提交
499 500 501 502 503 504 505 506 507
	export namespace env {
		/**
		 * Current logging level.
		 *
		 * @readonly
		 */
		export const logLevel: LogLevel;
	}

J
Johannes Rieken 已提交
508 509 510
	//#endregion

	//#region Joao: SCM validation
511

J
Joao Moreno 已提交
512 513 514 515 516 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
	/**
	 * 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 已提交
557

J
Johannes Rieken 已提交
558 559 560 561
	//#endregion

	//#region Matt: WebView

M
Matt Bierner 已提交
562 563 564 565 566
	/**
	 * Content settings for a webview.
	 */
	export interface WebviewOptions {
		/**
567
		 * Should scripts be enabled in the webview content?
M
Matt Bierner 已提交
568 569 570 571 572 573
		 *
		 * Defaults to false (scripts-disabled).
		 */
		readonly enableScripts?: boolean;

		/**
M
Matt Bierner 已提交
574
		 * Should command uris be enabled in webview content?
M
Matt Bierner 已提交
575 576 577 578 579
		 *
		 * Defaults to false.
		 */
		readonly enableCommandUris?: boolean;

580
		/**
581
		 * Root paths from which the webview can load local (filesystem) resources using the `vscode-resource:` scheme.
582
		 *
583
		 * Default to the root folders of the current workspace plus the extension's install directory.
584 585 586
		 *
		 * Pass in an empty array to disallow access to any local resources.
		 */
587
		readonly localResourceRoots?: ReadonlyArray<Uri>;
M
Matt Bierner 已提交
588 589 590
	}

	/**
591
	 * A webview displays html content, like an iframe.
M
Matt Bierner 已提交
592 593 594 595 596
	 */
	export interface Webview {
		/**
		 * Content settings for the webview.
		 */
M
Matt Bierner 已提交
597 598 599 600 601 602 603 604 605 606 607 608 609
		readonly options: WebviewOptions;

		/**
		 * Title of the webview shown in UI.
		 */
		title: string;

		/**
		 * Contents of the webview.
		 *
		 * Should be a complete html document.
		 */
		html: string;
M
Matt Bierner 已提交
610

M
Matt Bierner 已提交
611
		/**
612
		 * Fired when the webview content posts a message.
M
Matt Bierner 已提交
613
		 */
614
		readonly onDidReceiveMessage: Event<any>;
M
Matt Bierner 已提交
615

M
Matt Bierner 已提交
616
		/**
617 618 619 620 621
		 * Post a message to the webview content.
		 *
		 * Messages are only develivered if the webview is visible.
		 *
		 * @param message Body of the message.
M
Matt Bierner 已提交
622
		 */
623 624 625 626
		postMessage(message: any): Thenable<boolean>;
	}

	/**
627
	 * Content settings for a webview panel.
628
	 */
629
	export interface WebviewPanelOptions {
630
		/**
631
		 * Should the find widget be enabled in the panel?
632 633 634 635
		 *
		 * Defaults to false.
		 */
		readonly enableFindWidget?: boolean;
M
Matt Bierner 已提交
636 637

		/**
638
		 * Should the webview panel's content (iframe) be kept around even when the panel
639 640
		 * is no longer visible?
		 *
641 642
		 * Normally the webview panel's html context is created when the panel becomes visible
		 * and destroyed when it is is hidden. Extensions that have complex state
643 644
		 * or UI can set the `retainContextWhenHidden` to make VS Code keep the webview
		 * context around, even when the webview moves to a background tab. When
645
		 * the panel becomes visible again, the context is automatically restored
646 647 648
		 * in the exact same state it was in originally.
		 *
		 * `retainContextWhenHidden` has a high memory overhead and should only be used if
649
		 * your panel's context cannot be quickly saved and restored.
M
Matt Bierner 已提交
650
		 */
651 652
		readonly retainContextWhenHidden?: boolean;
	}
M
Matt Bierner 已提交
653

654
	/**
655
	 * A panel that contains a webview.
656
	 */
657
	interface WebviewPanel {
M
Matt Bierner 已提交
658
		/**
659
		 * Type of the webview panel, such as `'markdown.preview'`.
M
Matt Bierner 已提交
660
		 */
661
		readonly viewType: string;
M
Matt Bierner 已提交
662 663

		/**
664
		 * Webview belonging to the panel.
665 666 667 668
		 */
		readonly webview: Webview;

		/**
669
		 * Content settings for the webview panel.
670
		 */
671
		readonly options: WebviewPanelOptions;
672 673

		/**
674
		 * Editor position of the panel.
675
		 */
676
		readonly position?: ViewColumn;
677

678 679 680 681 682
		/**
		 * Is the panel current visible?
		 */
		readonly visible: boolean;

683
		/**
684
		 * Fired when the panel's view state changes.
685
		 */
686
		readonly onDidChangeViewState: Event<WebviewPanelOnDidChangeViewStateEvent>;
687 688

		/**
689
		 * Fired when the panel is disposed.
M
Matt Bierner 已提交
690
		 *
691
		 * This may be because the user closed the panel or because `.dispose()` was
692
		 * called on it.
M
Matt Bierner 已提交
693
		 *
694
		 * Trying to use the panel after it has been disposed throws an exception.
M
Matt Bierner 已提交
695
		 */
696
		readonly onDidDispose: Event<void>;
M
Matt Bierner 已提交
697

698
		/**
699
		 * Show the webview panel in a given column.
700
		 *
701 702
		 * A webview panel may only show in a single column at a time. If it is already showing, this
		 * method moves it to a new column.
703
		 */
704
		reveal(viewColumn: ViewColumn): void;
705

M
Matt Bierner 已提交
706
		/**
707
		 * Dispose of the webview panel.
M
Matt Bierner 已提交
708
		 *
709 710 711
		 * This closes the panel if it showing and disposes of the resources owned by the webview.
		 * Webview panels are also disposed when the user closes the webview panel. Both cases
		 * fire the `onDispose` event.
M
Matt Bierner 已提交
712 713 714 715
		 */
		dispose(): any;
	}

716 717 718
	/**
	 * Event fired when a webview panel's view state changes.
	 */
719
	export interface WebviewPanelOnDidChangeViewStateEvent {
720
		/**
721
		 * Webview panel whose view state changed.
722 723
		 */
		readonly webviewPanel: WebviewPanel;
724 725
	}

726
	/**
727
	 * Save and restore webview panels that have been persisted when vscode shuts down.
728
	 */
729
	interface WebviewPanelSerializer {
730
		/**
731
		 * Save a webview panel's `state`.
732
		 *
733 734
		 * Called before shutdown. Extensions have a 250ms timeframe to return a state. If serialization
		 * takes longer than 250ms, the panel will not be serialized.
735
		 *
736
		 * @param webviewPanel webview Panel to serialize. May or may not be visible.
737 738 739
		 *
		 * @returns JSON serializable state blob.
		 */
740
		serializeWebviewPanel(webviewPanel: WebviewPanel): Thenable<any>;
741 742

		/**
743
		 * Restore a webview panel from its seriailzed `state`.
744
		 *
745
		 * Called when a serialized webview first becomes visible.
746
		 *
747
		 * @param webviewPanel Webview panel to restore. The serializer should take ownership of this panel.
748
		 * @param state Persisted state.
749 750
		 *
		 * @return Thanble indicating that the webview has been fully restored.
751
		 */
752
		deserializeWebviewPanel(webviewPanel: WebviewPanel, state: any): Thenable<void>;
753 754
	}

M
Matt Bierner 已提交
755 756
	namespace window {
		/**
757
		 * Create and show a new webview panel.
M
Matt Bierner 已提交
758
		 *
759
		 * @param viewType Identifies the type of the webview panel.
760 761
		 * @param title Title of the panel.
		 * @param position Editor column to show the new panel in.
762
		 * @param options Settings for the new webview panel.
763 764
		 *
		 * @return New webview panel.
M
Matt Bierner 已提交
765
		 */
766
		export function createWebviewPanel(viewType: string, title: string, position: ViewColumn, options: WebviewPanelOptions & WebviewOptions): WebviewPanel;
767 768

		/**
769
		 * Registers a webview panel serializer.
770 771
		 *
		 * Extensions that support reviving should have an `"onView:viewType"` activation method and
772
		 * make sure that [registerWebviewPanelSerializer](#registerWebviewPanelSerializer) is called during activation.
773 774 775
		 *
		 * Only a single serializer may be registered at a time for a given `viewType`.
		 *
776
		 * @param viewType Type of the webview panel that can be serialized.
777 778
		 * @param reviver Webview serializer.
		 */
779
		export function registerWebviewPanelSerializer(viewType: string, reviver: WebviewPanelSerializer): Disposable;
M
Matt Bierner 已提交
780
	}
S
Sandeep Somavarapu 已提交
781

J
Johannes Rieken 已提交
782 783
	//#endregion

784 785 786
	//#region Tasks

	/**
787 788
	 * An object representing an executed Task. It can be used
	 * to terminate a task.
D
Dirk Baeumer 已提交
789 790
	 *
	 * This interface is not intended to be implemented.
791
	 */
792
	export interface TaskExecution {
D
Dirk Baeumer 已提交
793 794 795 796 797 798 799 800 801
		/**
		 * The task that got started.
		 */
		task: Task;

		/**
		 * Terminates the task execution.
		 */
		terminate(): void;
802 803 804 805
	}

	/**
	 * An event signaling the start of a task execution.
D
Dirk Baeumer 已提交
806 807
	 *
	 * This interface is not intended to be implemented.
808 809 810 811 812 813 814 815 816 817
	 */
	interface TaskStartEvent {
		/**
		 * The task item representing the task that got started.
		 */
		execution: TaskExecution;
	}

	/**
	 * An event signaling the end of an executed task.
D
Dirk Baeumer 已提交
818 819
	 *
	 * This interface is not intended to be implemented.
820 821 822 823 824 825 826 827 828
	 */
	interface TaskEndEvent {
		/**
		 * The task item representing the task that finished.
		 */
		execution: TaskExecution;
	}

	export namespace workspace {
829 830

		/**
831
		 * Fetches all task available in the systems. Thisweweb includes tasks
832 833
		 * from `tasks.json` files as well as tasks from task providers
		 * contributed through extensions.
834
		 */
835
		export function fetchTasks(): Thenable<Task[]>;
836 837

		/**
838 839 840 841
		 * Executes a task that is managed by VS Code. The returned
		 * task execution can be used to terminate the task.
		 *
		 * @param task the task to execute
842
		 */
843
		export function executeTask(task: Task): Thenable<TaskExecution>;
D
Dirk Baeumer 已提交
844 845

		/**
846 847 848 849
		 * Fires when a task starts.
		 */
		export const onDidStartTask: Event<TaskStartEvent>;

850
		/**
851
		 * Fires when a task ends.
852
		 */
853
		export const onDidEndTask: Event<TaskEndEvent>;
854 855 856
	}

	//#endregion
857 858 859 860

	//#region Terminal

	export namespace window {
D
Daniel Imms 已提交
861
		/**
D
jsdoc  
Daniel Imms 已提交
862 863
		 * The currently active terminals or an empty array.
		 *
D
Daniel Imms 已提交
864 865 866 867
		 * @readonly
		 */
		export let terminals: Terminal[];

D
jsdoc  
Daniel Imms 已提交
868 869 870 871
		/**
		 * An [event](#Event) which fires when a terminal has been created, either through the
		 * [createTerminal](#window.createTerminal) API or commands.
		 */
872 873 874 875
		export const onDidOpenTerminal: Event<Terminal>;
	}

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