vscode-languageserver-types
Version:
Types used by the Language server for node
1,490 lines (1,489 loc) • 101 kB
TypeScript
/**
* A tagging type for string properties that are actually document URIs.
*/
export type DocumentUri = string;
export declare namespace DocumentUri {
function is(value: any): value is DocumentUri;
}
/**
* A tagging type for string properties that are actually URIs
*
* @since 3.16.0
*/
export type URI = string;
export declare namespace URI {
function is(value: any): value is URI;
}
/**
* Defines an integer in the range of -2^31 to 2^31 - 1.
*/
export type integer = number;
export declare namespace integer {
const MIN_VALUE = -2147483648;
const MAX_VALUE = 2147483647;
function is(value: any): value is integer;
}
/**
* Defines an unsigned integer in the range of 0 to 2^31 - 1.
*/
export type uinteger = number;
export declare namespace uinteger {
const MIN_VALUE = 0;
const MAX_VALUE = 2147483647;
function is(value: any): value is uinteger;
}
/**
* Defines a decimal number. Since decimal numbers are very
* rare in the language server specification we denote the
* exact range with every decimal using the mathematics
* interval notations (e.g. [0, 1] denotes all decimals d with
* 0 <= d <= 1.
*/
export type decimal = number;
/**
* The LSP any type.
*
* In the current implementation we map LSPAny to any. This is due to the fact
* that the TypeScript compilers can't infer string access signatures for
* interface correctly (it can though for types). See the following issue for
* details: https://github.com/microsoft/TypeScript/issues/15300.
*
* When the issue is addressed LSPAny can be defined as follows:
*
* ```ts
* export type LSPAny = LSPObject | LSPArray | string | integer | uinteger | decimal | boolean | null | undefined;
* export type LSPObject = { [key: string]: LSPAny };
* export type LSPArray = LSPAny[];
* ```
*
* Please note that strictly speaking a property with the value `undefined`
* can't be converted into JSON preserving the property name. However for
* convenience it is allowed and assumed that all these properties are
* optional as well.
*
* @since 3.17.0
*/
export type LSPAny = any;
export type LSPObject = object;
export type LSPArray = any[];
/**
* Position in a text document expressed as zero-based line and character
* offset. Prior to 3.17 the offsets were always based on a UTF-16 string
* representation. So a string of the form `a𐐀b` the character offset of the
* character `a` is 0, the character offset of `𐐀` is 1 and the character
* offset of b is 3 since `𐐀` is represented using two code units in UTF-16.
* Since 3.17 clients and servers can agree on a different string encoding
* representation (e.g. UTF-8). The client announces it's supported encoding
* via the client capability [`general.positionEncodings`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#clientCapabilities).
* The value is an array of position encodings the client supports, with
* decreasing preference (e.g. the encoding at index `0` is the most preferred
* one). To stay backwards compatible the only mandatory encoding is UTF-16
* represented via the string `utf-16`. The server can pick one of the
* encodings offered by the client and signals that encoding back to the
* client via the initialize result's property
* [`capabilities.positionEncoding`](https://microsoft.github.io/language-server-protocol/specifications/specification-current/#serverCapabilities). If the string value
* `utf-16` is missing from the client's capability `general.positionEncodings`
* servers can safely assume that the client supports UTF-16. If the server
* omits the position encoding in its initialize result the encoding defaults
* to the string value `utf-16`. Implementation considerations: since the
* conversion from one encoding into another requires the content of the
* file / line the conversion is best done where the file is read which is
* usually on the server side.
*
* Positions are line end character agnostic. So you can not specify a position
* that denotes `\r|\n` or `\n|` where `|` represents the character offset.
*
* @since 3.17.0 - support for negotiated position encoding.
*/
export interface Position {
/**
* Line position in a document (zero-based).
*
* If a line number is greater than the number of lines in a document, it defaults back to the number of lines in the document.
* If a line number is negative, it defaults to 0.
*/
line: uinteger;
/**
* Character offset on a line in a document (zero-based).
*
* The meaning of this offset is determined by the negotiated
* `PositionEncodingKind`.
*
* If the character value is greater than the line length it defaults back to the
* line length.
*/
character: uinteger;
}
/**
* The Position namespace provides helper functions to work with
* {@link Position} literals.
*/
export declare namespace Position {
/**
* Creates a new Position literal from the given line and character.
* @param line The position's line.
* @param character The position's character.
*/
function create(line: uinteger, character: uinteger): Position;
/**
* Checks whether the given literal conforms to the {@link Position} interface.
*/
function is(value: any): value is Position;
}
/**
* A range in a text document expressed as (zero-based) start and end positions.
*
* If you want to specify a range that contains a line including the line ending
* character(s) then use an end position denoting the start of the next line.
* For example:
* ```ts
* {
* start: { line: 5, character: 23 }
* end : { line 6, character : 0 }
* }
* ```
*/
export interface Range {
/**
* The range's start position.
*/
start: Position;
/**
* The range's end position.
*/
end: Position;
}
/**
* The Range namespace provides helper functions to work with
* {@link Range} literals.
*/
export declare namespace Range {
/**
* Create a new Range literal.
* @param start The range's start position.
* @param end The range's end position.
*/
function create(start: Position, end: Position): Range;
/**
* Create a new Range literal.
* @param startLine The start line number.
* @param startCharacter The start character.
* @param endLine The end line number.
* @param endCharacter The end character.
*/
function create(startLine: uinteger, startCharacter: uinteger, endLine: uinteger, endCharacter: uinteger): Range;
/**
* Checks whether the given literal conforms to the {@link Range} interface.
*/
function is(value: any): value is Range;
}
/**
* Represents a location inside a resource, such as a line
* inside a text file.
*/
export interface Location {
uri: DocumentUri;
range: Range;
}
/**
* The Location namespace provides helper functions to work with
* {@link Location} literals.
*/
export declare namespace Location {
/**
* Creates a Location literal.
* @param uri The location's uri.
* @param range The location's range.
*/
function create(uri: DocumentUri, range: Range): Location;
/**
* Checks whether the given literal conforms to the {@link Location} interface.
*/
function is(value: any): value is Location;
}
/**
* Represents the connection of two locations. Provides additional metadata over normal {@link Location locations},
* including an origin range.
*/
export interface LocationLink {
/**
* Span of the origin of this link.
*
* Used as the underlined span for mouse interaction. Defaults to the word range at
* the definition position.
*/
originSelectionRange?: Range;
/**
* The target resource identifier of this link.
*/
targetUri: DocumentUri;
/**
* The full target range of this link. If the target for example is a symbol then target range is the
* range enclosing this symbol not including leading/trailing whitespace but everything else
* like comments. This information is typically used to highlight the range in the editor.
*/
targetRange: Range;
/**
* The range that should be selected and revealed when this link is being followed, e.g the name of a function.
* Must be contained by the `targetRange`. See also `DocumentSymbol#range`
*/
targetSelectionRange: Range;
}
/**
* The LocationLink namespace provides helper functions to work with
* {@link LocationLink} literals.
*/
export declare namespace LocationLink {
/**
* Creates a LocationLink literal.
* @param targetUri The definition's uri.
* @param targetRange The full range of the definition.
* @param targetSelectionRange The span of the symbol definition at the target.
* @param originSelectionRange The span of the symbol being defined in the originating source file.
*/
function create(targetUri: DocumentUri, targetRange: Range, targetSelectionRange: Range, originSelectionRange?: Range): LocationLink;
/**
* Checks whether the given literal conforms to the {@link LocationLink} interface.
*/
function is(value: any): value is LocationLink;
}
/**
* Represents a color in RGBA space.
*/
export interface Color {
/**
* The red component of this color in the range [0-1].
*/
readonly red: decimal;
/**
* The green component of this color in the range [0-1].
*/
readonly green: decimal;
/**
* The blue component of this color in the range [0-1].
*/
readonly blue: decimal;
/**
* The alpha component of this color in the range [0-1].
*/
readonly alpha: decimal;
}
/**
* The Color namespace provides helper functions to work with
* {@link Color} literals.
*/
export declare namespace Color {
/**
* Creates a new Color literal.
*/
function create(red: decimal, green: decimal, blue: decimal, alpha: decimal): Color;
/**
* Checks whether the given literal conforms to the {@link Color} interface.
*/
function is(value: any): value is Color;
}
/**
* Represents a color range from a document.
*/
export interface ColorInformation {
/**
* The range in the document where this color appears.
*/
range: Range;
/**
* The actual color value for this color range.
*/
color: Color;
}
/**
* The ColorInformation namespace provides helper functions to work with
* {@link ColorInformation} literals.
*/
export declare namespace ColorInformation {
/**
* Creates a new ColorInformation literal.
*/
function create(range: Range, color: Color): ColorInformation;
/**
* Checks whether the given literal conforms to the {@link ColorInformation} interface.
*/
function is(value: any): value is ColorInformation;
}
export interface 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 {@link TextEdit edit} which is applied to a document when selecting
* this presentation for the color. When `falsy` the {@link ColorPresentation.label label}
* is used.
*/
textEdit?: TextEdit;
/**
* An optional array of additional {@link TextEdit text edits} that are applied when
* selecting this color presentation. Edits must not overlap with the main {@link ColorPresentation.textEdit edit} nor with themselves.
*/
additionalTextEdits?: TextEdit[];
}
/**
* The Color namespace provides helper functions to work with
* {@link ColorPresentation} literals.
*/
export declare namespace ColorPresentation {
/**
* Creates a new ColorInformation literal.
*/
function create(label: string, textEdit?: TextEdit, additionalTextEdits?: TextEdit[]): ColorPresentation;
/**
* Checks whether the given literal conforms to the {@link ColorInformation} interface.
*/
function is(value: any): value is ColorPresentation;
}
/**
* A set of predefined range kinds.
*/
export declare namespace FoldingRangeKind {
/**
* Folding range for a comment
*/
const Comment = "comment";
/**
* Folding range for an import or include
*/
const Imports = "imports";
/**
* Folding range for a region (e.g. `#region`)
*/
const Region = "region";
}
/**
* A predefined folding range kind.
*
* The type is a string since the value set is extensible
*/
export type FoldingRangeKind = string;
/**
* Represents a folding range. To be valid, start and end line must be bigger than zero and smaller
* than the number of lines in the document. Clients are free to ignore invalid ranges.
*/
export interface FoldingRange {
/**
* The zero-based start line of the range to fold. The folded area starts after the line's last character.
* To be valid, the end must be zero or larger and smaller than the number of lines in the document.
*/
startLine: uinteger;
/**
* The zero-based character offset from where the folded range starts. If not defined, defaults to the length of the start line.
*/
startCharacter?: uinteger;
/**
* The zero-based end line of the range to fold. The folded area ends with the line's last character.
* To be valid, the end must be zero or larger and smaller than the number of lines in the document.
*/
endLine: uinteger;
/**
* The zero-based character offset before the folded range ends. If not defined, defaults to the length of the end line.
*/
endCharacter?: uinteger;
/**
* Describes the kind of the folding range such as `comment' or 'region'. The kind
* is used to categorize folding ranges and used by commands like 'Fold all comments'.
* See {@link FoldingRangeKind} for an enumeration of standardized kinds.
*/
kind?: FoldingRangeKind;
/**
* The text that the client should show when the specified range is
* collapsed. If not defined or not supported by the client, a default
* will be chosen by the client.
*
* @since 3.17.0
*/
collapsedText?: string;
}
/**
* The folding range namespace provides helper functions to work with
* {@link FoldingRange} literals.
*/
export declare namespace FoldingRange {
/**
* Creates a new FoldingRange literal.
*/
function create(startLine: uinteger, endLine: uinteger, startCharacter?: uinteger, endCharacter?: uinteger, kind?: FoldingRangeKind, collapsedText?: string): FoldingRange;
/**
* Checks whether the given literal conforms to the {@link FoldingRange} interface.
*/
function is(value: any): value is FoldingRange;
}
/**
* Represents a related message and source code location for a diagnostic. This should be
* used to point to code locations that cause or related to a diagnostics, e.g when duplicating
* a symbol in a scope.
*/
export interface DiagnosticRelatedInformation {
/**
* The location of this related diagnostic information.
*/
location: Location;
/**
* The message of this related diagnostic information.
*/
message: string;
}
/**
* The DiagnosticRelatedInformation namespace provides helper functions to work with
* {@link DiagnosticRelatedInformation} literals.
*/
export declare namespace DiagnosticRelatedInformation {
/**
* Creates a new DiagnosticRelatedInformation literal.
*/
function create(location: Location, message: string): DiagnosticRelatedInformation;
/**
* Checks whether the given literal conforms to the {@link DiagnosticRelatedInformation} interface.
*/
function is(value: any): value is DiagnosticRelatedInformation;
}
/**
* The diagnostic's severity.
*/
export declare namespace DiagnosticSeverity {
/**
* Reports an error.
*/
const Error: 1;
/**
* Reports a warning.
*/
const Warning: 2;
/**
* Reports an information.
*/
const Information: 3;
/**
* Reports a hint.
*/
const Hint: 4;
}
export type DiagnosticSeverity = 1 | 2 | 3 | 4;
/**
* The diagnostic tags.
*
* @since 3.15.0
*/
export declare namespace DiagnosticTag {
/**
* Unused or unnecessary code.
*
* Clients are allowed to render diagnostics with this tag faded out instead of having
* an error squiggle.
*/
const Unnecessary: 1;
/**
* Deprecated or obsolete code.
*
* Clients are allowed to rendered diagnostics with this tag strike through.
*/
const Deprecated: 2;
}
export type DiagnosticTag = 1 | 2;
/**
* Structure to capture a description for an error code.
*
* @since 3.16.0
*/
export interface CodeDescription {
/**
* An URI to open with more information about the diagnostic error.
*/
href: URI;
}
/**
* The CodeDescription namespace provides functions to deal with descriptions for diagnostic codes.
*
* @since 3.16.0
*/
export declare namespace CodeDescription {
function is(value: any): value is CodeDescription;
}
/**
* Represents a diagnostic, such as a compiler error or warning. Diagnostic objects
* are only valid in the scope of a resource.
*/
export interface Diagnostic {
/**
* The range at which the message applies
*/
range: Range;
/**
* The diagnostic's severity. Can be omitted. If omitted it is up to the
* client to interpret diagnostics as error, warning, info or hint.
*/
severity?: DiagnosticSeverity;
/**
* The diagnostic's code, which usually appear in the user interface.
*/
code?: integer | string;
/**
* An optional property to describe the error code.
* Requires the code field (above) to be present/not null.
*
* @since 3.16.0
*/
codeDescription?: CodeDescription;
/**
* A human-readable string describing the source of this
* diagnostic, e.g. 'typescript' or 'super lint'. It usually
* appears in the user interface.
*/
source?: string;
/**
* The diagnostic's message. It usually appears in the user interface
*/
message: string;
/**
* Additional metadata about the diagnostic.
*
* @since 3.15.0
*/
tags?: DiagnosticTag[];
/**
* An array of related diagnostic information, e.g. when symbol-names within
* a scope collide all definitions can be marked via this property.
*/
relatedInformation?: DiagnosticRelatedInformation[];
/**
* A data entry field that is preserved between a `textDocument/publishDiagnostics`
* notification and `textDocument/codeAction` request.
*
* @since 3.16.0
*/
data?: LSPAny;
}
/**
* The Diagnostic namespace provides helper functions to work with
* {@link Diagnostic} literals.
*/
export declare namespace Diagnostic {
/**
* Creates a new Diagnostic literal.
*/
function create(range: Range, message: string, severity?: DiagnosticSeverity, code?: integer | string, source?: string, relatedInformation?: DiagnosticRelatedInformation[]): Diagnostic;
/**
* Checks whether the given literal conforms to the {@link Diagnostic} interface.
*/
function is(value: any): value is Diagnostic;
}
/**
* Represents a reference to a command. Provides a title which
* will be used to represent a command in the UI and, optionally,
* an array of arguments which will be passed to the command handler
* function when invoked.
*/
export interface Command {
/**
* Title of the command, like `save`.
*/
title: string;
/**
* The identifier of the actual command handler.
*/
command: string;
/**
* Arguments that the command handler should be
* invoked with.
*/
arguments?: LSPAny[];
}
/**
* The Command namespace provides helper functions to work with
* {@link Command} literals.
*/
export declare namespace Command {
/**
* Creates a new Command literal.
*/
function create(title: string, command: string, ...args: any[]): Command;
/**
* Checks whether the given literal conforms to the {@link Command} interface.
*/
function is(value: any): value is Command;
}
/**
* A text edit applicable to a text document.
*/
export interface TextEdit {
/**
* The range of the text document to be manipulated. To insert
* text into a document create a range where start === end.
*/
range: Range;
/**
* The string to be inserted. For delete operations use an
* empty string.
*/
newText: string;
}
/**
* The TextEdit namespace provides helper function to create replace,
* insert and delete edits more easily.
*/
export declare namespace TextEdit {
/**
* Creates a replace text edit.
* @param range The range of text to be replaced.
* @param newText The new text.
*/
function replace(range: Range, newText: string): TextEdit;
/**
* Creates an insert text edit.
* @param position The position to insert the text at.
* @param newText The text to be inserted.
*/
function insert(position: Position, newText: string): TextEdit;
/**
* Creates a delete text edit.
* @param range The range of text to be deleted.
*/
function del(range: Range): TextEdit;
function is(value: any): value is TextEdit;
}
/**
* Additional information that describes document changes.
*
* @since 3.16.0
*/
export interface ChangeAnnotation {
/**
* A human-readable string describing the actual change. The string
* is rendered prominent in the user interface.
*/
label: string;
/**
* A flag which indicates that user confirmation is needed
* before applying the change.
*/
needsConfirmation?: boolean;
/**
* A human-readable string which is rendered less prominent in
* the user interface.
*/
description?: string;
}
export declare namespace ChangeAnnotation {
function create(label: string, needsConfirmation?: boolean, description?: string): ChangeAnnotation;
function is(value: any): value is ChangeAnnotation;
}
export declare namespace ChangeAnnotationIdentifier {
function is(value: any): value is ChangeAnnotationIdentifier;
}
/**
* An identifier to refer to a change annotation stored with a workspace edit.
*/
export type ChangeAnnotationIdentifier = string;
/**
* A special text edit with an additional change annotation.
*
* @since 3.16.0.
*/
export interface AnnotatedTextEdit extends TextEdit {
/**
* The actual identifier of the change annotation
*/
annotationId: ChangeAnnotationIdentifier;
}
export declare namespace AnnotatedTextEdit {
/**
* Creates an annotated replace text edit.
*
* @param range The range of text to be replaced.
* @param newText The new text.
* @param annotation The annotation.
*/
function replace(range: Range, newText: string, annotation: ChangeAnnotationIdentifier): AnnotatedTextEdit;
/**
* Creates an annotated insert text edit.
*
* @param position The position to insert the text at.
* @param newText The text to be inserted.
* @param annotation The annotation.
*/
function insert(position: Position, newText: string, annotation: ChangeAnnotationIdentifier): AnnotatedTextEdit;
/**
* Creates an annotated delete text edit.
*
* @param range The range of text to be deleted.
* @param annotation The annotation.
*/
function del(range: Range, annotation: ChangeAnnotationIdentifier): AnnotatedTextEdit;
function is(value: any): value is AnnotatedTextEdit;
}
/**
* Describes textual changes on a text document. A TextDocumentEdit describes all changes
* on a document version Si and after they are applied move the document to version Si+1.
* So the creator of a TextDocumentEdit doesn't need to sort the array of edits or do any
* kind of ordering. However the edits must be non overlapping.
*/
export interface TextDocumentEdit {
/**
* The text document to change.
*/
textDocument: OptionalVersionedTextDocumentIdentifier;
/**
* The edits to be applied.
*
* @since 3.16.0 - support for AnnotatedTextEdit. This is guarded using a
* client capability.
*/
edits: (TextEdit | AnnotatedTextEdit)[];
}
/**
* The TextDocumentEdit namespace provides helper function to create
* an edit that manipulates a text document.
*/
export declare namespace TextDocumentEdit {
/**
* Creates a new `TextDocumentEdit`
*/
function create(textDocument: OptionalVersionedTextDocumentIdentifier, edits: (TextEdit | AnnotatedTextEdit)[]): TextDocumentEdit;
function is(value: any): value is TextDocumentEdit;
}
/**
* A generic resource operation.
*/
interface ResourceOperation {
/**
* The resource operation kind.
*/
kind: string;
/**
* An optional annotation identifier describing the operation.
*
* @since 3.16.0
*/
annotationId?: ChangeAnnotationIdentifier;
}
/**
* Options to create a file.
*/
export interface CreateFileOptions {
/**
* Overwrite existing file. Overwrite wins over `ignoreIfExists`
*/
overwrite?: boolean;
/**
* Ignore if exists.
*/
ignoreIfExists?: boolean;
}
/**
* Create file operation.
*/
export interface CreateFile extends ResourceOperation {
/**
* A create
*/
kind: 'create';
/**
* The resource to create.
*/
uri: DocumentUri;
/**
* Additional options
*/
options?: CreateFileOptions;
}
export declare namespace CreateFile {
function create(uri: DocumentUri, options?: CreateFileOptions, annotation?: ChangeAnnotationIdentifier): CreateFile;
function is(value: any): value is CreateFile;
}
/**
* Rename file options
*/
export interface RenameFileOptions {
/**
* Overwrite target if existing. Overwrite wins over `ignoreIfExists`
*/
overwrite?: boolean;
/**
* Ignores if target exists.
*/
ignoreIfExists?: boolean;
}
/**
* Rename file operation
*/
export interface RenameFile extends ResourceOperation {
/**
* A rename
*/
kind: 'rename';
/**
* The old (existing) location.
*/
oldUri: DocumentUri;
/**
* The new location.
*/
newUri: DocumentUri;
/**
* Rename options.
*/
options?: RenameFileOptions;
}
export declare namespace RenameFile {
function create(oldUri: DocumentUri, newUri: DocumentUri, options?: RenameFileOptions, annotation?: ChangeAnnotationIdentifier): RenameFile;
function is(value: any): value is RenameFile;
}
/**
* Delete file options
*/
export interface DeleteFileOptions {
/**
* Delete the content recursively if a folder is denoted.
*/
recursive?: boolean;
/**
* Ignore the operation if the file doesn't exist.
*/
ignoreIfNotExists?: boolean;
}
/**
* Delete file operation
*/
export interface DeleteFile extends ResourceOperation {
/**
* A delete
*/
kind: 'delete';
/**
* The file to delete.
*/
uri: DocumentUri;
/**
* Delete options.
*/
options?: DeleteFileOptions;
}
export declare namespace DeleteFile {
function create(uri: DocumentUri, options?: DeleteFileOptions, annotation?: ChangeAnnotationIdentifier): DeleteFile;
function is(value: any): value is DeleteFile;
}
/**
* A workspace edit represents changes to many resources managed in the workspace. The edit
* should either provide `changes` or `documentChanges`. If documentChanges are present
* they are preferred over `changes` if the client can handle versioned document edits.
*
* Since version 3.13.0 a workspace edit can contain resource operations as well. If resource
* operations are present clients need to execute the operations in the order in which they
* are provided. So a workspace edit for example can consist of the following two changes:
* (1) a create file a.txt and (2) a text document edit which insert text into file a.txt.
*
* An invalid sequence (e.g. (1) delete file a.txt and (2) insert text into file a.txt) will
* cause failure of the operation. How the client recovers from the failure is described by
* the client capability: `workspace.workspaceEdit.failureHandling`
*/
export interface WorkspaceEdit {
/**
* Holds changes to existing resources.
*/
changes?: {
[uri: DocumentUri]: TextEdit[];
};
/**
* Depending on the client capability `workspace.workspaceEdit.resourceOperations` document changes
* are either an array of `TextDocumentEdit`s to express changes to n different text documents
* where each text document edit addresses a specific version of a text document. Or it can contain
* above `TextDocumentEdit`s mixed with create, rename and delete file / folder operations.
*
* Whether a client supports versioned document edits is expressed via
* `workspace.workspaceEdit.documentChanges` client capability.
*
* If a client neither supports `documentChanges` nor `workspace.workspaceEdit.resourceOperations` then
* only plain `TextEdit`s using the `changes` property are supported.
*/
documentChanges?: (TextDocumentEdit | CreateFile | RenameFile | DeleteFile)[];
/**
* A map of change annotations that can be referenced in `AnnotatedTextEdit`s or create, rename and
* delete file / folder operations.
*
* Whether clients honor this property depends on the client capability `workspace.changeAnnotationSupport`.
*
* @since 3.16.0
*/
changeAnnotations?: {
[id: ChangeAnnotationIdentifier]: ChangeAnnotation;
};
}
export declare namespace WorkspaceEdit {
function is(value: any): value is WorkspaceEdit;
}
/**
* A change to capture text edits for existing resources.
*/
export interface TextEditChange {
/**
* Gets all text edits for this change.
*
* @return An array of text edits.
*
* @since 3.16.0 - support for annotated text edits. This is usually
* guarded using a client capability.
*/
all(): (TextEdit | AnnotatedTextEdit)[];
/**
* Clears the edits for this change.
*/
clear(): void;
/**
* Adds a text edit.
*
* @param edit the text edit to add.
*
* @since 3.16.0 - support for annotated text edits. This is usually
* guarded using a client capability.
*/
add(edit: TextEdit | AnnotatedTextEdit): void;
/**
* Insert the given text at the given position.
*
* @param position A position.
* @param newText A string.
* @param annotation An optional annotation.
*/
insert(position: Position, newText: string): void;
insert(position: Position, newText: string, annotation: ChangeAnnotation | ChangeAnnotationIdentifier): ChangeAnnotationIdentifier;
/**
* Replace the given range with given text for the given resource.
*
* @param range A range.
* @param newText A string.
* @param annotation An optional annotation.
*/
replace(range: Range, newText: string): void;
replace(range: Range, newText: string, annotation?: ChangeAnnotation | ChangeAnnotationIdentifier): ChangeAnnotationIdentifier;
/**
* Delete the text at the given range.
*
* @param range A range.
* @param annotation An optional annotation.
*/
delete(range: Range): void;
delete(range: Range, annotation?: ChangeAnnotation | ChangeAnnotationIdentifier): ChangeAnnotationIdentifier;
}
/**
* A workspace change helps constructing changes to a workspace.
*/
export declare class WorkspaceChange {
private _workspaceEdit;
private _textEditChanges;
private _changeAnnotations;
constructor(workspaceEdit?: WorkspaceEdit);
/**
* Returns the underlying {@link WorkspaceEdit} literal
* use to be returned from a workspace edit operation like rename.
*/
get edit(): WorkspaceEdit;
/**
* Returns the {@link TextEditChange} to manage text edits
* for resources.
*/
getTextEditChange(textDocument: OptionalVersionedTextDocumentIdentifier): TextEditChange;
getTextEditChange(uri: DocumentUri): TextEditChange;
private initDocumentChanges;
private initChanges;
createFile(uri: DocumentUri, options?: CreateFileOptions): void;
createFile(uri: DocumentUri, annotation: ChangeAnnotation | ChangeAnnotationIdentifier, options?: CreateFileOptions): ChangeAnnotationIdentifier;
renameFile(oldUri: DocumentUri, newUri: DocumentUri, options?: RenameFileOptions): void;
renameFile(oldUri: DocumentUri, newUri: DocumentUri, annotation?: ChangeAnnotation | ChangeAnnotationIdentifier, options?: RenameFileOptions): ChangeAnnotationIdentifier;
deleteFile(uri: DocumentUri, options?: DeleteFileOptions): void;
deleteFile(uri: DocumentUri, annotation: ChangeAnnotation | ChangeAnnotationIdentifier, options?: DeleteFileOptions): ChangeAnnotationIdentifier;
}
/**
* A literal to identify a text document in the client.
*/
export interface TextDocumentIdentifier {
/**
* The text document's uri.
*/
uri: DocumentUri;
}
/**
* The TextDocumentIdentifier namespace provides helper functions to work with
* {@link TextDocumentIdentifier} literals.
*/
export declare namespace TextDocumentIdentifier {
/**
* Creates a new TextDocumentIdentifier literal.
* @param uri The document's uri.
*/
function create(uri: DocumentUri): TextDocumentIdentifier;
/**
* Checks whether the given literal conforms to the {@link TextDocumentIdentifier} interface.
*/
function is(value: any): value is TextDocumentIdentifier;
}
/**
* A text document identifier to denote a specific version of a text document.
*/
export interface VersionedTextDocumentIdentifier extends TextDocumentIdentifier {
/**
* The version number of this document.
*/
version: integer;
}
/**
* The VersionedTextDocumentIdentifier namespace provides helper functions to work with
* {@link VersionedTextDocumentIdentifier} literals.
*/
export declare namespace VersionedTextDocumentIdentifier {
/**
* Creates a new VersionedTextDocumentIdentifier literal.
* @param uri The document's uri.
* @param version The document's version.
*/
function create(uri: DocumentUri, version: integer): VersionedTextDocumentIdentifier;
/**
* Checks whether the given literal conforms to the {@link VersionedTextDocumentIdentifier} interface.
*/
function is(value: any): value is VersionedTextDocumentIdentifier;
}
/**
* A text document identifier to optionally denote a specific version of a text document.
*/
export interface OptionalVersionedTextDocumentIdentifier extends TextDocumentIdentifier {
/**
* The version number of this document. If a versioned text document identifier
* is sent from the server to the client and the file is not open in the editor
* (the server has not received an open notification before) the server can send
* `null` to indicate that the version is unknown and the content on disk is the
* truth (as specified with document content ownership).
*/
version: integer | null;
}
/**
* The OptionalVersionedTextDocumentIdentifier namespace provides helper functions to work with
* {@link OptionalVersionedTextDocumentIdentifier} literals.
*/
export declare namespace OptionalVersionedTextDocumentIdentifier {
/**
* Creates a new OptionalVersionedTextDocumentIdentifier literal.
* @param uri The document's uri.
* @param version The document's version.
*/
function create(uri: DocumentUri, version: integer | null): OptionalVersionedTextDocumentIdentifier;
/**
* Checks whether the given literal conforms to the {@link OptionalVersionedTextDocumentIdentifier} interface.
*/
function is(value: any): value is OptionalVersionedTextDocumentIdentifier;
}
/**
* An item to transfer a text document from the client to the
* server.
*/
export interface TextDocumentItem {
/**
* The text document's uri.
*/
uri: DocumentUri;
/**
* The text document's language identifier.
*/
languageId: string;
/**
* The version number of this document (it will increase after each
* change, including undo/redo).
*/
version: integer;
/**
* The content of the opened text document.
*/
text: string;
}
/**
* The TextDocumentItem namespace provides helper functions to work with
* {@link TextDocumentItem} literals.
*/
export declare namespace TextDocumentItem {
/**
* Creates a new TextDocumentItem literal.
* @param uri The document's uri.
* @param languageId The document's language identifier.
* @param version The document's version number.
* @param text The document's text.
*/
function create(uri: DocumentUri, languageId: string, version: integer, text: string): TextDocumentItem;
/**
* Checks whether the given literal conforms to the {@link TextDocumentItem} interface.
*/
function is(value: any): value is TextDocumentItem;
}
/**
* Describes the content type that a client supports in various
* result literals like `Hover`, `ParameterInfo` or `CompletionItem`.
*
* Please note that `MarkupKinds` must not start with a `$`. This kinds
* are reserved for internal usage.
*/
export declare namespace MarkupKind {
/**
* Plain text is supported as a content format
*/
const PlainText: 'plaintext';
/**
* Markdown is supported as a content format
*/
const Markdown: 'markdown';
/**
* Checks whether the given value is a value of the {@link MarkupKind} type.
*/
function is(value: any): value is MarkupKind;
}
export type MarkupKind = 'plaintext' | 'markdown';
/**
* A `MarkupContent` literal represents a string value which content is interpreted base on its
* kind flag. Currently the protocol supports `plaintext` and `markdown` as markup kinds.
*
* If the kind is `markdown` then the value can contain fenced code blocks like in GitHub issues.
* See https://help.github.com/articles/creating-and-highlighting-code-blocks/#syntax-highlighting
*
* Here is an example how such a string can be constructed using JavaScript / TypeScript:
* ```ts
* let markdown: MarkdownContent = {
* kind: MarkupKind.Markdown,
* value: [
* '# Header',
* 'Some text',
* '```typescript',
* 'someCode();',
* '```'
* ].join('\n')
* };
* ```
*
* *Please Note* that clients might sanitize the return markdown. A client could decide to
* remove HTML from the markdown to avoid script execution.
*/
export interface MarkupContent {
/**
* The type of the Markup
*/
kind: MarkupKind;
/**
* The content itself
*/
value: string;
}
export declare namespace MarkupContent {
/**
* Checks whether the given value conforms to the {@link MarkupContent} interface.
*/
function is(value: any): value is MarkupContent;
}
/**
* The kind of a completion entry.
*/
export declare namespace CompletionItemKind {
const Text: 1;
const Method: 2;
const Function: 3;
const Constructor: 4;
const Field: 5;
const Variable: 6;
const Class: 7;
const Interface: 8;
const Module: 9;
const Property: 10;
const Unit: 11;
const Value: 12;
const Enum: 13;
const Keyword: 14;
const Snippet: 15;
const Color: 16;
const File: 17;
const Reference: 18;
const Folder: 19;
const EnumMember: 20;
const Constant: 21;
const Struct: 22;
const Event: 23;
const Operator: 24;
const TypeParameter: 25;
}
export type CompletionItemKind = 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25;
/**
* Defines whether the insert text in a completion item should be interpreted as
* plain text or a snippet.
*/
export declare namespace InsertTextFormat {
/**
* The primary text to be inserted is treated as a plain string.
*/
const PlainText: 1;
/**
* The primary text to be inserted is treated as a snippet.
*
* A snippet can define tab stops and placeholders with `$1`, `$2`
* and `${3:foo}`. `$0` defines the final tab stop, it defaults to
* the end of the snippet. Placeholders with equal identifiers are linked,
* that is typing in one will update others too.
*
* See also: https://microsoft.github.io/language-server-protocol/specifications/specification-current/#snippet_syntax
*/
const Snippet: 2;
}
export type InsertTextFormat = 1 | 2;
/**
* Completion item tags are extra annotations that tweak the rendering of a completion
* item.
*
* @since 3.15.0
*/
export declare namespace CompletionItemTag {
/**
* Render a completion as obsolete, usually using a strike-out.
*/
const Deprecated = 1;
}
export type CompletionItemTag = 1;
/**
* A special text edit to provide an insert and a replace operation.
*
* @since 3.16.0
*/
export interface InsertReplaceEdit {
/**
* The string to be inserted.
*/
newText: string;
/**
* The range if the insert is requested
*/
insert: Range;
/**
* The range if the replace is requested.
*/
replace: Range;
}
/**
* The InsertReplaceEdit namespace provides functions to deal with insert / replace edits.
*
* @since 3.16.0
*/
export declare namespace InsertReplaceEdit {
/**
* Creates a new insert / replace edit
*/
function create(newText: string, insert: Range, replace: Range): InsertReplaceEdit;
/**
* Checks whether the given literal conforms to the {@link InsertReplaceEdit} interface.
*/
function is(value: TextEdit | InsertReplaceEdit): value is InsertReplaceEdit;
}
/**
* How whitespace and indentation is handled during completion
* item insertion.
*
* @since 3.16.0
*/
export declare namespace InsertTextMode {
/**
* The insertion or replace strings is taken as it is. If the
* value is multi line the lines below the cursor will be
* inserted using the indentation defined in the string value.
* The client will not apply any kind of adjustments to the
* string.
*/
const asIs: 1;
/**
* The editor adjusts leading whitespace of new lines so that
* they match the indentation up to the cursor of the line for
* which the item is accepted.
*
* Consider a line like this: <2tabs><cursor><3tabs>foo. Accepting a
* multi line completion item is indented using 2 tabs and all
* following lines inserted will be indented using 2 tabs as well.
*/
const adjustIndentation: 2;
}
export type InsertTextMode = 1 | 2;
/**
* Additional details for a completion item label.
*
* @since 3.17.0
*/
export interface CompletionItemLabelDetails {
/**
* An optional string which is rendered less prominently directly after {@link CompletionItem.label label},
* without any spacing. Should be used for function signatures and type annotations.
*/
detail?: string;
/**
* An optional string which is rendered less prominently after {@link CompletionItem.detail}. Should be used
* for fully qualified names and file paths.
*/
description?: string;
}
export declare namespace CompletionItemLabelDetails {
function is(value: any): value is CompletionItemLabelDetails;
}
/**
* A completion item represents a text snippet that is
* proposed to complete text that is being typed.
*/
export interface CompletionItem {
/**
* The label of this completion item.
*
* The label property is also by default the text that
* is inserted when selecting this completion.
*
* If label details are provided the label itself should
* be an unqualified name of the completion item.
*/
label: string;
/**
* Additional details for the label
*
* @since 3.17.0
*/
labelDetails?: CompletionItemLabelDetails;
/**
* The kind of this completion item. Based of the kind
* an icon is chosen by the editor.
*/
kind?: CompletionItemKind;
/**
* Tags for this completion item.
*
* @since 3.15.0
*/
tags?: CompletionItemTag[];
/**
* A human-readable string with additional information
* about this item, like type or symbol information.
*/
detail?: string;
/**
* A human-readable string that represents a doc-comment.
*/
documentation?: string | MarkupContent;
/**
* Indicates if this item is deprecated.
* @deprecated Use `tags` instead.
*/
deprecated?: boolean;
/**
* Select this item when showing.
*
* *Note* that only one completion item can be selected and that the
* tool / client decides which item that is. The rule is that the *first*
* item of those that match best is selected.
*/
preselect?: boolean;
/**
* A string that should be used when comparing this item
* with other items. When `falsy` the {@link CompletionItem.label label}
* is used.
*/
sortText?: string;
/**
* A string that should be used when filtering a set of
* completion items. When `falsy` the {@link CompletionItem.label label}
* is used.
*/
filterText?: string;
/**
* A string that should be inserted into a document when selecting
* this completion. When `falsy` the {@link CompletionItem.label label}
* is used.
*
* The `insertText` is subject to interpretation by the client side.
* Some tools might not take the string literally. For example
* VS Code when code complete is requested in this example
* `con<cursor position>` and a completion item with an `insertText` of
* `console` is provided it will only insert `sole`. Therefore it is
* recommended to use `textEdit` instead since it avoids additional client
* side interpretation.
*/
insertText?: string;
/**
* The format of the insert text. The format applies to both the
* `insertText` property and the `newText` property of a provided
* `textEdit`. If omitted defaults to `InsertTextFormat.PlainText`.
*
* Please note that the insertTextFormat doesn't apply to
* `additionalTextEdits`.
*/
insertTextFormat?: InsertTextFormat;
/**
* How whitespace and indentation is handled during completion
* item insertion. If not provided the clients default value depends on
* the `textDocument.completion.insertTextMode` client capability.
*
* @since 3.16.0
*/
insertTextMode?: InsertTextMode;
/**
* An {@link TextEdit edit} which is applied to a document when selecting
* this completion. When an edit is provided the value of
* {@link CompletionItem.insertText insertText} is ignored.
*
* Most editors support two different operations when accepting a completion
* item. One is to insert a completion text and the other is to replace an
* existing text with a completion text. Since this can usually not be
* predetermined by a server it can report both ranges. Clients need to
* signal support for `InsertReplaceEdits` via the
* `textDocument.completion.insertReplaceSupport` client capability
* property.
*
* *Note 1:* The text edit's range as well as both ranges from an insert
* replace edit must be a [single line] and they must contain the position
* at which completion has been requested.
* *Note 2:* If an `InsertReplaceEdit` is returned the edit's insert range
* must be a prefix of the edit's replace range, that means it must be
* contained and starting at the same position.
*
* @since 3.16.0 additional type `InsertReplaceEdit`
*/
textEdit?: TextEdit | InsertReplaceEdit;
/**
* The edit text used if the completion item is part of a CompletionList and
* CompletionList defines an item default for the text edit range.
*
* Clients will only honor this property if they opt into completion list
* item defaults using the capability `completionList.itemDefaults`.
*
* If not provided and a list's default range is provided the label
* property is used as a text.
*
* @since 3.17.0
*/
textEditText?: string;
/**
* An optional array of additional {@link TextEdit text edits} that are applied when
* selecting this completion. Edits must not overlap (including the same insert position)
* with the main {@link CompletionItem.textEdit edit} nor with themselves.
*
* Additional text edits should be used to change text unrelated to the current cursor position
* (for example adding an import statement at the top of the file if the completion item will
* insert an unqualified type).
*/
additionalTextEdits?: TextEdit[];
/**
* An optional set of characters that when pressed while this completion is active will accept it first and
* then type that character. *Note* that all commit characters should have `length=1` and that superfluous
* characters will be ignored.
*/
commitCharacters?: string[];
/**
* An optional {@link Command command} that is executed *after* inserting this completion. *Note* that
* additional modifications to the current document should be described with the
* {@link CompletionItem.additionalTextEdits additionalTextEdits}-property.
*/
command?: Command;
/**
* A data entry field that is preserved on a completion item between a
* {@link CompletionRequest} and a {@link CompletionResolveRequest}.