Merge pull request #34019 from octref/master

VS Code 1.18 Extension API
This commit is contained in:
Pine
2019-03-19 22:09:48 -07:00
committed by GitHub

View File

@@ -1,5 +1,5 @@
// Type definitions for Visual Studio Code 1.17
// Project: https://github.com/microsoft/vscode-extension-vscode
// Type definitions for Visual Studio Code 1.18
// 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.17 Extension API
* Type Definition for Visual Studio Code 1.18 Extension API
*/
declare module 'vscode' {
@@ -1514,6 +1514,22 @@ declare module 'vscode' {
onDidSelectItem?(item: QuickPickItem | string): any;
}
/**
* Options to configure the behaviour of the [workspace folder](#WorkspaceFolder) pick UI.
*/
export interface WorkspaceFolderPickOptions {
/**
* An optional string to show as place holder in the input box to guide the user what to pick on.
*/
placeHolder?: string;
/**
* Set to `true` to keep the picker open when focus moves to another part of the editor or to another window.
*/
ignoreFocusOut?: boolean;
}
/**
* Options to configure the behaviour of a file open dialog.
*
@@ -1671,7 +1687,7 @@ declare module 'vscode' {
* @return A human readable string which is presented as diagnostic message.
* Return `undefined`, `null`, or the empty string when 'value' is valid.
*/
validateInput?(value: string): string | undefined | null;
validateInput?(value: string): string | undefined | null | Thenable<string | undefined | null>;
}
/**
@@ -1679,7 +1695,7 @@ declare module 'vscode' {
* relatively to a base path. The base path can either be an absolute file path
* or a [workspace folder](#WorkspaceFolder).
*/
class RelativePattern {
export class RelativePattern {
/**
* A base file path to which this pattern will be matched against relatively.
@@ -1980,6 +1996,13 @@ declare module 'vscode' {
* @param value Markdown string.
*/
appendMarkdown(value: string): MarkdownString;
/**
* Appends the given string as codeblock using the provided language.
* @param value A code snippet.
* @param language An optional [language identifier](#languages.getLanguages).
*/
appendCodeblock(value: string, language?: string): MarkdownString;
}
/**
@@ -2983,6 +3006,133 @@ declare module 'vscode' {
resolveDocumentLink?(link: DocumentLink, token: CancellationToken): ProviderResult<DocumentLink>;
}
/**
* Represents a color in RGBA space.
*/
export class Color {
/**
* The red component of this color in the range [0-1].
*/
readonly red: number;
/**
* The green component of this color in the range [0-1].
*/
readonly green: number;
/**
* The blue component of this color in the range [0-1].
*/
readonly blue: number;
/**
* The alpha component of this color in the range [0-1].
*/
readonly alpha: number;
/**
* Creates a new color instance.
*
* @param red The red component.
* @param green The green component.
* @param blue The bluew component.
* @param alpha The alpha component.
*/
constructor(red: number, green: number, blue: number, alpha: number);
}
/**
* Represents a color range from a document.
*/
export class ColorInformation {
/**
* The range in the document where this color appers.
*/
range: Range;
/**
* The actual color value for this color range.
*/
color: Color;
/**
* Creates a new color range.
*
* @param range The range the color appears in. Must not be empty.
* @param color The value of the color.
* @param format The format in which this color is currently formatted.
*/
constructor(range: Range, color: Color);
}
/**
* A color presentation object describes how a [`color`](#Color) should be represented as text and what
* edits are required to refer to it from source code.
*
* For some languages one color can have multiple presentations, e.g. css can represent the color red with
* the constant `Red`, the hex-value `#ff0000`, or in rgba and hsla forms. In csharp other representations
* apply, e.g `System.Drawing.Color.Red`.
*/
export class ColorPresentation {
/**
* The label of this color presentation. It will be shown on the color
* picker header. By default this is also the text that is inserted when selecting
* this color presentation.
*/
label: string;
/**
* An [edit](#TextEdit) which is applied to a document when selecting
* this presentation for the color. When `falsy` the [label](#ColorPresentation.label)
* is used.
*/
textEdit?: TextEdit;
/**
* An optional array of additional [text edits](#TextEdit) that are applied when
* selecting this color presentation. Edits must not overlap with the main [edit](#ColorPresentation.textEdit) nor with themselves.
*/
additionalTextEdits?: TextEdit[];
/**
* Creates a new color presentation.
*
* @param label The label of this color presentation.
*/
constructor(label: string);
}
/**
* The document color provider defines the contract between extensions and feature of
* picking and modifying colors in the editor.
*/
export interface DocumentColorProvider {
/**
* Provide colors for the given document.
*
* @param document The document in which the command was invoked.
* @param token A cancellation token.
* @return An array of [color informations](#ColorInformation) or a thenable that resolves to such. The lack of a result
* can be signaled by returning `undefined`, `null`, or an empty array.
*/
provideDocumentColors(document: TextDocument, token: CancellationToken): ProviderResult<ColorInformation[]>;
/**
* Provide [representations](#ColorPresentation) for a color.
*
* @param color The color to show and insert.
* @param context A context object with additional information
* @param token A cancellation token.
* @return An array of color presentations or a thenable that resolves to such. The lack of a result
* can be signaled by returning `undefined`, `null`, or an empty array.
*/
provideColorPresentations(color: Color, context: { document: TextDocument, range: Range }, token: CancellationToken): ProviderResult<ColorPresentation[]>;
}
/**
* A tuple of two characters, like a pair of
* opening and closing brackets.
@@ -4589,6 +4739,15 @@ declare module 'vscode' {
*/
export function showQuickPick<T extends QuickPickItem>(items: T[] | Thenable<T[]>, options?: QuickPickOptions, token?: CancellationToken): Thenable<T | undefined>;
/**
* Shows a selection list of [workspace folders](#workspace.workspaceFolders) to pick from.
* Returns `undefined` if no folder is open.
*
* @param options Configures the behavior of the workspace folder list.
* @return A promise that resolves to the workspace folder or `undefined`.
*/
export function showWorkspaceFolderPick(options?: WorkspaceFolderPickOptions): Thenable<WorkspaceFolder | undefined>;
/**
* Shows a file open dialog to the user which allows to select a file
* for opening-purposes.
@@ -4830,6 +4989,10 @@ declare module 'vscode' {
* Args for the custom shell executable, this does not work on Windows (see #8429)
*/
shellArgs?: string[];
/**
* Object with environment variables that will be added to the VS Code process.
*/
env?: { [key: string]: string | null };
}
/**
@@ -5044,6 +5207,14 @@ declare module 'vscode' {
*/
export let workspaceFolders: WorkspaceFolder[] | undefined;
/**
* The name of the workspace. `undefined` when no folder
* has been opened.
*
* @readonly
*/
export let name: string | undefined;
/**
* An event that is emitted when a workspace folder is added or removed.
*/
@@ -5238,7 +5409,7 @@ declare module 'vscode' {
/**
* An event that is emitted when the [configuration](#WorkspaceConfiguration) changed.
*/
export const onDidChangeConfiguration: Event<void>;
export const onDidChangeConfiguration: Event<ConfigurationChangeEvent>;
/**
* Register a task provider.
@@ -5250,6 +5421,21 @@ declare module 'vscode' {
export function registerTaskProvider(type: string, provider: TaskProvider): Disposable;
}
/**
* An event describing the change in Configuration
*/
export interface ConfigurationChangeEvent {
/**
* Returns `true` if the given section for the given resource (if provided) is affected.
*
* @param section Configuration name, supports _dotted_ names.
* @param resource A resource Uri.
* @return `true` if the given section for the given resource (if provided) is affected.
*/
affectsConfiguration(section: string, resource?: Uri): boolean;
}
/**
* Namespace for participating in language-specific editor [features](https://code.visualstudio.com/docs/editor/editingevolved),
* like IntelliSense, code actions, diagnostics etc.
@@ -5563,6 +5749,19 @@ declare module 'vscode' {
*/
export function registerDocumentLinkProvider(selector: DocumentSelector, provider: DocumentLinkProvider): Disposable;
/**
* Register a color provider.
*
* Multiple providers can be registered for a language. In that case providers are asked in
* parallel and the results are merged. A failing provider (rejected promise or exception) will
* not cause a failure of the whole operation.
*
* @param selector A selector that defines the documents this provider is applicable to.
* @param provider A color provider.
* @return A [disposable](#Disposable) that unregisters this provider when being disposed.
*/
export function registerColorProvider(selector: DocumentSelector, provider: DocumentColorProvider): Disposable;
/**
* Set a [language configuration](#LanguageConfiguration) for a language.
*
@@ -5870,8 +6069,8 @@ declare module 'vscode' {
/**
* A debug configuration provider allows to add the initial debug configurations to a newly created launch.json
* and allows to resolve a launch configuration before it is used to start a new debug session.
* A debug configuration provider is registered via #workspace.registerDebugConfigurationProvider.
* and to resolve a launch configuration before it is used to start a new debug session.
* A debug configuration provider is registered via #debug.registerDebugConfigurationProvider.
*/
export interface DebugConfigurationProvider {
/**
@@ -5888,11 +6087,12 @@ declare module 'vscode' {
* Resolves a [debug configuration](#DebugConfiguration) by filling in missing values or by adding/changing/removing attributes.
* If more than one debug configuration provider is registered for the same type, the resolveDebugConfiguration calls are chained
* in arbitrary order and the initial debug configuration is piped through the chain.
* Returning the value 'undefined' prevents the debug session from starting.
*
* @param folder The workspace folder from which the configuration originates from or undefined for a folderless setup.
* @param debugConfiguration The [debug configuration](#DebugConfiguration) to resolve.
* @param token A cancellation token.
* @return The resolved debug configuration.
* @return The resolved debug configuration or undefined.
*/
resolveDebugConfiguration?(folder: WorkspaceFolder | undefined, debugConfiguration: DebugConfiguration, token?: CancellationToken): ProviderResult<DebugConfiguration>;
}