diff options
author | Paweł Marks <pmarks@virtuslab.com> | 2020-03-25 15:34:33 +0100 |
---|---|---|
committer | Kamil Doległo <kamilok1965@users.noreply.github.com> | 2020-03-25 15:45:32 +0100 |
commit | af9d525d75a517a5a7cb39d30fd4b2c9e8b93837 (patch) | |
tree | 19466eb468003e17a732ea483837848359ac76e4 /plugins/base/src/main/kotlin | |
parent | cf37a3d981bac28e791ec0402fe6f19f986e7a47 (diff) | |
download | dokka-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.kt | 26 |
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() ) |