vscode.proposed.d.ts 15.5 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 17 18 19
	//#region Joh: remote, search provider

	export interface TextSearchQuery {
		pattern: string;
20 21 22
		isRegExp: boolean;
		isCaseSensitive: boolean;
		isWordMatch: boolean;
23 24
	}

R
Rob Lourens 已提交
25
	export interface SearchOptions {
26
		folder: Uri;
R
Rob Lourens 已提交
27 28 29 30
		includes: string[]; // paths relative to folder
		excludes: string[];
		useIgnoreFiles?: boolean;
		followSymlinks?: boolean;
31 32
	}

R
Rob Lourens 已提交
33
	export interface TextSearchOptions extends SearchOptions {
R
Rob Lourens 已提交
34
		previewOptions?: any; // total length? # of context lines? leading and trailing # of chars?
35 36
		maxFileSize?: number;
		encoding?: string;
37 38
	}

39 40
	export interface FileSearchOptions extends SearchOptions { }

41
	export interface TextSearchResult {
42
		path: string;
43
		range: Range;
R
Rob Lourens 已提交
44 45 46

		// For now, preview must be a single line of text
		preview: { text: string, match: Range };
47 48 49
	}

	export interface SearchProvider {
50
		provideFileSearchResults?(options: FileSearchOptions, progress: Progress<string>, token: CancellationToken): Thenable<void>;
51
		provideTextSearchResults?(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): Thenable<void>;
52 53
	}

54
	export namespace workspace {
55
		export function registerSearchProvider(scheme: string, provider: SearchProvider): Disposable;
56 57
	}

J
Johannes Rieken 已提交
58
	//#endregion
59

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

J
Joao Moreno 已提交
62 63 64
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
65 66 67 68 69 70 71
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89
	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;
	}
90

J
Johannes Rieken 已提交
91 92 93
	//#endregion

	//#region Joh: decorations
94 95 96 97 98

	//todo@joh -> make class
	export interface DecorationData {
		priority?: number;
		title?: string;
99
		bubble?: boolean;
100 101
		abbreviation?: string;
		color?: ThemeColor;
102
		source?: string;
103 104
	}

105 106 107 108 109 110
	export interface SourceControlResourceDecorations {
		source?: string;
		letter?: string;
		color?: ThemeColor;
	}

111
	export interface DecorationProvider {
112
		onDidChangeDecorations: Event<undefined | Uri | Uri[]>;
113 114 115 116
		provideDecoration(uri: Uri, token: CancellationToken): ProviderResult<DecorationData>;
	}

	export namespace window {
117
		export function registerDecorationProvider(provider: DecorationProvider): Disposable;
118 119 120
	}

	//#endregion
121

J
Johannes Rieken 已提交
122 123
	//#region André: debug

124 125 126 127 128 129
	/**
	 * 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 已提交
130
		 * A command must be either an absolute path or the name of an executable looked up via the PATH environment variable.
131 132 133 134 135
		 * The special value 'node' will be mapped to VS Code's built-in node runtime.
		 */
		readonly command: string;

		/**
A
Andre Weinand 已提交
136
		 * Optional arguments passed to the debug adapter executable.
137 138 139 140 141 142 143 144 145 146 147
		 */
		readonly args: string[];

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

	export interface DebugConfigurationProvider {
		/**
148
		 * This optional method is called just before a debug adapter is started to determine its executable path and arguments.
149 150 151 152 153 154 155 156
		 * 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 已提交
157 158 159 160
	//#endregion

	//#region Rob, Matt: logging

161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187
	/**
	 * 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 已提交
188
		 * This extension's logger
189 190
		 */
		logger: Logger;
191 192 193 194 195 196 197

		/**
		 * 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;
198
	}
199

M
Matt Bierner 已提交
200 201 202 203 204 205 206 207 208
	export namespace env {
		/**
		 * Current logging level.
		 *
		 * @readonly
		 */
		export const logLevel: LogLevel;
	}

J
Johannes Rieken 已提交
209 210 211
	//#endregion

	//#region Joao: SCM validation
212

J
Joao Moreno 已提交
213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257
	/**
	 * 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 已提交
258

J
Johannes Rieken 已提交
259 260
	//#endregion

261 262 263 264 265
	//#region Comments
	/**
	 * Comments provider related APIs are still in early stages, they may be changed significantly during our API experiments.
	 */

266 267 268 269 270
	interface CommentInfo {
		threads: CommentThread[];
		commentingRanges?: Range[];
	}

271 272 273 274 275 276 277 278 279 280 281
	export enum CommentThreadCollapsibleState {
		/**
		 * Determines an item is collapsed
		 */
		Collapsed = 0,
		/**
		 * Determines an item is expanded
		 */
		Expanded = 1
	}

