aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/kotlin
diff options
context:
space:
mode:
authorDmitry Jemerov <yole@jetbrains.com>2016-01-05 18:01:13 +0100
committerDmitry Jemerov <yole@jetbrains.com>2016-01-05 18:01:13 +0100
commitada91f40f716b20a69d8372dc5c6e250312543f7 (patch)
tree74c3cb25f8662c5c3db30f572b9abae764a59664 /core/src/main/kotlin
parent9b9b689d67a20abb52fcde5ed4655d9a5092b8df (diff)
downloaddokka-ada91f40f716b20a69d8372dc5c6e250312543f7.tar.gz
dokka-ada91f40f716b20a69d8372dc5c6e250312543f7.tar.bz2
dokka-ada91f40f716b20a69d8372dc5c6e250312543f7.zip
render multiple type parameter constraints according to current Kotlin syntax
Diffstat (limited to 'core/src/main/kotlin')
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinLanguageService.kt25
1 files changed, 22 insertions, 3 deletions
diff --git a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
index 9c9c9fc7..a5bb5ee7 100644
--- a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
+++ b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
@@ -115,8 +115,8 @@ class KotlinLanguageService : LanguageService {
identifier(node.name)
}
- private fun ContentBlock.renderList(nodes: List<DocumentationNode>, separator: String = ", ",
- noWrap: Boolean = false, renderItem: (DocumentationNode) -> Unit) {
+ private fun <T> ContentBlock.renderList(nodes: List<T>, separator: String = ", ",
+ noWrap: Boolean = false, renderItem: (T) -> Unit) {
if (nodes.none())
return
renderItem(nodes.first())
@@ -201,7 +201,7 @@ class KotlinLanguageService : LanguageService {
identifier(node.name)
val constraints = node.details(NodeKind.UpperBound)
- if (constraints.any()) {
+ if (constraints.size == 1) {
nbsp()
symbol(":")
nbsp()
@@ -240,6 +240,22 @@ class KotlinLanguageService : LanguageService {
}
}
+ private fun ContentBlock.renderExtraTypeParameterConstraints(node: DocumentationNode, renderMode: RenderMode) {
+ val parametersWithMultipleConstraints = node.details(NodeKind.TypeParameter).filter { it.details(NodeKind.UpperBound).size > 1 }
+ val parametersWithConstraints = parametersWithMultipleConstraints
+ .flatMap { parameter -> parameter.details(NodeKind.UpperBound).map { constraint -> parameter to constraint } }
+ if (parametersWithMultipleConstraints.isNotEmpty()) {
+ keyword(" where ")
+ renderList(parametersWithConstraints) {
+ identifier(it.first.name)
+ nbsp()
+ symbol(":")
+ nbsp()
+ renderType(it.second, renderMode)
+ }
+ }
+ }
+
private fun ContentBlock.renderSupertypesForNode(node: DocumentationNode, renderMode: RenderMode) {
val supertypes = node.details(NodeKind.Supertype)
if (supertypes.any()) {
@@ -305,6 +321,7 @@ class KotlinLanguageService : LanguageService {
identifierOrDeprecated(node)
renderTypeParametersForNode(node, renderMode)
renderSupertypesForNode(node, renderMode)
+ renderExtraTypeParameterConstraints(node, renderMode)
}
private fun ContentBlock.renderFunction(node: DocumentationNode,
@@ -347,6 +364,7 @@ class KotlinLanguageService : LanguageService {
else {
symbol(")")
}
+ renderExtraTypeParameterConstraints(node, renderMode)
}
private fun ContentBlock.renderReceiver(node: DocumentationNode, renderMode: RenderMode, signatureMapper: SignatureMapper?) {
@@ -391,6 +409,7 @@ class KotlinLanguageService : LanguageService {
identifierOrDeprecated(node)
symbol(": ")
renderType(node.detail(NodeKind.Type), renderMode)
+ renderExtraTypeParameterConstraints(node, renderMode)
}
fun DocumentationNode.getPropertyKeyword() =