vscode.proposed.d.ts 9.2 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
	// todo@joh discover files etc
	export interface FileSystemProvider {
D
Dirk Baeumer 已提交
88

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

J
Johannes Rieken 已提交
91
		readonly root: Uri;
92

93 94
		// more...
		//
J
Johannes Rieken 已提交
95
		utimes(resource: Uri, mtime: number, atime: number): Thenable<FileStat>;
96

97
		stat(resource: Uri): Thenable<FileStat>;
98

99
		read(resource: Uri, offset: number, length: number, progress: Progress<Uint8Array>): Thenable<number>;
100 101 102 103 104

		// todo@remote
		// offset - byte offset to start
		// count - number of bytes to write
		// Thenable<number> - number of bytes actually written
105
		write(resource: Uri, content: Uint8Array): Thenable<void>;
106 107 108

		// todo@remote
		// Thenable<FileStat>
109 110 111 112 113
		move(resource: Uri, target: Uri): Thenable<FileStat>;

		// todo@remote
		// helps with performance bigly
		// copy?(from: Uri, to: Uri): Thenable<void>;
114 115 116

		// todo@remote
		// Thenable<FileStat>
117
		mkdir(resource: Uri): Thenable<FileStat>;
118

119 120 121 122 123
		readdir(resource: Uri): Thenable<[Uri, FileStat][]>;

		// todo@remote
		// ? merge both
		// ? recursive del
124
		rmdir(resource: Uri): Thenable<void>;
125 126 127 128
		unlink(resource: Uri): Thenable<void>;

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

		// find files by names
		findFiles?(query: string, progress: Progress<Uri>, token: CancellationToken): Thenable<void>;
132 133
	}

134
	export namespace workspace {
J
Johannes Rieken 已提交
135
		export function registerFileSystemProvider(authority: string, provider: FileSystemProvider): Disposable;
136 137
	}

138 139 140 141
	export namespace window {

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

J
Joao Moreno 已提交
143 144 145
	/**
	 * The contiguous set of modified lines in a diff.
	 */
J
Joao Moreno 已提交
146 147 148 149 150 151 152
	export interface LineChange {
		readonly originalStartLineNumber: number;
		readonly originalEndLineNumber: number;
		readonly modifiedStartLineNumber: number;
		readonly modifiedEndLineNumber: number;
	}

153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170
	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;
	}
171 172 173 174 175 176 177

	//#region decorations

	//todo@joh -> make class
	export interface DecorationData {
		priority?: number;
		title?: string;
178
		bubble?: boolean;
179 180
		abbreviation?: string;
		color?: ThemeColor;
181
		source?: string;
182 183
	}

184 185 186 187 188 189
	export interface SourceControlResourceDecorations {
		source?: string;
		letter?: string;
		color?: ThemeColor;
	}

190
	export interface DecorationProvider {
191
		onDidChangeDecorations: Event<undefined | Uri | Uri[]>;
192 193 194 195
		provideDecoration(uri: Uri, token: CancellationToken): ProviderResult<DecorationData>;
	}

	export namespace window {
196
		export function registerDecorationProvider(provider: DecorationProvider): Disposable;
197 198 199
	}

	//#endregion
200