M
Matt Bierner 已提交
282
	interface CommentThread {
283
		threadId: string;
284
		resource: Uri;
M
Matt Bierner 已提交
285 286
		range: Range;
		comments: Comment[];
287
		collapsibleState?: CommentThreadCollapsibleState;
M
Matt Bierner 已提交
288 289 290
	}

	interface Comment {
P
Peng Lyu 已提交
291
		commentId: string;
M
Matt Bierner 已提交
292 293
		body: MarkdownString;
		userName: string;
294
		gravatar: string;
295
		command?: Command;
M
Matt Bierner 已提交
296 297
	}

298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
	export interface CommentThreadChangedEvent {
		/**
		 * Added comment threads.
		 */
		readonly added: CommentThread[];

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

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

315 316
	interface DocumentCommentProvider {
		provideDocumentComments(document: TextDocument, token: CancellationToken): Promise<CommentInfo>;
317 318
		createNewCommentThread?(document: TextDocument, range: Range, text: string, token: CancellationToken): Promise<CommentThread>;
		replyToCommentThread?(document: TextDocument, range: Range, commentThread: CommentThread, text: string, token: CancellationToken): Promise<CommentThread>;
319 320 321 322 323
		onDidChangeCommentThreads?: Event<CommentThreadChangedEvent>;
	}

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

327
		onDidChangeCommentThreads?: Event<CommentThreadChangedEvent>;
M
Matt Bierner 已提交
328 329 330
	}

	namespace workspace {
331 332
		export function registerDocumentCommentProvider(provider: DocumentCommentProvider): Disposable;
		export function registerWorkspaceCommentProvider(provider: WorkspaceCommentProvider): Disposable;
M
Matt Bierner 已提交
333
	}
334 335
	//#endregion

336 337
	//#region Terminal

D
Daniel Imms 已提交
338
	export interface Terminal {
D
Daniel Imms 已提交
339
		/**
D
Daniel Imms 已提交
340
		 * Fires when the terminal's pty slave pseudo-device is written to. In other words, this
D
Daniel Imms 已提交
341 342 343
		 * provides access to the raw data stream from the process running within the terminal,
		 * including ANSI sequences.
		 */
D
Daniel Imms 已提交
344 345 346
		onData: Event<string>;
	}

347
	export namespace window {
D
Daniel Imms 已提交
348
		/**
349
		 * The currently opened terminals or an empty array.
D
jsdoc  
Daniel Imms 已提交
350
		 *
D
Daniel Imms 已提交
351 352 353 354
		 * @readonly
		 */
		export let terminals: Terminal[];

D
jsdoc  
Daniel Imms 已提交
355 356 357 358
		/**
		 * An [event](#Event) which fires when a terminal has been created, either through the
		 * [createTerminal](#window.createTerminal) API or commands.
		 */
359 360 361 362
		export const onDidOpenTerminal: Event<Terminal>;
	}

	//#endregion
J
Joao Moreno 已提交
363 364 365

	//#region URLs

J
Joao Moreno 已提交
366 367
	export interface ProtocolHandler {
		handleUri(uri: Uri): void;
J
Joao Moreno 已提交
368 369 370 371 372
	}

	export namespace window {

		/**
J
Joao Moreno 已提交
373
		 * Registers a protocol handler capable of handling system-wide URIs.
J
Joao Moreno 已提交
374
		 */
J
Joao Moreno 已提交
375
		export function registerProtocolHandler(handler: ProtocolHandler): Disposable;
J
Joao Moreno 已提交
376 377 378
	}

	//#endregion
379 380 381

	//#region Joh: hierarchical document symbols, https://github.com/Microsoft/vscode/issues/34968

382 383 384 385 386 387 388
	export class DocumentSymbol {

		/**
		 * The name of this symbol.
		 */
		name: string;

389 390 391 392 393
		/**
		 * More detail for this symbol, e.g the signature of a function.
		 */
		detail: string;

394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418
		/**
		 * The kind of this symbol.
		 */
		kind: SymbolKind;

		/**
		 * The full range of this symbol not including leading/trailing whitespace but everything else.
		 */
		fullRange: Range;

		/**
		 * The range that should be revealed when this symbol is being selected, e.g the name of a function.
		 * Must be contained by the [`fullRange`](#DocumentSymbol.fullRange).
		 */
		gotoRange: Range;

		/**
		 * Children of this symbol, e.g. properties of a class.
		 */
		children: DocumentSymbol[];

		/**
		 * Creates a new document symbol.
		 *
		 * @param name The name of the symbol.
419
		 * @param detail Details for the symbol.
420 421 422 423
		 * @param kind The kind of the symbol.
		 * @param fullRange The full range of the symbol.
		 * @param gotoRange The range that should be reveal.
		 */
424
		constructor(name: string, detail: string, kind: SymbolKind, fullRange: Range, gotoRange: Range);
425 426 427
	}

	export interface DocumentSymbolProvider {
428
		provideDocumentSymbols(document: TextDocument, token: CancellationToken): ProviderResult<SymbolInformation[] | DocumentSymbol[]>;
429 430 431
	}

	//#endregion
432 433 434 435 436 437 438 439

	//#region Joh -> exclusive document filters

	export interface DocumentFilter {
		exclusive?: boolean;
	}

	//#endregion
