From 8cb6efc97f8fa321381c95cc5f85a3ce7bc13c3f Mon Sep 17 00:00:00 2001 From: Kamil Doległo Date: Fri, 19 Jun 2020 14:08:49 +0200 Subject: Remove SourceSetDataCache, rename PassConfiguration to DokkaSourceSet and use it instead of SourceSetData --- core/src/main/kotlin/model/Documentable.kt | 59 +++++++++++----------- core/src/main/kotlin/model/SourceSetData.kt | 38 -------------- .../main/kotlin/model/documentableProperties.kt | 12 ++--- core/src/main/kotlin/model/documentableUtils.kt | 12 +++-- 4 files changed, 43 insertions(+), 78 deletions(-) delete mode 100644 core/src/main/kotlin/model/SourceSetData.kt (limited to 'core/src/main/kotlin/model') diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index 768bddc5..35278302 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -1,5 +1,6 @@ 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 @@ -11,8 +12,8 @@ abstract class Documentable { abstract val dri: DRI abstract val children: List abstract val documentation: SourceSetDependent - abstract val sourceSets: Set - abstract val expectPresentInSet: SourceSetData? + abstract val sourceSets: Set + abstract val expectPresentInSet: DokkaSourceSet? override fun toString(): String = "${javaClass.simpleName}($dri)" @@ -23,7 +24,7 @@ abstract class Documentable { override fun hashCode() = dri.hashCode() } -typealias SourceSetDependent = Map +typealias SourceSetDependent = Map interface WithExpectActual { val sources: SourceSetDependent @@ -88,8 +89,8 @@ data class DModule( override val name: String, val packages: List, override val documentation: SourceSetDependent, - override val expectPresentInSet: SourceSetData? = null, - override val sourceSets: Set, + override val expectPresentInSet: DokkaSourceSet? = null, + override val sourceSets: Set, override val extra: PropertyContainer = PropertyContainer.empty() ) : Documentable(), WithExtraProperties { override val dri: DRI = DRI.topLevel @@ -106,8 +107,8 @@ data class DPackage( override val classlikes: List, val typealiases: List, override val documentation: SourceSetDependent, - override val expectPresentInSet: SourceSetData? = null, - override val sourceSets: Set, + override val expectPresentInSet: DokkaSourceSet? = null, + override val sourceSets: Set, override val extra: PropertyContainer = PropertyContainer.empty() ) : Documentable(), WithScope, WithExtraProperties { override val name = dri.packageName.orEmpty() @@ -130,9 +131,9 @@ data class DClass( override val generics: List, override val supertypes: SourceSetDependent>, override val documentation: SourceSetDependent, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, override val modifier: SourceSetDependent, - override val sourceSets: Set, + override val sourceSets: Set, override val extra: PropertyContainer = PropertyContainer.empty() ) : DClasslike(), WithAbstraction, WithCompanion, WithConstructors, WithGenerics, WithSupertypes, WithExtraProperties { @@ -148,7 +149,7 @@ data class DEnum( override val name: String, val entries: List, override val documentation: SourceSetDependent, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, override val sources: SourceSetDependent, override val functions: List, override val properties: List, @@ -157,7 +158,7 @@ data class DEnum( override val companion: DObject?, override val constructors: List, override val supertypes: SourceSetDependent>, - override val sourceSets: Set, + override val sourceSets: Set, override val extra: PropertyContainer = PropertyContainer.empty() ) : DClasslike(), WithCompanion, WithConstructors, WithSupertypes, WithExtraProperties { override val children: List @@ -170,11 +171,11 @@ data class DEnumEntry( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, override val functions: List, override val properties: List, override val classlikes: List, - override val sourceSets: Set, + override val sourceSets: Set, override val extra: PropertyContainer = PropertyContainer.empty() ) : Documentable(), WithScope, WithExtraProperties { override val children: List @@ -189,14 +190,14 @@ data class DFunction( val isConstructor: Boolean, val parameters: List, override val documentation: SourceSetDependent, - override val expectPresentInSet: SourceSetData?, + 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 sourceSets: Set, override val extra: PropertyContainer = PropertyContainer.empty() ) : Documentable(), Callable, WithGenerics, WithExtraProperties { override val children: List @@ -209,7 +210,7 @@ data class DInterface( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, override val sources: SourceSetDependent, override val functions: List, override val properties: List, @@ -218,7 +219,7 @@ data class DInterface( override val companion: DObject?, override val generics: List, override val supertypes: SourceSetDependent>, - override val sourceSets: Set, + override val sourceSets: Set, override val extra: PropertyContainer = PropertyContainer.empty() ) : DClasslike(), WithCompanion, WithGenerics, WithSupertypes, WithExtraProperties { override val children: List @@ -231,14 +232,14 @@ data class DObject( override val name: String?, override val dri: DRI, override val documentation: SourceSetDependent, - override val expectPresentInSet: SourceSetData?, + 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 sourceSets: Set, override val extra: PropertyContainer = PropertyContainer.empty() ) : DClasslike(), WithSupertypes, WithExtraProperties { override val children: List @@ -251,7 +252,7 @@ data class DAnnotation( override val name: String, override val dri: DRI, override val documentation: SourceSetDependent, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, override val sources: SourceSetDependent, override val functions: List, override val properties: List, @@ -260,7 +261,7 @@ data class DAnnotation( override val companion: DObject?, override val constructors: List, override val generics: List, - override val sourceSets: Set, + override val sourceSets: Set, override val extra: PropertyContainer = PropertyContainer.empty() ) : DClasslike(), WithCompanion, WithConstructors, WithExtraProperties, WithGenerics { override val children: List @@ -273,7 +274,7 @@ data class DProperty( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, override val sources: SourceSetDependent, override val visibility: SourceSetDependent, override val type: Bound, @@ -281,7 +282,7 @@ data class DProperty( val setter: DFunction?, val getter: DFunction?, override val modifier: SourceSetDependent, - override val sourceSets: Set, + override val sourceSets: Set, override val generics: List, override val extra: PropertyContainer = PropertyContainer.empty() ) : Documentable(), Callable, WithExtraProperties, WithGenerics { @@ -296,9 +297,9 @@ data class DParameter( override val dri: DRI, override val name: String?, override val documentation: SourceSetDependent, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, val type: Bound, - override val sourceSets: Set, + override val sourceSets: Set, override val extra: PropertyContainer = PropertyContainer.empty() ) : Documentable(), WithExtraProperties { override val children: List @@ -311,9 +312,9 @@ data class DTypeParameter( override val dri: DRI, override val name: String, override val documentation: SourceSetDependent, - override val expectPresentInSet: SourceSetData?, + override val expectPresentInSet: DokkaSourceSet?, val bounds: List, - override val sourceSets: Set, + override val sourceSets: Set, override val extra: PropertyContainer = PropertyContainer.empty() ) : Documentable(), WithExtraProperties { override val children: List @@ -329,8 +330,8 @@ data class DTypeAlias( val underlyingType: SourceSetDependent, override val visibility: SourceSetDependent, override val documentation: SourceSetDependent, - override val expectPresentInSet: SourceSetData?, - override val sourceSets: Set, + override val expectPresentInSet: DokkaSourceSet?, + override val sourceSets: Set, override val extra: PropertyContainer = PropertyContainer.empty() ) : Documentable(), WithType, WithVisibility, WithExtraProperties { override val children: List diff --git a/core/src/main/kotlin/model/SourceSetData.kt b/core/src/main/kotlin/model/SourceSetData.kt deleted file mode 100644 index 3e38cc7b..00000000 --- a/core/src/main/kotlin/model/SourceSetData.kt +++ /dev/null @@ -1,38 +0,0 @@ -package org.jetbrains.dokka.model - -import org.jetbrains.dokka.DokkaConfiguration -import org.jetbrains.dokka.Platform -import org.jetbrains.dokka.plugability.DokkaContext - -data class SourceSetData( - val moduleName: String, - val sourceSetID: String, - val displayName: String, - val platform: Platform, - val sourceRoots: List = emptyList(), - val dependentSourceSets: List = emptyList() -) - -class SourceSetCache { - private val sourceSets = HashMap() - - val allSourceSets: List - get() = sourceSets.values.toList() - - fun getSourceSet(pass: DokkaConfiguration.PassConfiguration) = - sourceSets.getOrPut(pass.sourceSetID, - { - SourceSetData( - pass.moduleName, - pass.sourceSetID, - pass.displayName, - pass.analysisPlatform, - pass.sourceRoots, - pass.dependentSourceSets - ) - } - ) -} - -fun DokkaContext.sourceSet(pass: DokkaConfiguration.PassConfiguration): SourceSetData = - sourceSetCache.getSourceSet(pass) \ No newline at end of file diff --git a/core/src/main/kotlin/model/documentableProperties.kt b/core/src/main/kotlin/model/documentableProperties.kt index 2aec199c..cd6a9335 100644 --- a/core/src/main/kotlin/model/documentableProperties.kt +++ b/core/src/main/kotlin/model/documentableProperties.kt @@ -1,26 +1,26 @@ 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 -data class InheritedFunction(val inheritedFrom: SourceSetDependent): ExtraProperty { +data class InheritedFunction(val inheritedFrom: SourceSetDependent) : ExtraProperty { companion object : ExtraProperty.Key { override fun mergeStrategyFor(left: InheritedFunction, right: InheritedFunction) = MergeStrategy.Replace( InheritedFunction(left.inheritedFrom + right.inheritedFrom) ) } - fun isInherited(sourceSetDependent: SourceSetData): Boolean = inheritedFrom[sourceSetDependent] != null + fun isInherited(sourceSetDependent: DokkaSourceSet): Boolean = inheritedFrom[sourceSetDependent] != null override val key: ExtraProperty.Key = InheritedFunction } -data class ImplementedInterfaces(val interfaces: SourceSetDependent>): ExtraProperty { +data class ImplementedInterfaces(val interfaces: SourceSetDependent>) : ExtraProperty { companion object : ExtraProperty.Key { - override fun mergeStrategyFor(left: ImplementedInterfaces, right: ImplementedInterfaces) = MergeStrategy.Replace( - ImplementedInterfaces(left.interfaces + right.interfaces) - ) + override fun mergeStrategyFor(left: ImplementedInterfaces, right: ImplementedInterfaces) = + MergeStrategy.Replace(ImplementedInterfaces(left.interfaces + right.interfaces)) } override val key: ExtraProperty.Key = ImplementedInterfaces diff --git a/core/src/main/kotlin/model/documentableUtils.kt b/core/src/main/kotlin/model/documentableUtils.kt index 2d4ade15..7057a62c 100644 --- a/core/src/main/kotlin/model/documentableUtils.kt +++ b/core/src/main/kotlin/model/documentableUtils.kt @@ -1,12 +1,14 @@ package org.jetbrains.dokka.model -fun SourceSetDependent.filtered(platformDataList: Set) = filter { it.key in platformDataList } -fun SourceSetData?.filtered(platformDataList: Set) = takeIf { this in platformDataList } +import org.jetbrains.dokka.DokkaConfiguration.DokkaSourceSet -fun DTypeParameter.filter(filteredData: Set) = - if (filteredData.containsAll(sourceSets)) this +fun SourceSetDependent.filtered(sourceSets: Set) = filter { it.key in sourceSets } +fun DokkaSourceSet?.filtered(sourceSets: Set) = takeIf { this in sourceSets } + +fun DTypeParameter.filter(filteredSet: Set) = + if (filteredSet.containsAll(sourceSets)) this else { - val intersection = filteredData.intersect(sourceSets) + val intersection = filteredSet.intersect(sourceSets) if (intersection.isEmpty()) null else DTypeParameter( dri, -- cgit