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

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

declare module 'vscode' {

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

14
	//#region Joh: file system provider (OLD)
J
Johannes Rieken 已提交
15

16
	export enum DeprecatedFileChangeType {
17 18 19 20
		Updated = 0,
		Added = 1,
		Deleted = 2
	}
21 22
	export interface DeprecatedFileChange {
		type: DeprecatedFileChangeType;
23 24
		resource: Uri;
	}
25
	export enum DeprecatedFileType {
26 27 28 29
		File = 0,
		Dir = 1,
		Symlink = 2
	}
30
	export interface DeprecatedFileStat {
31
		id: number | string;
32 33
		mtime: number;
		size: number;
34
		type: DeprecatedFileType;
35
	}
36 37 38 39
	export interface DeprecatedFileSystemProvider {
		readonly onDidChange?: Event<DeprecatedFileChange[]>;
		utimes(resource: Uri, mtime: number, atime: number): Thenable<DeprecatedFileStat>;
		stat(resource: Uri): Thenable<DeprecatedFileStat>;
40
		read(resource: Uri, offset: number, length: number, progress: Progress<Uint8Array>): Thenable<number>;
41
		write(resource: Uri, content: Uint8Array): Thenable<void>;
42 43 44
		move(resource: Uri, target: Uri): Thenable<DeprecatedFileStat>;
		mkdir(resource: Uri): Thenable<DeprecatedFileStat>;
		readdir(resource: Uri): Thenable<[Uri, DeprecatedFileStat][]>;
45
		rmdir(resource: Uri): Thenable<void>;
46
		unlink(resource: Uri): Thenable<void>;
47
	}
48 49 50 51 52 53
	export namespace workspace {
		export function registerDeprecatedFileSystemProvider(scheme: string, provider: DeprecatedFileSystemProvider): Disposable;
	}

	//#endregion

54 55 56 57
	//#region Joh: remote, search provider

	export interface TextSearchQuery {
		pattern: string;
58
		isRegExp?: boolean;
59 60 61 62
		isCaseSensitive?: boolean;
		isWordMatch?: boolean;
	}

R
Rob Lourens 已提交
63
	export interface SearchOptions {
64
		folder: Uri;
R
Rob Lourens 已提交
65 66 67 68 69 70 71 72
		includes: string[]; // paths relative to folder
		excludes: string[];
		useIgnoreFiles?: boolean;
		followSymlinks?: boolean;
		previewOptions?: any; // total length? # of context lines? leading and trailing # of chars?
	}

	export interface TextSearchOptions extends SearchOptions {
73 74
		maxFileSize?: number;
		encoding?: string;
75 76
	}

77 78
	export interface FileSearchOptions extends SearchOptions { }

79 80 81
	export interface TextSearchResult {
		uri: Uri;
		range: Range;
R
Rob Lourens 已提交
82 83 84

		// For now, preview must be a single line of text
		preview: { text: string, match: Range };
85 86 87
	}

	export interface SearchProvider {
88
		provideFileSearchResults?(options: FileSearchOptions, progress: Progress<Uri>, token: CancellationToken): Thenable<void>;
89
		provideTextSearchResults?(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): Thenable<void>;
90 91
	}

92
	export namespace workspace {
93
		export function registerSearchProvider(scheme: string, provider: SearchProvider): Disposable;
94 95
	}

J
Johannes Rieken 已提交
96
	//#endregion
97

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

J
Joao Moreno 已提交
100 101 102
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
103 104 105 106 107 108 109
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127
	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;
	}
128

J
Johannes Rieken 已提交
129 130 131
	//#endregion

	//#region Joh: decorations
132 133 134 135 136

	//todo@joh -> make class
	export interface DecorationData {
		priority?: number;
		title?: string;
137
		bubble?: boolean;
138 139
		abbreviation?: string;
		color?: ThemeColor;
140
		source?: string;
141 142
	}

143 144 145 146 147 148
	export interface SourceControlResourceDecorations {
		source?: string;
		letter?: string;
		color?: ThemeColor;
	}

149
	export interface DecorationProvider {
150
		onDidChangeDecorations: Event<undefined | Uri | Uri[]>;
151 152 153 154
		provideDecoration(uri: Uri, token: CancellationToken): ProviderResult<DecorationData>;
	}

	export namespace window {
155
		export function registerDecorationProvider(provider: DecorationProvider): Disposable;
156 157 158
	}

	//#endregion
