VS Code 1.20 Extension API

This commit is contained in:
Pine Wu
2019-03-22 12:04:04 -07:00
parent 7ca44ad714
commit f7be7ede89
+222 -20
View File
@@ -1,4 +1,4 @@
// Type definitions for Visual Studio Code 1.19
// Type definitions for Visual Studio Code 1.20
// Project: https://github.com/microsoft/vscode
// Definitions by: Visual Studio Code Team, Microsoft <https://github.com/Microsoft>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
@@ -10,7 +10,7 @@
*--------------------------------------------------------------------------------------------*/
/**
* Type Definition for Visual Studio Code 1.19 Extension API
* Type Definition for Visual Studio Code 1.20 Extension API
* See https://code.visualstudio.com/api for more information
*/
@@ -272,7 +272,7 @@ declare module 'vscode' {
constructor(line: number, character: number);
/**
* Check if `other` is before this position.
* Check if this position is before `other`.
*
* @param other A position.
* @return `true` if position is on a smaller line
@@ -281,7 +281,7 @@ declare module 'vscode' {
isBefore(other: Position): boolean;
/**
* Check if `other` is before or equal to this position.
* Check if this position is before or equal to `other`.
*
* @param other A position.
* @return `true` if position is on a smaller line
@@ -290,7 +290,7 @@ declare module 'vscode' {
isBeforeOrEqual(other: Position): boolean;
/**
* Check if `other` is after this position.
* Check if this position is after `other`.
*
* @param other A position.
* @return `true` if position is on a greater line
@@ -299,7 +299,7 @@ declare module 'vscode' {
isAfter(other: Position): boolean;
/**
* Check if `other` is after or equal to this position.
* Check if this position is after or equal to `other`.
*
* @param other A position.
* @return `true` if position is on a greater line
@@ -308,7 +308,7 @@ declare module 'vscode' {
isAfterOrEqual(other: Position): boolean;
/**
* Check if `other` equals this position.
* Check if this position is equal to `other`.
*
* @param other A position.
* @return `true` if the line and character of the given position are equal to
@@ -847,6 +847,16 @@ declare module 'vscode' {
*/
borderWidth?: string;
/**
* CSS styling property that will be applied to text enclosed by a decoration.
*/
fontStyle?: string;
/**
* CSS styling property that will be applied to text enclosed by a decoration.
*/
fontWeight?: string;
/**
* CSS styling property that will be applied to text enclosed by a decoration.
*/
@@ -913,6 +923,14 @@ declare module 'vscode' {
* CSS styling property that will be applied to text enclosed by a decoration.
*/
borderColor?: string | ThemeColor;
/**
* CSS styling property that will be applied to the decoration attachment.
*/
fontStyle?: string;
/**
* CSS styling property that will be applied to the decoration attachment.
*/
fontWeight?: string;
/**
* CSS styling property that will be applied to the decoration attachment.
*/
@@ -1805,6 +1823,90 @@ declare module 'vscode' {
*/
export type ProviderResult<T> = T | undefined | null | Thenable<T | undefined | null>;
/**
* Kind of a code action.
*
* Kinds are a hierarchical list of identifiers separated by `.`, e.g. `"refactor.extract.function"`.
*/
export class CodeActionKind {
/**
* Empty kind.
*/
static readonly Empty: CodeActionKind;
/**
* Base kind for quickfix actions.
*/
static readonly QuickFix: CodeActionKind;
/**
* Base kind for refactoring actions.
*/
static readonly Refactor: CodeActionKind;
/**
* Base kind for refactoring extraction actions.
*
* Example extract actions:
*
* - Extract method
* - Extract function
* - Extract variable
* - Extract interface from class
* - ...
*/
static readonly RefactorExtract: CodeActionKind;
/**
* Base kind for refactoring inline actions.
*
* Example inline actions:
*
* - Inline function
* - Inline variable
* - Inline constant
* - ...
*/
static readonly RefactorInline: CodeActionKind;
/**
* Base kind for refactoring rewrite actions.
*
* Example rewrite actions:
*
* - Convert JavaScript function to class
* - Add or remove parameter
* - Encapsulate field
* - Make method static
* - Move method to base class
* - ...
*/
static readonly RefactorRewrite: CodeActionKind;
private constructor(value: string);
/**
* String value of the kind, e.g. `"refactor.extract.function"`.
*/
readonly value?: string;
/**
* Create a new kind by appending a more specific selector to the current kind.
*
* Does not modify the current kind.
*/
append(parts: string): CodeActionKind;
/**
* Does this kind contain `other`?
*
* The kind `"refactor"` for example contains `"refactor.extract"` and ``"refactor.extract.function"`, but not `"unicorn.refactor.extract"` or `"refactory.extract"`
*
* @param other Kind to check.
*/
contains(other: CodeActionKind): boolean;
}
/**
* Contains additional diagnostic information about the context in which
* a [code action](#CodeActionProvider.provideCodeActions) is run.
@@ -1814,6 +1916,60 @@ declare module 'vscode' {
* An array of diagnostics.
*/
readonly diagnostics: Diagnostic[];
/**
* Requested kind of actions to return.
*
* Actions not of this kind are filtered out before being shown by the lightbulb.
*/
readonly only?: CodeActionKind;
}
/**
* A code action represents a change that can be performed in code, e.g. to fix a problem or
* to refactor code.
*
* A CodeAction must set either [`edit`](CodeAction#edit) and/or a [`command`](CodeAction#command). If both are supplied, the `edit` is applied first, then the command is executed.
*/
export class CodeAction {
/**
* A short, human-readable, title for this code action.
*/
title: string;
/**
* A [workspace edit](#WorkspaceEdit) this code action performs.
*/
edit?: WorkspaceEdit;
/**
* [Diagnostics](#Diagnostic) that this code action resolves.
*/
diagnostics?: Diagnostic[];
/**
* A [command](#Command) this code action executes.
*/
command?: Command;
/**
* [Kind](#CodeActionKind) of the code action.
*
* Used to filter code actions.
*/
kind?: CodeActionKind;
/**
* Creates a new code action.
*
* A code action must have at least a [title](#CodeAction.title) and either [edits](#CodeAction.edit)
* or a [command](#CodeAction.command).
*
* @param title The title of the code action.
* @param kind The kind of the code action.
*/
constructor(title: string, kind?: CodeActionKind);
}
/**
@@ -1831,10 +1987,10 @@ declare module 'vscode' {
* @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 or a thenable of such. The lack of a result can be
* @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.
*/
provideCodeActions(document: TextDocument, range: Range, context: CodeActionContext, token: CancellationToken): ProviderResult<Command[]>;
provideCodeActions(document: TextDocument, range: Range, context: CodeActionContext, token: CancellationToken): ProviderResult<(Command | CodeAction)[]>;
}
/**
@@ -2372,7 +2528,8 @@ declare module 'vscode' {
}
/**
* A workspace edit represents textual changes for many documents.
* A workspace edit represents textual and files changes for
* multiple resources and documents.
*/
export class WorkspaceEdit {
@@ -2433,7 +2590,7 @@ declare module 'vscode' {
/**
* Get all text edits grouped by resource.
*
* @return An array of `[Uri, TextEdit[]]`-tuples.
* @return A shallow copy of `[Uri, TextEdit[]]`-tuples.
*/
entries(): [Uri, TextEdit[]][];
}
@@ -2863,7 +3020,7 @@ declare module 'vscode' {
export class CompletionList {
/**
* This list it not complete. Further typing should result in recomputing
* This list is not complete. Further typing should result in recomputing
* this list.
*/
isIncomplete?: boolean;
@@ -2893,7 +3050,11 @@ declare module 'vscode' {
/**
* Completion was triggered by a trigger character.
*/
TriggerCharacter = 1
TriggerCharacter = 1,
/**
* Completion was re-triggered as current completion list is incomplete
*/
TriggerForIncompleteCompletions = 2
}
/**
@@ -3662,7 +3823,7 @@ declare module 'vscode' {
* An output channel is a container for readonly textual information.
*
* To get an instance of an `OutputChannel` use
* [createOutputChannel](#window.createOutputChannel).
* [ createOutputChannel](#window.createOutputChannel).
*/
export interface OutputChannel {
@@ -4891,6 +5052,7 @@ declare module 'vscode' {
export interface TreeDataProvider<T> {
/**
* An optional event to signal that an element or root has changed.
* This will trigger the view to update the changed element/root and its children recursively (if shown).
* To signal that root has changed, do not pass any argument or pass `undefined` or `null`.
*/
onDidChangeTreeData?: Event<T | undefined | null>;
@@ -4914,15 +5076,30 @@ declare module 'vscode' {
export class TreeItem {
/**
* A human-readable string describing this item
* A human-readable string describing this item. When `falsy`, it is derived from [resourceUri](#TreeItem.resourceUri).
*/
label: string;
label?: string;
/**
* The icon path for the tree item
* Optional id for the tree item that has to be unique across tree. The id is used to preserve the selection and expansion state of the tree item.
*
* If not provided, an id is generated using the tree item's label. **Note** that when labels change, ids will change and that selection and expansion state cannot be kept stable anymore.
*/
id?: string;
/**
* The icon path for the tree item. When `falsy`, it is derived from [resourceUri](#TreeItem.resourceUri).
*/
iconPath?: string | Uri | { light: string | Uri; dark: string | Uri };
/**
* The [uri](#Uri) of the resource representing this item.
*
* Will be used to derive the [label](#TreeItem.label), when it is not provided.
* Will be used to derive the icon from current file icon theme, when [iconPath](#TreeItem.iconPath) is not provided.
*/
resourceUri?: Uri;
/**
* The [command](#Command) which should be run when the tree item is selected.
*/
@@ -4958,6 +5135,12 @@ declare module 'vscode' {
* @param collapsibleState [TreeItemCollapsibleState](#TreeItemCollapsibleState) of the tree item. Default is [TreeItemCollapsibleState.None](#TreeItemCollapsibleState.None)
*/
constructor(label: string, collapsibleState?: TreeItemCollapsibleState);
/**
* @param resourceUri The [uri](#Uri) of the resource representing this item.
* @param collapsibleState [TreeItemCollapsibleState](#TreeItemCollapsibleState) of the tree item. Default is [TreeItemCollapsibleState.None](#TreeItemCollapsibleState.None)
*/
constructor(resourceUri: Uri, collapsibleState?: TreeItemCollapsibleState);
}
/**
@@ -4996,6 +5179,12 @@ declare module 'vscode' {
* Args for the custom shell executable, this does not work on Windows (see #8429)
*/
shellArgs?: string[];
/**
* A path for the current working directory to be used for the terminal.
*/
cwd?: string;
/**
* Object with environment variables that will be added to the VS Code process.
*/
@@ -5276,13 +5465,14 @@ declare module 'vscode' {
* will be matched against the file paths of resulting matches relative to their workspace. Use a [relative pattern](#RelativePattern)
* to restrict the search results to a [workspace folder](#WorkspaceFolder).
* @param exclude A [glob pattern](#GlobPattern) that defines files and folders to exclude. The glob pattern
* will be matched against the file paths of resulting matches relative to their workspace.
* will be matched against the file paths of resulting matches relative to their workspace. When `undefined` only default excludes will
* apply, when `null` no excludes will apply.
* @param maxResults An upper-bound for the result.
* @param token A token that can be used to signal cancellation to the underlying search engine.
* @return A thenable that resolves to an array of resource identifiers. Will return no results if no
* [workspace folders](#workspace.workspaceFolders) are opened.
*/
export function findFiles(include: GlobPattern, exclude?: GlobPattern, maxResults?: number, token?: CancellationToken): Thenable<Uri[]>;
export function findFiles(include: GlobPattern, exclude?: GlobPattern | null, maxResults?: number, token?: CancellationToken): Thenable<Uri[]>;
/**
* Save all dirty files.
@@ -5363,11 +5553,23 @@ declare module 'vscode' {
/**
* An event that is emitted when a [text document](#TextDocument) is opened.
*
* To add an event listener when a visible text document is opened, use the [TextEditor](#TextEditor) events in the
* [window](#window) namespace. Note that:
*
* - The event is emitted before the [document](#TextDocument) is updated in the
* [active text editor](#window.activeTextEditor)
* - When a [text document](#TextDocument) is already open (e.g.: open in another [visible text editor](#window.visibleTextEditors)) this event is not emitted
*
*/
export const onDidOpenTextDocument: Event<TextDocument>;
/**
* An event that is emitted when a [text document](#TextDocument) is disposed.
*
* To add an event listener when a visible text document is closed, use the [TextEditor](#TextEditor) events in the
* [window](#window) namespace. Note that this event is not emitted when a [TextEditor](#TextEditor) is closed
* but the document remains open in another [visible text editor](#window.visibleTextEditors).
*/
export const onDidCloseTextDocument: Event<TextDocument>;
@@ -5411,7 +5613,7 @@ declare module 'vscode' {
* @param resource A resource for which the configuration is asked for
* @return The full configuration or a subset.
*/
export function getConfiguration(section?: string, resource?: Uri): WorkspaceConfiguration;
export function getConfiguration(section?: string, resource?: Uri | null): WorkspaceConfiguration;
/**
* An event that is emitted when the [configuration](#WorkspaceConfiguration) changed.