aboutsummaryrefslogtreecommitdiff
path: root/core
diff options
context:
space:
mode:
Diffstat (limited to 'core')
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinLanguageService.kt10
-rw-r--r--core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt3
-rw-r--r--core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt4
-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
-rw-r--r--core/testdata/format/website-samples/newLinesInImportList.kt12
-rw-r--r--core/testdata/format/website-samples/newLinesInImportList.md24
8 files changed, 64 insertions, 2 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/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt b/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt
index ca857aaa..7ac43184 100644
--- a/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt
+++ b/core/src/main/kotlin/Samples/KotlinWebsiteSampleProcessingService.kt
@@ -5,6 +5,7 @@ import com.intellij.psi.PsiElement
import com.intellij.psi.impl.source.tree.LeafPsiElement
import org.jetbrains.dokka.*
import org.jetbrains.kotlin.psi.*
+import org.jetbrains.kotlin.psi.psiUtil.allChildren
import org.jetbrains.kotlin.resolve.ImportPath
open class KotlinWebsiteSampleProcessingService
@@ -70,7 +71,7 @@ open class KotlinWebsiteSampleProcessingService
return ContentBlockCode("kotlin").apply {
append(ContentText("\n"))
psiFile.importList?.let {
- it.children.filter {
+ it.allChildren.filter {
it !is KtImportDirective || it.importPath !in importsToIgnore
}.forEach { append(ContentText(it.text)) }
}
diff --git a/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt b/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt
index 3e46ead7..0d586814 100644
--- a/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt
+++ b/core/src/test/kotlin/format/KotlinWebSiteRunnableSamplesFormatTest.kt
@@ -24,6 +24,10 @@ class KotlinWebSiteRunnableSamplesFormatTest {
verifyKWSNodeByName("newLinesInSamples", "foo")
}
+ @Test fun newLinesInImportList() {
+ verifyKWSNodeByName("newLinesInImportList", "foo")
+ }
+
private fun verifyKWSNodeByName(fileName: String, name: String) {
verifyOutput("testdata/format/website-samples/$fileName.kt", ".md", format = "kotlin-website-samples") { model, output ->
kwsService.createOutputBuilder(output, tempLocation).appendNodes(model.members.single().members.filter { it.name == name })
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index d21528b5..cdb55cba 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/simple"), "multiplatform/simple")
}
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` |
+
diff --git a/core/testdata/format/website-samples/newLinesInImportList.kt b/core/testdata/format/website-samples/newLinesInImportList.kt
new file mode 100644
index 00000000..836d9f6f
--- /dev/null
+++ b/core/testdata/format/website-samples/newLinesInImportList.kt
@@ -0,0 +1,12 @@
+import same.*
+import some.*
+
+/**
+ * @sample example1
+ */
+fun foo() {
+}
+
+fun example1() {
+
+} \ No newline at end of file
diff --git a/core/testdata/format/website-samples/newLinesInImportList.md b/core/testdata/format/website-samples/newLinesInImportList.md
new file mode 100644
index 00000000..27d796f8
--- /dev/null
+++ b/core/testdata/format/website-samples/newLinesInImportList.md
@@ -0,0 +1,24 @@
+---
+title: foo - test
+layout: api
+---
+
+<div class='api-docs-breadcrumbs'><a href="test/index">test</a> / <a href="test/foo">foo</a></div>
+
+# foo
+
+<div class="signature"><code><span class="keyword">fun </span><span class="identifier">foo</span><span class="symbol">(</span><span class="symbol">)</span><span class="symbol">: </span><span class="identifier">Unit</span></code></div>
+<div class="sample" markdown="1">
+
+``` kotlin
+import same.*
+import some.*
+
+fun main(args: Array<String>) {
+//sampleStart
+
+//sampleEnd
+}
+```
+
+</div>