159

J
Johannes Rieken 已提交
160 161
	//#region André: debug

162 163 164 165 166 167
	/**
	 * 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 已提交
168
		 * A command must be either an absolute path or the name of an executable looked up via the PATH environment variable.
169 170 171 172 173
		 * The special value 'node' will be mapped to VS Code's built-in node runtime.
		 */
		readonly command: string;

		/**
A
Andre Weinand 已提交
174
		 * Optional arguments passed to the debug adapter executable.
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194
		 */
		readonly args: string[];

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

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

J
Johannes Rieken 已提交
195 196 197 198
	//#endregion

	//#region Rob, Matt: logging

199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225
	/**
	 * 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 已提交
226
		 * This extension's logger
227 228
		 */
		logger: Logger;
229 230 231 232 233 234 235

		/**
		 * 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;
236
	}
237

M
Matt Bierner 已提交
238 239 240 241 242 243 244 245 246
	export namespace env {
		/**
		 * Current logging level.
		 *
		 * @readonly
		 */
		export const logLevel: LogLevel;
	}

J
Johannes Rieken 已提交
247 248 249
	//#endregion

	//#region Joao: SCM validation
250

J
Joao Moreno 已提交
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295
	/**
	 * 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 已提交
296

J
Johannes Rieken 已提交
297 298
	//#endregion

299
	//#region Matt: WebView Serializer
300

301
	/**
302
	 * Restore webview panels that have been persisted when vscode shuts down.
303
	 */
304
	interface WebviewPanelSerializer {
305
		/**
306
		 * Restore a webview panel from its seriailzed `state`.
307
		 *
308
		 * Called when a serialized webview first becomes visible.
309
		 *
310
		 * @param webviewPanel Webview panel to restore. The serializer should take ownership of this panel.
311
		 * @param state Persisted state.
312 313
		 *
		 * @return Thanble indicating that the webview has been fully restored.
314
		 */
315
		deserializeWebviewPanel(webviewPanel: WebviewPanel, state: any): Thenable<void>;
316 317
	}

M
Matt Bierner 已提交
318
	namespace window {
319
		/**
320
		 * Registers a webview panel serializer.
321 322
		 *
		 * Extensions that support reviving should have an `"onView:viewType"` activation method and
323
		 * make sure that [registerWebviewPanelSerializer](#registerWebviewPanelSerializer) is called during activation.
324 325 326
		 *
		 * Only a single serializer may be registered at a time for a given `viewType`.
		 *
327
		 * @param viewType Type of the webview panel that can be serialized.
328 329
		 * @param reviver Webview serializer.
		 */
330
		export function registerWebviewPanelSerializer(viewType: string, reviver: WebviewPanelSerializer): Disposable;
M
Matt Bierner 已提交
331
	}
S
Sandeep Somavarapu 已提交
332

J
Johannes Rieken 已提交
333 334
	//#endregion

335 336
	//#region Tasks

D
Dirk Baeumer 已提交
337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 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
	/**
	 * An object representing an executed Task. It can be used
	 * to terminate a task.
	 *
	 * This interface is not intended to be implemented.
	 */
	export interface TaskExecution {
		/**
		 * The task that got started.
		 */
		task: Task;

		/**
		 * Terminates the task execution.
		 */
		terminate(): void;
	}

	/**
	 * An event signaling the start of a task execution.
	 *
	 * This interface is not intended to be implemented.
	 */
	interface TaskStartEvent {
		/**
		 * The task item representing the task that got started.
		 */
		execution: TaskExecution;
	}

	/**
	 * An event signaling the end of an executed task.
	 *
	 * This interface is not intended to be implemented.
	 */
	interface TaskEndEvent {
		/**
		 * The task item representing the task that finished.
		 */
		execution: TaskExecution;
	}

379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412
	/**
	 * An event signaling the start of a process execution
	 * triggered through a task
	 */
	export interface TaskProcessStartEvent {

		/**
		 * The task execution for which the process got started.
		 */
		execution: TaskExecution;

		/**
		 * The underlying process id.
		 */
		processId: number;
	}

	/**
	 * An event signaling the end of a process execution
	 * triggered through a task
	 */
	export interface TaskProcessEndEvent {

		/**
		 * The task execution for which the process got started.
		 */
		execution: TaskExecution;

		/**
		 * The process's exit code.
		 */
		exitCode: number;
	}

