vscode.proposed.d.ts 30.0 KB
Newer Older
1 2 3 4 5 6 7
/*---------------------------------------------------------------------------------------------
 *  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.

8 9
import { QuickPickItem } from 'vscode';

10 11
declare module 'vscode' {

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

16
	//#region Rob: search provider
17

18 19 20
	/**
	 * The parameters of a query for text search.
	 */
21
	export interface TextSearchQuery {
22 23 24
		/**
		 * The text pattern to search for.
		 */
25
		pattern: string;
26 27 28 29

		/**
		 * Whether or not `pattern` should be interpreted as a regular expression.
		 */
R
Rob Lourens 已提交
30
		isRegExp?: boolean;
31 32 33 34

		/**
		 * Whether or not the search should be case-sensitive.
		 */
R
Rob Lourens 已提交
35
		isCaseSensitive?: boolean;
36 37 38 39

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

43 44 45 46 47 48 49 50 51 52
	/**
	 * 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 已提交
53
	export interface SearchOptions {
54 55 56
		/**
		 * The root folder to search within.
		 */
57
		folder: Uri;
58 59 60 61 62 63 64 65 66 67 68 69 70 71 72

		/**
		 * 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 已提交
73
		useIgnoreFiles?: boolean;
74 75 76 77 78

		/**
		 * Whether symlinks should be followed while searching.
		 * See the vscode setting `"search.followSymlinks"`.
		 */
R
Rob Lourens 已提交
79
		followSymlinks?: boolean;
80 81 82 83

		/**
		 * The maximum number of results to be returned.
		 */
R
Rob Lourens 已提交
84
		maxResults?: number;
85 86
	}

87 88 89
	/**
	 * Options that apply to text search.
	 */
R
Rob Lourens 已提交
90
	export interface TextSearchOptions extends SearchOptions {
91 92 93 94 95 96 97 98
		/**
		 *  TODO@roblou - total length? # of context lines? leading and trailing # of chars?
		 */
		previewOptions?: any;

		/**
		 * Exclude files larger than `maxFileSize` in bytes.
		 */
99
		maxFileSize?: number;
100 101 102 103 104

		/**
		 * Interpret files using this encoding.
		 * See the vscode setting `"files.encoding"`
		 */
105
		encoding?: string;
106 107
	}

108 109 110
	/**
	 * The parameters of a query for file search.
	 */
111
	export interface FileSearchQuery {
112 113 114
		/**
		 * The search pattern to match against file paths.
		 */
115
		pattern: string;
116 117 118 119 120

		/**
		 * `cacheKey` has the same value when `provideFileSearchResults` is invoked multiple times during a single quickopen session.
		 * Providers can optionally use this to cache results at the beginning of a quickopen session and filter results as the user types.
		 */
121 122 123
		cacheKey?: string;
	}

124 125 126
	/**
	 * Options that apply to file search.
	 */
127 128
	export interface FileSearchOptions extends SearchOptions { }

129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144
	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
	 */
145
	export interface TextSearchResult {
146 147 148
		/**
		 * The uri for the matching document.
		 */
149
		uri: Uri;
150 151 152 153

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

156 157 158 159
		/**
		 * A preview of the matching line
		 */
		preview: TextSearchResultPreview;
160 161
	}

162 163 164
	/**
	 * A SearchProvider provides search results for files or text in files. It can be invoked by quickopen, the search viewlet, and other extensions.
	 */
165
	export interface SearchProvider {
166 167 168 169 170 171 172
		/**
		 * 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.
		 */
173
		provideFileSearchResults?(query: FileSearchQuery, options: FileSearchOptions, progress: Progress<Uri>, token: CancellationToken): Thenable<void>;
174 175 176 177 178 179 180 181

		/**
		 * 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.
		 */
182
		provideTextSearchResults?(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): Thenable<void>;
183 184
	}

