fun sampleFile ( pathFromProjectRoot : String , fqPackageName : String , fillFile : KotlinSampleTestDataFile . ( ) -> Unit )

/**
 * Creates a `.kt` file outside of the source code directory. It should be used as input
 * for the `@sample` KDoc tag.
 *
 * To be picked by Dokka, this file must be included in [TestDokkaSourceSet.samples].
 *
 * @param pathFromProjectRoot path relative to the root of the test project. Must begin
 * with `/` to not confuse it with relative paths. Example: `/samples/collections.kt`
 * @param fqPackageName fully qualified package name to be used in the `package` statement of the file.
 * This parameter must be set because the package name cannot be deduced
 * from the file path, as samples usually reside outside of the source code directory.
 * Example: `org.jetbrains.dokka.sample.collections`
 */


fun compute ( currentJavaClassSnapshots : List < JavaClassSnapshot > , previousJavaClassSnapshots : List < JavaClassSnapshot > ) : ProgramSymbolSet

{ <EOL> val currentClasses : Map < ClassId , JavaClassSnapshot > = currentJavaClassSnapshots . associateBy { it . classId } <EOL> val previousClasses : Map < ClassId , JavaClassSnapshot > = previousJavaClassSnapshots . associateBy { it . classId } <EOL> val addedClasses = currentClasses . keys - previousClasses . keys <EOL> val removedClasses = previousClasses . keys - currentClasses . keys <EOL> val unchangedOrModifiedClasses = currentClasses . keys - addedClasses <EOL> return ProgramSymbolSet . Collector ( ) . run { <EOL> addClasses ( addedClasses ) <EOL> addClasses ( removedClasses ) <EOL> unchangedOrModifiedClasses . forEach { <EOL> collectClassChanges ( currentClasses [ it ] ! ! , previousClasses [ it ] ! ! , this ) <EOL> } <EOL> getResult ( ) <EOL> } <EOL> }

/**
 * Computes changes between two lists of [JavaClassSnapshot]s.
 *
 * NOTE: Each list of classes must not contain duplicates (having the same [JvmClassName]/[ClassId]).
 */


private fun collectClassChanges ( currentClassSnapshot : JavaClassSnapshot , previousClassSnapshot : JavaClassSnapshot , changes : ProgramSymbolSet . Collector )

{ <EOL> if ( currentClassSnapshot . classAbiHash == previousClassSnapshot . classAbiHash ) return <EOL> val classId = currentClassSnapshot . classId . also { check ( it == previousClassSnapshot . classId ) } <EOL> if ( currentClassSnapshot . classMemberLevelSnapshot != null && previousClassSnapshot . classMemberLevelSnapshot != null ) { <EOL> if ( currentClassSnapshot . classMemberLevelSnapshot . classAbiExcludingMembers . abiHash != previousClassSnapshot . classMemberLevelSnapshot . classAbiExcludingMembers . abiHash ) { <EOL> changes . addClass ( classId ) <EOL> } else { <EOL> collectClassMemberChanges ( classId , currentClassSnapshot . classMemberLevelSnapshot . fieldsAbi , previousClassSnapshot . classMemberLevelSnapshot . fieldsAbi , changes ) <EOL> collectClassMemberChanges ( classId , currentClassSnapshot . classMemberLevelSnapshot . methodsAbi , previousClassSnapshot . classMemberLevelSnapshot . methodsAbi , changes ) <EOL> } <EOL> } else { <EOL> changes . addClass ( classId ) <EOL> } <EOL> }

/**
 * Collects changes between two [JavaClassSnapshot]s.
 *
 * The two classes must have the same [ClassId].
 */


private fun collectClassMemberChanges ( classId : ClassId , currentMemberSnapshots : List < JavaElementSnapshot > , previousMemberSnapshots : List < JavaElementSnapshot > , changes : ProgramSymbolSet . Collector )

{ <EOL> val currentMemberHashes : Map < Long , JavaElementSnapshot > = currentMemberSnapshots . associateBy { it . abiHash } <EOL> val previousMemberHashes : Map < Long , JavaElementSnapshot > = previousMemberSnapshots . associateBy { it . abiHash } <EOL> val addedMembers = currentMemberHashes . keys - previousMemberHashes . keys <EOL> val removedMembers = previousMemberHashes . keys - currentMemberHashes . keys <EOL> changes . addClassMembers ( classId , addedMembers . map { currentMemberHashes [ it ] ! ! . name } ) <EOL> changes . addClassMembers ( classId , removedMembers . map { previousMemberHashes [ it ] ! ! . name } ) <EOL> if ( addedMembers . isNotEmpty ( ) || removedMembers . isNotEmpty ( ) ) { <EOL> changes . addClassMember ( classId , SAM_LOOKUP_NAME . asString ( ) ) <EOL> } <EOL> }

/** Collects changes between two lists of fields/methods within a class. */


abstract fun < K : Any , V , CONTEXT > createCache ( createValue : ( K , CONTEXT ) -> V ) : FirCache < K , V , CONTEXT >

/**
 * Creates a cache with returns a value by key on demand if it is computed
 * Otherwise computes the value in [createValue] and caches it for future invocations
 *
 * [FirCache.getValue] should not be called inside [createValue]
 *
 * Note, that [createValue] might be called multiple times for the same value,
 * but all threads will always get the same value
 *
 * Where:
 * [CONTEXT] -- type of value which be used to create value by [createValue]
 */


abstract fun < K : Any , V , CONTEXT > createCache ( initialCapacity : Int , loadFactor : Float , createValue : ( K , CONTEXT ) -> V ) : FirCache < K , V , CONTEXT >

/**
 * Creates a cache with returns a value by key on demand if it is computed
 * Otherwise computes the value in [createValue] and caches it for future invocations
 *
 * [FirCache.getValue] should not be called inside [createValue]
 *
 * Where:
 * [CONTEXT] -- type of value which be used to create value by [createValue]
 *
 * @param initialCapacity initial capacity for the underlying cache map
 * @param loadFactor loadFactor for the underlying cache map
 */


abstract fun < K : Any , V , CONTEXT , DATA > createCacheWithPostCompute ( createValue : ( K , CONTEXT ) -> Pair < V , DATA > , postCompute : ( K , V , DATA ) -> Unit ) : FirCache < K , V , CONTEXT >

/**
 * Creates a cache with returns a caches value on demand if it is computed
 * Otherwise computes the value in two phases:
 * - [createValue] -- creates values and stores value of type [V] to cache and passes [V] & [DATA] to [postCompute]
 * - [postCompute] -- performs some operations on computed value after it placed into map
 *
 * [FirCache.getValue] can be safely called in postCompute from the same thread and correct value computed by [createValue] will be returned
 * [FirCache.getValue] should not be called inside [createValue]
 *
 * Where:
 * [CONTEXT] -- type of value which be used to create value by [createValue]
 * [DATA] -- type of additional data which will be passed from [createValue] to [postCompute]
 */


fun resolve ( resolveAsInput : Boolean = false ) : Constraint

/**
 * Resolves all references and other constraints it contains,
 * to turn this constraint into one that represents a type.
 *
 * Should only be run after collecting all constraints,
 * and constraint should not be modified afterwards.
 *
 * When resolving as an input, resulting constraint
 * won't contain properties added to this constraint.
 */


internal fun checkDescriptor ( descriptor : OptionDescriptor < * , * > )

{ <EOL> if ( descriptor . multiple || descriptor . delimiter != null ) { <EOL> failAssertion ( "<STR_LIT>" ) <EOL> } <EOL> }

/**
 * Check descriptor for this kind of option.
 */


fun < T : Any , TResult , DefaultType : DefaultRequiredType > AbstractSingleOption < T , TResult , DefaultType > . multiple ( ) : <EOL> MultipleOption < T , MultipleOptionType . Repeated , DefaultType >

{ <EOL> val newOption = with ( ( delegate . cast < ParsingValue < T , T > > ( ) ) . descriptor as OptionDescriptor ) { <EOL> MultipleOption < T , MultipleOptionType . Repeated , DefaultType > ( OptionDescriptor ( optionFullFormPrefix , optionShortFromPrefix , type , fullName , shortName , description , listOfNotNull ( defaultValue ) , required , true , delimiter , deprecatedWarning ) , owner ) <EOL> } <EOL> owner . entity = newOption <EOL> return newOption <EOL> }

/**
 * Allows the option to have several values specified in command line string.
 * Number of values is unlimited.
 */


fun < T : Any , DefaultType : DefaultRequiredType > MultipleOption < T , MultipleOptionType . Delimited , DefaultType > . multiple ( ) : <EOL> MultipleOption < T , MultipleOptionType . RepeatedDelimited , DefaultRequiredType >

{ <EOL> val newOption = with ( ( delegate . cast < ParsingValue < T , List < T > > > ( ) ) . descriptor as OptionDescriptor ) { <EOL> if ( multiple ) { <EOL> error ( "<STR_LIT>" ) <EOL> } <EOL> MultipleOption < T , MultipleOptionType . RepeatedDelimited , DefaultRequiredType > ( OptionDescriptor ( optionFullFormPrefix , optionShortFromPrefix , type , fullName , shortName , description , defaultValue ? . toList ( ) ? : listOf ( ) , required , true , delimiter , deprecatedWarning ) , owner ) <EOL> } <EOL> owner . entity = newOption <EOL> return newOption <EOL> }


fun < T : Any > SingleNullableOption < T > . default ( value : T ) : SingleOption < T , DefaultRequiredType . Default >

{ <EOL> val newOption = with ( ( delegate . cast < ParsingValue < T , T > > ( ) ) . descriptor as OptionDescriptor ) { <EOL> SingleOption < T , DefaultRequiredType . Default > ( OptionDescriptor ( optionFullFormPrefix , optionShortFromPrefix , type , fullName , shortName , description , value , required , multiple , delimiter , deprecatedWarning ) , owner ) <EOL> } <EOL> owner . entity = newOption <EOL> return newOption <EOL> }

/**
 * Specifies the default value for the option, that will be used when no value is provided for it
 * in command line string.
 *
 * @param value the default value.
 */


fun < T : Any , OptionType : MultipleOptionType > <EOL> MultipleOption < T , OptionType , DefaultRequiredType . None > . default ( value : Collection < T > ) : <EOL> MultipleOption < T , OptionType , DefaultRequiredType . Default >

{ <EOL> val newOption = with ( ( delegate . cast < ParsingValue < T , List < T > > > ( ) ) . descriptor as OptionDescriptor ) { <EOL> require ( value . isNotEmpty ( ) ) { "<STR_LIT>" } <EOL> MultipleOption < T , OptionType , DefaultRequiredType . Default > ( OptionDescriptor ( optionFullFormPrefix , optionShortFromPrefix , type , fullName , shortName , description , value . toList ( ) , required , multiple , delimiter , deprecatedWarning ) , owner ) <EOL> } <EOL> owner . entity = newOption <EOL> return newOption <EOL> }

/**
 * Specifies the default value for the option with multiple values, that will be used when no values are provided
 * for it in command line string.
 *
 * @param value the default value, must be a non-empty collection.
 * @throws IllegalArgumentException if provided default value is empty collection.
 */


fun < T : Any > SingleNullableOption < T > . required ( ) : SingleOption < T , DefaultRequiredType . Required >

{ <EOL> val newOption = with ( ( delegate . cast < ParsingValue < T , T > > ( ) ) . descriptor as OptionDescriptor ) { <EOL> SingleOption < T , DefaultRequiredType . Required > ( OptionDescriptor ( optionFullFormPrefix , optionShortFromPrefix , type , fullName , shortName , description , defaultValue , true , multiple , delimiter , deprecatedWarning ) , owner ) <EOL> } <EOL> owner . entity = newOption <EOL> return newOption <EOL> }

/**
 * Requires the option to be always provided in command line.
 */


fun < T : Any , OptionType : MultipleOptionType > <EOL> MultipleOption < T , OptionType , DefaultRequiredType . None > . required ( ) : <EOL> MultipleOption < T , OptionType , DefaultRequiredType . Required >

{ <EOL> val newOption = with ( ( delegate . cast < ParsingValue < T , List < T > > > ( ) ) . descriptor as OptionDescriptor ) { <EOL> MultipleOption < T , OptionType , DefaultRequiredType . Required > ( OptionDescriptor ( optionFullFormPrefix , optionShortFromPrefix , type , fullName , shortName , description , defaultValue ? . toList ( ) ? : listOf ( ) , true , multiple , delimiter , deprecatedWarning ) , owner ) <EOL> } <EOL> owner . entity = newOption <EOL> return newOption <EOL> }


fun < T : Any , DefaultRequired : DefaultRequiredType > AbstractSingleOption < T , * , DefaultRequired > . delimiter ( delimiterValue : String ) : <EOL> MultipleOption < T , MultipleOptionType . Delimited , DefaultRequired >

