aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
authorSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-02-27 19:17:15 +0300
committerSimon Ogorodnik <Simon.Ogorodnik@jetbrains.com>2017-02-27 19:17:15 +0300
commit05c5a8f20167b652f918e8260fd16453efadf5ff (patch)
tree6bcc70e637623c307844a7f1dfda0856fe795069 /core
parent20b3b0d018248cbde0c509603c52c36445d996f0 (diff)
downloaddokka-05c5a8f20167b652f918e8260fd16453efadf5ff.tar.gz
dokka-05c5a8f20167b652f918e8260fd16453efadf5ff.tar.bz2
dokka-05c5a8f20167b652f918e8260fd16453efadf5ff.zip
Render functional type in parenthesis when it in receiver position
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinLanguageService.kt10
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt4
-rw-r--r--core/testdata/format/renderFunctionalTypeInParenthesisWhenItIsReceiver.kt3
-rw-r--r--core/testdata/format/renderFunctionalTypeInParenthesisWhenItIsReceiver.md6
4 files changed, 22 insertions, 1 deletions
diff --git a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
index e54772b3..f33c8c96 100644
--- a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
+++ b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
@@ -414,7 +414,15 @@ class KotlinLanguageService : LanguageService {
if (signatureMapper != null) {
signatureMapper.renderReceiver(receiver, this)
} else {
- renderType(receiver.detail(NodeKind.Type), renderMode)
+ val type = receiver.detail(NodeKind.Type)
+
+ if (type.isFunctionalType()) {
+ symbol("(")
+ renderFunctionalType(type, renderMode)
+ symbol(")")
+ } else {
+ renderType(type, renderMode)
+ }
}
symbol(".")
}
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index 4830d760..121e9afb 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -254,6 +254,10 @@ class MarkdownFormatTest {
verifyMarkdownNodes("memberExtension") { model -> model.members.single().members.filter { it.name == "Foo" } }
}
+ @Test fun renderFunctionalTypeInParenthesisWhenItIsReceiver() {
+ verifyMarkdownNode("renderFunctionalTypeInParenthesisWhenItIsReceiver")
+ }
+
@Test fun multiplePlatforms() {
verifyMultiplatformPackage(buildMultiplePlatforms("multiplatform"), "multiplatform")
}
diff --git a/core/testdata/format/renderFunctionalTypeInParenthesisWhenItIsReceiver.kt b/core/testdata/format/renderFunctionalTypeInParenthesisWhenItIsReceiver.kt
new file mode 100644
index 00000000..84f78dfb
--- /dev/null
+++ b/core/testdata/format/renderFunctionalTypeInParenthesisWhenItIsReceiver.kt
@@ -0,0 +1,3 @@
+fun (suspend () -> Unit).foo() {
+
+} \ No newline at end of file
diff --git a/core/testdata/format/renderFunctionalTypeInParenthesisWhenItIsReceiver.md b/core/testdata/format/renderFunctionalTypeInParenthesisWhenItIsReceiver.md
new file mode 100644
index 00000000..c9856976
--- /dev/null
+++ b/core/testdata/format/renderFunctionalTypeInParenthesisWhenItIsReceiver.md
@@ -0,0 +1,6 @@
+[test](test/index) / [kotlin.SuspendFunction0](test/kotlin.-suspend-function0/index)
+
+### Extensions for kotlin.SuspendFunction0
+
+| [foo](test/kotlin.-suspend-function0/foo) | `fun (suspend () -> Unit).foo(): Unit` |
+