vscode.proposed.d.ts 13.5 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 79
	}

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

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

	export interface SearchProvider {
R
Rob Lourens 已提交
86
		provideFileSearchResults?(query: string, options: SearchOptions, progress: Progress<Uri>, token: CancellationToken): Thenable<void>;
87
		provideTextSearchResults?(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): Thenable<void>;
88 89
	}

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

J
Johannes Rieken 已提交
94
	//#endregion
95

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

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

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

J
Johannes Rieken 已提交
127 128 129
	//#endregion

	//#region Joh: decorations
130 131 132 133 134

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

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

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

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

	//#endregion
157

J
Johannes Rieken 已提交
158 159
	//#region André: debug

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

		/**
A
Andre Weinand 已提交
172
		 * Optional arguments passed to the debug adapter executable.
173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
		 */
		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 已提交
193 194 195 196
	//#endregion

	//#region Rob, Matt: logging

197 198 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
	/**
	 * 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 已提交
224
		 * This extension's logger
225 226
		 */
		logger: Logger;
227 228 229 230 231 232 233

		/**
		 * 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;
234
	}
235

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

J
Johannes Rieken 已提交
245 246 247
	//#endregion

	//#region Joao: SCM validation
248

J
Joao Moreno 已提交
249 250 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
	/**
	 * 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 已提交
294

J
Johannes Rieken 已提交
295 296
	//#endregion

297
	//#region Matt: WebView Serializer
298

299
	/**
300
	 * Save and restore webview panels that have been persisted when vscode shuts down.
301
	 */
302
	interface WebviewPanelSerializer {
303
		/**
304
		 * Save a webview panel's `state`.
305
		 *
306 307
		 * Called before shutdown. Extensions have a 250ms timeframe to return a state. If serialization
		 * takes longer than 250ms, the panel will not be serialized.
308
		 *
309
		 * @param webviewPanel webview Panel to serialize. May or may not be visible.
310 311 312
		 *
		 * @returns JSON serializable state blob.
		 */
313
		serializeWebviewPanel(webviewPanel: WebviewPanel): Thenable<any>;
314 315

		/**
316
		 * Restore a webview panel from its seriailzed `state`.
317
		 *
318
		 * Called when a serialized webview first becomes visible.
319
		 *
320
		 * @param webviewPanel Webview panel to restore. The serializer should take ownership of this panel.
321
		 * @param state Persisted state.
322 323
		 *
		 * @return Thanble indicating that the webview has been fully restored.
324
		 */
325
		deserializeWebviewPanel(webviewPanel: WebviewPanel, state: any): Thenable<void>;
326 327
	}

M
Matt Bierner 已提交
328
	namespace window {
329
		/**
330
		 * Registers a webview panel serializer.
331 332
		 *
		 * Extensions that support reviving should have an `"onView:viewType"` activation method and
333
		 * make sure that [registerWebviewPanelSerializer](#registerWebviewPanelSerializer) is called during activation.
334 335 336
		 *
		 * Only a single serializer may be registered at a time for a given `viewType`.
		 *
337
		 * @param viewType Type of the webview panel that can be serialized.
338 339
		 * @param reviver Webview serializer.
		 */
340
		export function registerWebviewPanelSerializer(viewType: string, reviver: WebviewPanelSerializer): Disposable;
M
Matt Bierner 已提交
341
	}
S
Sandeep Somavarapu 已提交
342

J
Johannes Rieken 已提交
343 344
	//#endregion

345 346 347
	//#region Tasks

	/**
348 349
	 * An object representing an executed Task. It can be used
	 * to terminate a task.
D
Dirk Baeumer 已提交
350 351
	 *
	 * This interface is not intended to be implemented.
352
	 */
353
	export interface TaskExecution {
D
Dirk Baeumer 已提交
354 355 356 357 358 359 360 361 362
		/**
		 * The task that got started.
		 */
		task: Task;

		/**
		 * Terminates the task execution.
		 */
		terminate(): void;
363 364 365 366
	}

	/**
	 * An event signaling the start of a task execution.
D
Dirk Baeumer 已提交
367 368
	 *
	 * This interface is not intended to be implemented.
369 370 371 372 373 374 375 376 377 378
	 */
	interface TaskStartEvent {
		/**
		 * The task item representing the task that got started.
		 */
		execution: TaskExecution;
	}

	/**
	 * An event signaling the end of an executed task.
D
Dirk Baeumer 已提交
379 380
	 *
	 * This interface is not intended to be implemented.
381 382 383 384 385 386 387 388
	 */
	interface TaskEndEvent {
		/**
		 * The task item representing the task that finished.
		 */
		execution: TaskExecution;
	}

