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

J
Johannes Rieken 已提交
6
// This is the place for API experiments and proposals.
7

8 9
declare module 'vscode' {

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

14 15 16 17 18 19 20 21 22
	//#region Joh - https://github.com/Microsoft/vscode/issues/57093

	/**
	 * An insert text rule defines how the [`insertText`](#CompletionItem.insertText) of a
	 * completion item should be modified.
	 */
	export enum CompletionItemInsertTextRule {

		/**
J
Johannes Rieken 已提交
23 24 25
		 * Keep whitespace as is. By default, the editor adjusts leading
		 * whitespace of new lines so that they match the indentation of
		 * the line for which the item is accepeted.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
		 */
		KeepWhitespace = 0b01
	}

	export interface CompletionItem {

		/**
		 * Rules about how/if the `insertText` should be modified by the
		 * editor. Can be a bit mask of many rules.
		 */
		insertTextRules?: CompletionItemInsertTextRule;
	}

	//#endregion

41 42 43
	//#region Joh - clipboard https://github.com/Microsoft/vscode/issues/217

	export interface Clipboard {
44 45
		readText(): Thenable<string>;
		writeText(value: string): Thenable<void>;
46 47 48 49 50 51 52 53
	}

	export namespace env {
		export const clipboard: Clipboard;
	}

	//#endregion

54 55 56 57 58 59 60 61 62 63 64
	//#region Joh - read/write in chunks

	export interface FileSystemProvider {
		open?(resource: Uri): number | Thenable<number>;
		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

65
	//#region Rob: search provider
66

67 68 69
	/**
	 * The parameters of a query for text search.
	 */
70
	export interface TextSearchQuery {
71 72 73
		/**
		 * The text pattern to search for.
		 */
74
		pattern: string;
75

R
Rob Lourens 已提交
76 77 78 79 80
		/**
		 * Whether or not `pattern` should match multiple lines of text.
		 */
		isMultiline?: boolean;

81 82 83
		/**
		 * Whether or not `pattern` should be interpreted as a regular expression.
		 */
R
Rob Lourens 已提交
84
		isRegExp?: boolean;
85 86 87 88

		/**
		 * Whether or not the search should be case-sensitive.
		 */
R
Rob Lourens 已提交
89
		isCaseSensitive?: boolean;
90 91 92 93

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

97 98 99 100 101 102 103 104 105 106
	/**
	 * A file glob pattern to match file paths against.
	 * TODO@roblou - merge this with the GlobPattern docs/definition in vscode.d.ts.
	 * @see [GlobPattern](#GlobPattern)
	 */
	export type GlobString = string;

	/**
	 * Options common to file and text search
	 */
R
Rob Lourens 已提交
107
	export interface SearchOptions {
108 109 110
		/**
		 * The root folder to search within.
		 */
111
		folder: Uri;
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126

		/**
		 * 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 已提交
127
		useIgnoreFiles: boolean;
128 129 130 131 132

		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
133
		followSymlinks: boolean;
P
pkoushik 已提交
134 135 136 137 138 139 140

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

141
	}
142

R
Rob Lourens 已提交
143 144
	/**
	 * Options to specify the size of the result text preview.
R
Rob Lourens 已提交
145
	 * These options don't affect the size of the match itself, just the amount of preview text.
R
Rob Lourens 已提交
146
	 */
147
	export interface TextSearchPreviewOptions {
148
		/**
R
Rob Lourens 已提交
149
		 * The maximum number of lines in the preview.
R
Rob Lourens 已提交
150
		 * Only search providers that support multiline search will ever return more than one line in the match.
151
		 */
R
Rob Lourens 已提交
152
		matchLines: number;
R
Rob Lourens 已提交
153 154 155 156

		/**
		 * The maximum number of characters included per line.
		 */
R
Rob Lourens 已提交
157
		charsPerLine: number;
158 159
	}

160 161 162
	/**
	 * Options that apply to text search.
	 */
R
Rob Lourens 已提交
163
	export interface TextSearchOptions extends SearchOptions {
164
		/**
165
		 * The maximum number of results to be returned.
166
		 */
167 168
		maxResults: number;

R
Rob Lourens 已提交
169 170 171
		/**
		 * Options to specify the size of the result text preview.
		 */
172
		previewOptions?: TextSearchPreviewOptions;
173 174 175 176

		/**
		 * Exclude files larger than `maxFileSize` in bytes.
		 */
177
		maxFileSize?: number;
178 179 180 181 182

