From 8e5c63d035ef44a269b8c43430f43f5c8eebfb63 Mon Sep 17 00:00:00 2001 From: Ignat Beresnev Date: Fri, 10 Nov 2023 11:46:54 +0100 Subject: Restructure the project to utilize included builds (#3174) * Refactor and simplify artifact publishing * Update Gradle to 8.4 * Refactor and simplify convention plugins and build scripts Fixes #3132 --------- Co-authored-by: Adam <897017+aSemy@users.noreply.github.com> Co-authored-by: Oleg Yukhnevich --- core/src/main/kotlin/model/CompositeSourceSetID.kt | 46 -- core/src/main/kotlin/model/DisplaySourceSet.kt | 61 --- core/src/main/kotlin/model/Documentable.kt | 540 --------------------- core/src/main/kotlin/model/JvmField.kt | 14 - core/src/main/kotlin/model/WithChildren.kt | 98 ---- core/src/main/kotlin/model/additionalExtras.kt | 142 ------ core/src/main/kotlin/model/ancestryNode.kt | 18 - core/src/main/kotlin/model/classKinds.kt | 24 - core/src/main/kotlin/model/defaultValues.kt | 34 -- core/src/main/kotlin/model/doc/DocTag.kt | 372 -------------- .../src/main/kotlin/model/doc/DocumentationNode.kt | 9 - core/src/main/kotlin/model/doc/TagWrapper.kt | 36 -- .../main/kotlin/model/documentableProperties.kt | 71 --- core/src/main/kotlin/model/documentableUtils.kt | 27 -- core/src/main/kotlin/model/extraModifiers.kt | 68 --- core/src/main/kotlin/model/jvmName.kt | 11 - .../kotlin/model/properties/PropertyContainer.kt | 69 --- .../src/main/kotlin/model/properties/properties.kt | 36 -- 18 files changed, 1676 deletions(-) delete mode 100644 core/src/main/kotlin/model/CompositeSourceSetID.kt delete mode 100644 core/src/main/kotlin/model/DisplaySourceSet.kt delete mode 100644 core/src/main/kotlin/model/Documentable.kt delete mode 100644 core/src/main/kotlin/model/JvmField.kt delete mode 100644 core/src/main/kotlin/model/WithChildren.kt delete mode 100644 core/src/main/kotlin/model/additionalExtras.kt delete mode 100644 core/src/main/kotlin/model/ancestryNode.kt delete mode 100644 core/src/main/kotlin/model/classKinds.kt delete mode 100644 core/src/main/kotlin/model/defaultValues.kt delete mode 100644 core/src/main/kotlin/model/doc/DocTag.kt delete mode 100644 core/src/main/kotlin/model/doc/DocumentationNode.kt delete mode 100644 core/src/main/kotlin/model/doc/TagWrapper.kt delete mode 100644 core/src/main/kotlin/model/documentableProperties.kt delete mode 100644 core/src/main/kotlin/model/documentableUtils.kt delete mode 100644 core/src/main/kotlin/model/extraModifiers.kt delete mode 100644 core/src/main/kotlin/model/jvmName.kt delete mode 100644 core/src/main/kotlin/model/properties/PropertyContainer.kt delete mode 100644 core/src/main/kotlin/model/properties/properties.kt (limited to 'core/src/main/kotlin/model') diff --git a/core/src/main/kotlin/model/CompositeSourceSetID.kt b/core/src/main/kotlin/model/CompositeSourceSetID.kt deleted file mode 100644 index af7d1a5d..00000000 --- a/core/src/main/kotlin/model/CompositeSourceSetID.kt +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model - -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.DokkaSourceSetID - -/** - * A unique composite key of multiple [DokkaSourceSetID] that identifies [DisplaySourceSet]. - * Consists of multiple (non-zero) [DokkaSourceSetID] that the corresponding [DisplaySourceSet] was built from. - * - * Should not be constructed or copied outside of [DisplaySourceSet] instantiation. - */ -public data class CompositeSourceSetID( - private val children: Set -) { - public constructor(sourceSetIDs: Iterable) : this(sourceSetIDs.toSet()) - public constructor(sourceSetId: DokkaSourceSetID) : this(setOf(sourceSetId)) - - init { - require(children.isNotEmpty()) { "Expected at least one source set id" } - } - - public val merged: DokkaSourceSetID = children.sortedBy { it.scopeId + it.sourceSetName }.let { sortedChildren -> - DokkaSourceSetID( - scopeId = sortedChildren.joinToString(separator = "+") { it.scopeId }, - sourceSetName = sortedChildren.joinToString(separator = "+") { it.sourceSetName } - ) - } - - public val all: Set = setOf(merged, *children.toTypedArray()) - - public operator fun contains(sourceSetId: DokkaSourceSetID): Boolean { - return sourceSetId in all - } - - public operator fun contains(sourceSet: DokkaConfiguration.DokkaSourceSet): Boolean { - return sourceSet.sourceSetID in this - } - - public operator fun plus(other: DokkaSourceSetID): CompositeSourceSetID { - return copy(children = children + other) - } -} diff --git a/core/src/main/kotlin/model/DisplaySourceSet.kt b/core/src/main/kotlin/model/DisplaySourceSet.kt deleted file mode 100644 index 9d637048..00000000 --- a/core/src/main/kotlin/model/DisplaySourceSet.kt +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model - -import org.jetbrains.dokka.* -import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet - -/** - * Represents a final user-visible source set in the documentable model that is - * used to specify under which source sets/targets current signatures are available, - * can be used to filter in and out all available signatures under the specified source set, - * and, depending on the format, are rendered as "platform" selectors. - * - * E.g. HTML format renders display source sets as "bubbles" that later are used for filtering - * and informational purposes. - * - * [DisplaySourceSet]s typically have a one-to-one correspondence to the build system source sets, - * are created by the base plugin from [DokkaSourceSet] and never tweaked manually. - * [DisplaySourceSet] is uniquely identified by the corresponding [CompositeSourceSetID]. - * - * @property sourceSetIDs unique stable id of the display source set. - * It is composite by definition, as it uniquely defines the source set and all nested source sets. - * Apart from names, it also contains a substitute to a full source set path in order to differentiate - * source sets with the same name in a stable manner. - * @property name corresponds to the name of the original [DokkaSourceSet] - * @property platform the platform of the source set. If the source set is a mix of multiple source sets - * that correspond to multiple KMP platforms, then it is [Platform.common] - */ -public data class DisplaySourceSet( - val sourceSetIDs: CompositeSourceSetID, - val name: String, - val platform: Platform -) { - public constructor(sourceSet: DokkaSourceSet) : this( - sourceSetIDs = CompositeSourceSetID(sourceSet.sourceSetID), - name = sourceSet.displayName, - platform = sourceSet.analysisPlatform - ) -} - -/** - * Transforms the current [DokkaSourceSet] into [DisplaySourceSet], - * matching the corresponding subset of its properties to [DisplaySourceSet] properties. - */ -public fun DokkaSourceSet.toDisplaySourceSet(): DisplaySourceSet = DisplaySourceSet(this) - -/** - * Transforms all the given [DokkaSourceSet]s into [DisplaySourceSet]s. - */ -public fun Iterable.toDisplaySourceSets(): Set = - map { it.toDisplaySourceSet() }.toSet() - -@InternalDokkaApi -@Deprecated("Use computeSourceSetIds() and cache its results instead", replaceWith = ReplaceWith("computeSourceSetIds()")) -public val Iterable.sourceSetIDs: List get() = this.flatMap { it.sourceSetIDs.all } - -@InternalDokkaApi -public fun Iterable.computeSourceSetIds(): Set = - fold(hashSetOf()) { acc, set -> acc.addAll(set.sourceSetIDs.all); acc } diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt deleted file mode 100644 index c6109f47..00000000 --- a/core/src/main/kotlin/model/Documentable.kt +++ /dev/null @@ -1,540 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model - -import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.doc.DocumentationNode -import org.jetbrains.dokka.model.properties.PropertyContainer -import org.jetbrains.dokka.model.properties.WithExtraProperties - -public interface AnnotationTarget - -public abstract class Documentable : WithChildren, - AnnotationTarget { - public abstract val name: String? - public abstract val dri: DRI - public abstract val documentation: SourceSetDependent - public abstract val sourceSets: Set - public abstract val expectPresentInSet: DokkaSourceSet? - abstract override val children: List - - override fun toString(): String = - "${javaClass.simpleName}($dri)" - - override fun equals(other: Any?): Boolean = - other is Documentable && this.dri == other.dri // TODO: https://github.com/Kotlin/dokka/pull/667#discussion_r382555806 - - override fun hashCode(): Int = dri.hashCode() -} - -public typealias SourceSetDependent = Map - -public interface WithSources { - public val sources: SourceSetDependent -} - -public interface WithScope { - public val functions: List - public val properties: List - public val classlikes: List -} - -public interface WithVisibility { - public val visibility: SourceSetDependent -} - -public interface WithType { - public val type: Bound -} - -public interface WithAbstraction { - public val modifier: SourceSetDependent -} - -public sealed class Modifier( - public val name: String -) - -public sealed class KotlinModifier(name: String) : Modifier(name) { - public object Abstract : KotlinModifier("abstract") - public object Open : KotlinModifier("open") - public object Final : KotlinModifier("final") - public object Sealed : KotlinModifier("sealed") - public object Empty : KotlinModifier("") -} - -public sealed class JavaModifier(name: String) : Modifier(name) { - public object Abstract : JavaModifier("abstract") - public object Final : JavaModifier("final") - public object Empty : JavaModifier("") -} - -public interface WithCompanion { - public val companion: DObject? -} - -public interface WithConstructors { - public val constructors: List -} - -public interface WithGenerics { - public val generics: List -} - -public interface WithSupertypes { - public val supertypes: SourceSetDependent> -} - -public interface WithIsExpectActual { - public val isExpectActual: Boolean -} - -public interface Callable : WithVisibility, WithType, WithAbstraction, WithSources, WithIsExpectActual { - public val receiver: DParameter? -} - -public sealed class DClasslike : Documentable(), WithScope, WithVisibility, WithSources, WithIsExpectActual - -public data class DModule( - override val name: String, - val packages: List, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet? = null, - override val sourceSets: Set, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithExtraProperties { - override val dri: DRI = DRI.topLevel - override val children: List - get() = packages - - override fun withNewExtras(newExtras: PropertyContainer): DModule = copy(extra = newExtras) -} - -public data class DPackage( - override val dri: DRI, - override val functions: List, - override val properties: List, - override val classlikes: List, - val typealiases: List, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet? = null, - override val sourceSets: Set, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithScope, WithExtraProperties { - - val packageName: String = dri.packageName.orEmpty() - - /** - * !!! WARNING !!! - * This name is not guaranteed to be a be a canonical/real package name. - * e.g. this will return a human readable version for root packages. - * Use [packageName] or `dri.packageName` instead to obtain the real packageName - */ - override val name: String = packageName.ifBlank { "[root]" } - - override val children: List = properties + functions + classlikes + typealiases - - override fun withNewExtras(newExtras: PropertyContainer): DPackage = copy(extra = newExtras) -} - -public data class DClass( - override val dri: DRI, - override val name: String, - override val constructors: List, - override val functions: List, - override val properties: List, - override val classlikes: List, - override val sources: SourceSetDependent, - override val visibility: SourceSetDependent, - override val companion: DObject?, - override val generics: List, - override val supertypes: SourceSetDependent>, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val modifier: SourceSetDependent, - override val sourceSets: Set, - override val isExpectActual: Boolean, - override val extra: PropertyContainer = PropertyContainer.empty() -) : DClasslike(), WithAbstraction, WithCompanion, WithConstructors, WithGenerics, WithSupertypes, - WithExtraProperties { - - override val children: List - get() = (functions + properties + classlikes + constructors) - - override fun withNewExtras(newExtras: PropertyContainer): DClass = copy(extra = newExtras) -} - -public data class DEnum( - override val dri: DRI, - override val name: String, - val entries: List, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, - override val visibility: SourceSetDependent, - override val companion: DObject?, - override val constructors: List, - override val supertypes: SourceSetDependent>, - override val sourceSets: Set, - override val isExpectActual: Boolean, - override val extra: PropertyContainer = PropertyContainer.empty() -) : DClasslike(), WithCompanion, WithConstructors, WithSupertypes, WithExtraProperties { - override val children: List - get() = (entries + functions + properties + classlikes + constructors) - - override fun withNewExtras(newExtras: PropertyContainer): DEnum = copy(extra = newExtras) -} - -public data class DEnumEntry( - override val dri: DRI, - override val name: String, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val functions: List, - override val properties: List, - override val classlikes: List, - override val sourceSets: Set, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithScope, WithExtraProperties { - override val children: List - get() = (functions + properties + classlikes) - - override fun withNewExtras(newExtras: PropertyContainer): DEnumEntry = copy(extra = newExtras) -} - -public data class DFunction( - override val dri: DRI, - override val name: String, - val isConstructor: Boolean, - val parameters: List, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent, - override val visibility: SourceSetDependent, - override val type: Bound, - override val generics: List, - override val receiver: DParameter?, - override val modifier: SourceSetDependent, - override val sourceSets: Set, - override val isExpectActual: Boolean, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), Callable, WithGenerics, WithExtraProperties { - override val children: List - get() = parameters - - override fun withNewExtras(newExtras: PropertyContainer): DFunction = copy(extra = newExtras) -} - -public data class DInterface( - override val dri: DRI, - override val name: String, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, - override val visibility: SourceSetDependent, - override val companion: DObject?, - override val generics: List, - override val supertypes: SourceSetDependent>, - override val sourceSets: Set, - override val isExpectActual: Boolean, - override val extra: PropertyContainer = PropertyContainer.empty() -) : DClasslike(), WithCompanion, WithGenerics, WithSupertypes, WithExtraProperties { - override val children: List - get() = (functions + properties + classlikes) - - override fun withNewExtras(newExtras: PropertyContainer): DInterface = copy(extra = newExtras) -} - -public data class DObject( - override val name: String?, - override val dri: DRI, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, - override val visibility: SourceSetDependent, - override val supertypes: SourceSetDependent>, - override val sourceSets: Set, - override val isExpectActual: Boolean, - override val extra: PropertyContainer = PropertyContainer.empty() -) : DClasslike(), WithSupertypes, WithExtraProperties { - override val children: List - get() = (functions + properties + classlikes) - - override fun withNewExtras(newExtras: PropertyContainer): DObject = copy(extra = newExtras) -} - -public data class DAnnotation( - override val name: String, - override val dri: DRI, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent, - override val functions: List, - override val properties: List, - override val classlikes: List, - override val visibility: SourceSetDependent, - override val companion: DObject?, - override val constructors: List, - override val generics: List, - override val sourceSets: Set, - override val isExpectActual: Boolean, - override val extra: PropertyContainer = PropertyContainer.empty() -) : DClasslike(), WithCompanion, WithConstructors, WithExtraProperties, WithGenerics { - override val children: List - get() = (functions + properties + classlikes + constructors) - - override fun withNewExtras(newExtras: PropertyContainer): DAnnotation = copy(extra = newExtras) -} - -public data class DProperty( - override val dri: DRI, - override val name: String, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val sources: SourceSetDependent, - override val visibility: SourceSetDependent, - override val type: Bound, - override val receiver: DParameter?, - val setter: DFunction?, - val getter: DFunction?, - override val modifier: SourceSetDependent, - override val sourceSets: Set, - override val generics: List, - override val isExpectActual: Boolean, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), Callable, WithExtraProperties, WithGenerics { - override val children: List - get() = emptyList() - - override fun withNewExtras(newExtras: PropertyContainer): DProperty = copy(extra = newExtras) -} - -// TODO: treat named Parameters and receivers differently -public data class DParameter( - override val dri: DRI, - override val name: String?, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val type: Bound, - override val sourceSets: Set, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithExtraProperties, WithType { - override val children: List - get() = emptyList() - - override fun withNewExtras(newExtras: PropertyContainer): DParameter = copy(extra = newExtras) -} - -public data class DTypeParameter( - val variantTypeParameter: Variance, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - val bounds: List, - override val sourceSets: Set, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithExtraProperties { - - public constructor( - dri: DRI, - name: String, - presentableName: String?, - documentation: SourceSetDependent, - expectPresentInSet: DokkaSourceSet?, - bounds: List, - sourceSets: Set, - extra: PropertyContainer = PropertyContainer.empty() - ) : this( - Invariance(TypeParameter(dri, name, presentableName)), - documentation, - expectPresentInSet, - bounds, - sourceSets, - extra - ) - - override val dri: DRI by variantTypeParameter.inner::dri - override val name: String by variantTypeParameter.inner::name - - override val children: List - get() = emptyList() - - override fun withNewExtras(newExtras: PropertyContainer): DTypeParameter = copy(extra = newExtras) -} - -public data class DTypeAlias( - override val dri: DRI, - override val name: String, - override val type: Bound, - val underlyingType: SourceSetDependent, - override val visibility: SourceSetDependent, - override val documentation: SourceSetDependent, - override val expectPresentInSet: DokkaSourceSet?, - override val sourceSets: Set, - override val generics: List, - override val sources: SourceSetDependent, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Documentable(), WithType, WithVisibility, WithExtraProperties, WithGenerics, WithSources { - override val children: List - get() = emptyList() - - override fun withNewExtras(newExtras: PropertyContainer): DTypeAlias = copy(extra = newExtras) -} - -public sealed class Projection -public sealed class Bound : Projection() -public data class TypeParameter( - val dri: DRI, - val name: String, - val presentableName: String? = null, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Bound(), AnnotationTarget, WithExtraProperties { - override fun withNewExtras(newExtras: PropertyContainer): TypeParameter = - copy(extra = extra) -} - -public sealed class TypeConstructor : Bound(), AnnotationTarget { - public abstract val dri: DRI - public abstract val projections: List - public abstract val presentableName: String? -} - -public data class GenericTypeConstructor( - override val dri: DRI, - override val projections: List, - override val presentableName: String? = null, - override val extra: PropertyContainer = PropertyContainer.empty() -) : TypeConstructor(), WithExtraProperties { - override fun withNewExtras(newExtras: PropertyContainer): GenericTypeConstructor = - copy(extra = newExtras) -} - -public data class FunctionalTypeConstructor( - override val dri: DRI, - override val projections: List, - val isExtensionFunction: Boolean = false, - val isSuspendable: Boolean = false, - override val presentableName: String? = null, - override val extra: PropertyContainer = PropertyContainer.empty(), -) : TypeConstructor(), WithExtraProperties { - override fun withNewExtras(newExtras: PropertyContainer): FunctionalTypeConstructor = - copy(extra = newExtras) -} - -// kotlin.annotation.AnnotationTarget.TYPEALIAS -public data class TypeAliased( - val typeAlias: Bound, - val inner: Bound, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Bound(), AnnotationTarget, WithExtraProperties { - override fun withNewExtras(newExtras: PropertyContainer): TypeAliased = - copy(extra = newExtras) -} - -public data class PrimitiveJavaType( - val name: String, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Bound(), AnnotationTarget, WithExtraProperties { - override fun withNewExtras(newExtras: PropertyContainer): PrimitiveJavaType = - copy(extra = newExtras) -} - -public data class JavaObject(override val extra: PropertyContainer = PropertyContainer.empty()) : - Bound(), AnnotationTarget, WithExtraProperties { - override fun withNewExtras(newExtras: PropertyContainer): JavaObject = - copy(extra = newExtras) -} - -public data class UnresolvedBound( - val name: String, - override val extra: PropertyContainer = PropertyContainer.empty() -) : Bound(), AnnotationTarget, WithExtraProperties { - override fun withNewExtras(newExtras: PropertyContainer): UnresolvedBound = - copy(extra = newExtras) -} - -// The following Projections are not AnnotationTargets; they cannot be annotated. -public data class Nullable(val inner: Bound) : Bound() - -/** - * It introduces [definitely non-nullable types](https://github.com/Kotlin/KEEP/blob/c72601cf35c1e95a541bb4b230edb474a6d1d1a8/proposals/definitely-non-nullable-types.md) - */ -public data class DefinitelyNonNullable(val inner: Bound) : Bound() - -public sealed class Variance : Projection() { - public abstract val inner: T -} - -public data class Covariance(override val inner: T) : Variance() { - override fun toString(): String = "out" -} - -public data class Contravariance(override val inner: T) : Variance() { - override fun toString(): String = "in" -} - -public data class Invariance(override val inner: T) : Variance() { - override fun toString(): String = "" -} - -public object Star : Projection() - -public object Void : Bound() -public object Dynamic : Bound() - -public fun Variance.withDri(dri: DRI): Variance = when (this) { - is Contravariance -> Contravariance(TypeParameter(dri, inner.name, inner.presentableName)) - is Covariance -> Covariance(TypeParameter(dri, inner.name, inner.presentableName)) - is Invariance -> Invariance(TypeParameter(dri, inner.name, inner.presentableName)) -} - -public fun Documentable.dfs(predicate: (Documentable) -> Boolean): Documentable? = - if (predicate(this)) { - this - } else { - this.children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull() - } - -public sealed class Visibility(public val name: String) - -public sealed class KotlinVisibility(name: String) : Visibility(name) { - public object Public : KotlinVisibility("public") - public object Private : KotlinVisibility("private") - public object Protected : KotlinVisibility("protected") - public object Internal : KotlinVisibility("internal") -} - -public sealed class JavaVisibility(name: String) : Visibility(name) { - public object Public : JavaVisibility("public") - public object Private : JavaVisibility("private") - public object Protected : JavaVisibility("protected") - public object Default : JavaVisibility("") -} - -public fun SourceSetDependent?.orEmpty(): SourceSetDependent = this ?: emptyMap() - -public interface DocumentableSource { - public val path: String - - /** - * Computes the first line number of the documentable's declaration/signature/identifier. - * - * Numbering is always 1-based. - * - * May return null if the sources could not be found - for example, for synthetic/generated declarations. - */ - public fun computeLineNumber(): Int? -} - -public data class TypeConstructorWithKind(val typeConstructor: TypeConstructor, val kind: ClassKind) diff --git a/core/src/main/kotlin/model/JvmField.kt b/core/src/main/kotlin/model/JvmField.kt deleted file mode 100644 index a2b641c9..00000000 --- a/core/src/main/kotlin/model/JvmField.kt +++ /dev/null @@ -1,14 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model - -import org.jetbrains.dokka.links.DRI - -public const val JVM_FIELD_PACKAGE_NAME: String = "kotlin.jvm" -public const val JVM_FIELD_CLASS_NAMES: String = "JvmField" - -public fun DRI.isJvmField(): Boolean = packageName == JVM_FIELD_PACKAGE_NAME && classNames == JVM_FIELD_CLASS_NAMES - -public fun Annotations.Annotation.isJvmField(): Boolean = dri.isJvmField() diff --git a/core/src/main/kotlin/model/WithChildren.kt b/core/src/main/kotlin/model/WithChildren.kt deleted file mode 100644 index f73a5aa0..00000000 --- a/core/src/main/kotlin/model/WithChildren.kt +++ /dev/null @@ -1,98 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model - -public interface WithChildren { - public val children: List -} - -public inline fun WithChildren<*>.firstChildOfTypeOrNull(): T? = - children.filterIsInstance().firstOrNull() - -public inline fun WithChildren<*>.firstChildOfTypeOrNull(predicate: (T) -> Boolean): T? = - children.filterIsInstance().firstOrNull(predicate) - -public inline fun WithChildren<*>.firstChildOfType(): T = - children.filterIsInstance().first() - -public inline fun WithChildren<*>.childrenOfType(): List = - children.filterIsInstance() - -public inline fun WithChildren<*>.firstChildOfType(predicate: (T) -> Boolean): T = - children.filterIsInstance().first(predicate) - -public inline fun WithChildren>.firstMemberOfType(): T where T : WithChildren<*> { - return withDescendants().filterIsInstance().first() -} - -public inline fun WithChildren>.firstMemberOfType( - predicate: (T) -> Boolean -): T where T : WithChildren<*> = withDescendants().filterIsInstance().first(predicate) - - -public inline fun WithChildren>.firstMemberOfTypeOrNull(): T? where T : WithChildren<*> { - return withDescendants().filterIsInstance().firstOrNull() -} - -public fun T.withDescendants(): Sequence where T : WithChildren { - return sequence { - yield(this@withDescendants) - children.forEach { child -> - yieldAll(child.withDescendants()) - } - } -} - -@JvmName("withDescendantsProjection") -public fun WithChildren<*>.withDescendants(): Sequence { - return sequence { - yield(this@withDescendants) - children.forEach { child -> - if (child is WithChildren<*>) { - yieldAll(child.withDescendants()) - } - } - } -} - -@JvmName("withDescendantsAny") -public fun WithChildren.withDescendants(): Sequence { - return sequence { - yield(this@withDescendants) - children.forEach { child -> - if (child is WithChildren<*>) { - yieldAll(child.withDescendants().filterNotNull()) - } - } - } -} - -public fun T.dfs(predicate: (T) -> Boolean): T? where T : WithChildren = if (predicate(this)) { - this -} else { - children.asSequence().mapNotNull { it.dfs(predicate) }.firstOrNull() -} - -public fun > T.asPrintableTree( - nodeNameBuilder: Appendable.(T) -> Unit = { append(it.toString()) } -): String { - fun Appendable.append(element: T, ownPrefix: String, childPrefix: String) { - append(ownPrefix) - nodeNameBuilder(element) - appendLine() - element.children.takeIf(Collection<*>::isNotEmpty)?.also { children -> - val newOwnPrefix = "$childPrefix├─ " - val lastOwnPrefix = "$childPrefix└─ " - val newChildPrefix = "$childPrefix│ " - val lastChildPrefix = "$childPrefix " - children.forEachIndexed { n, e -> - if (n != children.lastIndex) append(e, newOwnPrefix, newChildPrefix) - else append(e, lastOwnPrefix, lastChildPrefix) - } - } - } - - return buildString { append(this@asPrintableTree, "", "") } -} diff --git a/core/src/main/kotlin/model/additionalExtras.kt b/core/src/main/kotlin/model/additionalExtras.kt deleted file mode 100644 index 1db8e59d..00000000 --- a/core/src/main/kotlin/model/additionalExtras.kt +++ /dev/null @@ -1,142 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model - -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.properties.ExtraProperty -import org.jetbrains.dokka.model.properties.MergeStrategy - -public class AdditionalModifiers( - public val content: SourceSetDependent> -) : ExtraProperty { - - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor( - left: AdditionalModifiers, - right: AdditionalModifiers - ): MergeStrategy = MergeStrategy.Replace(AdditionalModifiers(left.content + right.content)) - } - - override fun equals(other: Any?): Boolean = - if (other is AdditionalModifiers) other.content == content else false - - override fun hashCode(): Int = content.hashCode() - override val key: ExtraProperty.Key = AdditionalModifiers -} - -public fun SourceSetDependent>.toAdditionalModifiers(): AdditionalModifiers = AdditionalModifiers(this) - -public data class Annotations( - private val myContent: SourceSetDependent> -) : ExtraProperty { - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: Annotations, right: Annotations): MergeStrategy = - MergeStrategy.Replace(Annotations(left.myContent + right.myContent)) - } - - override val key: ExtraProperty.Key = Annotations - - public data class Annotation( - val dri: DRI, - val params: Map, - val mustBeDocumented: Boolean = false, - val scope: AnnotationScope = AnnotationScope.DIRECT - ) { - override fun equals(other: Any?): Boolean = when (other) { - is Annotation -> dri == other.dri - else -> false - } - - override fun hashCode(): Int = dri.hashCode() - } - - @Deprecated("Use directAnnotations or fileLevelAnnotations") - val content: SourceSetDependent> - get() = myContent - - val directAnnotations: SourceSetDependent> = annotationsByScope(AnnotationScope.DIRECT) - - val fileLevelAnnotations: SourceSetDependent> = annotationsByScope(AnnotationScope.FILE) - - private fun annotationsByScope(scope: AnnotationScope): SourceSetDependent> = - myContent.entries.mapNotNull { (key, value) -> - val withoutFileLevel = value.filter { it.scope == scope } - if (withoutFileLevel.isEmpty()) null - else Pair(key, withoutFileLevel) - }.toMap() - - public enum class AnnotationScope { - DIRECT, FILE, GETTER, SETTER - } -} - -public fun SourceSetDependent>.toAnnotations(): Annotations = Annotations(this) - -public sealed class AnnotationParameterValue - -public data class AnnotationValue(val annotation: Annotations.Annotation) : AnnotationParameterValue() - -public data class ArrayValue(val value: List) : AnnotationParameterValue() - -public data class EnumValue(val enumName: String, val enumDri: DRI) : AnnotationParameterValue() - -public data class ClassValue(val className: String, val classDRI: DRI) : AnnotationParameterValue() - -public abstract class LiteralValue : AnnotationParameterValue() { - public abstract fun text() : String -} -public data class IntValue(val value: Int) : LiteralValue() { - override fun text(): String = value.toString() -} - -public data class LongValue(val value: Long) : LiteralValue() { - override fun text(): String = value.toString() -} - -public data class FloatValue(val value: Float) : LiteralValue() { - override fun text(): String = value.toString() -} - -public data class DoubleValue(val value: Double) : LiteralValue() { - override fun text(): String = value.toString() -} - -public object NullValue : LiteralValue() { - override fun text(): String = "null" -} - -public data class BooleanValue(val value: Boolean) : LiteralValue() { - override fun text(): String = value.toString() -} - -public data class StringValue(val value: String) : LiteralValue() { - override fun text(): String = value - override fun toString(): String = value -} - -public object PrimaryConstructorExtra : ExtraProperty, ExtraProperty.Key { - override val key: ExtraProperty.Key = this -} - -public data class ActualTypealias( - val typeAlias: DTypeAlias -) : ExtraProperty { - - @Suppress("unused") - @Deprecated(message = "It can be removed soon. Use [typeAlias.underlyingType]", ReplaceWith("this.typeAlias.underlyingType")) - val underlyingType: SourceSetDependent - get() = typeAlias.underlyingType - - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor( - left: ActualTypealias, - right: ActualTypealias - ): MergeStrategy = MergeStrategy.Fail { - throw IllegalStateException("Adding [ActualTypealias] should be after merging all documentables") - } - } - - override val key: ExtraProperty.Key = ActualTypealias -} diff --git a/core/src/main/kotlin/model/ancestryNode.kt b/core/src/main/kotlin/model/ancestryNode.kt deleted file mode 100644 index 7203ab18..00000000 --- a/core/src/main/kotlin/model/ancestryNode.kt +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model - -public data class AncestryNode( - val typeConstructor: TypeConstructor, - val superclass: AncestryNode?, - val interfaces: List, -) { - public fun allImplementedInterfaces(): List { - fun traverseInterfaces(ancestry: AncestryNode): List = - ancestry.interfaces.flatMap { listOf(it.typeConstructor) + traverseInterfaces(it) } + - (ancestry.superclass?.let(::traverseInterfaces) ?: emptyList()) - return traverseInterfaces(this).distinct() - } -} diff --git a/core/src/main/kotlin/model/classKinds.kt b/core/src/main/kotlin/model/classKinds.kt deleted file mode 100644 index 25256022..00000000 --- a/core/src/main/kotlin/model/classKinds.kt +++ /dev/null @@ -1,24 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model - -public interface ClassKind - -public enum class KotlinClassKindTypes : ClassKind { - CLASS, - INTERFACE, - ENUM_CLASS, - ENUM_ENTRY, - ANNOTATION_CLASS, - OBJECT; -} - -public enum class JavaClassKindTypes : ClassKind { - CLASS, - INTERFACE, - ENUM_CLASS, - ENUM_ENTRY, - ANNOTATION_CLASS; -} diff --git a/core/src/main/kotlin/model/defaultValues.kt b/core/src/main/kotlin/model/defaultValues.kt deleted file mode 100644 index 426954fb..00000000 --- a/core/src/main/kotlin/model/defaultValues.kt +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model - -import org.jetbrains.dokka.model.properties.ExtraProperty -import org.jetbrains.dokka.model.properties.MergeStrategy - -public class DefaultValue( - public val expression: SourceSetDependent -): ExtraProperty { - - @Deprecated("Use `expression` property that depends on source set", ReplaceWith("this.expression.values.first()")) - public val value: Expression - get() = expression.values.first() - - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: DefaultValue, right: DefaultValue): MergeStrategy = - MergeStrategy.Replace(DefaultValue(left.expression + right.expression)) - - } - - override val key: ExtraProperty.Key - get() = Companion -} - -public interface Expression -public data class ComplexExpression(val value: String) : Expression -public data class IntegerConstant(val value: Long) : Expression -public data class StringConstant(val value: String) : Expression -public data class DoubleConstant(val value: Double) : Expression -public data class FloatConstant(val value: Float) : Expression -public data class BooleanConstant(val value: Boolean) : Expression diff --git a/core/src/main/kotlin/model/doc/DocTag.kt b/core/src/main/kotlin/model/doc/DocTag.kt deleted file mode 100644 index f4cb9b33..00000000 --- a/core/src/main/kotlin/model/doc/DocTag.kt +++ /dev/null @@ -1,372 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model.doc - -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.WithChildren - -public sealed class DocTag : WithChildren { - public abstract val params: Map - - public companion object { - public fun contentTypeParam(type: String): Map = mapOf("content-type" to type) - } -} - -public data class A( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Big( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class B( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class BlockQuote( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public object Br : DocTag() { - override val children: List = emptyList() - override val params: Map = emptyMap() -} - -public data class Cite( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public sealed class Code : DocTag() - -public data class CodeInline( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : Code() - -public data class CodeBlock( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : Code() - -public data class CustomDocTag( - override val children: List = emptyList(), - override val params: Map = emptyMap(), - val name: String -) : DocTag() - -public data class Dd( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Dfn( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Dir( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Div( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Dl( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class DocumentationLink( - val dri: DRI, - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Dt( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Em( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Font( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Footer( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Frame( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class FrameSet( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class H1( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class H2( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class H3( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class H4( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class H5( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class H6( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Head( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Header( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public object HorizontalRule : DocTag() { - override val children: List = emptyList() - override val params: Map = emptyMap() -} - -public data class Html( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class I( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class IFrame( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Img( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Index( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Input( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Li( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Link( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Listing( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Main( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Menu( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Meta( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Nav( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class NoFrames( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class NoScript( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Ol( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class P( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Pre( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Script( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Section( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Small( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Span( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Strikethrough( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Strong( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Sub( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Sup( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Table( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Text( - val body: String = "", - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class TBody( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Td( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class TFoot( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Th( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class THead( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Title( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Tr( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Tt( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class U( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Ul( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Var( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - -public data class Caption( - override val children: List = emptyList(), - override val params: Map = emptyMap() -) : DocTag() - diff --git a/core/src/main/kotlin/model/doc/DocumentationNode.kt b/core/src/main/kotlin/model/doc/DocumentationNode.kt deleted file mode 100644 index 9c270f79..00000000 --- a/core/src/main/kotlin/model/doc/DocumentationNode.kt +++ /dev/null @@ -1,9 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model.doc - -import org.jetbrains.dokka.model.WithChildren - -public data class DocumentationNode(override val children: List): WithChildren diff --git a/core/src/main/kotlin/model/doc/TagWrapper.kt b/core/src/main/kotlin/model/doc/TagWrapper.kt deleted file mode 100644 index e3eaffb7..00000000 --- a/core/src/main/kotlin/model/doc/TagWrapper.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model.doc - -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.WithChildren - -public sealed class TagWrapper : WithChildren { - public abstract val root: DocTag - - override val children: List - get() = root.children -} - -public sealed class NamedTagWrapper : TagWrapper() { - public abstract val name: String -} - -public data class Description(override val root: DocTag) : TagWrapper() -public data class Author(override val root: DocTag) : TagWrapper() -public data class Version(override val root: DocTag) : TagWrapper() -public data class Since(override val root: DocTag) : TagWrapper() -public data class See(override val root: DocTag, override val name: String, val address: DRI?) : NamedTagWrapper() -public data class Param(override val root: DocTag, override val name: String) : NamedTagWrapper() -public data class Return(override val root: DocTag) : TagWrapper() -public data class Receiver(override val root: DocTag) : TagWrapper() -public data class Constructor(override val root: DocTag) : TagWrapper() -//TODO this naming is confusing since kotlin has Throws annotation -public data class Throws(override val root: DocTag, override val name: String, val exceptionAddress: DRI?) : NamedTagWrapper() -public data class Sample(override val root: DocTag, override val name: String) : NamedTagWrapper() -public data class Deprecated(override val root: DocTag) : TagWrapper() -public data class Property(override val root: DocTag, override val name: String) : NamedTagWrapper() -public data class Suppress(override val root: DocTag) : TagWrapper() -public data class CustomTagWrapper(override val root: DocTag, override val name: String) : NamedTagWrapper() diff --git a/core/src/main/kotlin/model/documentableProperties.kt b/core/src/main/kotlin/model/documentableProperties.kt deleted file mode 100644 index b0ebb6ef..00000000 --- a/core/src/main/kotlin/model/documentableProperties.kt +++ /dev/null @@ -1,71 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model - -import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.model.properties.ExtraProperty -import org.jetbrains.dokka.model.properties.MergeStrategy - -public data class InheritedMember(val inheritedFrom: SourceSetDependent) : ExtraProperty { - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: InheritedMember, right: InheritedMember): MergeStrategy = MergeStrategy.Replace( - InheritedMember(left.inheritedFrom + right.inheritedFrom) - ) - } - - public fun isInherited(sourceSetDependent: DokkaSourceSet): Boolean = inheritedFrom[sourceSetDependent] != null - - override val key: ExtraProperty.Key = InheritedMember -} - -public data class ImplementedInterfaces(val interfaces: SourceSetDependent>) : ExtraProperty { - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: ImplementedInterfaces, right: ImplementedInterfaces): MergeStrategy = - MergeStrategy.Replace(ImplementedInterfaces(left.interfaces + right.interfaces)) - } - - override val key: ExtraProperty.Key = ImplementedInterfaces -} - -public data class ExceptionInSupertypes(val exceptions: SourceSetDependent>): ExtraProperty { - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: ExceptionInSupertypes, right: ExceptionInSupertypes): MergeStrategy = - MergeStrategy.Replace(ExceptionInSupertypes(left.exceptions + right.exceptions)) - } - - override val key: ExtraProperty.Key = ExceptionInSupertypes -} - -public object ObviousMember : ExtraProperty, ExtraProperty.Key { - override val key: ExtraProperty.Key = this -} - -/** - * Whether this [DProperty] is `var` or `val`, should be present both in Kotlin and in Java properties - * - * In case of properties that came from `Java`, [IsVar] is added if - * the java field has no accessors at all (plain field) or has a setter - */ -public object IsVar : ExtraProperty, ExtraProperty.Key { - override val key: ExtraProperty.Key = this -} - -public data class IsAlsoParameter(val inSourceSets: List) : ExtraProperty { - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: IsAlsoParameter, right: IsAlsoParameter): MergeStrategy = - MergeStrategy.Replace(IsAlsoParameter(left.inSourceSets + right.inSourceSets)) - } - - override val key: ExtraProperty.Key = IsAlsoParameter -} - -public data class CheckedExceptions(val exceptions: SourceSetDependent>) : ExtraProperty, ExtraProperty.Key { - public companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: CheckedExceptions, right: CheckedExceptions): MergeStrategy = - MergeStrategy.Replace(CheckedExceptions(left.exceptions + right.exceptions)) - } - override val key: ExtraProperty.Key = CheckedExceptions -} diff --git a/core/src/main/kotlin/model/documentableUtils.kt b/core/src/main/kotlin/model/documentableUtils.kt deleted file mode 100644 index c9d75bf4..00000000 --- a/core/src/main/kotlin/model/documentableUtils.kt +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model - -import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet - -public fun SourceSetDependent.filtered(sourceSets: Set): SourceSetDependent = filter { it.key in sourceSets } -public fun DokkaSourceSet?.filtered(sourceSets: Set): DokkaSourceSet? = takeIf { this in sourceSets } - -public fun DTypeParameter.filter(filteredSet: Set): DTypeParameter? = - if (filteredSet.containsAll(sourceSets)) this - else { - val intersection = filteredSet.intersect(sourceSets) - if (intersection.isEmpty()) null - else DTypeParameter( - variantTypeParameter, - documentation.filtered(intersection), - expectPresentInSet?.takeIf { intersection.contains(expectPresentInSet) }, - bounds, - intersection, - extra - ) - } - -public fun Documentable.isExtension(): Boolean = this is Callable && receiver != null diff --git a/core/src/main/kotlin/model/extraModifiers.kt b/core/src/main/kotlin/model/extraModifiers.kt deleted file mode 100644 index f1193070..00000000 --- a/core/src/main/kotlin/model/extraModifiers.kt +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model - -public sealed class ExtraModifiers(public val name: String) { - - public sealed class KotlinOnlyModifiers(name: String) : ExtraModifiers(name) { - public object Inline : KotlinOnlyModifiers("inline") - public object Value : KotlinOnlyModifiers("value") - public object Infix : KotlinOnlyModifiers("infix") - public object External : KotlinOnlyModifiers("external") - public object Suspend : KotlinOnlyModifiers("suspend") - public object Reified : KotlinOnlyModifiers("reified") - public object CrossInline : KotlinOnlyModifiers("crossinline") - public object NoInline : KotlinOnlyModifiers("noinline") - public object Override : KotlinOnlyModifiers("override") - public object Data : KotlinOnlyModifiers("data") - public object Const : KotlinOnlyModifiers("const") - public object Inner : KotlinOnlyModifiers("inner") - public object LateInit : KotlinOnlyModifiers("lateinit") - public object Operator : KotlinOnlyModifiers("operator") - public object TailRec : KotlinOnlyModifiers("tailrec") - public object VarArg : KotlinOnlyModifiers("vararg") - public object Fun : KotlinOnlyModifiers("fun") - } - - public sealed class JavaOnlyModifiers(name: String) : ExtraModifiers(name) { - public object Static : JavaOnlyModifiers("static") - public object Native : JavaOnlyModifiers("native") - public object Synchronized : JavaOnlyModifiers("synchronized") - public object StrictFP : JavaOnlyModifiers("strictfp") - public object Transient : JavaOnlyModifiers("transient") - public object Volatile : JavaOnlyModifiers("volatile") - public object Transitive : JavaOnlyModifiers("transitive") - } - - public companion object { - public fun valueOf(str: String): ExtraModifiers = when (str) { - "inline" -> KotlinOnlyModifiers.Inline - "value" -> KotlinOnlyModifiers.Value - "infix" -> KotlinOnlyModifiers.Infix - "external" -> KotlinOnlyModifiers.External - "suspend" -> KotlinOnlyModifiers.Suspend - "reified" -> KotlinOnlyModifiers.Reified - "crossinline" -> KotlinOnlyModifiers.CrossInline - "noinline" -> KotlinOnlyModifiers.NoInline - "override" -> KotlinOnlyModifiers.Override - "data" -> KotlinOnlyModifiers.Data - "const" -> KotlinOnlyModifiers.Const - "inner" -> KotlinOnlyModifiers.Inner - "lateinit" -> KotlinOnlyModifiers.LateInit - "operator" -> KotlinOnlyModifiers.Operator - "tailrec" -> KotlinOnlyModifiers.TailRec - "vararg" -> KotlinOnlyModifiers.VarArg - "static" -> JavaOnlyModifiers.Static - "native" -> JavaOnlyModifiers.Native - "synchronized" -> JavaOnlyModifiers.Synchronized - "strictfp" -> JavaOnlyModifiers.StrictFP - "transient" -> JavaOnlyModifiers.Transient - "volatile" -> JavaOnlyModifiers.Volatile - "transitive" -> JavaOnlyModifiers.Transitive - "fun" -> KotlinOnlyModifiers.Fun - else -> throw IllegalArgumentException("There is no Extra Modifier for given name $str") - } - } -} diff --git a/core/src/main/kotlin/model/jvmName.kt b/core/src/main/kotlin/model/jvmName.kt deleted file mode 100644 index 8fd7ccd9..00000000 --- a/core/src/main/kotlin/model/jvmName.kt +++ /dev/null @@ -1,11 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model - -import org.jetbrains.dokka.links.DRI - -public fun DRI.isJvmName(): Boolean = packageName == "kotlin.jvm" && classNames == "JvmName" - -public fun Annotations.Annotation.isJvmName(): Boolean = dri.isJvmName() diff --git a/core/src/main/kotlin/model/properties/PropertyContainer.kt b/core/src/main/kotlin/model/properties/PropertyContainer.kt deleted file mode 100644 index 7f5bb2f0..00000000 --- a/core/src/main/kotlin/model/properties/PropertyContainer.kt +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model.properties - -public data class PropertyContainer internal constructor( - @PublishedApi internal val map: Map, ExtraProperty> -) { - public operator fun plus(prop: ExtraProperty): PropertyContainer = - PropertyContainer(map + (prop.key to prop)) - - // TODO: Add logic for caching calculated properties - public inline operator fun get(key: ExtraProperty.Key): T? = when (val prop = map[key]) { - is T? -> prop - else -> throw ClassCastException("Property for $key stored under not matching key type.") - } - - public inline fun allOfType(): List = map.values.filterIsInstance() - - public fun addAll(extras: Collection>): PropertyContainer = - PropertyContainer(map + extras.map { p -> p.key to p }) - - public operator fun minus(prop: ExtraProperty.Key): PropertyContainer = - PropertyContainer(map.filterNot { it.key == prop }) - - public companion object { - public fun empty(): PropertyContainer = PropertyContainer(emptyMap()) - public fun withAll(vararg extras: ExtraProperty?): PropertyContainer = empty().addAll(extras.filterNotNull()) - public fun withAll(extras: Collection>): PropertyContainer = empty().addAll(extras) - } -} - -public operator fun PropertyContainer.plus(prop: ExtraProperty?): PropertyContainer = - if (prop == null) this else PropertyContainer(map + (prop.key to prop)) - - -public interface WithExtraProperties { - public val extra: PropertyContainer - - public fun withNewExtras(newExtras: PropertyContainer): C -} - -public fun C.mergeExtras(left: C, right: C): C where C : Any, C : WithExtraProperties { - val aggregatedExtras: List>> = - (left.extra.map.values + right.extra.map.values) - .groupBy { it.key } - .values - .map { it.distinct() } - - val (unambiguous, toMerge) = aggregatedExtras.partition { it.size == 1 } - - @Suppress("UNCHECKED_CAST") - val strategies: List> = toMerge.map { (l, r) -> - (l.key as ExtraProperty.Key>).mergeStrategyFor(l, r) - } - - strategies.filterIsInstance().firstOrNull()?.error?.invoke() - - val replaces: List> = - strategies.filterIsInstance>().map { it.newProperty } - - val needingFullMerge: List<(preMerged: C, left: C, right: C) -> C> = - strategies.filterIsInstance>().map { it.merger } - - val newExtras = PropertyContainer((unambiguous.flatten() + replaces).associateBy { it.key }) - - return needingFullMerge.fold(withNewExtras(newExtras)) { acc, merger -> merger(acc, left, right) } -} diff --git a/core/src/main/kotlin/model/properties/properties.kt b/core/src/main/kotlin/model/properties/properties.kt deleted file mode 100644 index ea76dc72..00000000 --- a/core/src/main/kotlin/model/properties/properties.kt +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2014-2023 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license. - */ - -package org.jetbrains.dokka.model.properties - -public interface ExtraProperty { - public interface Key { - public fun mergeStrategyFor(left: T, right: T): MergeStrategy = MergeStrategy.Fail { - throw NotImplementedError("Property merging for $this is not implemented") - } - } - - public val key: Key -} - -public interface CalculatedProperty : ExtraProperty.Key { - public fun calculate(subject: C): T -} - -public sealed class MergeStrategy { - - public class Replace( - public val newProperty: ExtraProperty - ) : MergeStrategy() - - public object Remove : MergeStrategy() - - public class Full( - public val merger: (preMerged: C, left: C, right: C) -> C - ) : MergeStrategy() - - public class Fail( - public val error: () -> Nothing - ) : MergeStrategy() -} -- cgit