Interface DocumentBuilder

Shared-service for building and updating LangiumDocuments.

interface DocumentBuilder {
    updateBuildOptions: BuildOptions;
    build<T>(documents: LangiumDocument<T>[], options?: BuildOptions, cancelToken?: CancellationToken): Promise<void>;
    onBuildPhase(targetState: DocumentState, callback: DocumentBuildListener): Disposable;
    onDocumentPhase(targetState: DocumentState, callback: DocumentPhaseListener): Disposable;
    onUpdate(callback: DocumentUpdateListener): Disposable;
    update(changed: URI[], deleted: URI[], cancelToken?: CancellationToken): Promise<void>;
    waitUntil(state: DocumentState, cancelToken?: CancellationToken): Promise<void>;
    waitUntil(state: DocumentState, uri?: URI, cancelToken?: CancellationToken): Promise<undefined | URI>;
}

Implemented by

Properties

updateBuildOptions: BuildOptions

The options used for rebuilding documents after an update.

Methods

  • This method is called when a document change is detected. It updates the state of all affected documents, including those with references to the changed ones, so they are rebuilt.

    Parameters

    • changed: URI[]

      URIs of changed or created documents

    • deleted: URI[]

      URIs of deleted documents

    • OptionalcancelToken: CancellationToken

      allows to cancel the current operation

    Returns Promise<void>

    OperationCancelled if cancellation is detected during execution

  • Wait until the workspace has reached the specified state for all documents.

    Parameters

    • state: DocumentState

      The desired state. The promise won't resolve until all documents have reached this state

    • OptionalcancelToken: CancellationToken

      Optionally allows to cancel the wait operation, disposing any listeners in the process

    Returns Promise<void>

    OperationCancelled if cancellation has been requested before the state has been reached

  • Wait until the document specified by the uri has reached the specified state.

    Parameters

    • state: DocumentState

      The desired state. The promise won't resolve until the document has reached this state.

    • Optionaluri: URI

      The specified URI that points to the document. If the URI does not exist, the promise will resolve once the workspace has reached the specified state.

    • OptionalcancelToken: CancellationToken

      Optionally allows to cancel the wait operation, disposing any listeners in the process.

    Returns Promise<undefined | URI>

    The URI of the document that has reached the desired state, or undefined if the document does not exist.

    OperationCancelled if cancellation has been requested before the state has been reached