aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-04-14 15:16:45 +0200
committerGitHub <noreply@github.com>2021-04-14 15:16:45 +0200
commit38270a3b8783857bd0bba4b9422b19b4de507e4c (patch)
tree71273a5c15db755ac264c6bddb164de40bbca2c1 /plugins/base/src/main
parentacd9234be6909a69f89600e9c8ddde642d36b1cf (diff)
downloaddokka-38270a3b8783857bd0bba4b9422b19b4de507e4c.tar.gz
dokka-38270a3b8783857bd0bba4b9422b19b4de507e4c.tar.bz2
dokka-38270a3b8783857bd0bba4b9422b19b4de507e4c.zip
Fix missing annotations in GFM and unresolved static imports (#1845)
* Fix missing unresolved links in GFM * Fix missing links to elements imported as static
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt13
1 files changed, 12 insertions, 1 deletions
diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
index 84510824..cd2bbfc6 100644
--- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
@@ -2,6 +2,8 @@ package org.jetbrains.dokka.base.translators.psi
import com.intellij.lang.jvm.JvmModifier
import com.intellij.lang.jvm.annotation.JvmAnnotationAttribute
+import com.intellij.lang.jvm.annotation.JvmAnnotationAttributeValue
+import com.intellij.lang.jvm.annotation.JvmAnnotationEnumFieldValue
import com.intellij.lang.jvm.types.JvmReferenceType
import com.intellij.openapi.vfs.VirtualFileManager
import com.intellij.psi.*
@@ -572,13 +574,22 @@ class DefaultPsiToDocumentableTranslator(
filter { it !is KtLightAbstractAnnotation }.mapNotNull { it.toAnnotation() }
private fun JvmAnnotationAttribute.toValue(): AnnotationParameterValue = when (this) {
- is PsiNameValuePair -> value?.toValue() ?: StringValue("")
+ is PsiNameValuePair -> value?.toValue() ?: attributeValue?.toValue() ?: StringValue("")
else -> StringValue(this.attributeName)
}.let { annotationValue ->
if (annotationValue is StringValue) annotationValue.copy(unquotedValue(annotationValue.value))
else annotationValue
}
+ /**
+ * This is a workaround for static imports from JDK like RetentionPolicy
+ * For some reason they are not represented in the same way than using normal import
+ */
+ private fun JvmAnnotationAttributeValue.toValue(): AnnotationParameterValue? = when (this) {
+ is JvmAnnotationEnumFieldValue -> (field as? PsiElement)?.let { EnumValue(fieldName ?: "", DRI.from(it)) }
+ else -> null
+ }
+
private fun PsiAnnotationMemberValue.toValue(): AnnotationParameterValue? = when (this) {
is PsiAnnotation -> toAnnotation()?.let { AnnotationValue(it) }
is PsiArrayInitializerMemberValue -> ArrayValue(initializers.mapNotNull { it.toValue() })