KaCompilerFacility¶
@SubclassOptInRequired(markerClass = [KaSessionComponentImplementationDetail::class])
interface KaCompilerFacility : KaSessionComponent
Inheritors¶
Properties¶
token¶
abstract val token: KaLifetimeToken
The KaLifetimeToken which determines the lifetime of the lifetime owner.
Functions¶
assertIsValidAndAccessible¶
inline fun KaLifetimeOwner.assertIsValidAndAccessible()
compile¶
abstract fun compile(file: KtFile, options: KaCompilationOptions): KaCompilationResult
Compiles the given file in-memory using the specified options.
The function rethrows exceptions from the compiler, wrapped in KaCodeCompilationException. The implementation should wrap the compile() call into a try/catch block when necessary.
Parameters
-
file: A file to compile. The file must be either a source module file, or a
KtCodeFragment. For aKtCodeFragment, a source module context, a compiled library source context, or an empty context (null) are supported. -
options: The compilation options created via
createCompilationOptions.
See also
createCompilationOptions¶
abstract fun createCompilationOptions(init: KaCompilationOptionsBuilder.() -> Unit): KaCompilationOptions
Creates a new KaCompilationOptions instance using the given DSL init block.
Example usage:
val options = createCompilationOptions {
target(KaCompilationTarget.JVM)
moduleName("myModule")
languageVersionSettings(languageSettings)
allowedErrorFilter { diagnostic -> diagnostic.factoryName in allowedErrors }
}
Parameters
- init: A lambda that configures the
KaCompilationOptionsBuilder.
isValid¶
fun KaLifetimeOwner.isValid(): Boolean
Whether the lifetime owner is still valid, i.e. we are still in the scope of the lifetime owner's regular lifetime.
modify¶
abstract fun KaCompilationOptions.modify(init: KaCompilationOptionsBuilder.() -> Unit): KaCompilationOptions
Creates a copy of these KaCompilationOptions, applying the given init modifications.
Options not explicitly overridden in init retain their original values.
Parameters
- init: A lambda that configures the
KaCompilationOptionsBuilderwith modifications to apply.
withValidityAssertion¶
inline fun <R> KaLifetimeOwner.withValidityAssertion(action: () -> R): R
Executes action only if the KaLifetimeOwner is still valid and accessible. Otherwise, throws a validity exception based on the concrete violation.