aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java/src/main
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-09-09 14:26:28 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-09-10 13:11:02 +0200
commit3792ef312ef347ef3300690e71c1cbf963a175e3 (patch)
tree8c9ece686ca772896602a8571ea54fcbd894d1bd /plugins/kotlin-as-java/src/main
parentd8a3e7db72109c8f439095a924bdc1da47b6ab6a (diff)
downloaddokka-3792ef312ef347ef3300690e71c1cbf963a175e3.tar.gz
dokka-3792ef312ef347ef3300690e71c1cbf963a175e3.tar.bz2
dokka-3792ef312ef347ef3300690e71c1cbf963a175e3.zip
Add tests
Diffstat (limited to 'plugins/kotlin-as-java/src/main')
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt27
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt13
2 files changed, 29 insertions, 11 deletions
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 d79bd7b1..38d904e4 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
@@ -175,20 +175,33 @@ internal fun DClass.asJava(): DClass = copy(
private fun DTypeParameter.asJava(): DTypeParameter = copy(
variantTypeParameter = variantTypeParameter.withDri(dri.possiblyAsJava()),
- bounds = bounds.map { it.asJava() }
+ bounds = bounds.map { it.asJava() as Bound }
)
-private fun Bound.asJava(): Bound = when (this) {
+private fun Projection.asJava(): Projection = when(this) {
+ is Star -> Star
+ is Covariance<*> -> copy(inner.asJava())
+ is Contravariance<*> -> copy(inner.asJava())
+ is Invariance<*> -> copy(inner.asJava())
+ is Bound -> asJava()
+}
+
+private fun Bound.asJava(): Bound = when(this) {
+ is TypeParameter -> copy(dri.possiblyAsJava())
is TypeConstructor -> copy(
- dri = dri.possiblyAsJava()
+ dri = dri.possiblyAsJava(),
+ projections = projections.map { it.asJava() }
)
is TypeAliased -> copy(
+ typeAlias = typeAlias.asJava(),
inner = inner.asJava()
)
- is Nullable -> copy(
- inner = inner.asJava()
- )
- else -> this
+ is Nullable -> copy(inner.asJava())
+ is PrimitiveJavaType -> this
+ is Void -> this
+ is JavaObject -> this
+ is Dynamic -> this
+ is UnresolvedBound -> this
}
internal fun DEnum.asJava(): DEnum = copy(
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 d24fa428..1d62a206 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
@@ -79,10 +79,10 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
c.supertypes.map { (p, dris) ->
val (classes, interfaces) = dris.partition { it.kind == JavaClassKindTypes.CLASS }
list(classes, prefix = " extends ", sourceSets = setOf(p)) {
- link(it.typeConstructor.dri.sureClassNames, it.typeConstructor.dri, sourceSets = setOf(p))
+ signatureForProjection(it.typeConstructor)
}
- list(interfaces, prefix = " implements ", sourceSets = setOf(p)){
- link(it.typeConstructor.dri.sureClassNames, it.typeConstructor.dri, sourceSets = setOf(p))
+ list(interfaces, prefix = " implements ", sourceSets = setOf(p)) {
+ signatureForProjection(it.typeConstructor)
}
}
}
@@ -160,7 +160,12 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
}
is Variance<*> -> group(styles = emptySet()) {
- text("$p ".takeIf { it.isNotBlank() } ?: "") // TODO: "super" && "extends"
+ val variance = when(p) {
+ is Covariance<*> -> "? extends "
+ is Contravariance<*> -> "? super "
+ is Invariance<*> -> ""
+ }
+ text(variance)
signatureForProjection(p.inner)
}