vscode.proposed.d.ts 29.7 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
	export namespace languages {

		/**
		 *
		 */
		export function changeLanguage(document: TextDocument, languageId: string): Thenable<void>;
	}

22 23 24 25 26 27 28 29 30 31 32
	//#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

33
	//#region Rob: search provider
34

35 36 37
	/**
	 * The parameters of a query for text search.
	 */
38
	export interface TextSearchQuery {
39 40 41
		/**
		 * The text pattern to search for.
		 */
42
		pattern: string;
43 44 45 46

		/**
		 * Whether or not `pattern` should be interpreted as a regular expression.
		 */
R
Rob Lourens 已提交
47
		isRegExp?: boolean;
48 49 50 51

		/**
		 * Whether or not the search should be case-sensitive.
		 */
R
Rob Lourens 已提交
52
		isCaseSensitive?: boolean;
53 54 55 56

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

60 61 62 63 64 65 66 67 68 69
	/**
	 * 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 已提交
70
	export interface SearchOptions {
71 72 73
		/**
		 * The root folder to search within.
		 */
74
		folder: Uri;
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89

		/**
		 * 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 已提交
90
		useIgnoreFiles: boolean;
91 92 93 94 95

		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
96
		followSymlinks: boolean;
97
	}
98

R
Rob Lourens 已提交
99 100
	/**
	 * Options to specify the size of the result text preview.
R
Rob Lourens 已提交
101
	 * These options don't affect the size of the match itself, just the amount of preview text.
R
Rob Lourens 已提交
102
	 */
103
	export interface TextSearchPreviewOptions {
104
		/**
R
Rob Lourens 已提交
105
		 * The maximum number of lines in the preview.
R
Rob Lourens 已提交
106
		 * Only search providers that support multiline search will ever return more than one line in the match.
107
		 */
108
		maxLines: number;
R
Rob Lourens 已提交
109 110 111 112

		/**
		 * The maximum number of characters included before the start of the match.
		 */
113
		leadingChars: number;
R
Rob Lourens 已提交
114 115 116 117

		/**
		 * The maximum number of characters included per line.
		 */
118
		totalChars: number;
119 120
	}

121 122 123
	/**
	 * Options that apply to text search.
	 */
R
Rob Lourens 已提交
124
	export interface TextSearchOptions extends SearchOptions {
125
		/**
126
		 * The maximum number of results to be returned.
127
		 */
128 129
		maxResults: number;

R
Rob Lourens 已提交
130 131 132
		/**
		 * Options to specify the size of the result text preview.
		 */
133
		previewOptions?: TextSearchPreviewOptions;
134 135 136 137

		/**
		 * Exclude files larger than `maxFileSize` in bytes.
		 */
138
		maxFileSize?: number;
139 140 141 142 143

		/**
		 * Interpret files using this encoding.
		 * See the vscode setting `"files.encoding"`
		 */
144
		encoding?: string;
145 146
	}

147 148 149
	/**
	 * The parameters of a query for file search.
	 */
150
	export interface FileSearchQuery {
151 152 153
		/**
		 * The search pattern to match against file paths.
		 */
154 155
		pattern: string;
	}
156 157 158 159

	/**
	 * Options that apply to file search.
	 */
160
	export interface FileSearchOptions extends SearchOptions {
161
		/**
162
		 * The maximum number of results to be returned.
163
		 */
164
		maxResults: number;
165 166
	}

167
	/**
168
	 * Options that apply to requesting the file index.
169
	 */
170
	export interface FileIndexOptions extends SearchOptions { }
171

R
Rob Lourens 已提交
172 173 174
	/**
	 * A preview of the text result.
	 */
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190
	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
	 */
191
	export interface TextSearchResult {
192 193 194
		/**
		 * The uri for the matching document.
		 */
195
		uri: Uri;
196 197 198 199

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

202
		/**
R
Rob Lourens 已提交
203
		 * A preview of the text result.
204 205
		 */
		preview: TextSearchResultPreview;
206 207
	}

208
	/**
R
Rob Lourens 已提交
209 210 211 212 213 214 215 216 217 218
	 * 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.
	 */
219
	export interface FileIndexProvider {
220
		/**
R
Rob Lourens 已提交
221
		 * Provide the set of files in the folder.
222 223 224
		 * @param options A set of options to consider while searching.
		 * @param token A cancellation token.
		 */
225
		provideFileIndex(options: FileIndexOptions, token: CancellationToken): Thenable<Uri[]>;
226 227
	}

228
	/**
R
Rob Lourens 已提交
229 230 231 232 233 234 235 236 237
	 * 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)
238
	 */
239
	export interface FileSearchProvider {
240 241 242 243 244 245 246
		/**
		 * 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.
		 */
247
		provideFileSearchResults(query: FileSearchQuery, options: FileSearchOptions, token: CancellationToken): Thenable<Uri[]>;
248
	}
249

R
Rob Lourens 已提交
250 251 252 253
	/**
	 * A TextSearchProvider provides search results for text results inside files in the workspace.
	 */
	export interface TextSearchProvider {
254 255 256 257 258 259 260
		/**
		 * 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.
		 */
R
Rob Lourens 已提交
261
		provideTextSearchResults(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): Thenable<void>;
262 263
	}

264 265 266
	/**
	 * Options that can be set on a findTextInFiles search.
	 */
R
Rob Lourens 已提交
267
	export interface FindTextInFilesOptions {
268 269 270 271 272
		/**
		 * 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).
		 */
273
		include?: GlobPattern;
274 275 276 277 278 279 280 281 282 283 284

		/**
		 * 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 已提交
285
		maxResults?: number;
286 287 288 289 290

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

		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
297
		followSymlinks?: boolean;
298 299 300 301 302

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

R
Rob Lourens 已提交
305 306 307
		/**
		 * Options to specify the size of the result text preview.
		 */
308
		previewOptions?: TextSearchPreviewOptions;
R
Rob Lourens 已提交
309 310
	}

311
	export namespace workspace {
312 313 314 315 316
		/**
		 * DEPRECATED
		 */
		export function registerSearchProvider(): Disposable;

317
		/**
R
Rob Lourens 已提交
318
		 * Register a file index provider.
319 320 321 322 323 324 325
		 *
		 * 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 已提交
326
		export function registerFileIndexProvider(scheme: string, provider: FileIndexProvider): Disposable;
327 328 329 330 331 332 333 334 335 336

		/**
		 * 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 已提交
337
		export function registerFileSearchProvider(scheme: string, provider: FileSearchProvider): Disposable;
338

339
		/**
R
Rob Lourens 已提交
340
		 * Register a text search provider.
341 342 343 344 345 346 347
		 *
		 * 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 已提交
348
		export function registerTextSearchProvider(scheme: string, provider: TextSearchProvider): Disposable;
349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366

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

		/**
		 * 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.
		 */
R
Rob Lourens 已提交
367
		export function findTextInFiles(query: TextSearchQuery, options: FindTextInFilesOptions, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<void>;
368 369
	}

J
Johannes Rieken 已提交
370
	//#endregion
371

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

J
Joao Moreno 已提交
374 375 376
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
377 378 379 380 381 382 383
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401
	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;
	}
402

J
Johannes Rieken 已提交
403 404 405
	//#endregion

	//#region Joh: decorations
406 407 408

	//todo@joh -> make class
	export interface DecorationData {
409
		letter?: string;
410 411 412
		title?: string;
		color?: ThemeColor;
		priority?: number;
413
		bubble?: boolean;
J
Johannes Rieken 已提交
414
		source?: string; // hacky... we should remove it and use equality under the hood
415 416
	}

417 418 419 420 421 422
	export interface SourceControlResourceDecorations {
		source?: string;
		letter?: string;
		color?: ThemeColor;
	}

423
	export interface DecorationProvider {
424
		onDidChangeDecorations: Event<undefined | Uri | Uri[]>;
425 426 427 428
		provideDecoration(uri: Uri, token: CancellationToken): ProviderResult<DecorationData>;
	}

	export namespace window {
429
		export function registerDecorationProvider(provider: DecorationProvider): Disposable;
430 431 432
	}

	//#endregion
433

J
Johannes Rieken 已提交
434 435
	//#region André: debug

436 437 438 439
	/**
	 * Represents a debug adapter executable and optional arguments passed to it.
	 */
	export class DebugAdapterExecutable {
440 441 442

		readonly type: 'executable';

443 444
		/**
		 * The command path of the debug adapter executable.
A
Andre Weinand 已提交
445
		 * A command must be either an absolute path or the name of an executable looked up via the PATH environment variable.
446 447 448 449 450
		 * The special value 'node' will be mapped to VS Code's built-in node runtime.
		 */
		readonly command: string;

		/**
A
Andre Weinand 已提交
451
		 * Optional arguments passed to the debug adapter executable.
452 453 454
		 */
		readonly args: string[];

455 456 457 458 459 460 461 462 463 464 465 466
		/**
		 * 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;

467 468 469
		/**
		 * Create a new debug adapter specification.
		 */
470
		constructor(command: string, args?: string[], env?: { [key: string]: string }, cwd?: string);
471 472
	}

473 474 475 476 477 478 479 480 481
	export class DebugAdapterServer {

		readonly type: 'server';

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

482 483 484 485 486
		/**
		 * The host.
		 */
		readonly host?: string;

487 488 489
		/**
		 * Create a new debug adapter specification.
		 */
490
		constructor(port: number, host?: string);
491 492 493 494
	}

	export type DebugAdapterDescriptor = DebugAdapterExecutable | DebugAdapterServer;

495 496
	export interface DebugConfigurationProvider {
		/**
497 498 499 500 501 502 503 504 505 506 507 508 509 510
		 * 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;
		 *   }
		 * Registering more than one provideDebugAdapter for a type results in an error.
		 * @param session The [debug session](#DebugSession) for which the debug adapter will be used.
511
		 * @param folder The workspace folder from which the configuration originates from or undefined for a folderless setup.
512 513
		 * @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.
514
		 * @param token A cancellation token.
515
		 * @return a [debug adapter's descriptor](#DebugAdapterDescriptor) or undefined.
516
		 */
517
		provideDebugAdapter?(session: DebugSession, folder: WorkspaceFolder | undefined, executable: DebugAdapterExecutable | undefined, config: DebugConfiguration, token?: CancellationToken): ProviderResult<DebugAdapterDescriptor>;
518 519

		/**
520
		 * Deprecated, use DebugConfigurationProvider.provideDebugAdapter instead.
521
		 * This optional method is called just before a debug adapter is started to determine its executable path and arguments.
522
		 * Registering more than one debugAdapterExecutable for a type results in an error.
523 524
		 * @param folder The workspace folder from which the configuration originates from or undefined for a folderless setup.
		 * @param token A cancellation token.
525 526
		 * @return a [debug adapter's executable and optional arguments](#DebugAdapterExecutable) or undefined.
		 * @deprecated Use DebugConfigurationProvider.provideDebugAdapter instead
527
		 */
528
		debugAdapterExecutable?(folder: WorkspaceFolder | undefined, token?: CancellationToken): ProviderResult<DebugAdapterExecutable>;
529 530
	}

J
Johannes Rieken 已提交
531 532 533 534
	//#endregion

	//#region Rob, Matt: logging

535 536 537 538 539 540 541 542 543 544 545 546 547
	/**
	 * 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 已提交
548 549 550 551 552
	export namespace env {
		/**
		 * Current logging level.
		 */
		export const logLevel: LogLevel;
553 554 555 556 557

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

J
Johannes Rieken 已提交
560 561 562
	//#endregion

	//#region Joao: SCM validation
563

J
Joao Moreno 已提交
564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608
	/**
	 * 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 已提交
609

J
Johannes Rieken 已提交
610 611
	//#endregion

612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628
	//#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>;
	}

	//#endregion

629 630 631 632 633
	//#region Comments
	/**
	 * Comments provider related APIs are still in early stages, they may be changed significantly during our API experiments.
	 */

634 635 636 637 638
	interface CommentInfo {
		threads: CommentThread[];
		commentingRanges?: Range[];
	}

639 640 641 642 643 644 645 646 647 648 649
	export enum CommentThreadCollapsibleState {
		/**
		 * Determines an item is collapsed
		 */
		Collapsed = 0,
		/**
		 * Determines an item is expanded
		 */
		Expanded = 1
	}

M
Matt Bierner 已提交
650
	interface CommentThread {
651
		threadId: string;
652
		resource: Uri;
M
Matt Bierner 已提交
653 654
		range: Range;
		comments: Comment[];
655
		collapsibleState?: CommentThreadCollapsibleState;
M
Matt Bierner 已提交
656 657 658
	}

	interface Comment {
659 660 661
		/**
		 * The id of the comment
		 */
P
Peng Lyu 已提交
662
		commentId: string;
663 664 665 666

		/**
		 * The text of the comment
		 */
M
Matt Bierner 已提交
667
		body: MarkdownString;
668 669 670 671

		/**
		 * The display name of the user who created the comment
		 */
M
Matt Bierner 已提交
672
		userName: string;
673 674 675 676

		/**
		 * The avatar src of the user who created the comment
		 */
677
		gravatar: string;
678 679 680 681 682 683 684 685 686 687 688 689

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

		/**
		 * The command to be executed if the comment is selected in the Comments Panel
		 */
690
		command?: Command;
M
Matt Bierner 已提交
691 692
	}

693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709
	export interface CommentThreadChangedEvent {
		/**
		 * Added comment threads.
		 */
		readonly added: CommentThread[];

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

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

710
	interface DocumentCommentProvider {
711 712 713
		/**
		 * Provide the commenting ranges and comment threads for the given document. The comments are displayed within the editor.
		 */
714
		provideDocumentComments(document: TextDocument, token: CancellationToken): Promise<CommentInfo>;
715 716 717 718

		/**
		 * Called when a user adds a new comment thread in the document at the specified range, with body text.
		 */
719
		createNewCommentThread(document: TextDocument, range: Range, text: string, token: CancellationToken): Promise<CommentThread>;
720 721 722 723

		/**
		 * Called when a user replies to a new comment thread in the document at the specified range, with body text.
		 */
724
		replyToCommentThread(document: TextDocument, range: Range, commentThread: CommentThread, text: string, token: CancellationToken): Promise<CommentThread>;
725 726 727 728 729 730 731 732 733

		/**
		 * Called when a user edits the comment body to the be new text text.
		 */
		editComment?(document: TextDocument, comment: Comment, text: string, token: CancellationToken): Promise<Comment>;

		/**
		 * Notify of updates to comment threads.
		 */
734
		onDidChangeCommentThreads: Event<CommentThreadChangedEvent>;
735 736 737
	}

	interface WorkspaceCommentProvider {
738 739 740 741
		/**
		 * Provide all comments for the workspace. Comments are shown within the comments panel. Selecting a comment
		 * from the panel runs the comment's command.
		 */
742
		provideWorkspaceComments(token: CancellationToken): Promise<CommentThread[]>;
743 744 745 746

		/**
		 * Notify of updates to comment threads.
		 */
747
		onDidChangeCommentThreads: Event<CommentThreadChangedEvent>;
M
Matt Bierner 已提交
748 749 750
	}

	namespace workspace {
751 752
		export function registerDocumentCommentProvider(provider: DocumentCommentProvider): Disposable;
		export function registerWorkspaceCommentProvider(provider: WorkspaceCommentProvider): Disposable;
M
Matt Bierner 已提交
753
	}
754 755
	//#endregion

756 757
	//#region Terminal

D
Daniel Imms 已提交
758
	export interface Terminal {
D
Daniel Imms 已提交
759
		/**
D
Daniel Imms 已提交
760
		 * Fires when the terminal's pty slave pseudo-device is written to. In other words, this
D
Daniel Imms 已提交
761
		 * provides access to the raw data stream from the process running within the terminal,
762
		 * including VT sequences.
D
Daniel Imms 已提交
763
		 */
764
		onDidWriteData: Event<string>;
D
Daniel Imms 已提交
765 766
	}

D
Daniel Imms 已提交
767
	/**
768
	 * Represents the dimensions of a terminal.
D
Daniel Imms 已提交
769 770 771 772 773
	 */
	export interface TerminalDimensions {
		/**
		 * The number of columns in the terminal.
		 */
774
		readonly columns: number;
D
Daniel Imms 已提交
775 776 777 778

		/**
		 * The number of rows in the terminal.
		 */
779
		readonly rows: number;
D
Daniel Imms 已提交
780 781
	}

782 783 784 785
	/**
	 * 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 已提交
786 787 788 789
	 *
	 * 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
790
	 * TerminalRenderer essentially acts as a process. For example when an
791 792
	 * [Terminal.onDidWriteData](#Terminal.onDidWriteData) listener is registered, that will fire
	 * when [TerminalRenderer.write](#TerminalRenderer.write) is called. Similarly when
D
Daniel Imms 已提交
793
	 * [Terminal.sendText](#Terminal.sendText) is triggered that will fire the
794
	 * [TerminalRenderer.onDidAcceptInput](#TerminalRenderer.onDidAcceptInput) event.
795 796 797 798 799 800 801
	 *
	 * **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');
	 * ```
802
	 */
803
	export interface TerminalRenderer {
804 805 806
		/**
		 * The name of the terminal, this will appear in the terminal selector.
		 */
807 808
		name: string;

D
Daniel Imms 已提交
809 810 811 812
		/**
		 * 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).
813 814 815 816 817 818 819 820
		 *
		 * **Example:** Override the dimensions of a TerminalRenderer to 20 columns and 10 rows
		 * ```typescript
		 * terminalRenderer.dimensions = {
		 *   cols: 20,
		 *   rows: 10
		 * };
		 * ```
D
Daniel Imms 已提交
821
		 */
822
		dimensions: TerminalDimensions | undefined;
D
Daniel Imms 已提交
823 824 825 826 827 828 829

		/**
		 * 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.
		 */
830
		readonly maximumDimensions: TerminalDimensions | undefined;
831

832 833 834
		/**
		 * The corressponding [Terminal](#Terminal) for this TerminalRenderer.
		 */
835
		readonly terminal: Terminal;
836

837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852
		/**
		 * 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 已提交
853
		write(text: string): void;
854

855 856 857 858
		/**
		 * 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.
859 860 861 862 863
		 *
		 * **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');
864
		 * terminalRenderer.onDidAcceptInput(data => {
865 866 867 868
		 *   cosole.log(data); // 'Hello world'
		 * });
		 * terminalRenderer.terminal.then(t => t.sendText('Hello world'));
		 * ```
869
		 */
870
		readonly onDidAcceptInput: Event<string>;
871

D
Daniel Imms 已提交
872 873 874 875
		/**
		 * An event which fires when the [maximum dimensions](#TerminalRenderer.maimumDimensions) of
		 * the terminal renderer change.
		 */
876
		readonly onDidChangeMaximumDimensions: Event<TerminalDimensions>;
877 878
	}

879
	export namespace window {
880 881 882 883
		/**
		 * The currently active terminal or `undefined`. The active terminal is the one that
		 * currently has focus or most recently had focus.
		 */
884
		export const activeTerminal: Terminal | undefined;
885 886 887

		/**
		 * An [event](#Event) which fires when the [active terminal](#window.activeTerminal)
888
		 * has changed. *Note* that the event also fires when the active terminal changes
889 890 891 892
		 * to `undefined`.
		 */
		export const onDidChangeActiveTerminal: Event<Terminal | undefined>;

D
Daniel Imms 已提交
893 894 895 896 897
		/**
		 * Create a [TerminalRenderer](#TerminalRenderer).
		 *
		 * @param name The name of the terminal renderer, this shows up in the terminal selector.
		 */
898
		export function createTerminalRenderer(name: string): TerminalRenderer;
899 900 901
	}

	//#endregion
J
Joao Moreno 已提交
902

903 904 905 906 907 908 909
	//#region Joh -> exclusive document filters

	export interface DocumentFilter {
		exclusive?: boolean;
	}

	//#endregion
C
Christof Marti 已提交
910

J
Johannes Rieken 已提交
911
	//#region mjbvz,joh: https://github.com/Microsoft/vscode/issues/43768
912 913 914
	export interface FileRenameEvent {
		readonly oldUri: Uri;
		readonly newUri: Uri;
C
Christof Marti 已提交
915 916
	}

917 918 919
	export interface FileWillRenameEvent {
		readonly oldUri: Uri;
		readonly newUri: Uri;
920
		waitUntil(thenable: Thenable<WorkspaceEdit>): void;
921 922
	}

923
	export namespace workspace {
924
		export const onWillRenameFile: Event<FileWillRenameEvent>;
925
		export const onDidRenameFile: Event<FileRenameEvent>;
926 927
	}
	//#endregion
928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975

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

	//#endregion
976 977 978 979 980 981 982 983 984

	//#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
J
Johannes Rieken 已提交
985
}