		/**
		 * Interpret files using this encoding.
		 * See the vscode setting `"files.encoding"`
		 */
183
		encoding?: string;
184 185
	}

186 187 188 189 190 191 192 193 194 195 196 197 198 199
	/**
	 * 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;
	}

200 201 202
	/**
	 * The parameters of a query for file search.
	 */
203
	export interface FileSearchQuery {
204 205 206
		/**
		 * The search pattern to match against file paths.
		 */
207 208
		pattern: string;
	}
209 210 211 212

	/**
	 * Options that apply to file search.
	 */
213
	export interface FileSearchOptions extends SearchOptions {
214
		/**
215
		 * The maximum number of results to be returned.
216
		 */
217
		maxResults: number;
218 219
	}

220
	/**
221
	 * Options that apply to requesting the file index.
222
	 */
223
	export interface FileIndexOptions extends SearchOptions { }
224

R
Rob Lourens 已提交
225 226 227
	/**
	 * A preview of the text result.
	 */
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243
	export interface TextSearchResultPreview {
		/**
		 * The matching line of text, or a portion of the matching line that contains the match.
		 * For now, this can only be a single line.
		 */
		text: string;

		/**
		 * The Range within `text` corresponding to the text of the match.
		 */
		match: Range;
	}

	/**
	 * A match from a text search
	 */
244
	export interface TextSearchResult {
245 246 247
		/**
		 * The uri for the matching document.
		 */
248
		uri: Uri;
249 250 251 252

		/**
		 * The range of the match within the document.
		 */
253
		range: Range;
R
Rob Lourens 已提交
254

255
		/**
R
Rob Lourens 已提交
256
		 * A preview of the text result.
257 258
		 */
		preview: TextSearchResultPreview;
259 260
	}

261
	/**
R
Rob Lourens 已提交
262 263 264 265 266 267 268 269 270 271
	 * A FileIndexProvider provides a list of files in the given folder. VS Code will filter that list for searching with quickopen or from other extensions.
	 *
	 * A FileIndexProvider is the simpler of two ways to implement file search in VS Code. Use a FileIndexProvider if you are able to provide a listing of all files
	 * in a folder, and want VS Code to filter them according to the user's search query.
	 *
	 * The FileIndexProvider will be invoked once when quickopen is opened, and VS Code will filter the returned list. It will also be invoked when
	 * `workspace.findFiles` is called.
	 *
	 * If a [`FileSearchProvider`](#FileSearchProvider) is registered for the scheme, that provider will be used instead.
	 */
272
	export interface FileIndexProvider {
273
		/**
R
Rob Lourens 已提交
274
		 * Provide the set of files in the folder.
275 276 277
		 * @param options A set of options to consider while searching.
		 * @param token A cancellation token.
		 */
278
		provideFileIndex(options: FileIndexOptions, token: CancellationToken): ProviderResult<Uri[]>;
279 280
	}

281
	/**
R
Rob Lourens 已提交
282 283 284 285 286 287 288 289 290
	 * 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.
	 *
	 * @see [FileIndexProvider](#FileIndexProvider)
291
	 */
292
	export interface FileSearchProvider {
293 294 295 296 297 298 299
		/**
		 * 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 progress A progress callback that must be invoked for all results.
		 * @param token A cancellation token.
		 */
300
		provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, token: CancellationToken): ProviderResult<Uri[]>;
301
	}
302

R
Rob Lourens 已提交
303 304 305 306
	/**
	 * A TextSearchProvider provides search results for text results inside files in the workspace.
	 */
	export interface TextSearchProvider {
307 308 309 310 311 312 313
		/**
		 * 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.
		 */
314
		provideTextSearchResults(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): ProviderResult<TextSearchComplete>;
315 316
	}

317 318 319
	/**
	 * Options that can be set on a findTextInFiles search.
	 */
R
Rob Lourens 已提交
320
	export interface FindTextInFilesOptions {
321 322 323 324 325
		/**
		 * 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).
		 */
326
		include?: GlobPattern;
327 328 329 330 331 332 333 334 335 336 337

		/**
		 * A [glob pattern](#GlobPattern) that defines files and folders to exclude. The glob pattern
		 * will be matched against the file paths of resulting matches relative to their workspace. When `undefined` only default excludes will
		 * apply, when `null` no excludes will apply.
		 */
		exclude?: GlobPattern | null;

