Interface TextDocuments<T>

A manager service that keeps track of all currently opened text documents.

Designed to be compatible with the TextDocuments class in the vscode-languageserver package.

interface TextDocuments<T> {
    onDidChangeContent: Event<TextDocumentChangeEvent<T>>;
    onDidClose: Event<TextDocumentChangeEvent<T>>;
    onDidOpen: Event<TextDocumentChangeEvent<T>>;
    onDidSave: Event<TextDocumentChangeEvent<T>>;
    onWillSave: Event<TextDocumentWillSaveEvent<T>>;
    all(): T[];
    delete(uri: string | URI | T): void;
    get(uri: string | URI): undefined | T;
    keys(): string[];
    listen(connection: Connection): Disposable;
    onWillSaveWaitUntil(handler: RequestHandler<TextDocumentWillSaveEvent<T>, TextEdit[], void>): void;
    set(document: T): boolean;
}

Type Parameters

  • T extends {
        uri: string;
    }

Implemented by

Properties

onDidChangeContent: Event<TextDocumentChangeEvent<T>>

An event that fires when a text document managed by this manager has been opened or the content changes.

onDidClose: Event<TextDocumentChangeEvent<T>>

An event that fires when a text document managed by this manager has been closed.

onDidOpen: Event<TextDocumentChangeEvent<T>>

An event that fires when a text document managed by this manager has been opened.

onDidSave: Event<TextDocumentChangeEvent<T>>

An event that fires when a text document managed by this manager has been saved.

onWillSave: Event<TextDocumentWillSaveEvent<T>>

An event that fires when a text document managed by this manager will be saved.

Methods

  • Returns the document for the given URI. Returns undefined if the document is not managed by this instance.

    Parameters

    • uri: string | URI

      The text document's URI to retrieve.

    Returns undefined | T

    the text document or undefined.

  • Listens for low level notification on the given connection to update the text documents managed by this instance.

    Please note that the connection only provides handlers not an event model. Therefore listening on a connection will overwrite the following handlers on a connection: onDidOpenTextDocument, onDidChangeTextDocument, onDidCloseTextDocument, onWillSaveTextDocument, onWillSaveTextDocumentWaitUntil and onDidSaveTextDocument.

    Use the corresponding events on the TextDocuments instance instead.

    Parameters

    • connection: Connection

      The connection to listen on.

    Returns Disposable

  • Sets a handler that will be called if a participant wants to provide edits during a text document save.

    Parameters

    • handler: RequestHandler<TextDocumentWillSaveEvent<T>, TextEdit[], void>

    Returns void