aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt6
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt2
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt38
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt4
-rw-r--r--plugins/javadoc/src/main/kotlin/org/jetbrains/dokka/javadoc/signatures/JavadocSignatureProvider.kt6
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt2
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt6
7 files changed, 33 insertions, 31 deletions
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index 82eeb296..d6beb474 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -295,7 +295,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
private fun signature(t: DTypeParameter) =
t.sourceSets.map {
contentBuilder.contentFor(t, styles = t.stylesIfDeprecated(it), sourceSets = setOf(it)) {
- link(t.name, t.dri.withTargetToDeclaration())
+ signatureForProjection(t.variantTypeParameter.withNewDri(t.dri.withTargetToDeclaration()))
list(t.nontrivialBounds, prefix = " : ") { bound ->
signatureForProjection(bound)
}
@@ -333,8 +333,8 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
}
}
- is Variance -> group(styles = emptySet()) {
- text(p.kind.toString() + " ")
+ is Variance<*> -> group(styles = emptySet()) {
+ text("$p ".takeIf { it.isNotBlank() } ?: "")
signatureForProjection(p.inner, showFullyQualifiedName)
}
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
index e8107177..c40c48a2 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
@@ -55,7 +55,7 @@ object KotlinSignatureUtils : JvmSignatureUtils {
is JavaObject -> listOf(DriOfAny)
is Dynamic -> emptyList()
is UnresolvedBound -> emptyList()
- is Variance -> inner.drisOfAllNestedBounds
+ is Variance<*> -> inner.drisOfAllNestedBounds
is Star -> emptyList()
}
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index 05c99af1..fccbe716 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -11,7 +11,6 @@ import org.jetbrains.dokka.links.Callable
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.Nullable
import org.jetbrains.dokka.model.TypeConstructor
-import org.jetbrains.dokka.model.Variance
import org.jetbrains.dokka.model.doc.*
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.plugability.DokkaContext
@@ -146,7 +145,7 @@ private class DokkaDescriptorVisitor(
visibility = descriptor.visibility.toDokkaVisibility().toSourceSetDependent(),
supertypes = info.supertypes.toSourceSetDependent(),
documentation = info.docs,
- generics = descriptor.declaredTypeParameters.map { it.toTypeParameter() },
+ generics = descriptor.declaredTypeParameters.map { it.toVariantTypeParameter() },
companion = descriptor.companion(driWithPlatform),
sourceSets = setOf(sourceSet),
extra = PropertyContainer.withAll(
@@ -254,7 +253,7 @@ private class DokkaDescriptorVisitor(
),
companion = descriptor.companionObjectDescriptor?.let { objectDescriptor(it, driWithPlatform) },
visibility = descriptor.visibility.toDokkaVisibility().toSourceSetDependent(),
- generics = descriptor.declaredTypeParameters.map { it.toTypeParameter() },
+ generics = descriptor.declaredTypeParameters.map { it.toVariantTypeParameter() },
constructors = descriptor.constructors.map { visitConstructorDescriptor(it, driWithPlatform) },
sources = descriptor.createSources()
)
@@ -284,7 +283,7 @@ private class DokkaDescriptorVisitor(
expectPresentInSet = sourceSet.takeIf { isExpect },
visibility = descriptor.visibility.toDokkaVisibility().toSourceSetDependent(),
supertypes = info.supertypes.toSourceSetDependent(),
- generics = descriptor.declaredTypeParameters.map { it.toTypeParameter() },
+ generics = descriptor.declaredTypeParameters.map { it.toVariantTypeParameter() },
documentation = info.docs,
modifier = descriptor.modifier().toSourceSetDependent(),
companion = descriptor.companion(driWithPlatform),
@@ -321,7 +320,7 @@ private class DokkaDescriptorVisitor(
type = descriptor.returnType!!.toBound(),
expectPresentInSet = sourceSet.takeIf { isExpect },
sourceSets = setOf(sourceSet),
- generics = descriptor.typeParameters.map { it.toTypeParameter() },
+ generics = descriptor.typeParameters.map { it.toVariantTypeParameter() },
extra = PropertyContainer.withAll(
(descriptor.additionalExtras() + descriptor.getAnnotationsWithBackingField()
.toAdditionalExtras()).toSet().toSourceSetDependent().toAdditionalModifiers(),
@@ -354,7 +353,7 @@ private class DokkaDescriptorVisitor(
expectPresentInSet = sourceSet.takeIf { isExpect },
sources = actual,
visibility = descriptor.visibility.toDokkaVisibility().toSourceSetDependent(),
- generics = descriptor.typeParameters.map { it.toTypeParameter() },
+ generics = descriptor.typeParameters.map { it.toVariantTypeParameter() },
documentation = descriptor.takeIf { it.kind != CallableMemberDescriptor.Kind.SYNTHESIZED }
?.resolveDescriptorData() ?: emptyMap(),
modifier = descriptor.modifier().toSourceSetDependent(),
@@ -402,7 +401,7 @@ private class DokkaDescriptorVisitor(
},
type = descriptor.returnType.toBound(),
modifier = descriptor.modifier().toSourceSetDependent(),
- generics = descriptor.typeParameters.map { it.toTypeParameter() },
+ generics = descriptor.typeParameters.map { it.toVariantTypeParameter() },
sourceSets = setOf(sourceSet),
extra = PropertyContainer.withAll<DFunction>(
descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(),
@@ -472,7 +471,7 @@ private class DokkaDescriptorVisitor(
visibility = descriptor.visibility.toDokkaVisibility().toSourceSetDependent(),
documentation = descriptor.resolveDescriptorData(),
type = descriptor.returnType!!.toBound(),
- generics = descriptor.typeParameters.map { it.toTypeParameter() },
+ generics = descriptor.typeParameters.map { it.toVariantTypeParameter() },
modifier = descriptor.modifier().toSourceSetDependent(),
expectPresentInSet = sourceSet.takeIf { isExpect },
receiver = descriptor.extensionReceiverParameter?.let {
@@ -501,7 +500,7 @@ private class DokkaDescriptorVisitor(
visibility = visibility.toDokkaVisibility().toSourceSetDependent(),
documentation = resolveDescriptorData(),
sourceSets = setOf(sourceSet),
- generics = descriptor.declaredTypeParameters.map { it.toTypeParameter() }
+ generics = descriptor.declaredTypeParameters.map { it.toVariantTypeParameter() }
)
}
@@ -588,10 +587,11 @@ private class DokkaDescriptorVisitor(
)
}
- private fun TypeParameterDescriptor.toTypeParameter() =
+ private fun TypeParameterDescriptor.toVariantTypeParameter() =
DTypeParameter(
- DRI.from(this).withPackageFallbackTo(fallbackPackageName()),
- name.identifier,
+ variantTypeParameter(
+ TypeParameter(DRI.from(this).withPackageFallbackTo(fallbackPackageName()), name.identifier)
+ ),
resolveDescriptorData(),
null,
upperBounds.map { it.toBound() },
@@ -621,12 +621,14 @@ private class DokkaDescriptorVisitor(
private fun TypeProjection.toProjection(): Projection =
if (isStarProjection) Star else formPossiblyVariant()
- private fun TypeProjection.formPossiblyVariant(): Projection = type.toBound().let {
- when (projectionKind) {
- org.jetbrains.kotlin.types.Variance.INVARIANT -> it
- org.jetbrains.kotlin.types.Variance.IN_VARIANCE -> Variance(Variance.Kind.In, it)
- org.jetbrains.kotlin.types.Variance.OUT_VARIANCE -> Variance(Variance.Kind.Out, it)
- }
+ private fun TypeProjection.formPossiblyVariant(): Projection = type.toBound().wrapWithVariance(projectionKind)
+
+ private fun TypeParameterDescriptor.variantTypeParameter(type: TypeParameter) = type.wrapWithVariance(variance)
+
+ private fun <T : Bound> T.wrapWithVariance(variance: org.jetbrains.kotlin.types.Variance) = when (variance) {
+ org.jetbrains.kotlin.types.Variance.INVARIANT -> Invariance(this)
+ org.jetbrains.kotlin.types.Variance.IN_VARIANCE -> Contravariance(this)
+ org.jetbrains.kotlin.types.Variance.OUT_VARIANCE -> Covariance(this)
}
private fun DeclarationDescriptor.getDocumentation() = findKDoc().let {
diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
index c9118920..c1ed4a08 100644
--- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
@@ -380,8 +380,8 @@ class DefaultPsiToDocumentableTranslator(
}
private fun getVariance(type: PsiWildcardType): Projection = when {
- type.extendsBound != PsiType.NULL -> Variance(Variance.Kind.Out, getBound(type.extendsBound))
- type.superBound != PsiType.NULL -> Variance(Variance.Kind.In, getBound(type.superBound))
+ type.extendsBound != PsiType.NULL -> Covariance(getBound(type.extendsBound))
+ type.superBound != PsiType.NULL -> Contravariance(getBound(type.superBound))
else -> throw IllegalStateException("${type.presentableText} has incorrect bounds")
}
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 d9aed18f..6c93c287 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
@@ -150,7 +150,7 @@ class JavadocSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLo
annotationsBlock(t)
}
signatureWithoutModifiers {
- text(t.name)
+ text(t.name) // Investigate if java classes can be somehow variant
}
supertypes {
list(t.bounds, prefix = "extends ") {
@@ -192,8 +192,8 @@ class JavadocSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLo
signatureForProjection(it)
}
}
- is Variance -> group {
- text(p.kind.toString() + " ")
+ is Variance<*> -> group {
+ text("$p ".takeIf { it.isNotBlank() } ?: "")
signatureForProjection(p.inner)
}
is Star -> text("?")
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 58c62622..f169f89a 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
@@ -172,7 +172,7 @@ internal fun DClass.asJava(): DClass = copy(
)
private fun DTypeParameter.asJava(): DTypeParameter = copy(
- dri = dri.possiblyAsJava(),
+ variantTypeParameter = variantTypeParameter.withNewDri(dri.possiblyAsJava()),
bounds = bounds.map { it.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 5134bd4d..d9b9dc5b 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
@@ -141,7 +141,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
private fun signature(t: DTypeParameter) =
t.sourceSets.map {
contentBuilder.contentFor(t, styles = t.stylesIfDeprecated(it), sourceSets = setOf(it)) {
- text(t.name.substringAfterLast("."))
+ text(t.name.substringAfterLast(".")) // Investigate if java classes can be somehow variant
list(t.bounds, prefix = " extends ") {
signatureForProjection(it)
}
@@ -159,8 +159,8 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
}
}
- is Variance -> group(styles = emptySet()) {
- text(p.kind.toString() + " ") // TODO: "super" && "extends"
+ is Variance<*> -> group(styles = emptySet()) {
+ text("$p ".takeIf { it.isNotBlank() } ?: "") // TODO: "super" && "extends"
signatureForProjection(p.inner)
}