389 390 391 392 393 394 395 396 397 398 399 400 401
	export interface TaskFilter {
		/**
		 * The task version as used in the tasks.json file.
		 * The string support the package.json semver notation.
		 */
		version?: string;

		/**
		 * The task type to return;
		 */
		type?: string;
	}

402
	export namespace workspace {
403 404

		/**
405
		 * Fetches all task available in the systems. Thisweweb includes tasks
406 407
		 * from `tasks.json` files as well as tasks from task providers
		 * contributed through extensions.
408 409
		 *
		 * @param filter a filter to filter the return tasks.
410
		 */
411
		export function fetchTasks(filter?: TaskFilter): Thenable<Task[]>;
412 413

		/**
414 415 416 417
		 * 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
418
		 */
419
		export function executeTask(task: Task): Thenable<TaskExecution>;
D
Dirk Baeumer 已提交
420

421 422 423 424 425
		/**
		 * The currently active task executions or an empty array.
		 *
		 * @readonly
		 */
426
		export let taskExecutions: ReadonlyArray<TaskExecution>;
427

D
Dirk Baeumer 已提交
428
		/**
429 430 431 432
		 * Fires when a task starts.
		 */
		export const onDidStartTask: Event<TaskStartEvent>;

433
		/**
434
		 * Fires when a task ends.
435
		 */
436
		export const onDidEndTask: Event<TaskEndEvent>;
437 438 439
	}

	//#endregion
440 441 442

	//#region Terminal

D
Daniel Imms 已提交
443
	export interface Terminal {
D
Daniel Imms 已提交
444
		/**
D
Daniel Imms 已提交
445
		 * Fires when the terminal's pty slave pseudo-device is written to. In other words, this
D
Daniel Imms 已提交
446 447 448
		 * provides access to the raw data stream from the process running within the terminal,
		 * including ANSI sequences.
		 */
D
Daniel Imms 已提交
449 450 451
		onData: Event<string>;
	}

452
	export namespace window {
D
Daniel Imms 已提交
453
		/**
D
jsdoc  
Daniel Imms 已提交
454 455
		 * The currently active terminals or an empty array.
		 *
D
Daniel Imms 已提交
456 457 458 459
		 * @readonly
		 */
		export let terminals: Terminal[];

D
jsdoc  
Daniel Imms 已提交
460 461 462 463
		/**
		 * An [event](#Event) which fires when a terminal has been created, either through the
		 * [createTerminal](#window.createTerminal) API or commands.
		 */
464 465 466 467
		export const onDidOpenTerminal: Event<Terminal>;
	}

	//#endregion
J
Joao Moreno 已提交
468 469 470

	//#region URLs

J
Joao Moreno 已提交
471 472
	export interface ProtocolHandler {
		handleUri(uri: Uri): void;
J
Joao Moreno 已提交
473 474 475 476 477
	}

	export namespace window {

		/**
J
Joao Moreno 已提交
478
		 * Registers a protocol handler capable of handling system-wide URIs.
J
Joao Moreno 已提交
479
		 */
J
Joao Moreno 已提交
480
		export function registerProtocolHandler(handler: ProtocolHandler): Disposable;
J
Joao Moreno 已提交
481 482 483
	}

	//#endregion
484 485 486 487 488 489

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

	export class HierarchicalSymbolInformation {
		name: string;
		kind: SymbolKind;
490
		detail: string;
491 492 493 494
		location: Location;
		range: Range;
		children: HierarchicalSymbolInformation[];

495
		constructor(name: string, detail: string, kind: SymbolKind, location: Location, range: Range);
496 497 498
	}

	export interface DocumentSymbolProvider {
J
Johannes Rieken 已提交
499
		provideDocumentSymbols(document: TextDocument, token: CancellationToken): ProviderResult<HierarchicalSymbolInformation[] | SymbolInformation[]>;
500 501 502
	}

	//#endregion
503 504 505 506 507 508 509 510

	//#region Joh -> exclusive document filters

	export interface DocumentFilter {
		exclusive?: boolean;
	}

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