{ <EOL> val newOption = with ( ( delegate . cast < ParsingValue < T , T > > ( ) ) . descriptor as OptionDescriptor ) { <EOL> MultipleOption < T , MultipleOptionType . Delimited , DefaultRequired > ( OptionDescriptor ( optionFullFormPrefix , optionShortFromPrefix , type , fullName , shortName , description , listOfNotNull ( defaultValue ) , required , multiple , delimiterValue , deprecatedWarning ) , owner ) <EOL> } <EOL> owner . entity = newOption <EOL> return newOption <EOL> }

/**
 * Allows the option to have several values joined with [delimiter] specified in command line string.
 * Number of values is unlimited.
 *
 * The value of the argument is an empty list in case if no value was specified in command line string.
 *
 * @param delimiterValue delimiter used to separate string value to option values list.
 */


fun < T : Any , DefaultRequired : DefaultRequiredType > MultipleOption < T , MultipleOptionType . Repeated , DefaultRequired > . delimiter ( delimiterValue : String ) : <EOL> MultipleOption < T , MultipleOptionType . RepeatedDelimited , DefaultRequired >

{ <EOL> val newOption = with ( ( delegate . cast < ParsingValue < T , List < T > > > ( ) ) . descriptor as OptionDescriptor ) { <EOL> MultipleOption < T , MultipleOptionType . RepeatedDelimited , DefaultRequired > ( OptionDescriptor ( optionFullFormPrefix , optionShortFromPrefix , type , fullName , shortName , description , defaultValue ? . toList ( ) ? : listOf ( ) , required , multiple , delimiterValue , deprecatedWarning ) , owner ) <EOL> } <EOL> owner . entity = newOption <EOL> return newOption <EOL> }


private fun JsScope . findOwnNameOrDeclare ( ident : String ) : JsName

= <EOL> when ( this ) { <EOL> is JsFunctionScope -> declareNameUnsafe ( ident ) <EOL> else -> declareName ( ident ) <EOL> }

/**
 * Overrides JsFunctionScope declareName as it's mapped to declareFreshName
 */


= super < AbstractSet > . hashCode ( )

/**
 * We provide [equals], so as a matter of style, we should also provide [hashCode].
 * However, the implementation from [AbstractSet] is enough.
 */


private fun CallableDescriptor . approximateCapturedTypes ( approximator : TypeApproximator ) : CallableDescriptor

{ <EOL> if ( ! isNewInferenceEnabled ) return this <EOL> val wrappedSubstitution = object : TypeSubstitution ( ) { <EOL> override fun get ( key : KotlinType ) : TypeProjection ? = null <EOL> override fun prepareTopLevelType ( topLevelType : KotlinType , position : Variance ) = when ( position ) { <EOL> Variance . INVARIANT -> null <EOL> Variance . OUT_VARIANCE -> approximator . approximateToSuperType ( topLevelType . unwrap ( ) , TypeApproximatorConfiguration . InternalTypesApproximation ) <EOL> Variance . IN_VARIANCE -> approximator . approximateToSubType ( topLevelType . unwrap ( ) , TypeApproximatorConfiguration . InternalTypesApproximation ) <EOL> } ? : topLevelType <EOL> } <EOL> return substitute ( TypeSubstitutor . create ( wrappedSubstitution ) ) <EOL> }

/**
 * this is bad hack for test like BlackBoxCodegenTestGenerated.Reflection.Properties#testGetPropertiesMutableVsReadonly (see last get call)
 * Main reason for this hack: when we have List<*> we do capturing and transform receiver type to List<Capture(*)>.
 * So method get has signature get(Int): Capture(*). If we also have smartcast to MutableList<String>, then there is also method get(Int): String.
 * And we should chose get(Int): String.
 */


@ kotlin . internal . InlineOnly <EOL> public actual inline fun print ( message : Any ? )

{ <EOL> System . out . print ( message ) <EOL> }

/** Prints the given [message] to the standard output stream. */


@ kotlin . internal . InlineOnly <EOL> public inline fun print ( message : Int )


@ kotlin . internal . InlineOnly <EOL> public inline fun print ( message : Long )


@ kotlin . internal . InlineOnly <EOL> public inline fun print ( message : Byte )


@ kotlin . internal . InlineOnly <EOL> public inline fun print ( message : Short )


@ kotlin . internal . InlineOnly <EOL> public inline fun print ( message : Char )


@ kotlin . internal . InlineOnly <EOL> public inline fun print ( message : Boolean )


@ kotlin . internal . InlineOnly <EOL> public inline fun print ( message : Float )


@ kotlin . internal . InlineOnly <EOL> public inline fun print ( message : Double )


@ kotlin . internal . InlineOnly <EOL> public inline fun print ( message : CharArray )


@ kotlin . internal . InlineOnly <EOL> public actual inline fun println ( message : Any ? )

{ <EOL> System . out . println ( message ) <EOL> }

/** Prints the given [message] and the line separator to the standard output stream. */


@ kotlin . internal . InlineOnly <EOL> public inline fun println ( message : Int )


@ kotlin . internal . InlineOnly <EOL> public inline fun println ( message : Long )


@ kotlin . internal . InlineOnly <EOL> public inline fun println ( message : Byte )


@ kotlin . internal . InlineOnly <EOL> public inline fun println ( message : Short )


@ kotlin . internal . InlineOnly <EOL> public inline fun println ( message : Char )


@ kotlin . internal . InlineOnly <EOL> public inline fun println ( message : Boolean )


@ kotlin . internal . InlineOnly <EOL> public inline fun println ( message : Float )


@ kotlin . internal . InlineOnly <EOL> public inline fun println ( message : Double )


@ kotlin . internal . InlineOnly <EOL> public inline fun println ( message : CharArray )


@ kotlin . internal . InlineOnly <EOL> public actual inline fun println ( )

{ <EOL> System . out . println ( ) <EOL> }

/** Prints the line separator to the standard output stream. */


@ SinceKotlin ( "<STR_LIT:1.6>" ) <EOL> public actual fun readln ( ) : String

= readlnOrNull ( ) ? : throw ReadAfterEOFException ( "<STR_LIT>" )

/**
 * Reads a line of input from the standard input stream and returns it,
 * or throws a [RuntimeException] if EOF has already been reached when [readln] is called.
 *
 * LF or CRLF is treated as the line terminator. Line terminator is not included in the returned string.
 *
 * The input is decoded using the system default Charset. A [CharacterCodingException] is thrown if input is malformed.
 */


@ SinceKotlin ( "<STR_LIT:1.6>" ) <EOL> public actual fun readlnOrNull ( ) : String ?

= readLine ( )

/**
 * Reads a line of input from the standard input stream and returns it,
 * or return `null` if EOF has already been reached when [readlnOrNull] is called.
 *
 * LF or CRLF is treated as the line terminator. Line terminator is not included in the returned string.
 *
 * The input is decoded using the system default Charset. A [CharacterCodingException] is thrown if input is malformed.
 */


= LineReader . readLine ( System . `in` , Charset . defaultCharset ( ) )

/**
 * Reads a line of input from the standard input stream.
 *
 * @return the line read or `null` if the input stream is redirected to a file and the end of file has been reached.
 */


@ Synchronized <EOL> fun readLine ( inputStream : InputStream , charset : Charset ) : String ?

{ <EOL> if ( ! :: decoder . isInitialized || decoder . charset ( ) != charset ) updateCharset ( charset ) <EOL> var nBytes = <NUM_LIT:0> <EOL> var nChars = <NUM_LIT:0> <EOL> while ( true ) { <EOL> val readByte = inputStream . read ( ) <EOL> if ( readByte == - <NUM_LIT:1> ) { <EOL> if ( sb . isEmpty ( ) && nBytes == <NUM_LIT:0> && nChars == <NUM_LIT:0> ) { <EOL> return null <EOL> } else { <EOL> nChars = decodeEndOfInput ( nBytes , nChars ) <EOL> break <EOL> } <EOL> } else { <EOL> bytes [ nBytes ++ ] = readByte . toByte ( ) <EOL> } <EOL> if ( readByte == '<CHAR_LIT:\n>' . code || nBytes == BUFFER_SIZE || ! directEOL ) { <EOL> byteBuf . limit ( nBytes ) <EOL> charBuf . position ( nChars ) <EOL> nChars = decode ( false ) <EOL> if ( nChars > <NUM_LIT:0> && chars [ nChars - <NUM_LIT:1> ] == '<CHAR_LIT:\n>' ) { <EOL> byteBuf . position ( <NUM_LIT:0> ) <EOL> break <EOL> } <EOL> nBytes = compactBytes ( ) <EOL> } <EOL> } <EOL> if ( nChars > <NUM_LIT:0> && chars [ nChars - <NUM_LIT:1> ] == '<CHAR_LIT:\n>' ) { <EOL> nChars -- <EOL> if ( nChars > <NUM_LIT:0> && chars [ nChars - <NUM_LIT:1> ] == '<CHAR_LIT:\r>' ) nChars -- <EOL> } <EOL> if ( sb . isEmpty ( ) ) return String ( chars , <NUM_LIT:0> , nChars ) <EOL> sb . append ( chars , <NUM_LIT:0> , nChars ) <EOL> val result = sb . toString ( ) <EOL> if ( sb . length > BUFFER_SIZE ) trimStringBuilder ( ) <EOL> sb . setLength ( <NUM_LIT:0> ) <EOL> return result <EOL> }

/**
 * Reads line from the specified [inputStream] with the given [charset].
 * The general design:
 * * This function contains only fast path code and all it state is kept in local variables as much as possible.
 * * All the slow-path code is moved to separate functions and the call-sequence bytecode is minimized for it.
 */


public fun FaceAlignmentModelBase < Bitmap > . detectLandmarks ( imageProxy : ImageProxy ) : List < Landmark >

{ <EOL> if ( this is CameraXCompatibleModel ) { <EOL> return doWithRotation ( imageProxy . imageInfo . rotationDegrees ) { <EOL> detectLandmarks ( imageProxy . toBitmap ( ) ) <EOL> } <EOL> } <EOL> return detectLandmarks ( imageProxy . toBitmap ( applyRotation = true ) ) <EOL> }

/**
 * Detects [Landmark] objects on the given [imageProxy].
 */


private fun selectSubstitutionClassifierId ( types : List < CirClassOrTypeAliasType > ) : CirEntityId ?

{ <EOL> val forwardSubstitutionAllowed = typeCommonizer . context . enableForwardTypeAliasSubstitution <EOL> val backwardsSubstitutionAllowed = typeCommonizer . context . enableBackwardsTypeAliasSubstitution <EOL> if ( ! forwardSubstitutionAllowed && ! backwardsSubstitutionAllowed ) { <EOL> return null <EOL> } <EOL> val associatedIds = types . singleDistinctValueOrNull { <EOL> classifiers . associatedIdsResolver . resolveAssociatedIds ( it . classifierId ) <EOL> } ? : return null <EOL> val typeSubstitutionCandidates = resolveTypeSubstitutionCandidates ( associatedIds , types ) <EOL> . onEach { typeSubstitutionCandidate -> <EOL> assert ( typeSubstitutionCandidate . typeDistance . isZero . not ( ) ) { "<STR_LIT>" } <EOL> assert ( typeSubstitutionCandidate . typeDistance . isReachable ) { "<STR_LIT>" } <EOL> } <EOL> return typeSubstitutionCandidates . minByOrNull { it . typeDistance . penalty } ? . id <EOL> }

/**
 * Will select *the* associated classifier that is
 * - reachable from all [types] on all platforms
 * - Has the lowest penalty score (where penalty score will be the maximum penalty on all platforms)
 *
 * Will return null if
 * - No substitution is allowed
 * - The input [types] do not have a single distinct set of associated ids
 */


public fun KtAnnotationValue . renderAsSourceCode ( ) : String

= <EOL> KtAnnotationValueRenderer . render ( this )

/**
 * Render annotation value, resulted string is a valid Kotlin source code.
 */


public fun lastObservedStackTrace ( ) : List < StackTraceElement >

{ <EOL> var frame : CoroutineStackFrame ? = lastObservedFrame ? : return emptyList ( ) <EOL> val result = ArrayList < StackTraceElement > ( ) <EOL> while ( frame != null ) { <EOL> frame . getStackTraceElement ( ) ? . let { result . add ( it ) } <EOL> frame = frame . callerFrame <EOL> } <EOL> return result <EOL> }

/**
 * Last observed stacktrace of the coroutine captured on its suspension or resumption point.
 * It means that for [running][State.RUNNING] coroutines resulting stacktrace is inaccurate and
 * reflects stacktrace of the resumption point, not the actual current stacktrace.
 */


fun forKlib ( ) : Iterable < CompiledDependency < KLIB > >

= klibDependencies

/** Dependencies needed to compile KLIB. */


fun forStaticCache ( klib : CompiledDependency < KLIB > , useHeaders : Boolean ) : Iterable < CompiledDependency < * > >

= <EOL> ( klibDependencies . asSequence ( ) . filter { it . type == FriendLibrary } + klib + if ( useHeaders ) staticCacheHeaderDependencies else staticCacheDependencies ) . asIterable ( )

/** Dependencies needed to compile KLIB static cache. */


