/*--------------------------------------------------------------------------------------------- * 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' { // 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, // } 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 { id: number | string; mtime: number; // atime: number; size: number; type: FileType; } export interface TextSearchQuery { pattern: string; isRegex?: boolean; isCaseSensitive?: boolean; isWordMatch?: boolean; } export interface TextSearchOptions { includes: GlobPattern[]; excludes: GlobPattern[]; } export interface TextSearchResult { uri: Uri; range: Range; preview: { leading: string, matching: string, trailing: string }; } // todo@joh discover files etc // todo@joh CancellationToken everywhere // todo@joh add open/close calls? export interface FileSystemProvider { readonly onDidChange?: Event; // todo@joh - remove this readonly root?: Uri; // more... // utimes(resource: Uri, mtime: number, atime: number): Thenable; stat(resource: Uri): Thenable; read(resource: Uri, offset: number, length: number, progress: Progress): Thenable; // todo@joh - have an option to create iff not exist // todo@remote // offset - byte offset to start // count - number of bytes to write // Thenable - number of bytes actually written write(resource: Uri, content: Uint8Array): Thenable; // todo@remote // Thenable move(resource: Uri, target: Uri): Thenable; // todo@remote // helps with performance bigly // copy?(from: Uri, to: Uri): Thenable; // todo@remote // Thenable mkdir(resource: Uri): Thenable; readdir(resource: Uri): Thenable<[Uri, FileStat][]>; // todo@remote // ? merge both // ? recursive del rmdir(resource: Uri): Thenable; unlink(resource: Uri): Thenable; // todo@remote // create(resource: Uri): Thenable; // find files by names // todo@joh, move into its own provider findFiles?(query: string, progress: Progress, token: CancellationToken): Thenable; provideTextSearchResults?(query: TextSearchQuery, options: TextSearchOptions, progress: Progress, token: CancellationToken): Thenable; } export namespace workspace { export function registerFileSystemProvider(scheme: string, provider: FileSystemProvider): Disposable; /** * Updates the workspace folders of the currently opened workspace. This method allows to add, remove * and change workspace folders a the same time. Use the [onDidChangeWorkspaceFolders()](#onDidChangeWorkspaceFolders) * event to get notified when the workspace folders have been updated. * * **Example:** adding a new workspace folder at the end of workspace folders * ```typescript * workspace.updateWorkspaceFolders(workspace.workspaceFolders ? workspace.workspaceFolders.length : 0, null, { uri: ...}); * ``` * * **Example:** removing the first workspace folder * ```typescript * workspace.updateWorkspaceFolders(0, 1); * ``` * * **Example:** replacing an existing workspace folder with a new one * ```typescript * workspace.updateWorkspaceFolders(0, 1, { uri: ...}); * ``` * * It is valid to remove an existing workspace folder and add it again with a different name * to rename that folder. * * Note: if the first workspace folder is added, removed or changed, all extensions will be restarted * so that the (deprecated) `rootPath` property is updated to point to the first workspace * folder. * * Note: it is not valid to call [updateWorkspaceFolders()](#updateWorkspaceFolders) multiple times * without waiting for the [onDidChangeWorkspaceFolders()](#onDidChangeWorkspaceFolders) to fire. * * @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. * Each workspace is identified with a mandatory URI and an optional name. * @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). */ export function updateWorkspaceFolders(start: number, deleteCount: number, ...workspaceFoldersToAdd: { uri: Uri, name?: string }[]): boolean; } export namespace window { export function sampleFunction(): Thenable; } /** * The contiguous set of modified lines in a diff. */ export interface LineChange { readonly originalStartLineNumber: number; readonly originalEndLineNumber: number; readonly modifiedStartLineNumber: number; readonly modifiedEndLineNumber: number; } 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; } //#region decorations //todo@joh -> make class export interface DecorationData { priority?: number; title?: string; bubble?: boolean; abbreviation?: string; color?: ThemeColor; source?: string; } export interface SourceControlResourceDecorations { source?: string; letter?: string; color?: ThemeColor; } export interface DecorationProvider { onDidChangeDecorations: Event; provideDecoration(uri: Uri, token: CancellationToken): ProviderResult; } export namespace window { export function registerDecorationProvider(provider: DecorationProvider): Disposable; } //#endregion 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; /** * Add breakpoints. * @param breakpoints The breakpoints to add. */ export function addBreakpoints(breakpoints: Breakpoint[]): void; /** * Remove breakpoints. * @param breakpoints The breakpoints to remove. */ export function removeBreakpoints(breakpoints: Breakpoint[]): void; } /** * 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[]; } /** * The base class of all breakpoint types. */ export class Breakpoint { /** * 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; protected constructor(enabled?: boolean, condition?: string, hitCondition?: string); } /** * A breakpoint specified by a source location. */ export class SourceBreakpoint extends Breakpoint { /** * The source and line position of this breakpoint. */ readonly location: Location; /** * Create a new breakpoint for a source location. */ constructor(location: Location, enabled?: boolean, condition?: string, hitCondition?: string); } /** * A breakpoint specified by a function name. */ export class FunctionBreakpoint extends Breakpoint { /** * The name of the function to which this breakpoint is attached. */ readonly functionName: string; /** * Create a new function breakpoint. */ constructor(functionName: string, enabled?: boolean, condition?: string, hitCondition?: string); } /** * 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 { readonly onDidChangeLogLevel: Event; readonly currentLevel: LogLevel; readonly logDirectory: Thenable; 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 { /** * This extension's logger */ logger: Logger; } export interface RenameInitialValue { range: Range; text?: string; } export namespace languages { export interface RenameProvider2 extends RenameProvider { resolveInitialRenameValue?(document: TextDocument, position: Position, token: CancellationToken): ProviderResult; } } }