aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/signatures
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-09-17 13:35:13 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-09-28 17:22:14 +0200
commit64ec7ad22e9541b639e854aa413a2cffd650e8d0 (patch)
tree42106fc356b23ce1a3c394deccb59e74d80ff0f0 /plugins/base/src/main/kotlin/signatures
parent2274d9261a59570cc3a1a26c3f7ddc167678fe8b (diff)
downloaddokka-64ec7ad22e9541b639e854aa413a2cffd650e8d0.tar.gz
dokka-64ec7ad22e9541b639e854aa413a2cffd650e8d0.tar.bz2
dokka-64ec7ad22e9541b639e854aa413a2cffd650e8d0.zip
Add better handling of functional types in rendered output
Diffstat (limited to 'plugins/base/src/main/kotlin/signatures')
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt28
1 files changed, 14 insertions, 14 deletions
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index 0a22cece..d701de04 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -323,14 +323,15 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
when (p) {
is TypeParameter -> link(p.name, p.dri)
- is TypeConstructor -> if (p.function)
+ is FunctionalTypeConstructor ->
+funType(mainDRI.single(), mainSourcesetData, p)
- else
+
+ is GenericTypeConstructor ->
group(styles = emptySet()) {
val linkText = if (showFullyQualifiedName && p.dri.packageName != null) {
"${p.dri.packageName}.${p.dri.classNames.orEmpty()}"
} else p.dri.classNames.orEmpty()
-
+ if (p.presentableName != null) text(p.presentableName + ": ")
link(linkText, p.dri)
list(p.projections, prefix = "<", suffix = ">") {
signatureForProjection(it, showFullyQualifiedName)
@@ -357,14 +358,18 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
is UnresolvedBound -> text(p.name)
}
- private fun funType(dri: DRI, sourceSets: Set<DokkaSourceSet>, type: TypeConstructor) =
+ private fun funType(dri: DRI, sourceSets: Set<DokkaSourceSet>, type: FunctionalTypeConstructor) =
contentBuilder.contentFor(dri, sourceSets, ContentKind.Main) {
- if (type.extension) {
+
+ if (type.presentableName != null) text(type.presentableName + ": ")
+ if (type.isSuspendable) text("suspend ")
+
+ if (type.isExtensionFunction) {
signatureForProjection(type.projections.first())
text(".")
}
- val args = if (type.extension)
+ val args = if (type.isExtensionFunction)
type.projections.drop(1)
else
type.projections
@@ -379,16 +384,11 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
}
}
-private fun PrimitiveJavaType.translateToKotlin() = TypeConstructor(
+private fun PrimitiveJavaType.translateToKotlin() = GenericTypeConstructor(
dri = dri,
- projections = emptyList()
+ projections = emptyList(),
+ presentableName = null
)
private val DTypeParameter.nontrivialBounds: List<Bound>
get() = bounds.filterNot { it is Nullable && it.inner.driOrNull == DriOfAny }
-
-val TypeConstructor.function
- get() = modifier == FunctionModifiers.FUNCTION || modifier == FunctionModifiers.EXTENSION
-
-val TypeConstructor.extension
- get() = modifier == FunctionModifiers.EXTENSION