vscode.proposed.d.ts 14.0 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' {

10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60
	// export enum FileErrorCodes {
	// 	/**
	// 	 * Not owner.
	// 	 */
	// 	EPERM = 1,
	// 	/**
	// 	 * No such file or directory.
	// 	 */
	// 	ENOENT = 2,
	// 	/**
	// 	 * I/O error.
	// 	 */
	// 	EIO = 5,
	// 	/**
	// 	 * Permission denied.
	// 	 */
	// 	EACCES = 13,
	// 	/**
	// 	 * File exists.
	// 	 */
	// 	EEXIST = 17,
	// 	/**
	// 	 * Not a directory.
	// 	 */
	// 	ENOTDIR = 20,
	// 	/**
	// 	 * Is a directory.
	// 	 */
	// 	EISDIR = 21,
	// 	/**
	// 	 *  File too large.
	// 	 */
	// 	EFBIG = 27,
	// 	/**
	// 	 * No space left on device.
	// 	 */
	// 	ENOSPC = 28,
	// 	/**
	// 	 * Directory is not empty.
	// 	 */
	// 	ENOTEMPTY = 66,
	// 	/**
	// 	 * Invalid file handle.
	// 	 */
	// 	ESTALE = 70,
	// 	/**
	// 	 * Illegal NFS file handle.
	// 	 */
	// 	EBADHANDLE = 10001,
	// }

61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
	export enum FileChangeType {
		Updated = 0,
		Added = 1,
		Deleted = 2
	}

	export interface FileChange {
		type: FileChangeType;
		resource: Uri;
	}

	export enum FileType {
		File = 0,
		Dir = 1,
		Symlink = 2
	}

	export interface FileStat {
79
		id: number | string;
80
		mtime: number;
J
Johannes Rieken 已提交
81
		// atime: number;
82 83 84 85
		size: number;
		type: FileType;
	}

J
Johannes Rieken 已提交
86 87 88 89 90 91 92
	export interface TextSearchQuery {
		pattern: string;
		isRegex?: boolean;
		isCaseSensitive?: boolean;
		isWordMatch?: boolean;
	}

93 94 95 96 97
	export interface TextSearchOptions {
		includes: GlobPattern[];
		excludes: GlobPattern[];
	}

J
Johannes Rieken 已提交
98
	export interface TextSearchResult {
99 100 101 102 103
		uri: Uri;
		range: Range;
		preview: { leading: string, matching: string, trailing: string };
	}

J
Johannes Rieken 已提交
104
	// todo@joh discover files etc
J
Johannes Rieken 已提交
105
	// todo@joh CancellationToken everywhere
J
Johannes Rieken 已提交
106
	// todo@joh add open/close calls?
J
Johannes Rieken 已提交
107
	export interface FileSystemProvider {
D
Dirk Baeumer 已提交
108

J
Johannes Rieken 已提交
109
		readonly onDidChange?: Event<FileChange[]>;
110

111 112
		// todo@joh - remove this
		readonly root?: Uri;
113

114 115
		// more...
		//
J
Johannes Rieken 已提交
116
		utimes(resource: Uri, mtime: number, atime: number): Thenable<FileStat>;
117

118
		stat(resource: Uri): Thenable<FileStat>;
119

120
		read(resource: Uri, offset: number, length: number, progress: Progress<Uint8Array>): Thenable<number>;
121

J
Johannes Rieken 已提交
122
		// todo@joh - have an option to create iff not exist
123 124 125 126
		// todo@remote
		// offset - byte offset to start
		// count - number of bytes to write
		// Thenable<number> - number of bytes actually written
127
		write(resource: Uri, content: Uint8Array): Thenable<void>;
128 129 130

		// todo@remote
		// Thenable<FileStat>
131 132 133 134 135
		move(resource: Uri, target: Uri): Thenable<FileStat>;

		// todo@remote
		// helps with performance bigly
		// copy?(from: Uri, to: Uri): Thenable<void>;
136 137 138

		// todo@remote
		// Thenable<FileStat>
139
		mkdir(resource: Uri): Thenable<FileStat>;
140

141 142 143 144 145
		readdir(resource: Uri): Thenable<[Uri, FileStat][]>;

		// todo@remote
		// ? merge both
		// ? recursive del
146
		rmdir(resource: Uri): Thenable<void>;
147 148 149 150
		unlink(resource: Uri): Thenable<void>;

		// todo@remote
		// create(resource: Uri): Thenable<FileStat>;
J
Johannes Rieken 已提交
151 152

		// find files by names
J
Johannes Rieken 已提交
153
		// todo@joh, move into its own provider
J
Johannes Rieken 已提交
154
		findFiles?(query: string, progress: Progress<Uri>, token: CancellationToken): Thenable<void>;
155
		provideTextSearchResults?(query: TextSearchQuery, options: TextSearchOptions, progress: Progress<TextSearchResult>, token: CancellationToken): Thenable<void>;
156 157
	}