fun forOneStageExecutable ( ) : Iterable < CompiledDependency < * > >

= <EOL> ( klibDependencies . asSequence ( ) + staticCacheDependencies ) . asIterable ( )

/** Dependencies needed to compile one-stage executable. */


fun forTwoStageExecutable ( includedKlib : CompiledDependency < KLIB > , includedKlibStaticCache : CompiledDependency < KLIBStaticCache > ? <EOL> ) : Iterable < CompiledDependency < * > >

= <EOL> ( klibDependencies . asSequence ( ) + staticCacheDependencies + listOfNotNull ( includedKlib , includedKlibStaticCache ) ) . asIterable ( )

/** Dependencies needed to compile two-stage executable. */


public fun apply ( input : I ) : O

/**
 * Performs preprocessing operation on the input.
 * @param [input] is an input to the operation of type [I].
 * @return an output of the operation of type [O].
 */


public fun getOutputShape ( inputShape : TensorShape ) : TensorShape

/**
 * Returns the output's shape of the operation having input of shape [inputShape].
 * @param [inputShape] is a shape of the input.
 */


public fun subprojects ( )

/**
 * Include to the merged report all subprojects of the current project.
 *
 * Kover plugin will be automatically applied in all subprojects.
 */


public fun subprojects ( filter : Spec < Project > )

/**
 * Include to the merged report subprojects of the current project that have passed the filter.
 *
 * Kover plugin will be automatically applied in passed subprojects.
 *
 * **Important!**
 *
 * It is impossible to guarantee exactly at what point in time the filter will be executed, before evaluation the corresponding project or during the evaluation.
 * Therefore, only static values can be read in filters, for example, the name of the project or its path.
 */


public fun allProjects ( )

/**
 * Include to the merged report all projects of the build.
 *
 * Kover plugin will be automatically applied in all projects.
 */


public fun allProjects ( filter : Spec < Project > )

/**
 * Include to the merged report all projects of the build that have passed the filter.
 *
 * Kover plugin will be automatically applied in passed subprojects.
 *
 * **Important!**
 *
 * It is impossible to guarantee exactly at what point in time the filter will be executed, before evaluation the corresponding project or during the evaluation.
 * Therefore, only static values can be read in filters, for example, the name of the project or its path.
 */


public fun projects ( vararg projectNameOrPath : String )

/**
 * Include to the merged report all specified projects.
 * You can specify both the project name and its path (starts with the `:` sign).
 *
 * Kover plugin will be automatically applied in these subprojects.
 */


public fun sources ( config : Action < KoverMergingVariantSources > )

/**
 * Limit the classes that will be included in the reports for all included projects.
 *
 * For more information about the settings, see [KoverVariantConfig.sources].
 *
 * This action is executed delayed, just before all tasks are created, at the after evaluate stage.
 * A corresponding project is passed in the argument. Analyzing this project, you can make flexible configurations.
 * ```
 * sources {
 * if (project.name == "projectName") {
 * excludedSourceSets.add("excluded")
 * }
 * }
 * ```
 */


public fun instrumentation ( config : Action < KoverMergingInstrumentation > )

/**
 * Instrumentation settings for all included projects.
 *
 * For more information about the settings, see [KoverVariantConfig.instrumentation].
 *
 * This action is executed delayed, just before all tasks are created, at the after evaluate stage.
 * A corresponding project is passed in the argument. Analyzing this project, you can make flexible configurations.
 * ```
 * instrumentation {
 * if (project.name == "projectName") {
 * excludedClasses.add("foo.bar.*")
 * }
 * }
 * ```
 */


public fun createVariant ( variantName : String , config : Action < KoverMergingVariantCreate > )

/**
 * Create custom report variant with name [variantName] in all included projects.
 *
 * For more information about the settings, see [KoverCurrentProjectVariantsConfig.createVariant].
 *
 * This action is executed delayed, just before all tasks are created, at the after evaluate stage.
 * A corresponding project is passed in the argument. Analyzing this project, you can make flexible configurations.
 * ```
 * createVariant("custom") {
 * if (project.plugins.hasPlugin("kotlin")) {
 * add("jvm")
 * }
 * }
 * ```
 */


private inline fun FirFile . forEachElementWithContainers ( crossinline saveDeclaration : ( element : FirElement , owners : List < FirBasedSymbol < * > > ) -> Unit )

{ <EOL> val declarationsCollector = object : FirVisitor < Unit , PersistentList < FirBasedSymbol < * > > > ( ) { <EOL> override fun visitElement ( element : FirElement , data : PersistentList < FirBasedSymbol < * > > ) { <EOL> if ( element is FirDeclaration ) { <EOL> saveDeclaration ( element , data ) <EOL> } <EOL> element . acceptChildren ( visitor = this , data = if ( element is FirDeclaration ) data . add ( element . symbol ) else data ) <EOL> } <EOL> } <EOL> accept ( declarationsCollector , persistentListOf ( ) ) <EOL> }

/**
 * Walks over every [FirElement] in [this] file and invokes [saveDeclaration] on it, passing each element and the list of its containing
 * declarations (like file, classes, functions/properties and so on).
 */


private inline fun FirDeclaration . forEachDirectChildDeclaration ( crossinline action : ( child : FirDeclaration ) -> Unit )

{ <EOL> this . acceptChildren ( object : FirDefaultVisitorVoid ( ) { <EOL> override fun visitElement ( element : FirElement ) { <EOL> } <EOL> override fun visitFile ( file : FirFile ) { <EOL> action ( file ) <EOL> } <EOL> override fun visitCallableDeclaration ( callableDeclaration : FirCallableDeclaration ) { <EOL> action ( callableDeclaration ) <EOL> } <EOL> override fun visitClassLikeDeclaration ( classLikeDeclaration : FirClassLikeDeclaration ) { <EOL> action ( classLikeDeclaration ) <EOL> } <EOL> } ) <EOL> }

/**
 * Calls [action] on every direct child declaration of [this] declaration.
 */


fun findPackageParts ( packageFqName : String ) : List < String >

/**
 * @return JVM internal names of package parts existing in the package with the given FQ name.
 *
 * For example, if a file named foo.kt in package org.test is compiled to a library, PackagePartProvider for such library
 * must return the list `["org/test/FooKt"]` for the query `"org.test"`
 * (in case the file is not annotated with @JvmName, @JvmPackageName or @JvmMultifileClass).
 */


fun computePackageSetWithNonClassDeclarations ( ) : Set < String >

/**
 * This method is only for sake of optimization
 * @return package names set for which that provider has package parts
 */


fun mayHaveOptionalAnnotationClasses ( ) : Boolean

/**
 * Returns `true` if [getAllOptionalAnnotationClasses] may return a non-empty list.
 */


private fun checkLibrariesInDistribution ( ) : Boolean

{ <EOL> val presentPlatformLibs = platformLibsDirectory <EOL> . listFiles { file -> file . isDirectory } . orEmpty ( ) <EOL> . map { it . name } . toSet ( ) <EOL> return presentDefs . toPlatformLibNames ( ) . all { it in presentPlatformLibs } <EOL> }

/**
 * Checks that all platform libs for [konanTarget] actually exist in the [distribution].
 */


{ <EOL> if ( ! shouldBuildCaches ) { <EOL> return true <EOL> } <EOL> val cacheDirectory = CacheBuilder . getRootCacheDirectory ( project . konanHome , konanTarget , true , konanCacheKind ) <EOL> return presentDefs . toPlatformLibNames ( ) . all { <EOL> cacheDirectory . resolve ( CacheBuilder . getCacheFileName ( it , konanCacheKind ) ) . listFilesOrEmpty ( ) . isNotEmpty ( ) <EOL> } <EOL> }

/**
 * Check that caches for all platform libs for [konanTarget] actually exist in the cache directory.
 */


fun isGenerated ( path : File ) : Boolean

= <EOL> generated . contains ( path )

/**
 * Are platform libraries in the given directory (e.g. <dist>/klib/platform/ios_x64) generated.
 */


{ <EOL> generated . add ( path ) <EOL> }

/**
 * Register that platform libraries in the given directory are generated.
 */


fun isCached ( path : File , kind : NativeCacheKind ) : Boolean

= <EOL> kind == NativeCacheKind . NONE || cached ( kind ) . contains ( path )

/**
 * Are platform libraries in the given directory (e.g. <dist>/klib/platform/ios_x64) cached with the given cache kind.
 */


fun setCached ( path : File , kind : NativeCacheKind )

{ <EOL> if ( kind != NativeCacheKind . NONE ) { <EOL> cached ( kind ) . add ( path ) <EOL> } <EOL> }

/**
 * Register that platform libraries in the give directory are cached with the given cache kind.
 */


internal fun Project . mavenPublishing ( configure : MavenPublishingSettings . ( ) -> Unit )

= <EOL> extensions . configure ( configure )

/** Configure the [KayrayBuildProperties] extension. */


@ Suppress ( "<STR_LIT:UNUSED_PARAMETER>" ) <EOL> internal fun File . patchSettingsFile ( description : String , koverVersion : String , snapshotRepos : List < String > , overrideKotlinVersion : String ? <EOL> )

{ <EOL> val language = if ( name . endsWith ( "<STR_LIT>" ) ) ScriptLanguage . KTS else ScriptLanguage . GROOVY <EOL> val originLines = readLines ( ) <EOL> bufferedWriter ( ) . use { writer -> <EOL> var firstStatement = true <EOL> originLines . forEach { line -> <EOL> if ( firstStatement && line . isNotBlank ( ) ) { <EOL> val isPluginManagement = line . trimStart ( ) . startsWith ( "<STR_LIT>" ) <EOL> writer . appendLine ( "<STR_LIT>" ) <EOL> val pluginManagementWriter = FormattedWriter { l -> writer . append ( l ) } <EOL> pluginManagementWriter . writePluginManagement ( language , koverVersion , snapshotRepos , overrideKotlinVersion ) <EOL> if ( ! isPluginManagement ) { <EOL> writer . appendLine ( "<STR_LIT:}>" ) <EOL> } <EOL> firstStatement = false <EOL> } else { <EOL> writer . appendLine ( line ) <EOL> } <EOL> } <EOL> if ( originLines . isEmpty ( ) ) { <EOL> val pluginManagementWriter = FormattedWriter { l -> writer . append ( l ) } <EOL> pluginManagementWriter . call ( "<STR_LIT>" ) { <EOL> pluginManagementWriter . writePluginManagement ( language , koverVersion , snapshotRepos , overrideKotlinVersion ) <EOL> } <EOL> } <EOL> val pluginManagementWriter = FormattedWriter { l -> writer . append ( l ) } <EOL> pluginManagementWriter . writeDependencyManagement ( language , snapshotRepos ) <EOL> } <EOL> }

/**
 * Override Kover version and add local repository to find artifact for current build.
 */


internal fun File . patchKoverDependency ( koverVersion : String )

{ <EOL> val originLines = readLines ( ) <EOL> bufferedWriter ( ) . use { writer -> <EOL> originLines . forEach { line -> <EOL> val lineToWrite = if ( line . contains ( "<STR_LIT>" ) ) { <EOL> line . replace ( "<STR_LIT>" , "<STR_LIT>" ) <EOL> } else { <EOL> line <EOL> } <EOL> writer . appendLine ( lineToWrite ) <EOL> } <EOL> } <EOL> }


fun String . invariantNewlines ( ) : String

= <EOL> lines ( ) . joinToString ( "<STR_LIT:\n>" )

/** Replace all newlines with `\n`, so the String can be used in assertions cross-platform */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> public expect fun Throwable . stackTraceToString ( ) : String

/**
 * Returns the detailed description of this throwable with its stack trace.
 *
 * The detailed description includes:
 * - the short description (see [Throwable.toString]) of this throwable;
 * - the complete stack trace;
 * - detailed descriptions of the exceptions that were [suppressed][suppressedExceptions] in order to deliver this exception;
 * - the detailed description of each throwable in the [Throwable.cause] chain.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> public expect fun Throwable . printStackTrace ( ) : Unit

/**
 * Prints the [detailed description][Throwable.stackTraceToString] of this throwable to the standard output or standard error output.
 */


@ SinceKotlin ( "<STR_LIT:1.4>" ) <EOL> @ Suppress ( "<STR_LIT>" ) <EOL> public expect fun Throwable . addSuppressed ( exception : Throwable )

/**
 * When supported by the platform, adds the specified exception to the list of exceptions that were
 * suppressed in order to deliver this exception.
 */


inline fun < reified IN , reified BUF , reified OUT > aggregatorOf ( noinline zero : ( ) -> BUF , noinline reduce : ( b : BUF , a : IN ) -> BUF , noinline merge : ( b1 : BUF , b2 : BUF ) -> BUF , noinline finish : ( reduction : BUF ) -> OUT , bufferEncoder : Encoder < BUF > = encoder ( ) , outputEncoder : Encoder < OUT > = encoder ( ) , ) : Aggregator < IN , BUF , OUT >

= Aggregator ( zero , reduce , merge , finish , bufferEncoder , outputEncoder )

