DocumentRegistry

sealed external interface DocumentRegistry(source)

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.

Functions

Link copied to clipboard
abstract fun acquireDocument(fileName: String, compilationSettingsOrHost: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: CreateSourceFileOptions = definedExternally): SourceFile
abstract fun acquireDocument(fileName: String, compilationSettingsOrHost: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: ScriptTarget = definedExternally): SourceFile
abstract fun acquireDocument(fileName: String, compilationSettingsOrHost: MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: CreateSourceFileOptions = definedExternally): SourceFile
abstract fun acquireDocument(fileName: String, compilationSettingsOrHost: MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: ScriptTarget = definedExternally): SourceFile

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.

Link copied to clipboard
abstract fun acquireDocumentWithKey(fileName: String, path: Path, compilationSettingsOrHost: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: CreateSourceFileOptions = definedExternally): SourceFile
abstract fun acquireDocumentWithKey(fileName: String, path: Path, compilationSettingsOrHost: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: ScriptTarget = definedExternally): SourceFile
abstract fun acquireDocumentWithKey(fileName: String, path: Path, compilationSettingsOrHost: MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: CreateSourceFileOptions = definedExternally): SourceFile
abstract fun acquireDocumentWithKey(fileName: String, path: Path, compilationSettingsOrHost: MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: ScriptTarget = definedExternally): SourceFile
Link copied to clipboard
abstract fun releaseDocument(fileName: String, compilationSettings: CompilerOptions, scriptKind: ScriptKind = definedExternally)
abstract fun releaseDocument(fileName: String, compilationSettings: CompilerOptions, scriptKind: ScriptKind, impliedNodeFormat: ResolutionMode)

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

Link copied to clipboard
abstract fun releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind = definedExternally)
abstract fun releaseDocumentWithKey(path: Path, key: DocumentRegistryBucketKey, scriptKind: ScriptKind, impliedNodeFormat: ResolutionMode)
Link copied to clipboard
abstract fun reportStats(): String
Link copied to clipboard
abstract fun updateDocument(fileName: String, compilationSettingsOrHost: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: CreateSourceFileOptions = definedExternally): SourceFile
abstract fun updateDocument(fileName: String, compilationSettingsOrHost: CompilerOptions, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: ScriptTarget = definedExternally): SourceFile
abstract fun updateDocument(fileName: String, compilationSettingsOrHost: MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: CreateSourceFileOptions = definedExternally): SourceFile
abstract fun updateDocument(fileName: String, compilationSettingsOrHost: MinimalResolutionCacheHost, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: ScriptTarget = definedExternally): SourceFile

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.

Link copied to clipboard
abstract fun updateDocumentWithKey(fileName: String, path: Path, compilationSettingsOrHost: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: CreateSourceFileOptions = definedExternally): SourceFile
abstract fun updateDocumentWithKey(fileName: String, path: Path, compilationSettingsOrHost: CompilerOptions, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: ScriptTarget = definedExternally): SourceFile
abstract fun updateDocumentWithKey(fileName: String, path: Path, compilationSettingsOrHost: MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: CreateSourceFileOptions = definedExternally): SourceFile
abstract fun updateDocumentWithKey(fileName: String, path: Path, compilationSettingsOrHost: MinimalResolutionCacheHost, key: DocumentRegistryBucketKey, scriptSnapshot: IScriptSnapshot, version: String, scriptKind: ScriptKind = definedExternally, sourceFileOptions: ScriptTarget = definedExternally): SourceFile