aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/src/main/kotlin/Kotlin/DocumentationBuilder.kt12
-rw-r--r--core/src/main/kotlin/Kotlin/KotlinLanguageService.kt4
-rw-r--r--core/src/test/kotlin/format/MarkdownFormatTest.kt8
-rw-r--r--core/testdata/format/dynamicExtension.kt3
-rw-r--r--core/testdata/format/dynamicExtension.md10
-rw-r--r--core/testdata/format/dynamicType.kt2
-rw-r--r--core/testdata/format/dynamicType.md5
7 files changed, 41 insertions, 3 deletions
diff --git a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
index 4974b765..d9561980 100644
--- a/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
+++ b/core/src/main/kotlin/Kotlin/DocumentationBuilder.kt
@@ -165,6 +165,11 @@ class DocumentationBuilder
return appendType(it.abbreviation)
}
+ if (kotlinType.isDynamic()) {
+ append(DocumentationNode("dynamic", Content.Empty, kind), RefKind.Detail)
+ return
+ }
+
val classifierDescriptor = kotlinType.constructor.declarationDescriptor
val name = when (classifierDescriptor) {
is ClassDescriptor -> {
@@ -361,13 +366,14 @@ class DocumentationBuilder
.filter { it.extensionReceiverParameter != null }
val extensionFunctionsByName = allExtensionFunctions.groupBy { it.name }
- allExtensionFunctions.forEach { extensionFunction ->
+ for (extensionFunction in allExtensionFunctions) {
val possiblyShadowingFunctions = extensionFunctionsByName[extensionFunction.name]
?.filter { fn -> fn.canShadow(extensionFunction) }
?: emptyList()
- val classDescriptor = extensionFunction.getExtensionClassDescriptor() ?: return@forEach
- val subclasses = classHierarchy[classDescriptor] ?: return@forEach
+ if (extensionFunction.extensionReceiverParameter?.type?.isDynamic() == true) continue
+ val classDescriptor = extensionFunction.getExtensionClassDescriptor() ?: continue
+ val subclasses = classHierarchy[classDescriptor] ?: continue
subclasses.forEach { subclass ->
if (subclass.isExtensionApplicable(extensionFunction) &&
possiblyShadowingFunctions.none { subclass.isExtensionApplicable(it) }) {
diff --git a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
index faac9f7d..e54772b3 100644
--- a/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
+++ b/core/src/main/kotlin/Kotlin/KotlinLanguageService.kt
@@ -186,6 +186,10 @@ class KotlinLanguageService : LanguageService {
}
private fun ContentBlock.renderType(node: DocumentationNode, renderMode: RenderMode) {
+ if (node.name == "dynamic") {
+ keyword("dynamic")
+ return
+ }
if (node.isFunctionalType()) {
renderFunctionalType(node, renderMode)
return
diff --git a/core/src/test/kotlin/format/MarkdownFormatTest.kt b/core/src/test/kotlin/format/MarkdownFormatTest.kt
index dc24c8d8..7c1cc8b3 100644
--- a/core/src/test/kotlin/format/MarkdownFormatTest.kt
+++ b/core/src/test/kotlin/format/MarkdownFormatTest.kt
@@ -242,6 +242,14 @@ class MarkdownFormatTest {
verifyMarkdownPackage("sinceKotlin")
}
+ @Test fun dynamicType() {
+ verifyMarkdownNode("dynamicType")
+ }
+
+ @Test fun dynamicExtension() {
+ verifyMarkdownNodes("dynamicExtension") { model -> model.members.single().members.filter { it.name == "Foo" } }
+ }
+
@Test fun multiplePlatforms() {
verifyMultiplatformPackage(buildMultiplePlatforms("multiplatform"), "multiplatform")
}
diff --git a/core/testdata/format/dynamicExtension.kt b/core/testdata/format/dynamicExtension.kt
new file mode 100644
index 00000000..5c83bf22
--- /dev/null
+++ b/core/testdata/format/dynamicExtension.kt
@@ -0,0 +1,3 @@
+class Foo
+
+fun dynamic.bar() {}
diff --git a/core/testdata/format/dynamicExtension.md b/core/testdata/format/dynamicExtension.md
new file mode 100644
index 00000000..2fd928f6
--- /dev/null
+++ b/core/testdata/format/dynamicExtension.md
@@ -0,0 +1,10 @@
+[test](test/index) / [Foo](test/-foo/index)
+
+# Foo
+
+`class Foo`
+
+### Constructors
+
+| [<init>](test/-foo/-init-) | `Foo()` |
+
diff --git a/core/testdata/format/dynamicType.kt b/core/testdata/format/dynamicType.kt
new file mode 100644
index 00000000..9d557ac0
--- /dev/null
+++ b/core/testdata/format/dynamicType.kt
@@ -0,0 +1,2 @@
+fun foo(): dynamic = ""
+
diff --git a/core/testdata/format/dynamicType.md b/core/testdata/format/dynamicType.md
new file mode 100644
index 00000000..a3d6696b
--- /dev/null
+++ b/core/testdata/format/dynamicType.md
@@ -0,0 +1,5 @@
+[test](test/index) / [foo](test/foo)
+
+# foo
+
+`fun foo(): dynamic` \ No newline at end of file