/** Creates an [Aggregator] in functional manner.
 *
 * @param zero A zero value for this aggregation. Should satisfy the property that any b + zero = b.
 * @param reduce Combine two values to produce a new value. For performance, the function may modify `b` and
 * return it instead of constructing new object for b.
 * @param merge Merge two intermediate values.
 * @param finish Transform the output of the reduction.
 * @param bufferEncoder Optional. Specifies the `Encoder` for the intermediate value type.
 * @param outputEncoder Optional. Specifies the `Encoder` for the final output value type.
 * */


inline fun < reified IN , reified OUT , reified AGG : Aggregator < IN , * , OUT > > udaf ( agg : AGG , nondeterministic : Boolean = false , ) : NamedUserDefinedFunction1 < IN , OUT >

= udaf ( name = agg :: class . simpleName ? : error ( "<STR_LIT>" ) , agg = agg , nondeterministic = nondeterministic , )

/**
 * Obtains a [NamedUserDefinedFunction1] that wraps the given [agg] so that it may be used with Data Frames.
 * @see functions.udaf
 *
 * @param name Optional. Tries to obtain name from the class of [agg] if not supplied.
 * Use [udafUnnamed] if no name is wanted.
 * @param agg the given [Aggregator] to convert into a UDAF. Can also be created using [aggregatorOf].
 * @param nondeterministic Optional. If true, sets the UserDefinedFunction as nondeterministic.
 *
 * @return a [NamedUserDefinedFunction1] that can be used as an aggregating expression
 *
 * @see udaf for a named variant.
 */


inline fun < reified IN , reified OUT , reified AGG : Aggregator < IN , * , OUT > > udaf ( name : String , agg : AGG , nondeterministic : Boolean = false , ) : NamedUserDefinedFunction1 < IN , OUT >

= <EOL> udafUnnamed ( agg = agg , nondeterministic = nondeterministic ) . withName ( name )


inline fun < reified IN , reified OUT , reified AGG : Aggregator < IN , * , OUT > > udafUnnamed ( agg : AGG , nondeterministic : Boolean = false , ) : UserDefinedFunction1 < IN , OUT >

{ <EOL> IN :: class . checkForValidType ( "<STR_LIT>" ) <EOL> return UserDefinedFunction1 ( udf = functions . udaf ( agg , encoder < IN > ( ) ) . let { if ( nondeterministic ) it . asNondeterministic ( ) else it } . let { if ( typeOf < OUT > ( ) . isMarkedNullable ) it else it . asNonNullable ( ) } , encoder = encoder < OUT > ( ) , ) <EOL> }

/**
 * Obtains a [UserDefinedFunction1] that wraps the given [agg] so that it may be used with Data Frames.
 * @see functions.udaf
 *
 * @param agg the given [Aggregator] to convert into a UDAF. Can also be created using [aggregatorOf].
 * @param nondeterministic Optional. If true, sets the UserDefinedFunction as nondeterministic.
 *
 * @return a [UserDefinedFunction1] that can be used as an aggregating expression
 *
 * @see udaf for a named variant.
 */


inline fun < reified IN , reified BUF , reified OUT > udaf ( noinline zero : ( ) -> BUF , noinline reduce : ( b : BUF , a : IN ) -> BUF , noinline merge : ( b1 : BUF , b2 : BUF ) -> BUF , noinline finish : ( reduction : BUF ) -> OUT , bufferEncoder : Encoder < BUF > = encoder ( ) , outputEncoder : Encoder < OUT > = encoder ( ) , nondeterministic : Boolean = false , ) : UserDefinedFunction1 < IN , OUT >

= udafUnnamed ( aggregatorOf ( zero = zero , reduce = reduce , merge = merge , finish = finish , bufferEncoder = bufferEncoder , outputEncoder = outputEncoder , ) , nondeterministic = nondeterministic , )

/**
 * Obtains a [UserDefinedFunction1] created from an [Aggregator] created by the given arguments
 * so that it may be used with Data Frames.
 * @see functions.udaf
 * @see aggregatorOf
 *
 * @param zero A zero value for this aggregation. Should satisfy the property that any b + zero = b.
 * @param reduce Combine two values to produce a new value. For performance, the function may modify `b` and
 * return it instead of constructing new object for b.
 * @param merge Merge two intermediate values.
 * @param finish Transform the output of the reduction.
 * @param bufferEncoder Optional. Specifies the `Encoder` for the intermediate value type.
 * @param outputEncoder Optional. Specifies the `Encoder` for the final output value type.
 * @param nondeterministic Optional. If true, sets the UserDefinedFunction as nondeterministic.
 *
 * @return a [UserDefinedFunction1] that can be used as an aggregating expression
 *
 * @see udaf for a named variant.
 */


inline fun < reified IN , reified BUF , reified OUT > udaf ( name : String , noinline zero : ( ) -> BUF , noinline reduce : ( b : BUF , a : IN ) -> BUF , noinline merge : ( b1 : BUF , b2 : BUF ) -> BUF , noinline finish : ( reduction : BUF ) -> OUT , bufferEncoder : Encoder < BUF > = encoder ( ) , outputEncoder : Encoder < OUT > = encoder ( ) , nondeterministic : Boolean = false , ) : NamedUserDefinedFunction1 < IN , OUT >

= udaf ( name = name , agg = aggregatorOf ( zero = zero , reduce = reduce , merge = merge , finish = finish , bufferEncoder = bufferEncoder , outputEncoder = outputEncoder , ) , nondeterministic = nondeterministic , )

/**
 * Obtains a [NamedUserDefinedFunction1] that wraps the given [agg] so that it may be used with Data Frames.
 * so that it may be used with Data Frames.
 * @see functions.udaf
 * @see aggregatorOf
 *
 * @param name Optional. Name for the UDAF.
 * @param zero A zero value for this aggregation. Should satisfy the property that any b + zero = b.
 * @param reduce Combine two values to produce a new value. For performance, the function may modify `b` and
 * return it instead of constructing new object for b.
 * @param merge Merge two intermediate values.
 * @param finish Transform the output of the reduction.
 * @param bufferEncoder Optional. Specifies the `Encoder` for the intermediate value type.
 * @param outputEncoder Optional. Specifies the `Encoder` for the final output value type.
 * @param nondeterministic Optional. If true, sets the UserDefinedFunction as nondeterministic.
 *
 * @return a [UserDefinedFunction1] that can be used as an aggregating expression
 *
 * @see udafUnnamed for an unnamed variant.
 */


inline fun < reified T1 , reified R > UDFRegistration . register ( name : String , agg : Aggregator < T1 , * , R > , nondeterministic : Boolean = false , ) : NamedUserDefinedFunction1 < T1 , R >

= register ( udaf ( name , agg , nondeterministic ) )

/**
 * Registers [agg] as a UDAF for SQL. Returns the UDAF as [NamedUserDefinedFunction].
 * Obtains a [NamedUserDefinedFunction1] that wraps the given [agg] so that it may be used with Data Frames.
 * @see UDFRegistration.register
 * @see functions.udaf
 *
 * @param agg the given [Aggregator] to convert into a UDAF. Can also be created using [aggregatorOf].
 * @param name Optional. Tries to obtain name from the class of [agg] if not supplied.
 * Use [udafUnnamed] if no name is wanted.
 * @param nondeterministic Optional. If true, sets the UserDefinedFunction as nondeterministic.
 *
 * @return a [NamedUserDefinedFunction1] that can be used as an aggregating expression
 */


inline fun < reified T1 , reified R > UDFRegistration . register ( agg : Aggregator < T1 , * , R > , nondeterministic : Boolean = false , ) : NamedUserDefinedFunction1 < T1 , R >

= register ( udaf ( agg , nondeterministic ) )


inline fun < reified IN , reified BUF , reified OUT > UDFRegistration . register ( name : String , noinline zero : ( ) -> BUF , noinline reduce : ( b : BUF , a : IN ) -> BUF , noinline merge : ( b1 : BUF , b2 : BUF ) -> BUF , noinline finish : ( reduction : BUF ) -> OUT , bufferEncoder : Encoder < BUF > = encoder ( ) , outputEncoder : Encoder < OUT > = encoder ( ) , nondeterministic : Boolean = false , ) : NamedUserDefinedFunction1 < IN , OUT >

= register ( udaf ( name , zero , reduce , merge , finish , bufferEncoder , outputEncoder , nondeterministic ) )

/**
 * Registers a UDAF for SQL based on the given arguments. Returns the UDAF as [NamedUserDefinedFunction].
 * Obtains a [NamedUserDefinedFunction1] that wraps the given [agg] so that it may be used with Data Frames.
 * @see UDFRegistration.register
 * @see functions.udaf
 *
 * @param name Optional. Name for the UDAF.
 * @param zero A zero value for this aggregation. Should satisfy the property that any b + zero = b.
 * @param reduce Combine two values to produce a new value. For performance, the function may modify `b` and
 * return it instead of constructing new object for b.
 * @param merge Merge two intermediate values.
 * @param finish Transform the output of the reduction.
 * @param bufferEncoder Optional. Specifies the `Encoder` for the intermediate value type.
 * @param outputEncoder Optional. Specifies the `Encoder` for the final output value type.
 * @param nondeterministic Optional. If true, sets the UserDefinedFunction as nondeterministic.
 *
 * @return a [NamedUserDefinedFunction1] that can be used as an aggregating expression.
 */


@ Test <EOL> fun testCleanupWithDynamicNonIncremental ( @ TempDir baseSourcesDir : File , @ TempDir outputDir : File , @ TempDir incrementalCacheDir : File , @ TempDir projectBaseDirFirstRun : File , @ TempDir projectBaseDirSecondRun : File )

{ <EOL> val sourcesDir = baseSourcesDir . resolve ( "<STR_LIT:test>" ) . also { base -> <EOL> base . mkdir ( ) <EOL> listOf ( "<STR_LIT>" , "<STR_LIT>" , "<STR_LIT>" ) . map { <EOL> TEST_DATA_DIR . resolve ( it ) . copyTo ( base . resolve ( it ) ) <EOL> } <EOL> } <EOL> val options = KaptOptions . Builder ( ) . apply { <EOL> projectBaseDir = projectBaseDirFirstRun <EOL> javaSourceRoots . add ( sourcesDir ) <EOL> sourcesOutputDir = outputDir <EOL> classesOutputDir = outputDir <EOL> stubsOutputDir = outputDir <EOL> incrementalDataOutputDir = outputDir <EOL> incrementalCache = incrementalCacheDir <EOL> } . build ( ) <EOL> val logger = WriterBackedKaptLogger ( isVerbose = true ) <EOL> KaptContext ( options , true , logger ) . use { <EOL> it . doAnnotationProcessing ( options . collectJavaSourceFiles ( SourcesToReprocess . FullRebuild ) , listOf ( DynamicProcessor ( RuntimeProcType . NON_INCREMENTAL ) . toDynamic ( ) ) ) <EOL> } <EOL> val optionsForSecondRun = KaptOptions . Builder ( ) . apply { <EOL> projectBaseDir = projectBaseDirSecondRun <EOL> javaSourceRoots . add ( sourcesDir ) <EOL> sourcesOutputDir = outputDir <EOL> classesOutputDir = outputDir <EOL> stubsOutputDir = outputDir <EOL> incrementalDataOutputDir = outputDir <EOL> incrementalCache = incrementalCacheDir <EOL> changedFiles . add ( sourcesDir . resolve ( "<STR_LIT>" ) ) <EOL> flags . add ( KaptFlag . INCREMENTAL_APT ) <EOL> } . build ( ) <EOL> KaptContext ( optionsForSecondRun , true , logger ) . use { <EOL> assertEquals ( SourcesToReprocess . FullRebuild , it . sourcesToReprocess ) <EOL> assertEquals ( listOf ( outputDir ) , outputDir . walkTopDown ( ) . toList ( ) ) <EOL> it . doAnnotationProcessing ( optionsForSecondRun . collectJavaSourceFiles ( it . sourcesToReprocess ) , listOf ( DynamicProcessor ( RuntimeProcType . NON_INCREMENTAL ) . toDynamic ( ) ) ) <EOL> } <EOL> assertTrue ( outputDir . resolve ( "<STR_LIT>" ) . exists ( ) ) <EOL> }


private fun findInheritableSimpleNames ( typeElement : KtTypeElement ) : List < String >

{ <EOL> return when ( typeElement ) { <EOL> is KtUserType -> { <EOL> val referenceName = typeElement . referencedName ? : return emptyList ( ) <EOL> buildList { <EOL> add ( referenceName ) <EOL> val ktFile = typeElement . containingKtFile <EOL> if ( ! ktFile . isCompiled ) { <EOL> addIfNotNull ( getImportedSimpleNameByImportAlias ( typeElement . containingKtFile , referenceName ) ) <EOL> } <EOL> } <EOL> } <EOL> is KtNullableType -> typeElement . innerType ? . let ( :: findInheritableSimpleNames ) ? : emptyList ( ) <EOL> else -> emptyList ( ) <EOL> } <EOL> }

