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.
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.
(acquire-document document-registry
file-name
compilation-settings-or-host
script-snapshot
version)
(acquire-document document-registry
file-name
compilation-settings-or-host
script-snapshot
version
script-kind)
(acquire-document document-registry
file-name
compilation-settings-or-host
script-snapshot
version
script-kind
source-file-options)
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:
file-name
: string
- The name of the file requestedcompilation-settings-or-host
: CompilerOptions | MinimalResolutionCacheHost
- 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. A minimal
resolution cache is needed to fully define a source file's shape when
the compilation settings include module: node16
+, so providing a cache host
object should be preferred. A common host is a language service ConfiguredProject
.script-snapshot
: 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.script-kind
: ScriptKind | undefined
source-file-options
: ScriptTarget | CreateSourceFileOptions | undefined
Returns: 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. **Parameters:** - `file-name`: `string` - The name of the file requested - `compilation-settings-or-host`: `CompilerOptions | MinimalResolutionCacheHost` - 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. A minimal resolution cache is needed to fully define a source file's shape when the compilation settings include `module: node16`+, so providing a cache host object should be preferred. A common host is a language service `ConfiguredProject`. - `script-snapshot`: `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. - `script-kind`: `ScriptKind | undefined` - `source-file-options`: `ScriptTarget | CreateSourceFileOptions | undefined` **Returns:** `SourceFile`
(acquire-document-with-key document-registry
file-name
path
compilation-settings-or-host
key
script-snapshot
version)
(acquire-document-with-key document-registry
file-name
path
compilation-settings-or-host
key
script-snapshot
version
script-kind)
(acquire-document-with-key document-registry
file-name
path
compilation-settings-or-host
key
script-snapshot
version
script-kind
source-file-options)
Parameters:
file-name
: string
path
: Path
compilation-settings-or-host
: CompilerOptions | MinimalResolutionCacheHost
key
: DocumentRegistryBucketKey
script-snapshot
: IScriptSnapshot
version
: string
script-kind
: ScriptKind | undefined
source-file-options
: ScriptTarget | CreateSourceFileOptions | undefined
Returns: SourceFile
**Parameters:** - `file-name`: `string` - `path`: `Path` - `compilation-settings-or-host`: `CompilerOptions | MinimalResolutionCacheHost` - `key`: `DocumentRegistryBucketKey` - `script-snapshot`: `IScriptSnapshot` - `version`: `string` - `script-kind`: `ScriptKind | undefined` - `source-file-options`: `ScriptTarget | CreateSourceFileOptions | undefined` **Returns:** `SourceFile`
(key-for-compilation-settings document-registry settings)
Parameters:
settings
: CompilerOptions
Returns: DocumentRegistryBucketKey
**Parameters:** - `settings`: `CompilerOptions` **Returns:** `DocumentRegistryBucketKey`
(release-document document-registry file-name compilation-settings)
(release-document document-registry file-name compilation-settings script-kind)
(release-document document-registry
file-name
compilation-settings
script-kind
implied-node-format)
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:
file-name
: string
- The name of the file to be releasedcompilation-settings
: CompilerOptions
- The compilation settings used to acquire the filescript-kind
: ScriptKind
- The script kind of the file to be releasedimplied-node-format
: ResolutionMode
- The implied source file format of the file to be releasedReturns: 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:** - `file-name`: `string` - The name of the file to be released - `compilation-settings`: `CompilerOptions` - The compilation settings used to acquire the file - `script-kind`: `ScriptKind` - The script kind of the file to be released - `implied-node-format`: `ResolutionMode` - The implied source file format of the file to be released **Returns:** `void`
(release-document-with-key document-registry path key)
(release-document-with-key document-registry path key script-kind)
(release-document-with-key document-registry
path
key
script-kind
implied-node-format)
Parameters:
path
: Path
key
: DocumentRegistryBucketKey
script-kind
: ScriptKind
implied-node-format
: ResolutionMode
Returns: void
**Parameters:** - `path`: `Path` - `key`: `DocumentRegistryBucketKey` - `script-kind`: `ScriptKind` - `implied-node-format`: `ResolutionMode` **Returns:** `void`
(report-stats document-registry)
Returns: string
**Returns:** `string`
(update-document document-registry
file-name
compilation-settings-or-host
script-snapshot
version)
(update-document document-registry
file-name
compilation-settings-or-host
script-snapshot
version
script-kind)
(update-document document-registry
file-name
compilation-settings-or-host
script-snapshot
version
script-kind
source-file-options)
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:
file-name
: string
- The name of the file requestedcompilation-settings-or-host
: CompilerOptions | MinimalResolutionCacheHost
- 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. A minimal
resolution cache is needed to fully define a source file's shape when
the compilation settings include module: node16
+, so providing a cache host
object should be preferred. A common host is a language service ConfiguredProject
.script-snapshot
: IScriptSnapshot
- Text of the file.version
: string
- Current version of the file.script-kind
: ScriptKind | undefined
source-file-options
: ScriptTarget | CreateSourceFileOptions | undefined
Returns: 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. **Parameters:** - `file-name`: `string` - The name of the file requested - `compilation-settings-or-host`: `CompilerOptions | MinimalResolutionCacheHost` - 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. A minimal resolution cache is needed to fully define a source file's shape when the compilation settings include `module: node16`+, so providing a cache host object should be preferred. A common host is a language service `ConfiguredProject`. - `script-snapshot`: `IScriptSnapshot` - Text of the file. - `version`: `string` - Current version of the file. - `script-kind`: `ScriptKind | undefined` - `source-file-options`: `ScriptTarget | CreateSourceFileOptions | undefined` **Returns:** `SourceFile`
(update-document-with-key document-registry
file-name
path
compilation-settings-or-host
key
script-snapshot
version)
(update-document-with-key document-registry
file-name
path
compilation-settings-or-host
key
script-snapshot
version
script-kind)
(update-document-with-key document-registry
file-name
path
compilation-settings-or-host
key
script-snapshot
version
script-kind
source-file-options)
Parameters:
file-name
: string
path
: Path
compilation-settings-or-host
: CompilerOptions | MinimalResolutionCacheHost
key
: DocumentRegistryBucketKey
script-snapshot
: IScriptSnapshot
version
: string
script-kind
: ScriptKind | undefined
source-file-options
: ScriptTarget | CreateSourceFileOptions | undefined
Returns: SourceFile
**Parameters:** - `file-name`: `string` - `path`: `Path` - `compilation-settings-or-host`: `CompilerOptions | MinimalResolutionCacheHost` - `key`: `DocumentRegistryBucketKey` - `script-snapshot`: `IScriptSnapshot` - `version`: `string` - `script-kind`: `ScriptKind | undefined` - `source-file-options`: `ScriptTarget | CreateSourceFileOptions | undefined` **Returns:** `SourceFile`
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close