		/**
		 * The maximum number of results to search for
		 */
R
Rob Lourens 已提交
338
		maxResults?: number;
339 340 341 342 343

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

P
pkoushik 已提交
346 347 348 349
		/**
		 * Whether global files that exclude files, like .gitignore, should be respected.
		 * See the vscode setting `"search.useGlobalIgnoreFiles"`.
		 */
350
		useGlobalIgnoreFiles?: boolean;
P
pkoushik 已提交
351

352 353 354 355
		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
356
		followSymlinks?: boolean;
357 358 359 360 361

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

R
Rob Lourens 已提交
364 365 366
		/**
		 * Options to specify the size of the result text preview.
		 */
367
		previewOptions?: TextSearchPreviewOptions;
R
Rob Lourens 已提交
368 369
	}

370
	export namespace workspace {
371 372 373 374 375
		/**
		 * DEPRECATED
		 */
		export function registerSearchProvider(): Disposable;

376
		/**
R
Rob Lourens 已提交
377
		 * Register a file index provider.
378 379 380 381 382 383 384
		 *
		 * 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.
		 */
R
Rob Lourens 已提交
385
		export function registerFileIndexProvider(scheme: string, provider: FileIndexProvider): Disposable;
386 387 388 389 390 391 392 393 394 395

		/**
		 * 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.
		 */
R
Rob Lourens 已提交
396
		export function registerFileSearchProvider(scheme: string, provider: FileSearchProvider): Disposable;
397

398
		/**
R
Rob Lourens 已提交
399
		 * Register a text search provider.
400 401 402 403 404 405 406
		 *
		 * 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.
		 */
R
Rob Lourens 已提交
407
		export function registerTextSearchProvider(scheme: string, provider: TextSearchProvider): Disposable;
408 409 410 411 412 413 414 415

		/**
		 * 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.
		 */
416
		export function findTextInFiles(query: TextSearchQuery, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<TextSearchComplete>;
417 418 419 420 421 422 423 424 425

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

J
Johannes Rieken 已提交
429
	//#endregion
430

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

J
Joao Moreno 已提交
433 434 435
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
436 437 438 439 440 441 442
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460
	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;
	}
461

J
Johannes Rieken 已提交
462 463 464
	//#endregion

	//#region Joh: decorations
465 466 467

	//todo@joh -> make class
	export interface DecorationData {
468
		letter?: string;
469 470 471
		title?: string;
		color?: ThemeColor;
		priority?: number;
472
		bubble?: boolean;
J
Johannes Rieken 已提交
473
		source?: string; // hacky... we should remove it and use equality under the hood
474 475
	}

476 477 478 479 480 481
	export interface SourceControlResourceDecorations {
		source?: string;
		letter?: string;
		color?: ThemeColor;
	}

482
	export interface DecorationProvider {
483
		onDidChangeDecorations: Event<undefined | Uri | Uri[]>;
484 485 486 487
		provideDecoration(uri: Uri, token: CancellationToken): ProviderResult<DecorationData>;
	}

	export namespace window {
488
		export function registerDecorationProvider(provider: DecorationProvider): Disposable;
489 490 491
	}

	//#endregion
492

J
Johannes Rieken 已提交
493 494
	//#region André: debug

495 496 497 498
	/**
	 * Represents a debug adapter executable and optional arguments passed to it.
	 */
	export class DebugAdapterExecutable {
499 500 501

		readonly type: 'executable';

502 503
		/**
		 * The command path of the debug adapter executable.
A
Andre Weinand 已提交
504
		 * A command must be either an absolute path or the name of an executable looked up via the PATH environment variable.
505 506 507 508 509
		 * The special value 'node' will be mapped to VS Code's built-in node runtime.
		 */
		readonly command: string;

		/**
A
Andre Weinand 已提交
510
		 * Optional arguments passed to the debug adapter executable.
511 512 513
		 */
		readonly args: string[];

514 515 516 517 518 519 520 521 522 523 524 525
		/**
		 * The additional environment of the executed program or shell. If omitted
		 * the parent process' environment is used. If provided it is merged with
		 * the parent process' environment.
		 */
		readonly env?: { [key: string]: string };

		/**
		 * The working directory for the debug adapter.
		 */
		readonly cwd?: string;

526
		/**
A
Andre Weinand 已提交
527
		 * Create a description for a debug adapter based on an executable program.
528
		 */
529
		constructor(command: string, args?: string[], env?: { [key: string]: string }, cwd?: string);
530 531
	}

A
Andre Weinand 已提交
532 533 534
	/**
	 * Represents a debug adapter running as a socket based server.
	 */
535 536 537 538 539 540 541 542 543
	export class DebugAdapterServer {

		readonly type: 'server';