/**
 * This is a simplified version of `KtTypeElement.index()` from the IDE. If we need to move more indexing code to Standalone, we should
 * consider moving more code from the IDE to the Analysis API.
 *
 * @see KotlinStaticDeclarationIndex.inheritableTypeAliasesByAliasedName
 */


fun throwExceptionIfCompilationFailed ( exitCode : ExitCode , executionStrategy : KotlinCompilerExecutionStrategy )

{ <EOL> when ( exitCode ) { <EOL> ExitCode . COMPILATION_ERROR -> throw CompilationErrorException ( "<STR_LIT>" ) <EOL> ExitCode . INTERNAL_ERROR -> throw FailedCompilationException ( "<STR_LIT>" ) <EOL> ExitCode . SCRIPT_EXECUTION_ERROR -> throw FailedCompilationException ( "<STR_LIT>" ) <EOL> ExitCode . OOM_ERROR -> throw OOMErrorException ( executionStrategy ) <EOL> ExitCode . OK -> Unit <EOL> else -> throw IllegalStateException ( "<STR_LIT>" ) <EOL> } <EOL> }

/** Throws [FailedCompilationException] if compilation completed with [exitCode] != [ExitCode.OK]. */


internal fun wrapAndRethrowCompilationException ( executionStrategy : KotlinCompilerExecutionStrategy , e : Throwable ) : Nothing

{ <EOL> if ( e is OutOfMemoryError || e . hasOOMCause ( ) ) { <EOL> throw OOMErrorException ( executionStrategy ) <EOL> } else if ( e is RemoteException ) { <EOL> throw DaemonCrashedException ( e ) <EOL> } else { <EOL> throw e <EOL> } <EOL> }

/**
 * Wraps an exception occurred during compiler execution.
 * Covers the case when compiler invocation failed before returning any [ExitCode].
 * Always throws some kind of exception.
 */


@ ExperimentalSerializationApi <EOL> public fun decodeNotNullMark ( ) : Boolean

/**
 * Returns `true` if the current value in decoder is not null, false otherwise.
 * This method is usually used to decode potentially nullable data:
 * ```
 * // Could be String? deserialize() method
 * public fun deserialize(decoder: Decoder): String? {
 * if (decoder.decodeNotNullMark()) {
 * return decoder.decodeString()
 * } else {
 * return decoder.decodeNull()
 * }
 * }
 * ```
 */


@ ExperimentalSerializationApi <EOL> public fun decodeNull ( ) : Nothing ?

/**
 * Decodes the `null` value and returns it.
 *
 * It is expected that `decodeNotNullMark` was called
 * prior to `decodeNull` invocation and the case when it returned `true` was handled.
 */


public fun decodeBoolean ( ) : Boolean

/**
 * Decodes a boolean value.
 * Corresponding kind is [PrimitiveKind.BOOLEAN].
 */


public fun decodeByte ( ) : Byte

/**
 * Decodes a single byte value.
 * Corresponding kind is [PrimitiveKind.BYTE].
 */


public fun decodeShort ( ) : Short

/**
 * Decodes a 16-bit short value.
 * Corresponding kind is [PrimitiveKind.SHORT].
 */


public fun decodeChar ( ) : Char

/**
 * Decodes a 16-bit unicode character value.
 * Corresponding kind is [PrimitiveKind.CHAR].
 */


public fun decodeInt ( ) : Int

/**
 * Decodes a 32-bit integer value.
 * Corresponding kind is [PrimitiveKind.INT].
 */


public fun decodeLong ( ) : Long

/**
 * Decodes a 64-bit integer value.
 * Corresponding kind is [PrimitiveKind.LONG].
 */


public fun decodeFloat ( ) : Float

/**
 * Decodes a 32-bit IEEE 754 floating point value.
 * Corresponding kind is [PrimitiveKind.FLOAT].
 */


public fun decodeDouble ( ) : Double

/**
 * Decodes a 64-bit IEEE 754 floating point value.
 * Corresponding kind is [PrimitiveKind.DOUBLE].
 */


public fun decodeString ( ) : String

/**
 * Decodes a string value.
 * Corresponding kind is [PrimitiveKind.STRING].
 */


public fun decodeEnum ( enumDescriptor : SerialDescriptor ) : Int

/**
 * Decodes a enum value and returns its index in [enumDescriptor] elements collection.
 * Corresponding kind is [SerialKind.ENUM].
 *
 * E.g. for the enum `enum class Letters { A, B, C, D }` and
 * underlying input "C", [decodeEnum] method should return `2` as a result.
 *
 * This method does not imply any restrictions on the input format,
 * the format is free to store the enum by its name, index, ordinal or any other enum representation.
 */


public fun decodeInline ( descriptor : SerialDescriptor ) : Decoder

/**
 * Returns [Decoder] for decoding an underlying type of a value class in an inline manner.
 * [descriptor] describes a target value class.
 *
 * Namely, for the `@Serializable @JvmInline value class MyInt(val my: Int)`, the following sequence is used:
 * ```
 * thisDecoder.decodeInline(MyInt.serializer().descriptor).decodeInt()
 * ```
 *
 * Current decoder may return any other instance of [Decoder] class, depending on the provided [descriptor].
 * For example, when this function is called on `Json` decoder with
 * `UInt.serializer().descriptor`, the returned decoder is able to decode unsigned integers.
 *
 * Note that this function returns [Decoder] instead of the [CompositeDecoder]
 * because value classes always have the single property.
 *
 * Calling [Decoder.beginStructure] on returned instance leads to an unspecified behavior and, in general, is prohibited.
 */


public fun beginStructure ( descriptor : SerialDescriptor ) : CompositeDecoder

/**
 * Decodes the beginning of the nested structure in a serialized form
 * and returns [CompositeDecoder] responsible for decoding this very structure.
 *
 * Typically, classes, collections and maps are represented as a nested structure in a serialized form.
 * E.g. the following JSON
 * ```
 * {
 * "a": 2,
 * "b": { "nested": "c" }
 * "c": [1, 2, 3],
 * "d": null
 * }
 * ```
 * has three nested structures: the very beginning of the data, "b" value and "c" value.
 */


public fun < T : Any ? > decodeSerializableValue ( deserializer : DeserializationStrategy < T > ) : T

= <EOL> deserializer . deserialize ( this )

/**
 * Decodes the value of type [T] by delegating the decoding process to the given [deserializer].
 * For example, `decodeInt` call us equivalent to delegating integer decoding to [Int.serializer][Int.Companion.serializer]:
 * `decodeSerializableValue(IntSerializer)`
 */


@ ExperimentalSerializationApi <EOL> public fun < T : Any > decodeNullableSerializableValue ( deserializer : DeserializationStrategy < T ? > ) : T ?

= decodeIfNullable ( deserializer ) { <EOL> decodeSerializableValue ( deserializer ) <EOL> }

/**
 * Decodes the nullable value of type [T] by delegating the decoding process to the given [deserializer].
 */


public fun endStructure ( descriptor : SerialDescriptor )

/**
 * Denotes the end of the structure associated with current decoder.
 * For example, composite decoder of JSON format will expect (and parse)
 * a closing bracket in the underlying input.
 */


@ ExperimentalSerializationApi <EOL> public fun decodeSequentially ( ) : Boolean

= false

/**
 * Checks whether the current decoder supports strictly ordered decoding of the data
 * without calling to [decodeElementIndex].
 * If the method returns `true`, the caller might skip [decodeElementIndex] calls
 * and start invoking `decode*Element` directly, incrementing the index of the element one by one.
 * This method can be called by serializers (either generated or user-defined) as a performance optimization,
 * but there is no guarantee that the method will be ever called. Practically, it means that implementations
 * that may benefit from sequential decoding should also support a regular [decodeElementIndex]-based decoding as well.
 *
 * Example of usage:
 * ```
 * class MyPair(i: Int, d: Double)
 *
 * object MyPairSerializer : KSerializer<MyPair> {
 * // ... other methods omitted
 *
 * fun deserialize(decoder: Decoder): MyPair {
 * val composite = decoder.beginStructure(descriptor)
 * if (composite.decodeSequentially()) {
 * val i = composite.decodeIntElement(descriptor, index = 0) // Mind the sequential indexing
 * val d = composite.decodeIntElement(descriptor, index = 1)
 * composite.endStructure(descriptor)
 * return MyPair(i, d)
 * } else {
 * // Fallback to `decodeElementIndex` loop, refer to its documentation for details
 * }
 * }
 * }
 * ```
 * This example is a rough equivalent of what serialization plugin generates for serializable pair class.
 *
 * Sequential decoding is a performance optimization for formats with strictly ordered schema,
 * usually binary ones. Regular formats such as JSON or ProtoBuf cannot use this optimization,
 * because e.g. in the latter example, the same data can be represented both as
 * `{"i": 1, "d": 1.0}`"` and `{"d": 1.0, "i": 1}` (thus, unordered).
 */


public fun decodeElementIndex ( descriptor : SerialDescriptor ) : Int

/**
 * Decodes the index of the next element to be decoded.
 * Index represents a position of the current element in the serial descriptor element that can be found
 * with [SerialDescriptor.getElementIndex].
 *
 * If this method returns non-negative index, the caller should call one of the `decode*Element` methods
 * with a resulting index.
 * Apart from positive values, this method can return [DECODE_DONE] to indicate that no more elements
 * are left or [UNKNOWN_NAME] to indicate that symbol with an unknown name was encountered.
 *
 * Example of usage:
 * ```
 * class MyPair(i: Int, d: Double)
 *
 * object MyPairSerializer : KSerializer<MyPair> {
 * // ... other methods omitted
 *
 * fun deserialize(decoder: Decoder): MyPair {
 * val composite = decoder.beginStructure(descriptor)
 * var i: Int? = null
 * var d: Double? = null
 * while (true) {
 * when (val index = composite.decodeElementIndex(descriptor)) {
 * 0 -> i = composite.decodeIntElement(descriptor, 0)
 * 1 -> d = composite.decodeDoubleElement(descriptor, 1)
 * DECODE_DONE -> break // Input is over
 * else -> error("Unexpected index: $index)
 * }
 * }
 * composite.endStructure(descriptor)
 * require(i != null && d != null)
 * return MyPair(i, d)
 * }
 * }
 * ```
 * This example is a rough equivalent of what serialization plugin generates for serializable pair class.
 *
 * The need in such a loop comes from unstructured nature of most serialization formats.
 * For example, JSON for the following input `{"d": 2.0, "i": 1}`, will first read `d` key with index `1`
 * and only after `i` with the index `0`.
 *
 * A potential implementation of this method for JSON format can be the following:
 * ```
 * fun decodeElementIndex(descriptor: SerialDescriptor): Int {
 * // Ignore arrays
 * val nextKey: String? = myStringJsonParser.nextKey()
 * if (nextKey == null) return DECODE_DONE
 * return descriptor.getElementIndex(nextKey) // getElementIndex can return UNKNOWN_NAME
 * }
 * ```
 *
 * If [decodeSequentially] returns `true`, the caller might skip calling this method.
 */


public fun decodeCollectionSize ( descriptor : SerialDescriptor ) : Int

= - <NUM_LIT:1>

/**
 * Method to decode collection size that may be called before the collection decoding.
 * Collection type includes [Collection], [Map] and [Array] (including primitive arrays).
 * Method can return `-1` if the size is not known in advance, though for [sequential decoding][decodeSequentially]
 * knowing precise size is a mandatory requirement.
 */


public fun decodeBooleanElement ( descriptor : SerialDescriptor , index : Int ) : Boolean

/**
 * Decodes a boolean value from the underlying input.
 * The resulting value is associated with the [descriptor] element at the given [index].
 * The element at the given index should have [PrimitiveKind.BOOLEAN] kind.
 */


public fun decodeByteElement ( descriptor : SerialDescriptor , index : Int ) : Byte

/**
 * Decodes a single byte value from the underlying input.
 * The resulting value is associated with the [descriptor] element at the given [index].
 * The element at the given index should have [PrimitiveKind.BYTE] kind.
 */


public fun decodeCharElement ( descriptor : SerialDescriptor , index : Int ) : Char

/**
 * Decodes a 16-bit unicode character value from the underlying input.
 * The resulting value is associated with the [descriptor] element at the given [index].
 * The element at the given index should have [PrimitiveKind.CHAR] kind.
 */


public fun decodeShortElement ( descriptor : SerialDescriptor , index : Int ) : Short

/**
 * Decodes a 16-bit short value from the underlying input.
 * The resulting value is associated with the [descriptor] element at the given [index].
 * The element at the given index should have [PrimitiveKind.SHORT] kind.
 */


public fun decodeIntElement ( descriptor : SerialDescriptor , index : Int ) : Int

/**
 * Decodes a 32-bit integer value from the underlying input.
 * The resulting value is associated with the [descriptor] element at the given [index].
 * The element at the given index should have [PrimitiveKind.INT] kind.
 */


public fun decodeLongElement ( descriptor : SerialDescriptor , index : Int ) : Long

