diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-09-17 13:35:13 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-09-28 17:22:14 +0200 |
commit | 64ec7ad22e9541b639e854aa413a2cffd650e8d0 (patch) | |
tree | 42106fc356b23ce1a3c394deccb59e74d80ff0f0 /core | |
parent | 2274d9261a59570cc3a1a26c3f7ddc167678fe8b (diff) | |
download | dokka-64ec7ad22e9541b639e854aa413a2cffd650e8d0.tar.gz dokka-64ec7ad22e9541b639e854aa413a2cffd650e8d0.tar.bz2 dokka-64ec7ad22e9541b639e854aa413a2cffd650e8d0.zip |
Add better handling of functional types in rendered output
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/kotlin/model/Documentable.kt | 40 |
1 files changed, 26 insertions, 14 deletions
diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index f3b88d8e..62268fef 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -340,12 +340,13 @@ data class DTypeParameter( constructor( dri: DRI, name: String, + presentableName: String?, documentation: SourceSetDependent<DocumentationNode>, expectPresentInSet: DokkaSourceSet?, bounds: List<Bound>, sourceSets: Set<DokkaSourceSet>, extra: PropertyContainer<DTypeParameter> = PropertyContainer.empty() - ) : this(Invariance(TypeParameter(dri, name)), documentation, expectPresentInSet, bounds, sourceSets, extra) + ) : 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 @@ -376,13 +377,28 @@ data class DTypeAlias( sealed class Projection sealed class Bound : Projection() -data class TypeParameter(val dri: DRI, val name: String) : Bound() +data class TypeParameter(val dri: DRI, val name: String, val presentableName: String? = null) : Bound() object Star : Projection() -data class TypeConstructor( - val dri: DRI, - val projections: List<Projection>, - val modifier: FunctionModifiers = FunctionModifiers.NONE -) : Bound() + +sealed class TypeConstructor : Bound() { + abstract val dri: DRI + abstract val projections: List<Projection> + abstract val presentableName: String? +} + +data class GenericTypeConstructor( + override val dri: DRI, + override val projections: List<Projection>, + override val presentableName: String? = null +) : TypeConstructor() + +data class FunctionalTypeConstructor( + override val dri: DRI, + override val projections: List<Projection>, + val isExtensionFunction: Boolean = false, + val isSuspendable: Boolean = false, + override val presentableName: String? = null +) : TypeConstructor() data class Nullable(val inner: Bound) : Bound() @@ -406,14 +422,10 @@ object JavaObject : Bound() object Dynamic : Bound() data class UnresolvedBound(val name: String) : Bound() -enum class FunctionModifiers { - NONE, FUNCTION, EXTENSION -} - fun Variance<TypeParameter>.withDri(dri: DRI) = when(this) { - is Contravariance -> Contravariance(TypeParameter(dri, inner.name)) - is Covariance -> Covariance(TypeParameter(dri, inner.name)) - is Invariance -> Invariance(TypeParameter(dri, inner.name)) + 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)) } private fun String.shorten(maxLength: Int) = lineSequence().first().let { |