R
Rob Lourens 已提交
185 186 187 188 189 190 191 192 193
	export interface FindTextInFilesOptions {
		includes?: GlobPattern[];
		excludes?: GlobPattern[];
		maxResults?: number;
		useIgnoreFiles?: boolean;
		followSymlinks?: boolean;
		encoding?: string;
	}

194
	export namespace workspace {
195
		export function registerSearchProvider(scheme: string, provider: SearchProvider): Disposable;
R
Rob Lourens 已提交
196
		export function findTextInFiles(query: TextSearchQuery, options: FindTextInFilesOptions, callback: (result: TextSearchResult) => void, token?: CancellationToken): Thenable<void>;
197 198
	}

J
Johannes Rieken 已提交
199
	//#endregion
200

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

J
Joao Moreno 已提交
203 204 205
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
206 207 208 209 210 211 212
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230
	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;
	}
231

J
Johannes Rieken 已提交
232 233 234
	//#endregion

	//#region Joh: decorations
235 236 237 238 239

	//todo@joh -> make class
	export interface DecorationData {
		priority?: number;
		title?: string;
240
		bubble?: boolean;
241 242
		abbreviation?: string;
		color?: ThemeColor;
243
		source?: string;
244 245
	}

246 247 248 249 250 251
	export interface SourceControlResourceDecorations {
		source?: string;
		letter?: string;
		color?: ThemeColor;
	}

252
	export interface DecorationProvider {
253
		onDidChangeDecorations: Event<undefined | Uri | Uri[]>;
254 255 256 257
		provideDecoration(uri: Uri, token: CancellationToken): ProviderResult<DecorationData>;
	}

	export namespace window {
258
		export function registerDecorationProvider(provider: DecorationProvider): Disposable;
259 260 261
	}

	//#endregion
262

J
Johannes Rieken 已提交
263 264
	//#region André: debug

265 266 267 268 269 270
	/**
	 * 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 已提交
271
		 * A command must be either an absolute path or the name of an executable looked up via the PATH environment variable.
272 273 274 275 276
		 * The special value 'node' will be mapped to VS Code's built-in node runtime.
		 */
		readonly command: string;

		/**
A
Andre Weinand 已提交
277
		 * Optional arguments passed to the debug adapter executable.
278 279 280 281 282 283 284 285 286 287 288
		 */
		readonly args: string[];

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

	export interface DebugConfigurationProvider {
		/**
289
		 * This optional method is called just before a debug adapter is started to determine its executable path and arguments.
290 291 292 293 294 295 296 297
		 * 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 已提交
298 299 300 301
	//#endregion

	//#region Rob, Matt: logging

302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328
	/**
	 * 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 已提交
329
		 * This extension's logger
330 331
		 */
		logger: Logger;
332 333 334 335 336 337 338

		/**
		 * 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;
339
	}
340

M
Matt Bierner 已提交
341 342 343 344 345 346 347 348 349
	export namespace env {
		/**
		 * Current logging level.
		 *
		 * @readonly
		 */
		export const logLevel: LogLevel;
	}

J
Johannes Rieken 已提交
350 351 352
	//#endregion

	//#region Joao: SCM validation
353

J
Joao Moreno 已提交
354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398
	/**
	 * 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 已提交
399

J
Johannes Rieken 已提交
400 401
	//#endregion

402 403 404 405 406
	//#region Comments
	/**
	 * Comments provider related APIs are still in early stages, they may be changed significantly during our API experiments.
	 */

407 408 409 410 411
	interface CommentInfo {
		threads: CommentThread[];
		commentingRanges?: Range[];
	}

412 413 414 415 416 417 418 419 420 421 422
	export enum CommentThreadCollapsibleState {
		/**
		 * Determines an item is collapsed
		 */
		Collapsed = 0,
		/**
		 * Determines an item is expanded
		 */
		Expanded = 1
	}