/**
 * Decodes a 64-bit integer value from the underlying input.
 * The resulting value is associated with the [descriptor] element at the given [index].
 * The element at the given index should have [PrimitiveKind.LONG] kind.
 */


public fun decodeFloatElement ( descriptor : SerialDescriptor , index : Int ) : Float

/**
 * Decodes a 32-bit IEEE 754 floating point value from the underlying input.
 * The resulting value is associated with the [descriptor] element at the given [index].
 * The element at the given index should have [PrimitiveKind.FLOAT] kind.
 */


public fun decodeDoubleElement ( descriptor : SerialDescriptor , index : Int ) : Double

/**
 * Decodes a 64-bit IEEE 754 floating point value from the underlying input.
 * The resulting value is associated with the [descriptor] element at the given [index].
 * The element at the given index should have [PrimitiveKind.DOUBLE] kind.
 */


public fun decodeStringElement ( descriptor : SerialDescriptor , index : Int ) : String

/**
 * Decodes a string value from the underlying input.
 * The resulting value is associated with the [descriptor] element at the given [index].
 * The element at the given index should have [PrimitiveKind.STRING] kind.
 */


public fun decodeInlineElement ( descriptor : SerialDescriptor , index : Int ) : Decoder

/**
 * Returns [Decoder] for decoding an underlying type of a value class in an inline manner.
 * Serializable value class is described by the [child descriptor][SerialDescriptor.getElementDescriptor]
 * of given [descriptor] at [index].
 *
 * Namely, for the `@Serializable @JvmInline value class MyInt(val my: Int)`,
 * and `@Serializable class MyData(val myInt: MyInt)` the following sequence is used:
 * ```
 * thisDecoder.decodeInlineElement(MyData.serializer().descriptor, 0).decodeInt()
 * ```
 *
 * This method provides an opportunity for the optimization to avoid boxing of a carried value
 * and its invocation should be equivalent to the following:
 * ```
 * thisDecoder.decodeSerializableElement(MyData.serializer.descriptor, 0, MyInt.serializer())
 * ```
 *
 * Current decoder may return any other instance of [Decoder] class, depending on the provided descriptor.
 * For example, when this function is called on `Json` decoder with descriptor that has
 * `UInt.serializer().descriptor` at the given [index], the returned decoder is able
 * to decode unsigned integers.
 *
 * Note that this function returns [Decoder] instead of the [CompositeDecoder]
 * because value classes always have the single property.
 * Calling [Decoder.beginStructure] on returned instance leads to an unspecified behavior and, in general, is prohibited.
 *
 * @see Decoder.decodeInline
 * @see SerialDescriptor.getElementDescriptor
 */


public fun < T : Any ? > decodeSerializableElement ( descriptor : SerialDescriptor , index : Int , deserializer : DeserializationStrategy < T > , previousValue : T ? = null ) : T

/**
 * Decodes value of the type [T] with the given [deserializer].
 *
 * Implementations of [CompositeDecoder] may use their format-specific deserializers
 * for particular data types, e.g. handle [ByteArray] specifically if format is binary.
 *
 * If value at given [index] was already decoded with previous [decodeSerializableElement] call with the same index,
 * [previousValue] would contain a previously decoded value.
 * This parameter can be used to aggregate multiple values of the given property to the only one.
 * Implementation can safely ignore it and return a new value, effectively using 'the last one wins' strategy,
 * or apply format-specific aggregating strategies, e.g. appending scattered Protobuf lists to a single one.
 */


@ ExperimentalSerializationApi <EOL> public fun < T : Any > decodeNullableSerializableElement ( descriptor : SerialDescriptor , index : Int , deserializer : DeserializationStrategy < T ? > , previousValue : T ? = null ) : T ?

/**
 * Decodes nullable value of the type [T] with the given [deserializer].
 *
 * If value at given [index] was already decoded with previous [decodeSerializableElement] call with the same index,
 * [previousValue] would contain a previously decoded value.
 * This parameter can be used to aggregate multiple values of the given property to the only one.
 * Implementation can safely ignore it and return a new value, efficiently using 'the last one wins' strategy,
 * or apply format-specific aggregating strategies, e.g. appending scattered Protobuf lists to a single one.
 */


public inline fun < T > Decoder . decodeStructure ( descriptor : SerialDescriptor , crossinline block : CompositeDecoder . ( ) -> T ) : T

{ <EOL> val composite = beginStructure ( descriptor ) <EOL> val result = composite . block ( ) <EOL> composite . endStructure ( descriptor ) <EOL> return result <EOL> }

/**
 * Begins a structure, decodes it using the given [block], ends it and returns decoded element.
 */


/**
 * [kotlin.collections.listO<caret>f]
 */


private fun isReceiverAncestor ( descriptor : DeclarationDescriptor ) : Boolean

{ <EOL> if ( descriptor !is ReceiverParameterDescriptor ) return false <EOL> if ( containingDescriptor !is ClassDescriptor && containingDescriptor !is ConstructorDescriptor ) return false <EOL> val containingClass = getParentOfType ( containingDescriptor , ClassDescriptor :: class . java , false ) ? : return false <EOL> val currentClass = descriptor . containingDeclaration as? ClassDescriptor ? : return false <EOL> for ( outerDeclaration in generateSequence ( containingClass ) { it . containingDeclaration as? ClassDescriptor } ) { <EOL> if ( outerDeclaration == currentClass ) return true <EOL> } <EOL> return false <EOL> }

/**
 * We shouldn't capture current `this` or outer `this`. Assuming `C` is current translating class,
 * we have `descriptor == A::this` in the following cases:
 * * `A == C`
 * * `C` in inner class of `A`
 * * `A <: C`
 * * among outer classes of `C` there is `T` such that `A <: T`
 *
 * If fact, the latter case is the generalization of all previous cases, assuming that `is inner class of` and `<:` relations
 * are reflective. All this cases allow to refer to `this` directly or via sequence of `outer` fields.
 *
 * Note that the continuous sequence of inner classes may be interrupted by non-class descriptor. This means that
 * the last class of the sequence if a local class. We stop there, since this means that the next class in the sequence
 * is referred by closure variable rather than by dedicated `$outer` field.
 *
 * The nested classes are out of scope, since nested class can't refer to outer's class `this`, thus frontend will
 * never generate ReceiverParameterDescriptor for this case.
 */


private fun isSingletonReceiver ( descriptor : DeclarationDescriptor ) : Boolean

{ <EOL> if ( descriptor !is ReceiverParameterDescriptor ) return false <EOL> val container = descriptor . containingDeclaration <EOL> if ( ! DescriptorUtils . isObject ( container ) ) return false <EOL> if ( containingDescriptor !is ClassDescriptor ) { <EOL> val containingClass = getParentOfType ( containingDescriptor , ClassDescriptor :: class . java , false ) <EOL> if ( containingClass == container ) return false <EOL> } <EOL> return true <EOL> }

/**
 * Test for the case like this:
 *
 * ```
 * object A {
 * var x: Int
 *
 * class B {
 * fun foo() {
 * { x }
 * }
 * }
 * }
 * ```
 *
 * We don't want to capture `A::this`, since we always can refer A by its FQN
 */


public fun isApplicable ( customTag : CustomTagWrapper ) : Boolean

/**
 * Whether this content provider supports given [CustomTagWrapper].
 *
 * Tags can be filtered out either by name or by nested [DocTag] type
 */


public fun DocumentableContentBuilder . contentForDescription ( sourceSet : DokkaSourceSet , customTag : CustomTagWrapper )

/**
 * Full blown content description, most likely to be on a separate page
 * dedicated to just one element (i.e one class/function), so any
 * amount of detail should be fine.
 */


public fun DocumentableContentBuilder . contentForBrief ( sourceSet : DokkaSourceSet , customTag : CustomTagWrapper )

/**
 * Brief comment section, usually displayed as a summary/preview.
 *
 * For instance, when listing all functions of a class on one page,
 * it'll be too much to display complete documentation for each function.
 * Instead, a small brief is shown for each one (i.e the first paragraph
 * or some other important information) - the user can go to the dedicated
 * page for more details if they find the brief interesting.
 *
 * Tag-wise, it would make sense to include `Since Kotlin`, since it's
 * important information for the users of stdlib. It would make little
 * sense to include `@usesMathjax` here, as this information seems
 * to be more specific and detailed than is needed for a brief.
 */


public fun < T > symbol ( column : ColumnReference < T > , parameters : LetsPlotNonPositionalMappingParametersCategorical < T , Symbol > . ( ) -> Unit = { } ) : NonPositionalMapping < T , Symbol >

