aboutsummaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorVadim Mishenev <vad-mishenev@yandex.ru>2022-03-28 18:26:29 +0300
committerGitHub <noreply@github.com>2022-03-28 18:26:29 +0300
commit57133de2fef1be68d9f05e6c262c31288de6cbcd (patch)
tree93ab537a9c1783d6f9dbf97534da5a8ab19eb2d1 /plugins
parent414475f9f87a9bc49b0a27f8cc4c690d6910a13e (diff)
downloaddokka-57133de2fef1be68d9f05e6c262c31288de6cbcd.tar.gz
dokka-57133de2fef1be68d9f05e6c262c31288de6cbcd.tar.bz2
dokka-57133de2fef1be68d9f05e6c262c31288de6cbcd.zip
Bug resolving in ultralightmethod (#2400)
Diffstat (limited to 'plugins')
-rw-r--r--plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt69
1 files changed, 67 insertions, 2 deletions
diff --git a/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt b/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt
index 27a06b77..9f74e219 100644
--- a/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt
+++ b/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt
@@ -1,13 +1,17 @@
package translators
-import org.jetbrains.dokka.model.doc.Text
-import org.jetbrains.dokka.model.firstMemberOfType
+import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.Annotations
+import org.jetbrains.dokka.model.TypeConstructor
+import org.jetbrains.dokka.model.doc.Text
+import org.jetbrains.dokka.model.firstMemberOfType
+import org.jetbrains.dokka.plugability.DokkaPlugin
import org.junit.jupiter.api.Assertions.assertEquals
import org.junit.jupiter.api.Assertions.assertTrue
import org.junit.jupiter.api.Test
+import utils.assertNotNull
class DefaultPsiToDocumentableTranslatorTest : BaseAbstractTest() {
val configuration = dokkaConfiguration {
@@ -193,4 +197,65 @@ class DefaultPsiToDocumentableTranslatorTest : BaseAbstractTest() {
}
}
}
+
+ class OnlyPsiPlugin : DokkaPlugin() {
+ private val dokkaBase by lazy { plugin<DokkaBase>() }
+
+ @Suppress("unused")
+ val psiOverrideDescriptorTranslator by extending {
+ (dokkaBase.psiToDocumentableTranslator
+ override dokkaBase.descriptorToDocumentableTranslator)
+ }
+ }
+
+ // for Kotlin classes from DefaultPsiToDocumentableTranslator
+ @Test
+ fun `should resolve ultralight class`() {
+ val configurationWithNoJVM = dokkaConfiguration {
+ sourceSets {
+ sourceSet {
+ sourceRoots = listOf("src/main/java")
+ }
+ }
+ }
+
+ testInline(
+ """
+ |/src/main/java/example/Test.kt
+ |package example
+ |
+ |open class KotlinSubClass {
+ | fun kotlinSubclassFunction(bar: String): String {
+ | return "KotlinSubClass"
+ | }
+ |}
+ |
+ |/src/main/java/example/JavaLeafClass.java
+ |package example;
+ |
+ |public class JavaLeafClass extends KotlinSubClass {
+ | public String javaLeafClassFunction(String baz) {
+ | return "JavaLeafClass";
+ | }
+ |}
+ """.trimMargin(),
+ configurationWithNoJVM,
+ pluginOverrides = listOf(OnlyPsiPlugin()) // suppress a descriptor translator because of psi and descriptor translators work in parallel
+ ) {
+ documentablesMergingStage = { module ->
+ val kotlinSubclassFunction =
+ module.packages.single().classlikes.find { it.name == "JavaLeafClass" }?.functions?.find { it.name == "kotlinSubclassFunction" }
+ .assertNotNull("kotlinSubclassFunction ")
+
+ assertEquals(
+ "String",
+ (kotlinSubclassFunction.type as? TypeConstructor)?.dri?.classNames
+ )
+ assertEquals(
+ "String",
+ (kotlinSubclassFunction.parameters.firstOrNull()?.type as? TypeConstructor)?.dri?.classNames
+ )
+ }
+ }
+ }
}