		/**
		 * The port.
		 */
		readonly port: number;

544 545 546 547 548
		/**
		 * The host.
		 */
		readonly host?: string;

549
		/**
A
Andre Weinand 已提交
550
		 * Create a description for a debug adapter running as a socket based server.
551
		 */
552
		constructor(port: number, host?: string);
553 554
	}

A
Andre Weinand 已提交
555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571
	/**
	 * Represents a debug adapter that is implemented in the extension.
	 */
	export class DebugAdapterImplementation {

		readonly type: 'implementation';

		readonly implementation: any;

		/**
		 * Create a description for a debug adapter directly implemented in the extension.
		 * The implementation's "type": TBD
		 */
		constructor(implementation: any);
	}

	export type DebugAdapterDescriptor = DebugAdapterExecutable | DebugAdapterServer | DebugAdapterImplementation;
572

A
Andre Weinand 已提交
573 574 575 576 577 578 579 580 581 582 583 584 585 586 587
	/**
	 * A Debug Adapter Tracker is a means to track the communication between VS Code and a Debug Adapter.
	 */
	export interface IDebugAdapterTracker {
		// VS Code -> Debug Adapter
		startDebugAdapter?(): void;
		toDebugAdapter?(message: any): void;
		stopDebugAdapter?(): void;

		// Debug Adapter -> VS Code
		fromDebugAdapter?(message: any): void;
		debugAdapterError?(error: Error): void;
		debugAdapterExit?(code?: number, signal?: string): void;
	}

588 589
	export interface DebugConfigurationProvider {
		/**
590 591 592 593 594 595 596 597 598 599 600 601
		 * The optional method 'provideDebugAdapter' is called at the start of a debug session to provide details about the debug adapter to use.
		 * These details must be returned as objects of type DebugAdapterDescriptor.
		 * Currently two types of debug adapters are supported:
		 * - a debug adapter executable specified as a command path and arguments (see DebugAdapterExecutable),
		 * - a debug adapter server reachable via a communication port (see DebugAdapterServer).
		 * If the method is not implemented the default behavior is this:
		 *   provideDebugAdapter(session: DebugSession, folder: WorkspaceFolder | undefined, executable: DebugAdapterExecutable, config: DebugConfiguration, token?: CancellationToken) {
		 *      if (typeof config.debugServer === 'number') {
		 *         return new DebugAdapterServer(config.debugServer);
		 *      }
		 * 		return executable;
		 *   }
602 603
		 * An extension is only allowed to register a DebugConfigurationProvider with a provideDebugAdapter method if the extension defines the debug type. Otherwise an error is thrown.
		 * Registering more than one DebugConfigurationProvider with a provideDebugAdapter method for a type results in an error.
604
		 * @param session The [debug session](#DebugSession) for which the debug adapter will be used.
605
		 * @param folder The workspace folder from which the configuration originates from or undefined for a folderless setup.
606 607
		 * @param executable The debug adapter's executable information as specified in the package.json (or undefined if no such information exists).
		 * @param config The resolved debug configuration.
608
		 * @param token A cancellation token.
609
		 * @return a [debug adapter's descriptor](#DebugAdapterDescriptor) or undefined.
610
		 */
611
		provideDebugAdapter?(session: DebugSession, folder: WorkspaceFolder | undefined, executable: DebugAdapterExecutable | undefined, config: DebugConfiguration, token?: CancellationToken): ProviderResult<DebugAdapterDescriptor>;
612

A
Andre Weinand 已提交
613 614 615 616 617 618 619 620 621
		/**
		 * The optional method 'provideDebugAdapterTracker' is called at the start of a debug session to provide a tracker that gives access to the communication between VS Code and a Debug Adapter.
		 * @param session The [debug session](#DebugSession) for which the tracker will be used.
		 * @param folder The workspace folder from which the configuration originates from or undefined for a folderless setup.
		 * @param config The resolved debug configuration.
		 * @param token A cancellation token.
		 */
		provideDebugAdapterTracker?(session: DebugSession, folder: WorkspaceFolder | undefined, config: DebugConfiguration, token?: CancellationToken): ProviderResult<IDebugAdapterTracker>;

622
		/**
623 624
		 * Deprecated, use DebugConfigurationProvider.provideDebugAdapter instead.
		 * @deprecated Use DebugConfigurationProvider.provideDebugAdapter instead
625
		 */
626
		debugAdapterExecutable?(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult<DebugAdapterExecutable>;
627 628
	}

J
Johannes Rieken 已提交
629 630 631 632
	//#endregion