201
	/**
J
Johannes Rieken 已提交
202 203
	 * A code action represents a change that can be performed in code, e.g. to fix a problem or
	 * to refactor code.
204 205 206 207
	 */
	export class CodeAction {

		/**
J
Johannes Rieken 已提交
208
		 * A short, human-readanle, title for this code action.
209
		 */
J
Johannes Rieken 已提交
210
		title: string;
211 212 213 214 215 216 217 218 219 220 221 222 223

		/**
		 * Optional edit that performs the code action.
		 *
		 * Either `command` or `edits` must be provided for a `CodeAction`.
		 */
		edits?: TextEdit[] | WorkspaceEdit;

		/**
		 * Diagnostics that this code action resolves.
		 */
		diagnostics?: Diagnostic[];

J
Johannes Rieken 已提交
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239
		/**
		 * Optional command that performs the code action.
		 *
		 * Executed after `edits` if any edits are provided. Either `command` or `edits` must be provided for a `CodeAction`.
		 */
		command?: Command;

		/**
		 * Creates a new code action.
		 *
		 * A code action must have at least a [title](#CodeAction.title) and either [edits](#CodeAction.edits)
		 * or a [command](#CodeAction.command).
		 *
		 * @param title The title of the code action.
		 * @param edits The edit of the code action.
		 */
240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258
		constructor(title: string, edits?: TextEdit[] | WorkspaceEdit);
	}

	export interface CodeActionProvider {

		/**
		 * Provide commands for the given document and range.
		 *
		 * If implemented, overrides `provideCodeActions`
		 *
		 * @param document The document in which the command was invoked.
		 * @param range The range for which the command was invoked.
		 * @param context Context carrying additional information.
		 * @param token A cancellation token.
		 * @return An array of commands, quick fixes, or refactorings or a thenable of such. The lack of a result can be
		 * signaled by returning `undefined`, `null`, or an empty array.
		 */
		provideCodeActions2?(document: TextDocument, range: Range, context: CodeActionContext, token: CancellationToken): ProviderResult<(Command | CodeAction)[]>;
	}
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

	export namespace debug {

		/**
		 * List of breakpoints.
		 *
		 * @readonly
		 */
		export let breakpoints: Breakpoint[];

		/**
		 * An event that is emitted when a breakpoint is added, removed, or changed.
		 */
		export const onDidChangeBreakpoints: Event<BreakpointsChangeEvent>;
	}

	/**
	 * An event describing a change to the set of [breakpoints](#debug.Breakpoint).
	 */
	export interface BreakpointsChangeEvent {
		/**
		 * Added breakpoints.
		 */
		readonly added: Breakpoint[];

		/**
		 * Removed breakpoints.
		 */
		readonly removed: Breakpoint[];

		/**
		 * Changed breakpoints.
		 */
		readonly changed: Breakpoint[];
	}

295 296 297 298
	/**
	 * The base class of all breakpoint types.
	 */
	export class Breakpoint {
299 300 301 302 303 304 305 306 307 308 309 310
		/**
		 * Is breakpoint enabled.
		 */
		readonly enabled: boolean;
		/**
		 * An optional expression for conditional breakpoints.
		 */
		readonly condition?: string;
		/**
		 * An optional expression that controls how many hits of the breakpoint are ignored.
		 */
		readonly hitCondition?: string;
311 312

		protected constructor(enabled: boolean, condition: string, hitCondition: string);
313 314
	}

315 316 317 318
	/**
	 * A breakpoint specified by a source location.
	 */
	export class SourceBreakpoint extends Breakpoint {
319
		/**
320
		 * The source and line position of this breakpoint.
321
		 */
322
		readonly location: Location;
323 324

		private constructor(enabled: boolean, condition: string, hitCondition: string, location: Location);
325 326
	}

327 328 329 330
	/**
	 * A breakpoint specified by a function name.
	 */
	export class FunctionBreakpoint extends Breakpoint {
331 332 333 334
		/**
		 * The name of the function to which this breakpoint is attached.
		 */
		readonly functionName: string;
335 336

		private constructor(enabled: boolean, condition: string, hitCondition: string, functionName: string);
337
	}
338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355

	/**
	 * 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 {
356
		readonly onDidChangeLogLevel: Event<LogLevel>;
357
		readonly currentLevel: LogLevel;
358
		readonly logDirectory: Thenable<string>;
359 360 361 362 363 364 365 366 367 368 369 370 371 372 373

		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 {
		/**
		 * A logger
		 */
		logger: Logger;
	}
J
Johannes Rieken 已提交
374
}