Options
All
  • Public
  • Public/Protected
  • All
Menu

Interface DocumentRegistry

The document registry represents a store of SourceFile objects that can be shared between multiple LanguageService instances. A LanguageService instance holds on the SourceFile (AST) of files in the context. SourceFile objects account for most of the memory usage by the language service. Sharing the same DocumentRegistry instance between different instances of LanguageService allow for more efficient memory utilization since all projects will share at least the library file (lib.d.ts).

A more advanced use of the document registry is to serialize sourceFile objects to disk and re-hydrate them when needed.

To create a default DocumentRegistry, use createDocumentRegistry to create one, and pass it to all subsequent createLanguageService calls.

Hierarchy

  • DocumentRegistry

Index

Methods

acquireDocument

  • Request a stored SourceFile with a given fileName and compilationSettings. The first call to acquire will call createLanguageServiceSourceFile to generate the SourceFile if was not found in the registry.

    Parameters

    • fileName: string

      The name of the file requested

    • compilationSettings: CompilerOptions

      Some compilation settings like target affects the shape of a the resulting SourceFile. This allows the DocumentRegistry to store multiple copies of the same file for different compilation settings.

    • scriptSnapshot: IScriptSnapshot

      Text of the file. Only used if the file was not found in the registry and a new one was created.

    • version: string

      Current version of the file. Only used if the file was not found in the registry and a new one was created.

    • Optional scriptKind: ScriptKind

    Returns SourceFile

acquireDocumentWithKey

getKeyForCompilationSettings

releaseDocument

  • deprecated

    pass scriptKind for correctness

    Parameters

    Returns void

  • Informs the DocumentRegistry that a file is not needed any longer.

    Note: It is not allowed to call release on a SourceFile that was not acquired from this registry originally.

    Parameters

    • fileName: string

      The name of the file to be released

    • compilationSettings: CompilerOptions

      The compilation settings used to acquire the file

    • scriptKind: ScriptKind

      The script kind of the file to be released

    Returns void

releaseDocumentWithKey

reportStats

  • reportStats(): string
  • Returns string

updateDocument

  • Request an updated version of an already existing SourceFile with a given fileName and compilationSettings. The update will in-turn call updateLanguageServiceSourceFile to get an updated SourceFile.

    Parameters

    • fileName: string

      The name of the file requested

    • compilationSettings: CompilerOptions

      Some compilation settings like target affects the shape of a the resulting SourceFile. This allows the DocumentRegistry to store multiple copies of the same file for different compilation settings.

    • scriptSnapshot: IScriptSnapshot

      Text of the file.

    • version: string

      Current version of the file.

    • Optional scriptKind: ScriptKind

    Returns SourceFile

updateDocumentWithKey

Generated using TypeDoc