	//#region Rob, Matt: logging

633 634 635 636 637 638 639 640 641 642 643 644 645
	/**
	 * The severity level of a log message
	 */
	export enum LogLevel {
		Trace = 1,
		Debug = 2,
		Info = 3,
		Warning = 4,
		Error = 5,
		Critical = 6,
		Off = 7
	}

M
Matt Bierner 已提交
646 647 648 649 650
	export namespace env {
		/**
		 * Current logging level.
		 */
		export const logLevel: LogLevel;
651 652 653 654 655

		/**
		 * An [event](#Event) that fires when the log level has changed.
		 */
		export const onDidChangeLogLevel: Event<LogLevel>;
M
Matt Bierner 已提交
656 657
	}

J
Johannes Rieken 已提交
658 659 660
	//#endregion

	//#region Joao: SCM validation
661

J
Joao Moreno 已提交
662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706
	/**
	 * 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 已提交
707

J
Johannes Rieken 已提交
708 709
	//#endregion

710 711 712 713 714 715 716 717 718 719 720 721 722
	//#region Joao: SCM selected provider

	export interface SourceControl {

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

		/**
		 * An event signaling when the selection state changes.
		 */
		readonly onDidChangeSelection: Event<boolean>;
723 724 725 726
	}

	//#endregion

727 728 729 730 731 732 733 734 735 736 737 738 739 740 741
	//#region Joao: SCM Input Box

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

		/**
		* Whether the input box is visible.
		*/
		visible: boolean;
	}

	//#endregion

742 743 744 745 746
	//#region Comments
	/**
	 * Comments provider related APIs are still in early stages, they may be changed significantly during our API experiments.
	 */

747
	interface CommentInfo {
748 749 750
		/**
		 * All of the comment threads associated with the document.
		 */
751
		threads: CommentThread[];
752 753 754 755

		/**
		 * The ranges of the document which support commenting.
		 */
756 757 758
		commentingRanges?: Range[];
	}

759 760 761 762 763 764 765 766 767 768 769
	export enum CommentThreadCollapsibleState {
		/**
		 * Determines an item is collapsed
		 */
		Collapsed = 0,
		/**
		 * Determines an item is expanded
		 */
		Expanded = 1
	}

770 771 772
	/**
	 * A collection of comments representing a conversation at a particular range in a document.
	 */
M
Matt Bierner 已提交
773
	interface CommentThread {
774 775 776
		/**
		 * A unique identifier of the comment thread.
		 */
777
		threadId: string;
778 779 780 781

		/**
		 * The uri of the document the thread has been created on.
		 */
782
		resource: Uri;
783 784 785 786 787

		/**
		 * The range the comment thread is located within the document. The thread icon will be shown
		 * at the first line of the range.
		 */
M
Matt Bierner 已提交
788
		range: Range;
789 790 791 792

		/**
		 * The ordered comments of the thread.
		 */
M
Matt Bierner 已提交
793
		comments: Comment[];
794 795 796 797

		/**
		 * Whether the thread should be collapsed or expanded when opening the document. Defaults to Collapsed.
		 */
798
		collapsibleState?: CommentThreadCollapsibleState;
M
Matt Bierner 已提交
799 800
	}

801 802 803
	/**
	 * A comment is displayed within the editor or the Comments Panel, depending on how it is provided.
	 */
M
Matt Bierner 已提交
804
	interface Comment {
805 806 807
		/**
		 * The id of the comment
		 */
P
Peng Lyu 已提交
808
		commentId: string;
809 810 811 812

		/**
		 * The text of the comment
		 */
M
Matt Bierner 已提交
813
		body: MarkdownString;
814 815 816 817

		/**
		 * The display name of the user who created the comment
		 */
M
Matt Bierner 已提交
818
		userName: string;
819 820

		/**
821 822 823 824 825 826 827
		 * The icon path for the user who created the comment
		 */
		userIconPath?: Uri;


		/**
		 * @deprecated Use userIconPath instead. The avatar src of the user who created the comment
828
		 */
829
		gravatar?: string;
830 831 832 833 834 835 836 837 838

		/**
		 * Whether the current user has permission to edit the comment.
		 *
		 * This will be treated as false if the comment is provided by a `WorkspaceCommentProvider`, or
		 * if it is provided by a `DocumentCommentProvider` and  no `editComment` method is given.
		 */
		canEdit?: boolean;

839 840 841 842 843 844 845 846
		/**
		 * Whether the current user has permission to delete the comment.
		 *
		 * This will be treated as false if the comment is provided by a `WorkspaceCommentProvider`, or
		 * if it is provided by a `DocumentCommentProvider` and  no `deleteComment` method is given.
		 */
		canDelete?: boolean;

847 848 849
		/**
		 * The command to be executed if the comment is selected in the Comments Panel
		 */
850
		command?: Command;
M
Matt Bierner 已提交
851 852
	}

853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869
	export interface CommentThreadChangedEvent {
		/**
		 * Added comment threads.
		 */
		readonly added: CommentThread[];

