aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/test/kotlin
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2022-08-30 13:27:59 +0200
committerGitHub <noreply@github.com>2022-08-30 13:27:59 +0200
commita4bccbf8920a2f6f5fcf5bdf1f201d1129a05b62 (patch)
tree9856dd2958398f8a675b4e7205c2f239550cea8e /plugins/base/src/test/kotlin
parente68eea63f2affbacf69af041252bad4444fc812f (diff)
downloaddokka-a4bccbf8920a2f6f5fcf5bdf1f201d1129a05b62.tar.gz
dokka-a4bccbf8920a2f6f5fcf5bdf1f201d1129a05b62.tar.bz2
dokka-a4bccbf8920a2f6f5fcf5bdf1f201d1129a05b62.zip
Handle `PsiImmediateClassType` as `PsiClassType` to resolve bounds (#2647)
Fixes #2646
Diffstat (limited to 'plugins/base/src/test/kotlin')
-rw-r--r--plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt53
1 files changed, 53 insertions, 0 deletions
diff --git a/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt b/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt
index f5c96f4a..5f42bd9a 100644
--- a/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt
+++ b/plugins/base/src/test/kotlin/translators/DefaultPsiToDocumentableTranslatorTest.kt
@@ -4,6 +4,7 @@ import org.jetbrains.dokka.DokkaConfiguration
import org.jetbrains.dokka.base.DokkaBase
import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest
import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.links.PointingToDeclaration
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.doc.Text
import org.jetbrains.dokka.plugability.DokkaPlugin
@@ -538,4 +539,56 @@ class DefaultPsiToDocumentableTranslatorTest : BaseAbstractTest() {
}
}
}
+
+ @Test // see https://github.com/Kotlin/dokka/issues/2646
+ fun `should resolve PsiImmediateClassType as class reference`() {
+ testInline(
+ """
+ |/src/main/java/test/JavaEnum.java
+ |package test;
+ |public enum JavaEnum {
+ | FOO, BAR
+ |}
+ |
+ |/src/main/java/test/ContainingEnumType.java
+ |package test;
+ |public class ContainingEnumType {
+ |
+ | public JavaEnum returningEnumType() {
+ | return null;
+ | }
+ |
+ | public JavaEnum[] returningEnumTypeArray() {
+ | return null;
+ | }
+ |
+ | public void acceptingEnumType(JavaEnum javaEnum) {}
+ |}
+ """.trimIndent(),
+ configuration
+ ) {
+ documentablesMergingStage = { module ->
+ val expectedType = GenericTypeConstructor(
+ dri = DRI(packageName = "test", classNames = "JavaEnum", target = PointingToDeclaration),
+ projections = emptyList()
+ )
+ val expectedArrayType = GenericTypeConstructor(
+ dri = DRI("kotlin", "Array", target = PointingToDeclaration),
+ projections = listOf(expectedType)
+ )
+
+ val classWithEnumUsage = module.packages.single().classlikes.single { it.name == "ContainingEnumType" }
+
+ val returningEnum = classWithEnumUsage.functions.single { it.name == "returningEnumType" }
+ assertEquals(expectedType, returningEnum.type)
+
+ val acceptingEnum = classWithEnumUsage.functions.single { it.name == "acceptingEnumType" }
+ assertEquals(1, acceptingEnum.parameters.size)
+ assertEquals(expectedType, acceptingEnum.parameters[0].type)
+
+ val returningArray = classWithEnumUsage.functions.single { it.name == "returningEnumTypeArray" }
+ assertEquals(expectedArrayType, returningArray.type)
+ }
+ }
+ }
}