vscode.proposed.d.ts 12.9 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 15 16 17
	//#region Joh: remote, search provider

	export interface TextSearchQuery {
		pattern: string;
18
		isRegExp?: boolean;
19 20 21 22
		isCaseSensitive?: boolean;
		isWordMatch?: boolean;
	}

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

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

37 38
	export interface FileSearchOptions extends SearchOptions { }

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

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

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

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

J
Johannes Rieken 已提交
56
	//#endregion
57

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

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

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

J
Johannes Rieken 已提交
89 90 91
	//#endregion

	//#region Joh: decorations
92 93 94 95 96

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

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

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

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

	//#endregion
119

J
Johannes Rieken 已提交
120 121
	//#region André: debug

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

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

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

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

	//#region Rob, Matt: logging

159 160 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
	/**
	 * 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 已提交
186
		 * This extension's logger
187 188
		 */
		logger: Logger;
189 190 191 192 193 194 195

		/**
		 * 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;
196
	}
197

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

J
Johannes Rieken 已提交
207 208 209
	//#endregion

	//#region Joao: SCM validation
210

J
Joao Moreno 已提交
211 212 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
	/**
	 * 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 已提交
256

J
Johannes Rieken 已提交
257 258
	//#endregion

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

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

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

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

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

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

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

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

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

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

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

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

334 335
	//#region Terminal

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

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

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

	//#endregion
J
Joao Moreno 已提交
361 362 363

	//#region URLs

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

	export namespace window {

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

	//#endregion
377 378 379

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

380
	export class SymbolInformation2 extends SymbolInformation {
381 382
		definingRange: Range;
		children: SymbolInformation2[];
383 384 385
	}

	export interface DocumentSymbolProvider {
386
		provideDocumentSymbols(document: TextDocument, token: CancellationToken): ProviderResult<SymbolInformation[] | SymbolInformation2[]>;
387 388 389
	}

	//#endregion
390 391 392 393 394 395 396 397

	//#region Joh -> exclusive document filters

	export interface DocumentFilter {
		exclusive?: boolean;
	}

	//#endregion
C
Christof Marti 已提交
398

399 400 401 402 403 404 405 406 407 408
	//#region mjbvz: Unused diagnostics
	/**
	 * Additional metadata about the type of diagnostic.
	 */
	export enum DiagnosticTag {
		/**
		 * Unused or unnecessary code.
		 */
		Unnecessary = 1,
	}
C
Christof Marti 已提交
409

410
	export interface Diagnostic {
C
Christof Marti 已提交
411
		/**
412
		 * Additional metadata about the type of the diagnostic.
C
Christof Marti 已提交
413
		 */
414 415 416 417
		customTags?: DiagnosticTag[];
	}

	//#endregion
418 419 420 421 422

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

425 426 427 428
	export namespace workspace {
		export const onDidRenameResource: Event<ResourceRenamedEvent>;
	}
	//#endregion
429 430 431

	//#region mjbvz: Code action trigger

C
Christof Marti 已提交
432
	/**
433
	 * How a [code action provider](#CodeActionProvider) was triggered
C
Christof Marti 已提交
434
	 */
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451
	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 已提交
452 453 454
	}

	//#endregion
455

456 457 458

	//#region Matt: WebView Serializer

459
	/**
460
	 * Restore webview panels that have been persisted when vscode shuts down.
461
	 */
462
	interface WebviewPanelSerializer {
463
		/**
464 465 466 467 468 469 470 471
		 * 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.
472
		 */
473
		deserializeWebviewPanel(webviewPanel: WebviewPanel, state: any): Thenable<void>;
474 475
	}

476
	namespace window {
477
		/**
478 479 480 481 482 483 484 485 486
		 * 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.
487
		 */
488
		export function registerWebviewPanelSerializer(viewType: string, serializer: WebviewPanelSerializer): Disposable;
489 490 491
	}

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