acquireDocument

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

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

The name of the file requested

compilationSettingsOrHost

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.

scriptSnapshot

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

version

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