diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt | 69 |
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 + ) + } + } + } } |