D
Dirk Baeumer 已提交
413
	export interface TaskFilter {
D
Dirk Baeumer 已提交
414
		/**
D
Dirk Baeumer 已提交
415 416
		 * The task version as used in the tasks.json file.
		 * The string support the package.json semver notation.
D
Dirk Baeumer 已提交
417
		 */
D
Dirk Baeumer 已提交
418
		version?: string;
D
Dirk Baeumer 已提交
419

420
		/**
D
Dirk Baeumer 已提交
421
		 * The task type to return;
422
		 */
D
Dirk Baeumer 已提交
423 424
		type?: string;
	}
425

D
Dirk Baeumer 已提交
426
	export namespace workspace {
427

D
Dirk Baeumer 已提交
428
		/**
D
Dirk Baeumer 已提交
429 430 431 432 433
		 * Fetches all tasks available in the systems. This includes tasks
		 * from `tasks.json` files as well as tasks from task providers
		 * contributed through extensions.
		 *
		 * @param filter a filter to filter the return tasks.
D
Dirk Baeumer 已提交
434
		 */
D
Dirk Baeumer 已提交
435
		export function fetchTasks(filter?: TaskFilter): Thenable<Task[]>;
436 437

		/**
D
Dirk Baeumer 已提交
438 439 440 441
		 * Executes a task that is managed by VS Code. The returned
		 * task execution can be used to terminate the task.
		 *
		 * @param task the task to execute
442
		 */
D
Dirk Baeumer 已提交
443
		export function executeTask(task: Task): Thenable<TaskExecution>;
444 445

		/**
D
Dirk Baeumer 已提交
446 447 448
		 * The currently active task executions or an empty array.
		 *
		 * @readonly
449
		 */
D
Dirk Baeumer 已提交
450
		export let taskExecutions: ReadonlyArray<TaskExecution>;
451

452
		/**
D
Dirk Baeumer 已提交
453
		 * Fires when a task starts.
454
		 */
D
Dirk Baeumer 已提交
455
		export const onDidStartTask: Event<TaskStartEvent>;
456 457

		/**
D
Dirk Baeumer 已提交
458
		 * Fires when a task ends.
459
		 */
D
Dirk Baeumer 已提交
460
		export const onDidEndTask: Event<TaskEndEvent>;
461 462
	}

D
Dirk Baeumer 已提交
463 464 465 466 467 468 469 470 471 472 473 474 475
	/**
	 * Namespace for tasks functionality.
	 */
	export namespace tasks {

		/**
		 * Register a task provider.
		 *
		 * @param type The task kind type this provider is registered for.
		 * @param provider A task provider.
		 * @return A [disposable](#Disposable) that unregisters this provider when being disposed.
		 */
		export function registerTaskProvider(type: string, provider: TaskProvider): Disposable;
476 477

		/**
478
		 * Fetches all tasks available in the systems. This includes tasks
479 480
		 * from `tasks.json` files as well as tasks from task providers
		 * contributed through extensions.
481 482
		 *
		 * @param filter a filter to filter the return tasks.
483
		 */
484
		export function fetchTasks(filter?: TaskFilter): Thenable<Task[]>;
485 486

		/**
487 488 489 490
		 * Executes a task that is managed by VS Code. The returned
		 * task execution can be used to terminate the task.
		 *
		 * @param task the task to execute
491
		 */
492
		export function executeTask(task: Task): Thenable<TaskExecution>;
D
Dirk Baeumer 已提交
493

494 495 496 497 498
		/**
		 * The currently active task executions or an empty array.
		 *
		 * @readonly
		 */
499
		export let taskExecutions: ReadonlyArray<TaskExecution>;
500

D
Dirk Baeumer 已提交
501
		/**
502 503 504 505
		 * Fires when a task starts.
		 */
		export const onDidStartTask: Event<TaskStartEvent>;

506
		/**
507
		 * Fires when a task ends.
508
		 */
509
		export const onDidEndTask: Event<TaskEndEvent>;
D
Dirk Baeumer 已提交
510 511 512 513 514 515 516 517 518 519 520 521 522 523

		/**
		 * Fires when the underlying process has been started.
		 * This event will not fire for tasks that don't
		 * execute an underlying process.
		 */
		export const onDidStartTaskProcess: Event<TaskProcessStartEvent>;

		/**
		 * Fires when the underlying process has ended.
		 * This event will not fire for tasks that don't
		 * execute an underlying process.
		 */
		export const onDidEndTaskProcess: Event<TaskProcessEndEvent>;
524 525 526
	}

	//#endregion
