aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin
diff options
context:
space:
mode:
authorPaweł Marks <pmarks@virtuslab.com>2020-03-25 15:34:33 +0100
committerKamil Doległo <kamilok1965@users.noreply.github.com>2020-03-25 15:45:32 +0100
commitaf9d525d75a517a5a7cb39d30fd4b2c9e8b93837 (patch)
tree19466eb468003e17a732ea483837848359ac76e4 /plugins/base/src/main/kotlin
parentcf37a3d981bac28e791ec0402fe6f19f986e7a47 (diff)
downloaddokka-af9d525d75a517a5a7cb39d30fd4b2c9e8b93837.tar.gz
dokka-af9d525d75a517a5a7cb39d30fd4b2c9e8b93837.tar.bz2
dokka-af9d525d75a517a5a7cb39d30fd4b2c9e8b93837.zip
Fix inproper resolution of annotations
Diffstat (limited to 'plugins/base/src/main/kotlin')
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt26
1 files changed, 12 insertions, 14 deletions
diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
index 91a498bc..74a6a7ea 100644
--- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
@@ -4,13 +4,10 @@ import com.intellij.lang.jvm.JvmModifier
import com.intellij.lang.jvm.types.JvmReferenceType
import com.intellij.psi.*
import com.intellij.psi.impl.source.PsiClassReferenceType
-import org.jetbrains.dokka.links.*
+import org.jetbrains.dokka.links.DRI
+import org.jetbrains.dokka.links.DriOfAny
+import org.jetbrains.dokka.links.withClass
import org.jetbrains.dokka.model.*
-import org.jetbrains.dokka.model.DAnnotation
-import org.jetbrains.dokka.model.DEnum
-import org.jetbrains.dokka.model.DFunction
-import org.jetbrains.dokka.model.Nullable
-import org.jetbrains.dokka.model.TypeConstructor
import org.jetbrains.dokka.model.properties.PropertyContainer
import org.jetbrains.dokka.pages.PlatformData
import org.jetbrains.dokka.plugability.DokkaContext
@@ -21,6 +18,7 @@ import org.jetbrains.kotlin.load.java.JvmAbi
import org.jetbrains.kotlin.load.java.propertyNameByGetMethodName
import org.jetbrains.kotlin.load.java.propertyNamesBySetMethodName
import org.jetbrains.kotlin.name.Name
+import org.jetbrains.kotlin.psi.psiUtil.getChildOfType
import org.jetbrains.kotlin.resolve.DescriptorUtils
object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
@@ -291,7 +289,7 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
if (bounds.isEmpty()) emptyList() else bounds.mapNotNull {
(it as? PsiClassType)?.let { classType ->
val resolved = classType.resolve()!!
- val dri = if(resolved.qualifiedName == "java.lang.Object") DriOfAny
+ val dri = if (resolved.qualifiedName == "java.lang.Object") DriOfAny
else DRI.from(resolved)
Nullable(TypeConstructor(dri, emptyList()))
}
@@ -350,18 +348,18 @@ object DefaultPsiToDocumentableTranslator : PsiToDocumentableTranslator {
}
private fun Collection<PsiAnnotation>.toExtra() = mapNotNull { annotation ->
- val fqname = annotation.qualifiedName ?: run {
- logger.error("No fqName for $annotation!")
+ val resolved = annotation.getChildOfType<PsiJavaCodeReferenceElement>()?.resolve() ?: run {
+ logger.error("$annotation cannot be resolved to symbol!")
return@mapNotNull null
}
Annotations.Annotation(
- DRI.from(annotation),
- annotation.attributes.mapNotNull {
- if (it is PsiNameValuePair) {
- it.attributeName to it.value.toString()
+ DRI.from(resolved),
+ annotation.attributes.mapNotNull { attr ->
+ if (attr is PsiNameValuePair) {
+ attr.value?.text?.let { attr.attributeName to it }
} else {
- it.attributeName to ""
+ attr.attributeName to ""
}
}.toMap()
)