Class VirtualDocument

A notebook can hold one or more virtual documents; there is always one, "root" document, corresponding to the language of the kernel. All other virtual documents are extracted out of the notebook, based on magics, or other syntax constructs, depending on the kernel language.

Virtual documents represent the underlying code in a single language, which has been parsed excluding interactive kernel commands (magics) which could be misunderstood by the specific LSP server.

VirtualDocument has no awareness of the notebook or editor it lives in, however it is able to transform its content back to the notebook space, as it keeps editor coordinates for each virtual line.

The notebook/editor aware transformations are preferred to be placed in VirtualEditor descendants rather than here.

No dependency on editor implementation (such as CodeMirrorEditor) is allowed for VirtualEditor.

Implements

Constructors

Properties

blankLinesBetweenCells: number = 2

Number of blank lines appended to the virtual document between each cell.

documentInfo: IDocumentInfo

the remote document uri, version and other server-related info

fileExtension: undefined | string

File extension of the document.

foreignDocuments: Map<string, VirtualDocument>

Map holding the children VirtualDocument .

hasLspSupportedFile: boolean

Notebooks or any other aggregates of documents are not supported by the LSP specification, and we need to make appropriate adjustments for them, pretending they are simple files so that the LSP servers do not refuse to cooperate.

instanceId: number

Unique id of the virtual document.

language: string

The language identifier of the document.

lastSourceLine: number

Line number of the last line in the real document.

lastVirtualLine: number

Line number of the last line in the virtual document.

lineBlocks: string[]
parent?: null | VirtualDocument

Parent of the current virtual document.

path: string

Path to the document.

sourceLines: Map<number, ISourceLine>
standalone: boolean

Being standalone is relevant to foreign documents and defines whether following chunks of code in the same language should be appended to this document (false, not standalone) or should be considered separate documents (true, standalone)

unusedStandaloneDocuments: DefaultMap<string, VirtualDocument[]>
updateManager: UpdateManager

The update manager object.

virtualLines: Map<number, IVirtualLine>

Virtual lines keep all the lines present in the document AND extracted to the foreign document.

Accessors

  • get remainingLifetime(): number
  • When this counter goes down to 0, the document will be destroyed and the associated connection will be closed; This is meant to reduce the number of open connections when a foreign code snippet was removed from the document.

    Note: top level virtual documents are currently immortal (unless killed by other means); it might be worth implementing culling of unused documents, but if and only if JupyterLab will also implement culling of idle kernels - otherwise the user experience could be a bit inconsistent, and we would need to invent our own rules.

    Returns number

  • set remainingLifetime(value: number): void
  • Parameters

    • value: number

    Returns void

Methods