svelte-language-server
Version:
A language server for Svelte
63 lines (62 loc) • 1.78 kB
TypeScript
import { Position, Range, TextDocument, TextDocumentContentChangeEvent } from 'vscode-languageserver';
/**
* Represents a textual document.
*/
export declare abstract class ReadableDocument implements TextDocument {
/**
* Get the text content of the document
*/
abstract getText(range?: Range): string;
/**
* Returns the url of the document
*/
abstract getURL(): string;
/**
* Returns the file path if the url scheme is file
*/
abstract getFilePath(): string | null;
/**
* Current version of the document.
*/
version: number;
/**
* Should be cleared when there's an update to the text
*/
protected lineOffsets?: number[];
/**
* Get the length of the document's content
*/
getTextLength(): number;
/**
* Get the line and character based on the offset
* @param offset The index of the position
*/
positionAt(offset: number): Position;
/**
* Get the index of the line and character position
* @param position Line and character position
*/
offsetAt(position: Position): number;
private getLineOffsets;
/**
* Implements TextDocument
*/
get uri(): string;
get lineCount(): number;
abstract languageId: string;
}
/**
* Represents a textual document that can be manipulated.
*/
export declare abstract class WritableDocument extends ReadableDocument {
/**
* Set the text content of the document.
* Implementers should set `lineOffsets` to `undefined` here.
* @param text The new text content
*/
abstract setText(text: string): void;
/**
* Batch update the document with the LSP change events.
*/
update(changes: TextDocumentContentChangeEvent[]): void;
}