diff options
9 files changed, 27 insertions, 13 deletions
diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index c7338458..d7bc52aa 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -399,6 +399,8 @@ data class Invariance<out T : Bound>(override val inner: T) : Variance<T>() { override fun toString() = "" } +data class TypeAliased(val typeAlias: Bound, val inner: Bound) : Bound() + data class PrimitiveJavaType(val name: String) : Bound() object Void : Bound() object JavaObject : Bound() diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt index be9543f4..2a091ff5 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt @@ -345,6 +345,8 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog text("?") } + is TypeAliased -> signatureForProjection(p.typeAlias) + is JavaObject -> link("Any", DriOfAny) is Void -> link("Unit", DriOfUnit) is PrimitiveJavaType -> signatureForProjection(p.translateToKotlin(), showFullyQualifiedName) diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt index c40c48a2..2266b691 100644 --- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt +++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt @@ -35,14 +35,15 @@ object KotlinSignatureUtils : JvmSignatureUtils { val Bound.driOrNull: DRI? get() { return when (this) { - is TypeParameter -> this.dri - is TypeConstructor -> this.dri - is Nullable -> this.inner.driOrNull - is PrimitiveJavaType -> this.dri + is TypeParameter -> dri + is TypeConstructor -> dri + is Nullable -> inner.driOrNull + is PrimitiveJavaType -> dri is Void -> DriOfUnit is JavaObject -> DriOfAny is Dynamic -> null is UnresolvedBound -> null + is TypeAliased -> typeAlias.driOrNull } } @@ -57,6 +58,7 @@ object KotlinSignatureUtils : JvmSignatureUtils { is UnresolvedBound -> emptyList() is Variance<*> -> inner.drisOfAllNestedBounds is Star -> emptyList() + is TypeAliased -> listOfNotNull(typeAlias.driOrNull, inner.driOrNull) } } diff --git a/plugins/base/src/main/kotlin/transformers/documentables/ExtensionExtractorTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/ExtensionExtractorTransformer.kt index af65c205..2a8baf0b 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/ExtensionExtractorTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/ExtensionExtractorTransformer.kt @@ -9,6 +9,7 @@ import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.flow import kotlinx.coroutines.flow.flowOn import kotlinx.coroutines.flow.toList +import org.jetbrains.dokka.base.signatures.KotlinSignatureUtils.driOrNull import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.links.DriOfAny import org.jetbrains.dokka.model.* @@ -101,6 +102,7 @@ private fun Callable.findReceiverDRIs(bound: Bound): Sequence<DRI> = when (bound is JavaObject -> sequenceOf(DriOfAny) is Dynamic -> sequenceOf(DriOfAny) is UnresolvedBound -> emptySequence() + is TypeAliased -> findReceiverDRIs(bound.typeAlias) } private fun <T, U> Iterable<Pair<T, U>>.toMultiMap(): Map<T, List<U>> = @@ -124,4 +126,4 @@ fun <T : Any> ReceiveChannel<T>.consumeAsFlow(): Flow<T> = flow { } catch (_: ClosedReceiveChannelException) { // cool and good } -}.flowOn(Dispatchers.Default)
\ No newline at end of file +}.flowOn(Dispatchers.Default) diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index d42acb32..392bba7e 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -631,12 +631,12 @@ private class DokkaDescriptorVisitor( private fun KotlinType.toBound(): Bound = when (this) { is DynamicType -> Dynamic + is AbbreviatedType -> TypeAliased( + abbreviation.toBound(), + expandedType.toBound() + ) else -> { - val ctor = when (this) { - is AbbreviatedType -> abbreviation.constructor.declarationDescriptor - else -> constructor.declarationDescriptor - } - when (ctor) { + when (val ctor = constructor.declarationDescriptor) { is TypeParameterDescriptor -> TypeParameter( dri = DRI.from(ctor), name = ctor.name.asString() diff --git a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt index 7ebc3b4d..df2c3825 100644 --- a/plugins/base/src/test/kotlin/signatures/SignatureTest.kt +++ b/plugins/base/src/test/kotlin/signatures/SignatureTest.kt @@ -442,8 +442,8 @@ class SignatureTest : AbstractCoreTest() { ) { renderingStage = { _, _ -> writerPlugin.writer.renderedContent("root/example.html").signature().first().match( - "typealias ", A("GenericTypealias"), "<", Span("T"), "> = ", A("Comparable"), - "<", Span("T"), ">", Span() + "typealias ", A("GenericTypealias"), "<", A("T"), "> = ", A("Comparable"), + "<", A("T"), ">", Span() ) } } diff --git a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt index 2183fd1c..735309fc 100644 --- a/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt +++ b/plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt @@ -202,6 +202,7 @@ class JavadocSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLo is Void -> text("void") is PrimitiveJavaType -> text(p.name) is UnresolvedBound -> text(p.name) + is TypeAliased -> signatureForProjection(p.inner) } private fun DRI.fqName(): String = "${packageName.orEmpty()}.${classNames.orEmpty()}" diff --git a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt index e0ac3c40..d79bd7b1 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt @@ -58,7 +58,8 @@ internal fun DPackage.asJava(): DPackage { return copy( functions = emptyList(), properties = emptyList(), - classlikes = classlikes.map { it.asJava() } + syntheticClasses + classlikes = classlikes.map { it.asJava() } + syntheticClasses, + typealiases = emptyList() ) } @@ -181,6 +182,9 @@ private fun Bound.asJava(): Bound = when (this) { is TypeConstructor -> copy( dri = dri.possiblyAsJava() ) + is TypeAliased -> copy( + inner = inner.asJava() + ) is Nullable -> copy( inner = inner.asJava() ) diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt index 121c4def..d24fa428 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt @@ -172,5 +172,6 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge is Void -> text("void") is PrimitiveJavaType -> text(p.name) is UnresolvedBound -> text(p.name) + is TypeAliased -> signatureForProjection(p.inner) } } |