		/**
		 * Removed comment threads.
		 */
		readonly removed: CommentThread[];

		/**
		 * Changed comment threads.
		 */
		readonly changed: CommentThread[];
	}

870
	interface DocumentCommentProvider {
871 872 873
		/**
		 * Provide the commenting ranges and comment threads for the given document. The comments are displayed within the editor.
		 */
874
		provideDocumentComments(document: TextDocument, token: CancellationToken): Promise<CommentInfo>;
875 876 877 878

		/**
		 * Called when a user adds a new comment thread in the document at the specified range, with body text.
		 */
879
		createNewCommentThread(document: TextDocument, range: Range, text: string, token: CancellationToken): Promise<CommentThread>;
880 881 882 883

		/**
		 * Called when a user replies to a new comment thread in the document at the specified range, with body text.
		 */
884
		replyToCommentThread(document: TextDocument, range: Range, commentThread: CommentThread, text: string, token: CancellationToken): Promise<CommentThread>;
885 886

		/**
N
Nick Schonning 已提交
887
		 * Called when a user edits the comment body to the be new text.
888
		 */
889
		editComment?(document: TextDocument, comment: Comment, text: string, token: CancellationToken): Promise<void>;
890

891 892 893 894 895
		/**
		 * Called when a user deletes the comment.
		 */
		deleteComment?(document: TextDocument, comment: Comment, token: CancellationToken): Promise<void>;

896 897 898
		/**
		 * Notify of updates to comment threads.
		 */
899
		onDidChangeCommentThreads: Event<CommentThreadChangedEvent>;
900 901 902
	}

	interface WorkspaceCommentProvider {
903 904 905 906
		/**
		 * Provide all comments for the workspace. Comments are shown within the comments panel. Selecting a comment
		 * from the panel runs the comment's command.
		 */
907
		provideWorkspaceComments(token: CancellationToken): Promise<CommentThread[]>;
908 909 910 911

		/**
		 * Notify of updates to comment threads.
		 */
912
		onDidChangeCommentThreads: Event<CommentThreadChangedEvent>;
M
Matt Bierner 已提交
913 914 915
	}

	namespace workspace {
916 917
		export function registerDocumentCommentProvider(provider: DocumentCommentProvider): Disposable;
		export function registerWorkspaceCommentProvider(provider: WorkspaceCommentProvider): Disposable;
M
Matt Bierner 已提交
918
	}
919 920
	//#endregion

921 922
	//#region Terminal

D
Daniel Imms 已提交
923
	export interface Terminal {
D
Daniel Imms 已提交
924
		/**
D
Daniel Imms 已提交
925
		 * Fires when the terminal's pty slave pseudo-device is written to. In other words, this
D
Daniel Imms 已提交
926
		 * provides access to the raw data stream from the process running within the terminal,
927
		 * including VT sequences.
D
Daniel Imms 已提交
928
		 */
929
		onDidWriteData: Event<string>;
D
Daniel Imms 已提交
930 931
	}

D
Daniel Imms 已提交
932
	/**
933
	 * Represents the dimensions of a terminal.
D
Daniel Imms 已提交
934 935 936 937 938
	 */
	export interface TerminalDimensions {
		/**
		 * The number of columns in the terminal.
		 */
939
		readonly columns: number;
D
Daniel Imms 已提交
940 941 942 943