{ <EOL> return addNonPositionalMapping < T , Symbol > ( SHAPE , column . name ( ) , LetsPlotNonPositionalMappingParametersCategorical < T , Symbol > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the symbol aesthetic to a data column by [ColumnReference].
 *
 * @param column the data column to map to the symbol.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


public fun < T > symbol ( column : KProperty < T > , parameters : LetsPlotNonPositionalMappingParametersCategorical < T , Symbol > . ( ) -> Unit = { } ) : NonPositionalMapping < T , Symbol >

{ <EOL> return addNonPositionalMapping < T , Symbol > ( SHAPE , column . name , LetsPlotNonPositionalMappingParametersCategorical < T , Symbol > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the symbol aesthetic to a data column by [KProperty].
 *
 * @param column the data column to map to the symbol.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


public fun symbol ( column : String , parameters : LetsPlotNonPositionalMappingParametersCategorical < Any ? , Symbol > . ( ) -> Unit = { } ) : NonPositionalMapping < Any ? , Symbol >

{ <EOL> return addNonPositionalMapping ( SHAPE , column , LetsPlotNonPositionalMappingParametersCategorical < Any ? , Symbol > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the symbol aesthetic to a data column by [String].
 *
 * @param column the data column to map to the symbol.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


public fun < T > symbol ( values : Iterable < T > , name : String ? = null , parameters : LetsPlotNonPositionalMappingParametersCategorical < T , Symbol > . ( ) -> Unit = { } ) : NonPositionalMapping < T , Symbol >

{ <EOL> return addNonPositionalMapping ( SHAPE , values . toList ( ) , name , LetsPlotNonPositionalMappingParametersCategorical < T , Symbol > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the symbol aesthetic to iterable of values.
 *
 * @param values the iterable containing the categorical values.
 * @param name optional name for this aesthetic mapping.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


public fun < T > symbol ( values : DataColumn < T > , parameters : LetsPlotNonPositionalMappingParametersCategorical < T , Symbol > . ( ) -> Unit = { } ) : NonPositionalMapping < T , Symbol >

{ <EOL> return addNonPositionalMapping ( SHAPE , values , LetsPlotNonPositionalMappingParametersCategorical < T , Symbol > ( ) . apply ( parameters ) ) <EOL> }

/**
 * Maps the symbol aesthetic to a data column.
 *
 * @param values the data column to map to the symbol.
 * @param parameters optional lambda to configure additional scale parameters.
 * @return a [NonPositionalMapping] object representing the mapping.
 */


public abstract fun < T : InferenceModel < * > , U > loadModel ( modelType : ModelType < T , U > , loadingMode : LoadingMode = LoadingMode . SKIP_LOADING_IF_EXISTS ) : T

/**
 * Loads model configuration without weights.
 *
 * @param [modelType] This unique identifier defines the way to the S3 bucket with the model and its weights and the local directory for the model and its weights.
 * @param [loadingMode] Strategy of existing model use-case handling.
 * @return Raw model without weights. Needs in compilation and weights loading before usage.
 */


public fun < T : InferenceModel < * > , U > loadPretrainedModel ( modelType : ModelType < T , U > , loadingMode : LoadingMode = LoadingMode . SKIP_LOADING_IF_EXISTS ) : U

{ <EOL> return modelType . pretrainedModel ( this ) <EOL> }

/**
 * Loads pretrained model of [modelType] from the ModelHub in [loadingMode].
 *
 * @param [modelType] This unique identifier defines the way to the S3 bucket with the model and its weights and the local directory for the model and its weights.
 * @param [loadingMode] Strategy of existing model use-case handling.
 * @return Pretrained model.
 */


public operator fun < T : InferenceModel < * > , U > get ( modelType : ModelType < T , U > ) : U

{ <EOL> return loadPretrainedModel ( modelType = modelType ) <EOL> }

/**
 * This operator equivalent to [loadPretrainedModel].
 */


public fun cleanupTestCoroutines ( )

/**
 * Call after the test completes to ensure that there were no uncaught exceptions.
 *
 * The first exception in uncaughtExceptions is rethrown. All other exceptions are
 * printed using [Throwable.printStackTrace].
 *
 * @throws Throwable the first uncaught exception, if there are any uncaught exceptions.
 */


public fun Source . asNSInputStream ( ) : NSInputStream

= SourceNSInputStream ( this )

/**
 * Returns an input stream that reads from this source. Closing the stream will also close this source.
 *
 * The stream supports both polling and run-loop scheduling, please check
 * [Apple's documentation](https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/Streams/Articles/PollingVersusRunloop.html)
 * for information about stream events handling.
 *
 * The stream does not implement initializers
 * ([NSInputStream.initWithURL](https://developer.apple.com/documentation/foundation/nsinputstream/1417891-initwithurl),
 * [NSInputStream.initWithData](https://developer.apple.com/documentation/foundation/nsinputstream/1412470-initwithdata),
 * [NSInputStream.initWithFileAtPath](https://developer.apple.com/documentation/foundation/nsinputstream/1408976-initwithfileatpath)),
 * their use will result in a runtime error.
 *
 * @sample kotlinx.io.samples.KotlinxIoSamplesApple.asStream
 */


protected fun computeOutputShape ( inputShape : Shape ) : Shape

{ <EOL> val shapes = ( kernelSize . indices ) . map { <EOL> convTransposeOutputLength ( inputShape . size ( it + <NUM_LIT:1> ) , kernelSize [ it ] , padding , outputPadding ? . get ( <NUM_LIT:2> * ( it + <NUM_LIT:1> ) ) , outputPadding ? . get ( <NUM_LIT:2> * ( it + <NUM_LIT:1> ) + <NUM_LIT:1> ) , strides [ it + <NUM_LIT:1> ] , dilations [ it + <NUM_LIT:1> ] ) <EOL> } <EOL> return Shape . make ( inputShape . size ( <NUM_LIT:0> ) , * ( shapes + filters . toLong ( ) ) . toLongArray ( ) ) <EOL> }

/**
 * Computes the output shape of the layer given the input shape.
 */


internal fun IntArray . withStandardPadding ( padding : ConvPadding , kernelSize : IntArray , dilations : IntArray ) : IntArray

{ <EOL> val withStandardPadding = kernelSize . indices . flatMap { dim -> <EOL> convTransposePadding ( padding , this [ <NUM_LIT:2> * dim ] , this [ <NUM_LIT:2> * dim + <NUM_LIT:1> ] , kernelSize [ dim ] , dilations [ dim + <NUM_LIT:1> ] ) <EOL> } <EOL> return intArrayOf ( <NUM_LIT:0> , <NUM_LIT:0> , * ( withStandardPadding . toIntArray ( ) ) , <NUM_LIT:0> , <NUM_LIT:0> ) <EOL> }

/**
 * Combines explicitly provided padding value with the standard padding from the provided padding method.
 * This is needed since [org.tensorflow.op.NnOps.conv2dBackpropInput] function does not support specifying
 * both padding method and explicit output padding at the same time.
 */


internal fun buildOptions ( dilations : IntArray , outputPadding : IntArray ? ) : Array < Conv2dBackpropInput . Options >

{ <EOL> val options = mutableListOf ( Conv2dBackpropInput . dilations ( dilations . toLongList ( ) ) ) <EOL> if ( outputPadding != null ) { <EOL> options . add ( Conv2dBackpropInput . explicitPaddings ( outputPadding . toLongList ( ) ) ) <EOL> } <EOL> return options . map { it . dataFormat ( "<STR_LIT>" ) } . toTypedArray ( ) <EOL> }

/**
 * Builds options to pass dilations and output padding to the [org.tensorflow.op.NnOps.conv2dBackpropInput].
 */


internal fun Ops . shapeWithDynamicBatchSize ( tensorShape : TensorShape , input : Operand < Float > ) : Operand < Int >

{ <EOL> val batchSize = squeeze ( slice ( shape ( input ) , constant ( intArrayOf ( <NUM_LIT:0> ) ) , constant ( intArrayOf ( <NUM_LIT:1> ) ) ) ) <EOL> val otherDims = tensorShape . dims ( ) . toList ( ) . drop ( <NUM_LIT:1> ) . map { constant ( it . toInt ( ) ) } <EOL> return stack ( listOf ( batchSize ) + otherDims ) <EOL> }

/**
 * Creates an integer vector with the contents of [tensorShape], except for the first dimension (batch size):
 * batch size from the [input] is used instead.
 * This is needed as [org.tensorflow.op.NnOps.conv2dBackpropInput] and [org.tensorflow.op.NnOps.conv3dBackpropInput]
 * need to have an exact shape provided, including batch size.
 * Typically, when the layer is built, batch size is not known and [tensorShape] contains a "-1" instead.
 * This why here a first value of the [input] shape is used, which is going to be known at runtime.
 * See also [https://github.com/tensorflow/tensorflow/issues/833](https://github.com/tensorflow/tensorflow/issues/833)
 */


@ Throws ( IndexOutOfBoundsException :: class ) <EOL> fun getCell ( id : Int ) : CodeCell

/**
 * Mapping allowing to get cell by execution number
 */


@ Throws ( IndexOutOfBoundsException :: class ) <EOL> fun getResult ( id : Int ) : Any ?

/**
 * Mapping allowing to get result by execution number
 */


fun getAllDisplays ( ) : List < DisplayResultWithCell >

/**
 * Information about all display data objects
 */


fun getDisplaysById ( id : String ? ) : List < DisplayResultWithCell >

/**
 * Information about displays with the given [id]
 */


fun history ( before : Int ) : CodeCell ?

/**
 * Get cell by relative offset: 0 for current cell,
 * 1 for previous cell, and so on
 *
 * @param before Relative offset
 * @return Cell from history
 */


fun changeColorScheme ( newScheme : ColorScheme )

/**
 * Change color scheme and run callbacks. Works correctly only in Kotlin Notebook plugin
 */


fun renderHtmlAsIFrame ( data : HtmlData ) : MimeTypedResult

/**
 * Renders HTML as iframe that fixes scrolling and color scheme issues in Kotlin Notebook plugin
 */


public fun toRawFloatArray ( image : BufferedImage , colorMode : ColorMode ? = null ) : FloatArray

{ <EOL> return imageToFloatArray ( image , colorMode ) <EOL> }

/**
 * Converts [image] to [FloatArray] without normalization.
 *
 * @param [image] image to convert
 * @param [colorMode] color mode to convert the image to. `null` value keeps the original color mode.
 * @return [FloatArray] with pixel values in the `[0, 255]` range
 * */


public fun toRawFloatArray ( inputStream : InputStream , colorMode : ColorMode ? = null ) : FloatArray

{ <EOL> return toRawFloatArray ( toBufferedImage ( inputStream ) , colorMode ) <EOL> }

/**
 * Reads the image from [inputStream] and converts it to [FloatArray] without normalization.
 *
 * @param [inputStream] source of the image to convert
 * @param [colorMode] color mode to convert the image to. `null` value keeps the original color mode.
 * @return [FloatArray] with pixel values in `[0, 255]` range
 * */


public fun toRawFloatArray ( imageFile : File , colorMode : ColorMode ? = null ) : FloatArray

{ <EOL> return imageFile . inputStream ( ) . use { toRawFloatArray ( it , colorMode ) } <EOL> }

/**
 * Reads the image from [imageFile] and converts it to [FloatArray] without normalization.
 *
 * @param [imageFile] source of the image to convert
 * @param [colorMode] color mode to convert the image to. `null` value keeps the original color mode.
 * @return [FloatArray] with pixel values in the `[0, 255]` range
 * */


public fun toNormalizedFloatArray ( image : BufferedImage , colorMode : ColorMode ? = null ) : FloatArray

{ <EOL> return toRawFloatArray ( image , colorMode ) . also { normalize ( it ) } <EOL> }

/**
 * Converts [image] to [FloatArray] and scales the values, so they would fit into the `[0, 1)` range.
 *
 * @param [image] image to convert
 * @param [colorMode] color mode to convert the image to. `null` value keeps the original color mode.
 * @return [FloatArray] with pixel values in the `[0, 1)` range
 * */


public fun toNormalizedFloatArray ( inputStream : InputStream , colorMode : ColorMode ? = null ) : FloatArray

{ <EOL> return toNormalizedFloatArray ( toBufferedImage ( inputStream ) , colorMode ) <EOL> }

/**
 * Reads the image from [inputStream], converts it to [FloatArray] and scales the values,
 * so they would fit into the `[0, 1)` range.
 *
 * @param [inputStream] source of the image to convert
 * @param [colorMode] color mode to convert the image to. `null` value keeps the original color mode.
 * @return [FloatArray] with pixel values in the `[0, 1)` range
 * */


public fun toNormalizedFloatArray ( imageFile : File , colorMode : ColorMode ? = null ) : FloatArray

{ <EOL> return imageFile . inputStream ( ) . use { toNormalizedFloatArray ( it , colorMode ) } <EOL> }

/**
 * Reads the image from [imageFile], converts it to [FloatArray] and scales the values,
 * so they would fit into the `[0, 1)` range.
 *
 * @param [imageFile] source of the image to convert
 * @param [colorMode] color mode to convert the image to. `null` value keeps the original color mode.
 * @return [FloatArray] with pixel values in the `[0, 1)` range
 * */


@ Throws ( IOException :: class ) <EOL> public fun toBufferedImage ( inputStream : InputStream ) : BufferedImage

{ <EOL> ImageIO . setUseCache ( false ) <EOL> return ImageIO . read ( inputStream ) <EOL> }

/**
 * Returns [BufferedImage] extracted from [inputStream].
 *
 * @param [inputStream] source of the image
 */


@ Throws ( IOException :: class ) <EOL> public fun toBufferedImage ( file : File ) : BufferedImage

{ <EOL> return file . inputStream ( ) . use { inputStream -> toBufferedImage ( inputStream ) } <EOL> }

/**
 * Returns [BufferedImage] extracted from [file].
 *
 * @param [file] source of the image
 */


public fun swapRandB ( image : FloatArray )

{ <EOL> for ( i in image . indices step <NUM_LIT:3> ) { <EOL> val tmp = image [ i ] <EOL> image [ i ] = image [ i + <NUM_LIT:2> ] <EOL> image [ i + <NUM_LIT:2> ] = tmp <EOL> } <EOL> }

/**
 * Given a float array representing an image, swaps red and green channels in it.
 *
 * @param [image] image to swap channels in
 */


public fun imageTo3DFloatArray ( image : BufferedImage , colorMode : ColorMode = ColorMode . BGR ) : Array < Array < FloatArray > >

{ <EOL> val pixels = ( image . raster . dataBuffer as DataBufferByte ) . data <EOL> val width = image . width <EOL> val height = image . height <EOL> val hasAlphaChannel = image . alphaRaster != null <EOL> val lastDimensions = if ( hasAlphaChannel ) <NUM_LIT:4> else <NUM_LIT:3> <EOL> val result = Array ( height ) { Array ( width ) { FloatArray ( lastDimensions ) } } <EOL> if ( hasAlphaChannel ) { <EOL> val pixelLength = <NUM_LIT:4> <EOL> var pixel = <NUM_LIT:0> <EOL> var row = <NUM_LIT:0> <EOL> var col = <NUM_LIT:0> <EOL> while ( pixel < pixels . size ) { <EOL> result [ row ] [ col ] [ <NUM_LIT:3> ] = ( pixels [ pixel ] . toInt ( ) and <NUM_LIT> shl <NUM_LIT> ) . toFloat ( ) <EOL> result [ row ] [ col ] [ <NUM_LIT:0> ] = ( pixels [ pixel + <NUM_LIT:1> ] . toInt ( ) and <NUM_LIT> ) . toFloat ( ) <EOL> if ( colorMode == ColorMode . RGB ) { <EOL> result [ row ] [ col ] [ <NUM_LIT:1> ] = ( pixels [ pixel + <NUM_LIT:2> ] . toInt ( ) and <NUM_LIT> shl <NUM_LIT:8> ) . toFloat ( ) <EOL> result [ row ] [ col ] [ <NUM_LIT:2> ] = ( pixels [ pixel + <NUM_LIT:3> ] . toInt ( ) and <NUM_LIT> shl <NUM_LIT:16> ) . toFloat ( ) <EOL> } else { <EOL> result [ row ] [ col ] [ <NUM_LIT:2> ] = ( pixels [ pixel + <NUM_LIT:2> ] . toInt ( ) and <NUM_LIT> shl <NUM_LIT:8> ) . toFloat ( ) <EOL> result [ row ] [ col ] [ <NUM_LIT:1> ] = ( pixels [ pixel + <NUM_LIT:3> ] . toInt ( ) and <NUM_LIT> shl <NUM_LIT:16> ) . toFloat ( ) <EOL> } <EOL> col ++ <EOL> if ( col == width ) { <EOL> col = <NUM_LIT:0> <EOL> row ++ <EOL> } <EOL> pixel += pixelLength <EOL> } <EOL> } else { <EOL> val pixelLength = <NUM_LIT:3> <EOL> var pixel = <NUM_LIT:0> <EOL> var row = <NUM_LIT:0> <EOL> var col = <NUM_LIT:0> <EOL> while ( pixel < pixels . size ) { <EOL> result [ row ] [ col ] [ <NUM_LIT:0> ] = ( pixels [ pixel ] . toInt ( ) and <NUM_LIT> ) . toFloat ( ) <EOL> if ( colorMode == ColorMode . RGB ) { <EOL> result [ row ] [ col ] [ <NUM_LIT:1> ] = ( pixels [ pixel + <NUM_LIT:1> ] . toInt ( ) and <NUM_LIT> shl <NUM_LIT:8> ) . toFloat ( ) <EOL> result [ row ] [ col ] [ <NUM_LIT:2> ] = ( pixels [ pixel + <NUM_LIT:2> ] . toInt ( ) and <NUM_LIT> shl <NUM_LIT:16> ) . toFloat ( ) <EOL> } else { <EOL> result [ row ] [ col ] [ <NUM_LIT:2> ] = ( pixels [ pixel + <NUM_LIT:1> ] . toInt ( ) and <NUM_LIT> shl <NUM_LIT:8> ) . toFloat ( ) <EOL> result [ row ] [ col ] [ <NUM_LIT:1> ] = ( pixels [ pixel + <NUM_LIT:2> ] . toInt ( ) and <NUM_LIT> shl <NUM_LIT:16> ) . toFloat ( ) <EOL> } <EOL> col ++ <EOL> if ( col == width ) { <EOL> col = <NUM_LIT:0> <EOL> row ++ <EOL> } <EOL> pixel += pixelLength <EOL> } <EOL> } <EOL> return result <EOL> }

/**
 * Converts [image] with [colorMode] to the 3D array.
 *
 * @param [image] image to convert
 * @param [colorMode] color mode used in the target array
 * @return a 3D array with the image in a format `height x width x channels`
 * */


public fun floatArrayToBufferedImage ( inputArray : FloatArray , outputShape : TensorShape , arrayColorMode : ColorMode , isNormalized : Boolean ) : BufferedImage

{ <EOL> return floatArrayToBufferedImage ( inputArray , outputShape [ <NUM_LIT:0> ] . toInt ( ) , outputShape [ <NUM_LIT:1> ] . toInt ( ) , arrayColorMode , isNormalized ) <EOL> }

/**
 * Converts [inputArray] of type [FloatArray] to [BufferedImage] with [outputShape] provided.
 *
 * The output [BufferedImage] will have the same ColorMode as [arrayColorMode] of an input tensor.
 *
 * If [isNormalized] is true, then [inputArray] values considered to be in [0..1) interval
 * and will be rescaled to [0..255) interval. Values that are outside this range are clamped
 * to avoid artifacts on the image.
 *
 * If an array requires custom processing, one can use method variation that accepts [ArrayTransform].
 *
 * @param [inputArray] float array to convert.
 * @param [outputShape] shape of the output image.
 * @param [arrayColorMode] [ColorMode] of an [inputArray].
 * @param [isNormalized] [Boolean] that indicates [inputArray] should be rescaled to [0..255) interval.
 * @return [BufferedImage] result image.
 * */


public fun floatArrayToBufferedImage ( inputArray : FloatArray , width : Int , height : Int , arrayColorMode : ColorMode , isNormalized : Boolean ) : BufferedImage

{ <EOL> return floatArrayToBufferedImage ( inputArray , width , height , arrayColorMode ) { <EOL> if ( isNormalized ) denormalizeInplace ( it , scale = <NUM_LIT> ) <EOL> for ( ( i , value ) in it . withIndex ( ) ) { <EOL> if ( value < <NUM_LIT:0> ) it [ i ] = <NUM_LIT> <EOL> if ( value > <NUM_LIT> ) it [ i ] = <NUM_LIT> <EOL> } <EOL> it <EOL> } <EOL> }

/**
 * Converts [inputArray] of type [FloatArray] to [BufferedImage] with [width] and [height] provided.
 *
 * The output [BufferedImage] will have the same ColorMode as [arrayColorMode] of an input tensor.
 *
 * If [isNormalized] is true, then [inputArray] values considered to be in [0..1) interval
 * and will be rescaled to [0..255) interval. Values that are outside this range are clamped
 * to avoid artifacts on the image.
 *
 * If an array requires custom processing, one can use method variation that accepts [ArrayTransform].
 *
 * @param [inputArray] float array to convert.
 * @param [width] width of the output image.
 * @param [height] height of the output image.
 * @param [arrayColorMode] [ColorMode] of an [inputArray].
 * @param [isNormalized] [Boolean] that indicates [inputArray] should be rescaled to [0..255) interval.
 * @return [BufferedImage] result image.
 * */


public fun floatArrayToBufferedImage ( inputArray : FloatArray , width : Int , height : Int , arrayColorMode : ColorMode , arrayTransform : ArrayTransform ? = null ) : BufferedImage

{ <EOL> val dataCopy = arrayTransform ? . invoke ( inputArray . copyOf ( ) ) ? : inputArray . copyOf ( ) <EOL> require ( width * height * arrayColorMode . channels == dataCopy . size ) { <EOL> "<STR_LIT>" <EOL> } <EOL> if ( arrayColorMode == ColorMode . BGR ) { <EOL> swapRandB ( dataCopy ) <EOL> } <EOL> val output = BufferedImage ( width , height , arrayColorMode . imageType ( ) ) <EOL> output . raster . setPixels ( <NUM_LIT:0> , <NUM_LIT:0> , output . width , output . height , dataCopy ) <EOL> return output <EOL> }

/**
 * Converts [inputArray] of type [FloatArray] to [BufferedImage] with [width] and [height] provided.
 * If a custom [arrayTransform] is needed, lambda or ArrayTransform can be provided.
 *
 * The output [BufferedImage] will have the same ColorMode as [arrayColorMode] of an input tensor.
 *
 * If an [arrayTransform] is given, then [arrayColorMode] is interpreted as a color mode of an array after transform.
 *
 * [inputArray] is explicitly copied before applying [arrayTransform].
 *
 * @see ArrayTransform
 *
 * @param [inputArray] float array to convert.
 * @param [width] shape of the output image.
 * @param [height] height of the output image.
 * @param [arrayColorMode] [ColorMode] of an [inputArray].
 * @param [arrayTransform] [ArrayTransform] implementation.
 * Thanks to Kotlin SAM convention it can be supplied as [(FloatArray) -> FloatArray] lambda.
 * @return [BufferedImage] result image.
 * */


public fun ColorMode . imageType ( ) : Int

{ <EOL> return when ( this ) { <EOL> ColorMode . RGB -> BufferedImage . TYPE_INT_RGB <EOL> ColorMode . BGR -> BufferedImage . TYPE_3BYTE_BGR <EOL> ColorMode . GRAYSCALE -> BufferedImage . TYPE_BYTE_GRAY <EOL> } <EOL> }

/**
 * Returns an integer representing a type of [BufferedImage] corresponding to this color mode.
 */


internal fun < T > projectStoredProperty ( initializer : Project . ( ) -> T ) : ReadOnlyProperty < Project , T >

= StoredLazyProperty ( storage = { storedPropertyStorage } , initializer = initializer )

/**
 * ### Generic mechanism of attaching 'data' to [Project]
 * #### e.g. attaching a simple property to a [Project]
 * ```kotlin
 * class Foo(val projectName: String)
 *
 * val Project.myFoo by projectStoredProperty {
 * Foo(project.name)
 * }
 * ```
 *
 * _Usage in Project 'a'_
 *
 * ```kotlin
 * class MyPlugin : Plugin<Project> {
 * fun apply(project: Project) {
 * // prints 'Foo("a")'
 * println(project.myFoo)
 * }
 * }
 * ```
 * _Usage in Project 'b'_
 *
 * ```kotlin
 * class MyPlugin : Plugin<Project> {
 * fun apply(project: Project) {
 * // prints 'Foo("b")'
 * println(project.myFoo)
 * }
 * }
 * ```
 *
 * ### Note:
 * The key used for storing the property to the [Project] is the instance of the returned [ReadOnlyProperty],
 * *not* the type, or any String based key
 *
 */


internal fun < R : HasMutableExtras , T > extrasStoredProperty ( initializer : R . ( ) -> T ) : ReadOnlyProperty < R , T >

/**
 * Same as [projectStoredProperty], but will allow storing the property on any object implementing [HasMutableExtras]
 */


fun dumpLibrary ( library : KotlinLibrary , testMode : Boolean )

{ <EOL> val moduleMetadata = loadModuleMetadata ( library ) <EOL> . let { originalModuleMetadata -> if ( testMode ) preprocessMetadataForTests ( originalModuleMetadata ) else originalModuleMetadata } <EOL> val signatureComputer = prepareSignatureComputer ( library , moduleMetadata ) <EOL> KlibKotlinp ( Settings ( isVerbose = true , sortDeclarations = testMode ) , signatureComputer ) . renderModule ( moduleMetadata , printer ) <EOL> }

/**
 * @param testMode if `true` then a special pre-processing is performed towards the metadata before rendering:
 * - empty package fragments are removed
 * - package fragments with the same package FQN are merged
 * - classes are sorted in alphabetical order
 */


private fun KtFile . facadeIsPossible ( ) : Boolean

= when { <EOL> isCompiled && ! name . endsWith ( "<STR_LIT>" ) -> false <EOL> isScript ( ) -> false <EOL> canHaveAdditionalFilesInFacade ( ) -> true <EOL> else -> hasTopLevelCallables ( ) <EOL> }

/**
 * lightweight applicability check
 */


fun open ( ) : CompositeMetadataArtifactContent

/**
 * Provides access to the actual content provided by this artifact.
 * Note: [CompositeMetadataArtifactContent] is [Closeable] and might actively open Files on access.
 * A [Closeable.close] call is required.
 *
 * Alternatively use the [read] function instead.
 */


fun exists ( ) : Boolean

/**
 * Checks if physical files are present on disk
 */


internal inline fun < T > CompositeMetadataArtifact . read ( action : ( artifactContent : CompositeMetadataArtifactContent ) -> T ) : T

{ <EOL> return open ( ) . use ( action ) <EOL> }

/**
 * Safe shortcut function for opening and reading the content of this artifact.
 * The [CompositeMetadataArtifactContent] will be closed after the [action] executed.
 */


fun copyTo ( file : File ) : Boolean

/**
 * Copies the content of this [Binary] directly into the given [file].
 * The [file] will be overwritten when it already exists.
 * Parent directories will be created if necessary.
 */


fun copyIntoDirectory ( directory : File )

= copyTo ( directory . resolve ( relativeFile ) )

/**
 * Copies the content of this [Binary] into the [directory] appending the [relativeFile] to it.
 * @see copyTo
 */


fun MultifileClass ( representativeFile : KtFile ? , descriptor : PackageFragmentDescriptor ) : JvmDeclarationOrigin

= <EOL> JvmDeclarationOrigin ( MULTIFILE_CLASS , representativeFile , descriptor )

/**
 * @param representativeFile one of the files representing this multifile class (will be used for diagnostics)
 */


public fun < T : Comparable < T > > checkInRange ( aes : Aes , value : T , range : ClosedRange < T > ) : Unit

= <EOL> require ( value in range ) { <EOL> "<STR_LIT>" <EOL> }

/**
 * Checks if a given value for an aesthetic (aes) lies within a specified range.
 * Throws an exception if the value is outside the range.
 *
 * @param T The type of the value which should be comparable.
 * @param aes The aesthetic whose value is being checked.
 * @param value The actual value of the aesthetic.
 * @param range The permissible range for the aesthetics's value.
 *
 * @throws IllegalArgumentException If the provided aesthetic value is not within the specified range.
 */


public fun checkRequiredAes ( requiredAes : Set < Aes > , layerContext : LayerContextInterface , plotContext : PlotContext ? )

{ <EOL> val layerAssignedAes : Set < Aes > = with ( layerContext . bindingCollector ) { <EOL> mappings . keys + settings . keys <EOL> } <EOL> val plotAssignedAes : Set < Aes > ? = plotContext ? . bindingCollector ? . run { <EOL> mappings . keys + settings . keys <EOL> } <EOL> val assignedAes : Set < Aes > = layerAssignedAes + ( plotAssignedAes ? : setOf ( ) ) <EOL> requiredAes . forEach { <EOL> require ( it in assignedAes ) { "<STR_LIT>" } <EOL> } <EOL> }

/**
 * Ensures that all required aesthetics are assigned either in the layer or plot context.
 * If any of the required aesthetics are not found, an exception is thrown.
 *
 * @param requiredAes A set of aesthetics that need to be assigned.
 * @param layerContext The context of the layer where the aesthetics could be assigned.
 * @param plotContext The context of the plot where the aesthetics could be assigned (optional).
 *
 * @throws IllegalArgumentException If any of the required aesthetics is not assigned in either the layer or the plot context.
 */


{ <EOL> val tagName : PsiElement ? = findChildByType ( KDocTokens . TAG_NAME ) <EOL> if ( tagName != null ) { <EOL> return tagName . text . substring ( <NUM_LIT:1> ) <EOL> } <EOL> return null <EOL> }

/**
 * Returns the name of this tag, not including the leading @ character.
 *
 * @return tag name or null if this tag represents the default section of a doc comment
 * or the code has a syntax error.
 */


= getSubjectLink ( ) ? . getLinkText ( )

/**
 * Returns the name of the entity documented by this tag (for example, the name of the parameter
 * for the @param tag), or null if this tag does not document any specific entity.
 */