158
	export namespace workspace {
159
		export function registerFileSystemProvider(scheme: string, provider: FileSystemProvider): Disposable;
160 161

		/**
B
Benjamin Pasero 已提交
162 163 164 165 166 167 168 169 170 171
		 * This method replaces `deleteCount` [workspace folders](#workspace.workspaceFolders) starting at index `start`
		 * by an optional set of `workspaceFoldersToAdd` on the `vscode.workspace.workspaceFolders` array. This "splice"
		 * behavior can be used to add, remove and change workspace folders in a single operation.
		 *
		 * If the first workspace folder is added, removed or changed, the currently executing extensions (including the
		 * one that called this method) will be terminated and restarted so that the (deprecated) `rootPath` property is
		 * updated to point to the first workspace folder.
		 *
		 * Use the [`onDidChangeWorkspaceFolders()`](#onDidChangeWorkspaceFolders) event to get notified when the
		 * workspace folders have been updated.
172
		 *
B
Benjamin Pasero 已提交
173
		 * **Example:** adding a new workspace folder at the end of workspace folders
174
		 * ```typescript
B
Benjamin Pasero 已提交
175
		 * workspace.updateWorkspaceFolders(workspace.workspaceFolders ? workspace.workspaceFolders.length : 0, null, { uri: ...});
176 177
		 * ```
		 *
B
Benjamin Pasero 已提交
178
		 * **Example:** removing the first workspace folder
179
		 * ```typescript
B
Benjamin Pasero 已提交
180
		 * workspace.updateWorkspaceFolders(0, 1);
181 182
		 * ```
		 *
B
Benjamin Pasero 已提交
183
		 * **Example:** replacing an existing workspace folder with a new one
184
		 * ```typescript
B
Benjamin Pasero 已提交
185
		 * workspace.updateWorkspaceFolders(0, 1, { uri: ...});
186 187
		 * ```
		 *
B
Benjamin Pasero 已提交
188 189 190
		 * It is valid to remove an existing workspace folder and add it again with a different name
		 * to rename that folder.
		 *
B
Benjamin Pasero 已提交
191
		 * **Note:** it is not valid to call [updateWorkspaceFolders()](#updateWorkspaceFolders) multiple times
B
Benjamin Pasero 已提交
192
		 * without waiting for the [`onDidChangeWorkspaceFolders()`](#onDidChangeWorkspaceFolders) to fire.
B
Benjamin Pasero 已提交
193
		 *
B
Benjamin Pasero 已提交
194 195 196 197
		 * @param start the zero-based location in the list of currently opened [workspace folders](#WorkspaceFolder)
		 * from which to start deleting workspace folders.
		 * @param deleteCount the optional number of workspace folders to remove.
		 * @param workspaceFoldersToAdd the optional variable set of workspace folders to add in place of the deleted ones.
B
Benjamin Pasero 已提交
198
		 * Each workspace is identified with a mandatory URI and an optional name.
B
Benjamin Pasero 已提交
199 200
		 * @return true if the operation was successfully started and false otherwise if arguments were used that would result
		 * in invalid workspace folder state (e.g. 2 folders with the same URI).
201
		 */
202
		export function updateWorkspaceFolders(start: number, deleteCount: number, ...workspaceFoldersToAdd: { uri: Uri, name?: string }[]): boolean;
203 204
	}

205 206 207 208
	export namespace window {

		export function sampleFunction(): Thenable<any>;
	}
P
Pine Wu 已提交
209

J
Joao Moreno 已提交
210 211 212
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
213 214 215 216 217 218 219
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237
	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;
	}
238 239 240 241 242 243 244

	//#region decorations

	//todo@joh -> make class
	export interface DecorationData {
		priority?: number;
		title?: string;
245
		bubble?: boolean;
246 247
		abbreviation?: string;
		color?: ThemeColor;
248
		source?: string;
249 250
	}

251 252 253 254 255 256
	export interface SourceControlResourceDecorations {
		source?: string;
		letter?: string;
		color?: ThemeColor;
	}

