aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinLanguageService.kt16
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt4
-rw-r--r--core/testdata/format/nullableTypeParameterFunction.kt8
-rw-r--r--core/testdata/format/nullableTypeParameterFunction.md18
4 files changed, 43 insertions, 3 deletions
diff --git a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
index f57708ed..5f43c22e 100644
--- a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
+++ b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
@@ -166,8 +166,18 @@ class KotlinLanguageService : CommonLanguageService() {
keyword("dynamic")
return
}
+
+ val nullabilityModifier = node.detailOrNull(NodeKind.NullabilityModifier)
+
if (node.isFunctionalType()) {
- renderFunctionalType(node, renderMode)
+ if (nullabilityModifier != null) {
+ symbol("(")
+ renderFunctionalType(node, renderMode)
+ symbol(")")
+ symbol(nullabilityModifier.name)
+ } else {
+ renderFunctionalType(node, renderMode)
+ }
return
}
if (renderMode == RenderMode.FULL) {
@@ -185,8 +195,8 @@ class KotlinLanguageService : CommonLanguageService() {
}
symbol(">")
}
- val nullabilityModifier = node.details(NodeKind.NullabilityModifier).singleOrNull()
- if (nullabilityModifier != null) {
+
+ nullabilityModifier ?.apply {
symbol(nullabilityModifier.name)
}
}
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index 9fb34e95..b078292b 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -539,4 +539,8 @@ class MarkdownFormatTest: FileGeneratorTestCase() {
nodesWithName
}
}
+
+ @Test fun nullableTypeParameterFunction() {
+ verifyMarkdownNode("nullableTypeParameterFunction", withKotlinRuntime = true)
+ }
}
diff --git a/core/testdata/format/nullableTypeParameterFunction.kt b/core/testdata/format/nullableTypeParameterFunction.kt
new file mode 100644
index 00000000..01805a7b
--- /dev/null
+++ b/core/testdata/format/nullableTypeParameterFunction.kt
@@ -0,0 +1,8 @@
+class Bar<T> {
+ val dataList = mutableListOf<T>()
+
+ open fun checkElement(
+ elem: T,
+ addFunc: ((elem: T) -> Unit)? = { dataList.add(it) }
+ ): Int = 1
+} \ No newline at end of file
diff --git a/core/testdata/format/nullableTypeParameterFunction.md b/core/testdata/format/nullableTypeParameterFunction.md
new file mode 100644
index 00000000..5764007b
--- /dev/null
+++ b/core/testdata/format/nullableTypeParameterFunction.md
@@ -0,0 +1,18 @@
+[test](../index.md) / [Bar](./index.md)
+
+# Bar
+
+`class Bar<T>`
+
+### Constructors
+
+| [&lt;init&gt;](-init-.md) | `Bar()` |
+
+### Properties
+
+| [dataList](data-list.md) | `val dataList: MutableList<`[`T`](index.md#T)`>` |
+
+### Functions
+
+| [checkElement](check-element.md) | `fun checkElement(elem: `[`T`](index.md#T)`, addFunc: ((elem: `[`T`](index.md#T)`) -> Unit)? = { dataList.add(it) }): Int` |
+