		/**
		 * The number of rows in the terminal.
		 */
944
		readonly rows: number;
D
Daniel Imms 已提交
945 946
	}

947 948 949 950
	/**
	 * Represents a terminal without a process where all interaction and output in the terminal is
	 * controlled by an extension. This is similar to an output window but has the same VT sequence
	 * compatility as the regular terminal.
D
Daniel Imms 已提交
951 952 953 954
	 *
	 * Note that an instance of [Terminal](#Terminal) will be created when a TerminalRenderer is
	 * created with all its APIs available for use by extensions. When using the Terminal object
	 * of a TerminalRenderer it acts just like normal only the extension that created the
955
	 * TerminalRenderer essentially acts as a process. For example when an
956 957
	 * [Terminal.onDidWriteData](#Terminal.onDidWriteData) listener is registered, that will fire
	 * when [TerminalRenderer.write](#TerminalRenderer.write) is called. Similarly when
D
Daniel Imms 已提交
958
	 * [Terminal.sendText](#Terminal.sendText) is triggered that will fire the
959
	 * [TerminalRenderer.onDidAcceptInput](#TerminalRenderer.onDidAcceptInput) event.
960 961 962 963 964 965 966
	 *
	 * **Example:** Create a terminal renderer, show it and write hello world in red
	 * ```typescript
	 * const renderer = window.createTerminalRenderer('foo');
	 * renderer.terminal.then(t => t.show());
	 * renderer.write('\x1b[31mHello world\x1b[0m');
	 * ```
967
	 */
968
	export interface TerminalRenderer {
969 970 971
		/**
		 * The name of the terminal, this will appear in the terminal selector.
		 */
972 973
		name: string;

D
Daniel Imms 已提交
974 975 976 977
		/**
		 * The dimensions of the terminal, the rows and columns of the terminal can only be set to
		 * a value smaller than the maximum value, if this is undefined the terminal will auto fit
		 * to the maximum value [maximumDimensions](TerminalRenderer.maximumDimensions).
978 979 980 981 982 983 984 985
		 *
		 * **Example:** Override the dimensions of a TerminalRenderer to 20 columns and 10 rows
		 * ```typescript
		 * terminalRenderer.dimensions = {
		 *   cols: 20,
		 *   rows: 10
		 * };
		 * ```
D
Daniel Imms 已提交
986
		 */
987
		dimensions: TerminalDimensions | undefined;
D
Daniel Imms 已提交
988 989 990 991 992 993 994

		/**
		 * The maximum dimensions of the terminal, this will be undefined immediately after a
		 * terminal renderer is created and also until the terminal becomes visible in the UI.
		 * Listen to [onDidChangeMaximumDimensions](TerminalRenderer.onDidChangeMaximumDimensions)
		 * to get notified when this value changes.
		 */
995
		readonly maximumDimensions: TerminalDimensions | undefined;
996

997 998 999
		/**
		 * The corressponding [Terminal](#Terminal) for this TerminalRenderer.
		 */
1000
		readonly terminal: Terminal;
1001

1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017
		/**
		 * Write text to the terminal. Unlike [Terminal.sendText](#Terminal.sendText) which sends
		 * text to the underlying _process_, this will write the text to the terminal itself.
		 *
		 * **Example:** Write red text to the terminal
		 * ```typescript
		 * terminalRenderer.write('\x1b[31mHello world\x1b[0m');
		 * ```
		 *
		 * **Example:** Move the cursor to the 10th row and 20th column and write an asterisk
		 * ```typescript
		 * terminalRenderer.write('\x1b[10;20H*');
		 * ```
		 *
		 * @param text The text to write.
		 */
D
Daniel Imms 已提交
1018
		write(text: string): void;
1019

1020 1021 1022 1023
		/**
		 * An event which fires on keystrokes in the terminal or when an extension calls
		 * [Terminal.sendText](#Terminal.sendText). Keystrokes are converted into their
		 * corresponding VT sequence representation.
1024 1025 1026 1027 1028
		 *
		 * **Example:** Simulate interaction with the terminal from an outside extension or a
		 * workbench command such as `workbench.action.terminal.runSelectedText`
		 * ```typescript
		 * const terminalRenderer = window.createTerminalRenderer('test');
1029
		 * terminalRenderer.onDidAcceptInput(data => {
1030 1031 1032 1033
		 *   cosole.log(data); // 'Hello world'
		 * });
		 * terminalRenderer.terminal.then(t => t.sendText('Hello world'));
		 * ```
1034
		 */
1035
		readonly onDidAcceptInput: Event<string>;
1036

D
Daniel Imms 已提交
1037 1038 1039 1040
		/**
		 * An event which fires when the [maximum dimensions](#TerminalRenderer.maimumDimensions) of
		 * the terminal renderer change.
		 */
1041
		readonly onDidChangeMaximumDimensions: Event<TerminalDimensions>;
1042 1043
	}

1044
	export namespace window {
D
Daniel Imms 已提交
1045 1046 1047 1048 1049
		/**
		 * Create a [TerminalRenderer](#TerminalRenderer).
		 *
		 * @param name The name of the terminal renderer, this shows up in the terminal selector.
		 */
1050
		export function createTerminalRenderer(name: string): TerminalRenderer;
1051 1052 1053
	}