M
Matt Bierner 已提交
423
	interface CommentThread {
424
		threadId: string;
425
		resource: Uri;
M
Matt Bierner 已提交
426 427
		range: Range;
		comments: Comment[];
428
		collapsibleState?: CommentThreadCollapsibleState;
M
Matt Bierner 已提交
429 430 431
	}

	interface Comment {
P
Peng Lyu 已提交
432
		commentId: string;
M
Matt Bierner 已提交
433 434
		body: MarkdownString;
		userName: string;
435
		gravatar: string;
436
		command?: Command;
M
Matt Bierner 已提交
437 438
	}

439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
	export interface CommentThreadChangedEvent {
		/**
		 * Added comment threads.
		 */
		readonly added: CommentThread[];

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

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

456 457
	interface DocumentCommentProvider {
		provideDocumentComments(document: TextDocument, token: CancellationToken): Promise<CommentInfo>;
458 459
		createNewCommentThread?(document: TextDocument, range: Range, text: string, token: CancellationToken): Promise<CommentThread>;
		replyToCommentThread?(document: TextDocument, range: Range, commentThread: CommentThread, text: string, token: CancellationToken): Promise<CommentThread>;
460 461 462 463 464
		onDidChangeCommentThreads?: Event<CommentThreadChangedEvent>;
	}

	interface WorkspaceCommentProvider {
		provideWorkspaceComments(token: CancellationToken): Promise<CommentThread[]>;
465 466 467
		createNewCommentThread?(document: TextDocument, range: Range, text: string, token: CancellationToken): Promise<CommentThread>;
		replyToCommentThread?(document: TextDocument, range: Range, commentThread: CommentThread, text: string, token: CancellationToken): Promise<CommentThread>;

468
		onDidChangeCommentThreads?: Event<CommentThreadChangedEvent>;
M
Matt Bierner 已提交
469 470 471
	}

	namespace workspace {
472 473
		export function registerDocumentCommentProvider(provider: DocumentCommentProvider): Disposable;
		export function registerWorkspaceCommentProvider(provider: WorkspaceCommentProvider): Disposable;
M
Matt Bierner 已提交
474
	}
475 476
	//#endregion

477 478
	//#region Terminal

D
Daniel Imms 已提交
479
	export interface Terminal {
D
Daniel Imms 已提交
480
		/**
D
Daniel Imms 已提交
481
		 * Fires when the terminal's pty slave pseudo-device is written to. In other words, this
D
Daniel Imms 已提交
482
		 * provides access to the raw data stream from the process running within the terminal,
483
		 * including VT sequences.
D
Daniel Imms 已提交
484
		 */
485
		onDidWriteData: Event<string>;
D
Daniel Imms 已提交
486 487
	}

D
Daniel Imms 已提交
488
	/**
489
	 * Represents the dimensions of a terminal.
D
Daniel Imms 已提交
490 491 492 493 494
	 */
	export interface TerminalDimensions {
		/**
		 * The number of columns in the terminal.
		 */
495
		readonly columns: number;
D
Daniel Imms 已提交
496 497 498 499

		/**
		 * The number of rows in the terminal.
		 */
500
		readonly rows: number;
D
Daniel Imms 已提交
501 502
	}

503 504 505 506
	/**
	 * 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 已提交
507 508 509 510
	 *
	 * 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
511
	 * TerminalRenderer essentially acts as a process. For example when an
512 513
	 * [Terminal.onDidWriteData](#Terminal.onDidWriteData) listener is registered, that will fire
	 * when [TerminalRenderer.write](#TerminalRenderer.write) is called. Similarly when
D
Daniel Imms 已提交
514
	 * [Terminal.sendText](#Terminal.sendText) is triggered that will fire the
515
	 * [TerminalRenderer.onDidAcceptInput](#TerminalRenderer.onDidAcceptInput) event.
516 517 518 519 520 521 522
	 *
	 * **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');
	 * ```
523
	 */
524
	export interface TerminalRenderer {
525 526 527
		/**
		 * The name of the terminal, this will appear in the terminal selector.
		 */
528 529
		name: string;

D
Daniel Imms 已提交
530 531 532 533
		/**
		 * 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).
534 535 536 537 538 539 540 541
		 *
		 * **Example:** Override the dimensions of a TerminalRenderer to 20 columns and 10 rows
		 * ```typescript
		 * terminalRenderer.dimensions = {
		 *   cols: 20,
		 *   rows: 10
		 * };
		 * ```
D
Daniel Imms 已提交
542
		 */
543
		dimensions: TerminalDimensions | undefined;
D
Daniel Imms 已提交
544 545 546 547 548 549 550

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

553 554 555
		/**
		 * The corressponding [Terminal](#Terminal) for this TerminalRenderer.
		 */
556
		readonly terminal: Terminal;
557

558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573
		/**
		 * 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 已提交
574
		write(text: string): void;
575

576 577 578 579
		/**
		 * 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.
580 581 582 583 584
		 *
		 * **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');
585
		 * terminalRenderer.onDidAcceptInput(data => {
586 587 588 589
		 *   cosole.log(data); // 'Hello world'
		 * });
		 * terminalRenderer.terminal.then(t => t.sendText('Hello world'));
		 * ```
590
		 */
591
		readonly onDidAcceptInput: Event<string>;
592

D
Daniel Imms 已提交
593 594 595 596
		/**
		 * An event which fires when the [maximum dimensions](#TerminalRenderer.maimumDimensions) of
		 * the terminal renderer change.
		 */
597
		readonly onDidChangeMaximumDimensions: Event<TerminalDimensions>;
598 599
	}

600
	export namespace window {
D
Daniel Imms 已提交
601
		/**
602
		 * The currently opened terminals or an empty array.
D
Daniel Imms 已提交
603
		 */
604
		export const terminals: ReadonlyArray<Terminal>;
D
Daniel Imms 已提交
605

606 607 608 609
		/**
		 * The currently active terminal or `undefined`. The active terminal is the one that
		 * currently has focus or most recently had focus.
		 */
610
		export const activeTerminal: Terminal | undefined;
611 612 613

		/**
		 * An [event](#Event) which fires when the [active terminal](#window.activeTerminal)
614
		 * has changed. *Note* that the event also fires when the active terminal changes
615 616 617 618
		 * to `undefined`.
		 */
		export const onDidChangeActiveTerminal: Event<Terminal | undefined>;

D
jsdoc  
Daniel Imms 已提交
619 620 621 622
		/**
		 * An [event](#Event) which fires when a terminal has been created, either through the
		 * [createTerminal](#window.createTerminal) API or commands.
		 */
623
		export const onDidOpenTerminal: Event<Terminal>;
624

D
Daniel Imms 已提交
625 626 627 628 629
		/**
		 * Create a [TerminalRenderer](#TerminalRenderer).
		 *
		 * @param name The name of the terminal renderer, this shows up in the terminal selector.
		 */
630
		export function createTerminalRenderer(name: string): TerminalRenderer;
631 632 633
	}

	//#endregion
J
Joao Moreno 已提交
634 635 636

	//#region URLs

J
Joao Moreno 已提交
637 638
	export interface ProtocolHandler {
		handleUri(uri: Uri): void;
J
Joao Moreno 已提交
639 640 641 642 643
	}

	export namespace window {

		/**
J
Joao Moreno 已提交
644
		 * Registers a protocol handler capable of handling system-wide URIs.
J
Joao Moreno 已提交
645
		 */
J
Joao Moreno 已提交
646
		export function registerProtocolHandler(handler: ProtocolHandler): Disposable;
J
Joao Moreno 已提交
647 648 649
	}

	//#endregion
650

651 652 653 654 655 656 657
	//#region Joh -> exclusive document filters

	export interface DocumentFilter {
		exclusive?: boolean;
	}

	//#endregion
C
Christof Marti 已提交
658

659 660 661 662
	//#region QuickInput API

	export namespace window {

C
Christof Marti 已提交
663 664 665 666 667 668
		/**
		 * A back button for [QuickPick](#QuickPick) and [InputBox](#InputBox).
		 *
		 * When a navigation 'back' button is needed this one should be used for consistency.
		 * It comes with a predefined icon, tooltip and location.
		 */
C
Christof Marti 已提交
669 670
		export const quickInputBackButton: QuickInputButton;

C
Christof Marti 已提交
671 672 673 674 675
		/**
		 * Creates a [QuickPick](#QuickPick) to let the user pick an item from a list
		 * of items of type T.
		 *
		 * Note that in many cases the more convenient [window.showQuickPick](#window.showQuickPick)
676 677
		 * is easier to use. [window.createQuickPick](#window.createQuickPick) should be used,
		 * when [window.showQuickPick](#window.showQuickPick) does not offer the required flexibility.
C
Christof Marti 已提交
678 679 680
		 *
		 * @return A new [QuickPick](#QuickPick).
		 */
681
		export function createQuickPick<T extends QuickPickItem>(): QuickPick<T>;
682

C
Christof Marti 已提交
683 684 685 686
		/**
		 * Creates a [InputBox](#InputBox) to let the user enter some text input.
		 *
		 * Note that in many cases the more convenient [window.showInputBox](#window.showInputBox)
687 688
		 * is easier to use. [window.createInputBox](#window.createInputBox) should be used,
		 * when [window.showInputBox](#window.showInputBox) does not offer the required flexibility.
C
Christof Marti 已提交
689 690 691
		 *
		 * @return A new [InputBox](#InputBox).
		 */
692 693 694
		export function createInputBox(): InputBox;
	}

C
Christof Marti 已提交
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715
	/**
	 * A light-weight user input UI that is intially not visible. After
	 * configuring it through its properties the extension can make it
	 * visible by calling [QuickInput.show](#QuickInput.show).
	 *
	 * There are several reasons why this UI might have to be hidden and
	 * the extension will be notified through [QuickInput.onDidHide](#QuickInput.onDidHide).
	 * (Examples include: an explict call to [QuickInput.hide](#QuickInput.hide),
	 * the user pressing Esc, some other input UI opening, etc.)
	 *
	 * A user pressing Enter or some other gesture implying acceptance
	 * of the current state does not automatically hide this UI component.
	 * It is up to the extension to decide whether to accept the user's input
	 * and if the UI should indeed be hidden through a call to [QuickInput.hide](#QuickInput.hide).
	 *
	 * When the extension no longer needs this input UI, it should
	 * [QuickInput.dispose](#QuickInput.dispose) it to allow for freeing up
	 * any resources associated with it.
	 *
	 * See [QuickPick](#QuickPick) and [InputBox](#InputBox) for concrete UIs.
	 */
716 717
	export interface QuickInput {

C
Christof Marti 已提交
718 719 720
		/**
		 * An optional title.
		 */
C
Christof Marti 已提交
721 722
		title: string | undefined;

C
Christof Marti 已提交
723 724 725
		/**
		 * An optional current step count.
		 */
C
Christof Marti 已提交
726 727
		step: number | undefined;

C
Christof Marti 已提交
728 729 730
		/**
		 * An optional total step count.
		 */
C
Christof Marti 已提交
731 732
		totalSteps: number | undefined;

C
Christof Marti 已提交
733 734 735 736 737 738
		/**
		 * If the UI should allow for user input. Defaults to true.
		 *
		 * Change this to false, e.g., while validating user input or
		 * loading data for the next step in user input.
		 */
739 740
		enabled: boolean;

C
Christof Marti 已提交
741 742 743 744 745 746
		/**
		 * If the UI should show a progress indicator. Defaults to false.
		 *
		 * Change this to true, e.g., while loading more data or validating
		 * user input.
		 */
747 748
		busy: boolean;

C
Christof Marti 已提交
749 750 751
		/**
		 * If the UI should stay open even when loosing UI focus. Defaults to false.
		 */
752 753
		ignoreFocusOut: boolean;

C
Christof Marti 已提交
754 755 756 757
		/**
		 * Makes the input UI visible in its current configuration. Any other input
		 * UI will first fire an [QuickInput.onDidHide](#QuickInput.onDidHide) event.
		 */
758 759
		show(): void;

C
Christof Marti 已提交
760 761 762 763
		/**
		 * Hides this input UI. This will also fire an [QuickInput.onDidHide](#QuickInput.onDidHide)
		 * event.
		 */
764 765
		hide(): void;

C
Christof Marti 已提交
766 767 768 769 770 771 772 773
		/**
		 * An event signaling when this input UI is hidden.
		 *
		 * There are several reasons why this UI might have to be hidden and
		 * the extension will be notified through [QuickInput.onDidHide](#QuickInput.onDidHide).
		 * (Examples include: an explict call to [QuickInput.hide](#QuickInput.hide),
		 * the user pressing Esc, some other input UI opening, etc.)
		 */
774 775
		onDidHide: Event<void>;

C
Christof Marti 已提交
776 777 778 779 780 781
		/**
		 * Dispose of this input UI and any associated resources. If it is still
		 * visible, it is first hidden. After this call the input UI is no longer
		 * functional and no additional methods or properties on it should be
		 * accessed. Instead a new input UI should be created.
		 */
782 783 784
		dispose(): void;
	}

C
Christof Marti 已提交
785 786 787 788 789 790 791
	/**
	 * A concrete [QuickInput](#QuickInput) to let the user pick an item from a
	 * list of items of type T. The items can be filtered through a filter text field and
	 * there is an option [canSelectMany](#QuickPick.canSelectMany) to allow for
	 * selecting multiple items.
	 *
	 * Note that in many cases the more convenient [window.showQuickPick](#window.showQuickPick)
792 793
	 * is easier to use. [window.createQuickPick](#window.createQuickPick) should be used,
	 * when [window.showQuickPick](#window.showQuickPick) does not offer the required flexibility.
C
Christof Marti 已提交
794
	 */
795
	export interface QuickPick<T extends QuickPickItem> extends QuickInput {
796

C
Christof Marti 已提交
797 798 799
		/**
		 * Current value of the filter text.
		 */
800 801
		value: string;

C
Christof Marti 已提交
802 803 804
		/**
		 * Optional placeholder in the filter text.
		 */
805
		placeholder: string | undefined;
806

C
Christof Marti 已提交
807 808 809
		/**
		 * An event signaling when the value of the filter text has changed.
		 */
810 811
		readonly onDidChangeValue: Event<string>;

C
Christof Marti 已提交
812 813 814
		/**
		 * An event signaling when the user indicated acceptance of the selected item(s).
		 */
815 816
		readonly onDidAccept: Event<void>;

C
Christof Marti 已提交
817 818 819
		/**
		 * Buttons for actions in the UI.
		 */
820 821
		buttons: ReadonlyArray<QuickInputButton>;

C
Christof Marti 已提交
822 823 824
		/**
		 * An event signaling when a button was triggered.
		 */
825 826
		readonly onDidTriggerButton: Event<QuickInputButton>;

C
Christof Marti 已提交
827 828 829
		/**
		 * Items to pick from.
		 */
830
		items: ReadonlyArray<T>;
831

C
Christof Marti 已提交
832 833 834
		/**
		 * If multiple items can be selected at the same time. Defaults to false.
		 */
835 836
		canSelectMany: boolean;

C
Christof Marti 已提交
837 838 839
		/**
		 * If the filter text should also be matched against the description of the items. Defaults to false.
		 */
840 841
		matchOnDescription: boolean;

C
Christof Marti 已提交
842 843 844
		/**
		 * If the filter text should also be matched against the detail of the items. Defaults to false.
		 */
845 846
		matchOnDetail: boolean;

C
Christof Marti 已提交
847 848 849
		/**
		 * Active items. This can be read and updated by the extension.
		 */
850
		activeItems: ReadonlyArray<T>;
851

C
Christof Marti 已提交
852 853 854
		/**
		 * An event signaling when the active items have changed.
		 */
855
		readonly onDidChangeActive: Event<T[]>;
856

C
Christof Marti 已提交
857 858 859
		/**
		 * Selected items. This can be read and updated by the extension.
		 */
860
		selectedItems: ReadonlyArray<T>;
861

C
Christof Marti 已提交
862 863 864
		/**
		 * An event signaling when the selected items have changed.
		 */
865
		readonly onDidChangeSelection: Event<T[]>;
866 867
	}

C
Christof Marti 已提交
868 869 870 871
	/**
	 * A concrete [QuickInput](#QuickInput) to let the user input a text value.
	 *
	 * Note that in many cases the more convenient [window.showInputBox](#window.showInputBox)
872 873
	 * is easier to use. [window.createInputBox](#window.createInputBox) should be used,
	 * when [window.showInputBox](#window.showInputBox) does not offer the required flexibility.
C
Christof Marti 已提交
874
	 */
875 876
	export interface InputBox extends QuickInput {

C
Christof Marti 已提交
877 878 879
		/**
		 * Current input value.
		 */
880 881
		value: string;

C
Christof Marti 已提交
882 883 884
		/**
		 * Optional placeholder in the filter text.
		 */
885
		placeholder: string | undefined;
886

C
Christof Marti 已提交
887 888 889
		/**
		 * If the input value should be hidden. Defaults to false.
		 */
890 891
		password: boolean;

C
Christof Marti 已提交
892 893 894
		/**
		 * An event signaling when the value has changed.
		 */
895 896
		readonly onDidChangeValue: Event<string>;

C
Christof Marti 已提交
897 898 899
		/**
		 * An event signaling when the user indicated acceptance of the input value.
		 */
900
		readonly onDidAccept: Event<void>;
901

C
Christof Marti 已提交
902 903 904
		/**
		 * Buttons for actions in the UI.
		 */
905 906
		buttons: ReadonlyArray<QuickInputButton>;

C
Christof Marti 已提交
907 908 909
		/**
		 * An event signaling when a button was triggered.
		 */
910 911
		readonly onDidTriggerButton: Event<QuickInputButton>;

C
Christof Marti 已提交
912 913 914
		/**
		 * An optional prompt text providing some ask or explanation to the user.
		 */
915
		prompt: string | undefined;
916

C
Christof Marti 已提交
917 918 919
		/**
		 * An optional validation message indicating a problem with the current input value.
		 */
920
		validationMessage: string | undefined;
921 922
	}

C
Christof Marti 已提交
923 924 925
	/**
	 * Button for an action in a [QuickPick](#QuickPick) or [InputBox](#InputBox).
	 */
926
	export interface QuickInputButton {
C
Christof Marti 已提交
927 928 929 930

		/**
		 * Icon for the button.
		 */
C
Christof Marti 已提交
931
		readonly iconPath: string | Uri | { light: string | Uri; dark: string | Uri } | ThemeIcon;
C
Christof Marti 已提交
932 933 934 935

		/**
		 * An optional tooltip.
		 */
C
Christof Marti 已提交
936
		readonly tooltip?: string | undefined;
937 938 939 940
	}

	//#endregion

J
Johannes Rieken 已提交
941 942
	//#region joh: https://github.com/Microsoft/vscode/issues/10659

J
Johannes Rieken 已提交
943 944 945 946 947 948 949
	/**
	 * A workspace edit is a collection of textual and files changes for
	 * multiple resources and documents. Use the [applyEdit](#workspace.applyEdit)-function
	 * to apply a workspace edit. Note that all changes are applied in the same order in which
	 * they have been added and that invalid sequences like 'delete file a' -> 'insert text in
	 * file a' causes failure of the operation.
	 */
J
Johannes Rieken 已提交
950
	export interface WorkspaceEdit {
J
Johannes Rieken 已提交
951 952 953 954 955 956 957

		/**
		 * Create a regular file.
		 *
		 * @param uri Uri of the new file..
		 * @param options Defines if an existing file should be overwritten or be ignored.
		 */
958
		createFile(uri: Uri, options?: { overwrite?: boolean, ignoreIfExists?: boolean }): void;
J
Johannes Rieken 已提交
959 960 961 962 963 964

		/**
		 * Delete a file or folder.
		 *
		 * @param uri The uri of the file that is to be deleted.
		 */
965
		deleteFile(uri: Uri, options?: { recursive?: boolean }): void;
J
Johannes Rieken 已提交
966 967 968 969 970 971 972 973

		/**
		 * Rename a file or folder.
		 *
		 * @param oldUri The existing file.
		 * @param newUri The new location.
		 * @param options Defines if existing files should be overwritten.
		 */
J
Johannes Rieken 已提交
974
		renameFile(oldUri: Uri, newUri: Uri, options?: { overwrite?: boolean }): void;
975 976 977 978

		// replaceText(uri: Uri, range: Range, newText: string): void;
		// insertText(uri: Uri, position: Position, newText: string): void;
		// deleteText(uri: Uri, range: Range): void;
J
Johannes Rieken 已提交
979 980
	}

J
Johannes Rieken 已提交
981 982 983 984 985 986 987 988 989 990 991 992 993 994 995
	export namespace workspace {
		/**
		 * Make changes to one or many resources as defined by the given
		 * [workspace edit](#WorkspaceEdit).
		 *
		 * The editor implements an 'all-or-nothing'-strategy and that means failure to modify,
		 * delete, rename, or create one file will abort the operation. In that case, the thenable returned
		 * by this function resolves to `false`.
		 *
		 * @param edit A workspace edit.
		 * @return A thenable that resolves when the edit could be applied.
		 */
		export function applyEdit(edit: WorkspaceEdit): Thenable<boolean>;
	}

J
Johannes Rieken 已提交
996 997
	//#endregion

J
Johannes Rieken 已提交
998
	//#region mjbvz,joh: https://github.com/Microsoft/vscode/issues/43768
999 1000 1001
	export interface FileRenameEvent {
		readonly oldUri: Uri;
		readonly newUri: Uri;
C
Christof Marti 已提交
1002 1003
	}

1004 1005 1006
	export interface FileWillRenameEvent {
		readonly oldUri: Uri;
		readonly newUri: Uri;
1007
		waitUntil(thenable: Thenable<WorkspaceEdit>): void;
1008 1009
	}

1010
	export namespace workspace {
1011
		export const onWillRenameFile: Event<FileWillRenameEvent>;
1012
		export const onDidRenameFile: Event<FileRenameEvent>;
1013 1014
	}
	//#endregion
1015

M
Matt Bierner 已提交
1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057
	//#region Matt: Deinition range

	/**
	 * Information about where a symbol is defined.
	 *
	 * Provides additional metadata over normal [location](#Location) definitions, including the range of
	 * the defining symbol
	 */
	export interface DefinitionLink {
		/**
		 * Span of the symbol being defined in the source file.
		 *
		 * Used as the underlined span for mouse definition hover. Defaults to the word range at
		 * the definition position.
		 */
		origin?: Range;

		/**
		 * The resource identifier of the definition.
		 */
		uri: Uri;

		/**
		 * The full range of the definition.
		 *
		 * For a class definition for example, this would be the entire body of the class definition.
		 */
		range: Range;

		/**
		 * The span of the symbol definition.
		 *
		 * For a class definition, this would be the class name itself in the class definition.
		 */
		selectionRange?: Range;
	}

	export interface DefinitionProvider {
		provideDefinition2?(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<Definition | DefinitionLink[]>;
	}

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