527 528 529

	//#region Terminal

D
Daniel Imms 已提交
530
	export interface Terminal {
D
Daniel Imms 已提交
531
		/**
D
Daniel Imms 已提交
532
		 * Fires when the terminal's pty slave pseudo-device is written to. In other words, this
D
Daniel Imms 已提交
533 534 535
		 * provides access to the raw data stream from the process running within the terminal,
		 * including ANSI sequences.
		 */
D
Daniel Imms 已提交
536 537 538
		onData: Event<string>;
	}

539
	export namespace window {
D
Daniel Imms 已提交
540
		/**
D
jsdoc  
Daniel Imms 已提交
541 542
		 * The currently active terminals or an empty array.
		 *
D
Daniel Imms 已提交
543 544 545 546
		 * @readonly
		 */
		export let terminals: Terminal[];

D
jsdoc  
Daniel Imms 已提交
547 548 549 550
		/**
		 * An [event](#Event) which fires when a terminal has been created, either through the
		 * [createTerminal](#window.createTerminal) API or commands.
		 */
551 552 553 554
		export const onDidOpenTerminal: Event<Terminal>;
	}

	//#endregion
J
Joao Moreno 已提交
555 556 557

	//#region URLs

J
Joao Moreno 已提交
558 559
	export interface ProtocolHandler {
		handleUri(uri: Uri): void;
J
Joao Moreno 已提交
560 561 562 563 564
	}

	export namespace window {

		/**
J
Joao Moreno 已提交
565
		 * Registers a protocol handler capable of handling system-wide URIs.
J
Joao Moreno 已提交
566
		 */
J
Joao Moreno 已提交
567
		export function registerProtocolHandler(handler: ProtocolHandler): Disposable;
J
Joao Moreno 已提交
568 569 570
	}

	//#endregion
571 572 573

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

574 575 576 577 578 579 580
	export class Hierarchy<T> {
		parent: T;
		children: Hierarchy<T>[];
		constructor(element: T);
	}

	export class SymbolInformation2 extends SymbolInformation {
581
		detail: string;
582
		range: Range;
583
		constructor(name: string, detail: string, kind: SymbolKind, range: Range, location: Location);
584 585 586
	}

	export interface DocumentSymbolProvider {
587
		provideDocumentSymbols(document: TextDocument, token: CancellationToken): ProviderResult<SymbolInformation[] | Hierarchy<SymbolInformation>[]>;
588 589 590
	}

	//#endregion
591 592 593 594 595 596 597 598

	//#region Joh -> exclusive document filters

	export interface DocumentFilter {
		exclusive?: boolean;
	}

	//#endregion
C
Christof Marti 已提交
599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622

	//#region Multi-step input

	export namespace window {

		/**
		 * Collect multiple inputs from the user. The provided handler will be called with a
		 * [`QuickInput`](#QuickInput) that should be used to control the UI.
		 *
		 * @param handler The callback that will collect the inputs.
		 */
		export function multiStepInput<T>(handler: (input: QuickInput, token: CancellationToken) => Thenable<T>, token?: CancellationToken): Thenable<T>;
	}

	/**
	 * Controls the UI within a multi-step input session. The handler passed to [`window.multiStepInput`](#window.multiStepInput)
	 * should use the instance of this interface passed to it to collect all inputs.
	 */
	export interface QuickInput {
		showQuickPick: typeof window.showQuickPick;
		showInputBox: typeof window.showInputBox;
	}

	//#endregion
623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642

	//#region mjbvz: Unused diagnostics
	/**
	 * Additional metadata about the type of diagnostic.
	 */
	export enum DiagnosticTag {
		/**
		 * Unused or unnecessary code.
		 */
		Unnecessary = 1,
	}

	export interface Diagnostic {
		/**
		 * Additional metadata about the type of the diagnostic.
		 */
		customTags?: DiagnosticTag[];
	}

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