257
	export interface DecorationProvider {
258
		onDidChangeDecorations: Event<undefined | Uri | Uri[]>;
259 260 261 262
		provideDecoration(uri: Uri, token: CancellationToken): ProviderResult<DecorationData>;
	}

	export namespace window {
263
		export function registerDecorationProvider(provider: DecorationProvider): Disposable;
264 265 266
	}

	//#endregion
267

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

		/**
A
Andre Weinand 已提交
280
		 * Optional arguments passed to the debug adapter executable.
281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300
		 */
		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>;
	}

301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317
	/**
	 * 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 {
318
		readonly onDidChangeLogLevel: Event<LogLevel>;
319
		readonly currentLevel: LogLevel;
320
		readonly logDirectory: Thenable<string>;
321 322 323 324 325 326 327 328 329 330 331

		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 已提交
332
		 * This extension's logger
333 334 335
		 */
		logger: Logger;
	}
336 337 338 339 340 341 342 343 344 345 346

	export interface RenameInitialValue {
		range: Range;
		text?: string;
	}

	export namespace languages {
		export interface RenameProvider2 extends RenameProvider {
			resolveInitialRenameValue?(document: TextDocument, position: Position, token: CancellationToken): ProviderResult<RenameInitialValue>;
		}
	}
347

J
Joao Moreno 已提交
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 379 380 381 382 383 384 385 386 387 388 389 390 391 392
	/**
	 * 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 已提交
393 394 395 396 397 398

	/**
	 * Content settings for a webview.
	 */
	export interface WebviewOptions {
		/**
399
		 * Should scripts be enabled in the webview content?
M
Matt Bierner 已提交
400 401 402 403 404 405
		 *
		 * Defaults to false (scripts-disabled).
		 */
		readonly enableScripts?: boolean;

		/**
M
Matt Bierner 已提交
406
		 * Should command uris be enabled in webview content?
M
Matt Bierner 已提交
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425
		 *
		 * Defaults to false.
		 */
		readonly enableCommandUris?: boolean;

		/**
		 * Should the webview content be kept arount even when the webview is no longer visible?
		 *
		 * Normally a webview content is created when the webview becomes visible
		 * and destroyed when the webview is hidden. Apps that have complex state
		 * or UI can set the `keepAlive` property to make VS Code keep the webview
		 * content around, even when the webview itself is no longer visible. When
		 * the webview becomes visible again, the content is automatically restored
		 * in the exact same state it was in originally
		 *
		 * `keepAlive` has a high memory overhead and should only be used if your
		 * webview content cannot be quickly saved and restored.
		 */
		readonly keepAlive?: boolean;
426 427 428 429 430 431 432 433 434

		/**
		 * Root paths from which the webview can load local (filesystem) resources using the `vscode-workspace-resource:` scheme.
		 *
		 * Default to the root folders of the current workspace.
		 *
		 * Pass in an empty array to disallow access to any local resources.
		 */
		readonly localResourceRoots?: Uri[];
M
Matt Bierner 已提交
435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455
	}

	/**
	 * A webview is an editor with html content, like an iframe.
	 */
	export interface Webview {
		/**
		 * Title of the webview.
		 */
		title: string;

		/**
		 * Contents of the webview.
		 */
		html: string;

		/**
		 * Content settings for the webview.
		 */
		options: WebviewOptions;

M
Matt Bierner 已提交
456 457 458 459 460
		/**
		 * The column in which the webview is showing.
		 */
		readonly viewColumn?: ViewColumn;

M
Matt Bierner 已提交
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
		/**
		 * Fired when the webview content posts a message.
		 */
		readonly onMessage: Event<any>;

		/**
		 * Fired when the webview becomes the active editor.
		 */
		readonly onBecameActive: Event<void>;

		/**
		 * Fired when the webview stops being the active editor
		 */
		readonly onBecameInactive: Event<void>;

		/**
		 * Post a message to the webview content.
		 *
		 * Messages are only develivered if the webview is visible.
		 *
		 * @param message Body of the message.
		 */
		postMessage(message: any): Thenable<any>;

		/**
		 * Dispose the webview.
		 */
		dispose(): any;
	}

	namespace window {
		/**
		 * Create and show a new webview.
		 *
		 * @param title Title of the webview.
		 * @param column Editor column to show the new webview in.
		 * @param options Webview content options.
		 */
		export function createWebview(title: string, column: ViewColumn, options: WebviewOptions): Webview;
	}
J
Johannes Rieken 已提交
501
}