	//#endregion
J
Joao Moreno 已提交
1054

1055 1056 1057 1058 1059 1060 1061
	//#region Joh -> exclusive document filters

	export interface DocumentFilter {
		exclusive?: boolean;
	}

	//#endregion
C
Christof Marti 已提交
1062

J
Johannes Rieken 已提交
1063
	//#region mjbvz,joh: https://github.com/Microsoft/vscode/issues/43768
1064 1065 1066
	export interface FileRenameEvent {
		readonly oldUri: Uri;
		readonly newUri: Uri;
C
Christof Marti 已提交
1067 1068
	}

1069 1070 1071
	export interface FileWillRenameEvent {
		readonly oldUri: Uri;
		readonly newUri: Uri;
1072
		waitUntil(thenable: Thenable<WorkspaceEdit>): void;
1073 1074
	}

1075
	export namespace workspace {
1076
		export const onWillRenameFile: Event<FileWillRenameEvent>;
1077
		export const onDidRenameFile: Event<FileRenameEvent>;
1078 1079
	}
	//#endregion
1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126

	//#region Signature Help
	/**
	 * How a [Signature provider](#SignatureHelpProvider) was triggered
	 */
	export enum SignatureHelpTriggerReason {
		/**
		 * Signature help was invoked manually by the user or by a command.
		 */
		Invoke = 1,

		/**
		 * Signature help was triggered by a trigger character.
		 */
		TriggerCharacter = 2,

		/**
		 * Signature help was retriggered.
		 *
		 * Retriggers occur when the signature help is already active and can be caused by typing a trigger character
		 * or by a cursor move.
		 */
		Retrigger = 3,
	}

	/**
	 * Contains additional information about the context in which a
	 * [signature help provider](#SignatureHelpProvider.provideSignatureHelp) is triggered.
	 */
	export interface SignatureHelpContext {
		/**
		 * Action that caused signature help to be requested.
		 */
		readonly triggerReason: SignatureHelpTriggerReason;

		/**
		 * Character that caused signature help to be requested.
		 *
		 * This is `undefined` for manual triggers or retriggers for a cursor move.
		 */
		readonly triggerCharacter?: string;
	}

	export interface SignatureHelpProvider {
		provideSignatureHelp(document: TextDocument, position: Position, token: CancellationToken, context: SignatureHelpContext): ProviderResult<SignatureHelp>;
	}

1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138
	export interface SignatureHelpProviderMetadata {
		readonly triggerCharacters: ReadonlyArray<string>;
		readonly retriggerCharacters: ReadonlyArray<string>;
	}

	namespace languages {
		export function registerSignatureHelpProvider(
			selector: DocumentSelector,
			provider: SignatureHelpProvider,
			metadata: SignatureHelpProviderMetadata
		): Disposable;
	}
1139
	//#endregion
1140 1141 1142 1143 1144 1145 1146 1147 1148

	//#region Alex - OnEnter enhancement
	export interface OnEnterRule {
		/**
		 * This rule will only execute if the text above the this line matches this regular expression.
		 */
		oneLineAboveText?: RegExp;
	}
	//#endregion
1149

1150
	//#region Tree Item Label Highlights
1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163
	/**
	 * Label describing the [Tree item](#TreeItem)
	 */
	export interface TreeItemLabel {

		/**
		 * A human-readable string describing the [Tree item](#TreeItem).
		 */
		label: string;

		/**
		 * Ranges in the label to highlight.
		 */
S
Sandeep Somavarapu 已提交
1164
		highlights?: [number, number][];
1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179

	}

	export class TreeItem2 extends TreeItem {
		/**
		 * Label describing this item. When `falsy`, it is derived from [resourceUri](#TreeItem.resourceUri).
		 */
		label?: string | TreeItemLabel | /* for compilation */ any;

		/**
		 * @param label Label describing this item
		 * @param collapsibleState [TreeItemCollapsibleState](#TreeItemCollapsibleState) of the tree item. Default is [TreeItemCollapsibleState.None](#TreeItemCollapsibleState.None)
		 */
		constructor(label: TreeItemLabel, collapsibleState?: TreeItemCollapsibleState);
	}
1180 1181 1182 1183 1184 1185 1186 1187 1188 1189
	//#endregion

	//#region Task
	/**
	 * Controls how the task is presented in the UI.
	 */
	export interface TaskPresentationOptions {
		/**
		 * Controls whether the terminal is cleared before executing the task.
		 */
1190
		clear?: boolean;
1191 1192 1193
	}
	//#endregion

J
Johannes Rieken 已提交
1194
}