C
Christof Marti 已提交
440

441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531
	//#region QuickInput API

	export namespace window {

		/**
		 * Implementation incomplete. See #49340.
		 */
		export function createQuickPick(): QuickPick;

		/**
		 * Implementation incomplete. See #49340.
		 */
		export function createInputBox(): InputBox;
	}

	export interface QuickInput {

		enabled: boolean;

		busy: boolean;

		ignoreFocusOut: boolean;

		show(): void;

		hide(): void;

		onDidHide: Event<void>;

		dispose(): void;
	}

	export interface QuickPick extends QuickInput {

		value: string;

		placeholder: string;

		readonly onDidChangeValue: Event<string>;

		readonly onDidAccept: Event<void>;

		buttons: ReadonlyArray<QuickInputButton>;

		readonly onDidTriggerButton: Event<QuickInputButton>;

		items: ReadonlyArray<QuickPickItem>;

		canSelectMany: boolean;

		matchOnDescription: boolean;

		matchOnDetail: boolean;

		readonly activeItems: ReadonlyArray<QuickPickItem>;

		readonly onDidChangeActive: Event<QuickPickItem[]>;

		readonly selectedItems: ReadonlyArray<QuickPickItem>;

		readonly onDidChangeSelection: Event<QuickPickItem[]>;
	}

	export interface InputBox extends QuickInput {

		value: string;

		placeholder: string;

		password: boolean;

		readonly onDidChangeValue: Event<string>;

		readonly onDidAccept: Event<string>;

		buttons: ReadonlyArray<QuickInputButton>;

		readonly onDidTriggerButton: Event<QuickInputButton>;

		prompt: string;

		validationMessage: string;
	}

	export interface QuickInputButton {
		iconPath: string | Uri | { light: string | Uri; dark: string | Uri } | ThemeIcon;
		tooltip?: string | undefined;
	}

	//#endregion

532 533 534 535 536 537 538 539 540 541
	//#region mjbvz: Unused diagnostics
	/**
	 * Additional metadata about the type of diagnostic.
	 */
	export enum DiagnosticTag {
		/**
		 * Unused or unnecessary code.
		 */
		Unnecessary = 1,
	}
C
Christof Marti 已提交
542

543
	export interface Diagnostic {
C
Christof Marti 已提交
544
		/**
545
		 * Additional metadata about the type of the diagnostic.
C
Christof Marti 已提交
546
		 */
547 548 549 550
		customTags?: DiagnosticTag[];
	}

	//#endregion
551 552 553 554 555

	//#region mjbvz: File rename events
	export interface ResourceRenamedEvent {
		readonly oldResource: Uri;
		readonly newResource: Uri;
C
Christof Marti 已提交
556 557
	}

558 559 560 561
	export namespace workspace {
		export const onDidRenameResource: Event<ResourceRenamedEvent>;
	}
	//#endregion
562 563 564

	//#region mjbvz: Code action trigger

C
Christof Marti 已提交
565
	/**
566
	 * How a [code action provider](#CodeActionProvider) was triggered
C
Christof Marti 已提交
567
	 */
568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584
	export enum CodeActionTrigger {
		/**
		 * Provider was triggered automatically by VS Code.
		 */
		Automatic = 1,

		/**
		 * User requested code actions.
		 */
		Manual = 2,
	}

	interface CodeActionContext {
		/**
		 * How the code action provider was triggered.
		 */
		triggerKind?: CodeActionTrigger;
C
Christof Marti 已提交
585 586 587
	}

	//#endregion
588

589 590 591

	//#region Matt: WebView Serializer

592
	/**
593
	 * Restore webview panels that have been persisted when vscode shuts down.
594
	 */
595
	interface WebviewPanelSerializer {
596
		/**
597 598 599 600 601 602 603 604
		 * Restore a webview panel from its seriailzed `state`.
		 *
		 * Called when a serialized webview first becomes visible.
		 *
		 * @param webviewPanel Webview panel to restore. The serializer should take ownership of this panel.
		 * @param state Persisted state.
		 *
		 * @return Thanble indicating that the webview has been fully restored.
605
		 */
606
		deserializeWebviewPanel(webviewPanel: WebviewPanel, state: any): Thenable<void>;
607 608
	}

609
	namespace window {
610
		/**
611 612 613 614 615 616 617 618 619
		 * Registers a webview panel serializer.
		 *
		 * Extensions that support reviving should have an `"onWebviewPanel:viewType"` activation method and
		 * make sure that [registerWebviewPanelSerializer](#registerWebviewPanelSerializer) is called during activation.
		 *
		 * Only a single serializer may be registered at a time for a given `viewType`.
		 *
		 * @param viewType Type of the webview panel that can be serialized.
		 * @param serializer Webview serializer.
620
		 */
621
		export function registerWebviewPanelSerializer(viewType: string, serializer: WebviewPanelSerializer): Disposable;
622 623 624
	}

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