diff options
author | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-02-16 17:50:23 +0300 |
---|---|---|
committer | Simon Ogorodnik <Simon.Ogorodnik@jetbrains.com> | 2017-02-16 17:50:23 +0300 |
commit | 994a86700210fe5f26a8bc131815bde2f6269ac5 (patch) | |
tree | 0a58b950b24288d2b1692aaf9136ec1f0433944c /core/src/main/kotlin/Kotlin/KotlinLanguageService.kt | |
parent | dcb948ea12a7ef3c2515dc621d648baf4c6806d9 (diff) | |
download | dokka-994a86700210fe5f26a8bc131815bde2f6269ac5.tar.gz dokka-994a86700210fe5f26a8bc131815bde2f6269ac5.tar.bz2 dokka-994a86700210fe5f26a8bc131815bde2f6269ac5.zip |
KT-16262 Dokka does not render suspending function types properly
#KT-16262 fixed
Diffstat (limited to 'core/src/main/kotlin/Kotlin/KotlinLanguageService.kt')
-rw-r--r-- | core/src/main/kotlin/Kotlin/KotlinLanguageService.kt | 58 |
1 files changed, 38 insertions, 20 deletions
diff --git a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt index 75a8a948..faac9f7d 100644 --- a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt +++ b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt @@ -151,26 +151,43 @@ class KotlinLanguageService : LanguageService { } } - private fun ContentBlock.renderType(node: DocumentationNode, renderMode: RenderMode) { + private fun ContentBlock.renderFunctionalType(node: DocumentationNode, renderMode: RenderMode) { var typeArguments = node.details(NodeKind.Type) - if (node.name == "Function${typeArguments.count() - 1}") { - // lambda - val isExtension = node.annotations.any { it.name == "ExtensionFunctionType" } - if (isExtension) { - renderType(typeArguments.first(), renderMode) - symbol(".") - typeArguments = typeArguments.drop(1) - } - symbol("(") - renderList(typeArguments.take(typeArguments.size - 1), noWrap = true) { - renderFunctionalTypeParameterName(it, renderMode) - renderType(it, renderMode) - } - symbol(")") - nbsp() - symbol("->") - nbsp() - renderType(typeArguments.last(), renderMode) + + if (node.name.startsWith("Suspend")) { + keyword("suspend ") + } + + // lambda + val isExtension = node.annotations.any { it.name == "ExtensionFunctionType" } + if (isExtension) { + renderType(typeArguments.first(), renderMode) + symbol(".") + typeArguments = typeArguments.drop(1) + } + symbol("(") + renderList(typeArguments.take(typeArguments.size - 1), noWrap = true) { + renderFunctionalTypeParameterName(it, renderMode) + renderType(it, renderMode) + } + symbol(")") + nbsp() + symbol("->") + nbsp() + renderType(typeArguments.last(), renderMode) + + } + + private fun DocumentationNode.isFunctionalType(): Boolean { + val typeArguments = details(NodeKind.Type) + val functionalTypeName = "Function${typeArguments.count() - 1}" + val suspendFunctionalTypeName = "Suspend$functionalTypeName" + return name == functionalTypeName || name == suspendFunctionalTypeName + } + + private fun ContentBlock.renderType(node: DocumentationNode, renderMode: RenderMode) { + if (node.isFunctionalType()) { + renderFunctionalType(node, renderMode) return } if (renderMode == RenderMode.FULL) { @@ -178,7 +195,8 @@ class KotlinLanguageService : LanguageService { } renderModifiersForNode(node, renderMode, true) renderLinked(node) { identifier(it.name, IdentifierKind.TypeName) } - if (typeArguments.any()) { + val typeArguments = node.details(NodeKind.Type) + if (typeArguments.isNotEmpty()) { symbol("<") renderList(typeArguments, noWrap = true) { renderType(it, renderMode) |