aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/translators
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2022-07-07 13:29:53 +0200
committerGitHub <noreply@github.com>2022-07-07 13:29:53 +0200
commit3332f9f95be5cdea153818ae5d965298aa8c82f9 (patch)
treea9771053cd9f40317938d6ec8790e197cfb2f1f9 /plugins/base/src/main/kotlin/translators
parentfd92fc0d261f50139ab80d47251316c4f7882dea (diff)
downloaddokka-3332f9f95be5cdea153818ae5d965298aa8c82f9.tar.gz
dokka-3332f9f95be5cdea153818ae5d965298aa8c82f9.tar.bz2
dokka-3332f9f95be5cdea153818ae5d965298aa8c82f9.zip
Improve handling of Java annotation parameters (#2562)
Fixes #2509 Fixes #2551 Fixes #2350
Diffstat (limited to 'plugins/base/src/main/kotlin/translators')
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt11
1 files changed, 9 insertions, 2 deletions
diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
index 500b0728..3c1a2cc7 100644
--- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
@@ -692,8 +692,15 @@ class DefaultPsiToDocumentableTranslator(
is PsiArrayInitializerMemberValue -> ArrayValue(initializers.mapNotNull { it.toValue() })
is PsiReferenceExpression -> psiReference?.let { EnumValue(text ?: "", DRI.from(it)) }
is PsiClassObjectAccessExpression -> {
- val psiClass = ((type as PsiImmediateClassType).parameters.single() as PsiClassReferenceType).resolve()
- psiClass?.let { ClassValue(text ?: "", DRI.from(psiClass)) }
+ val parameterType = (type as? PsiClassType)?.parameters?.firstOrNull()
+ val classType = when (parameterType) {
+ is PsiClassType -> parameterType.resolve()
+ // Notice: Array<String>::class will be passed down as String::class
+ // should probably be Array::class instead but this reflects behaviour for Kotlin sources
+ is PsiArrayType -> (parameterType.componentType as? PsiClassType)?.resolve()
+ else -> null
+ }
+ classType?.let { ClassValue(it.name ?: "", DRI.from(it)) }
}
is PsiLiteralExpression -> toValue()
else -> StringValue(text ?: "")