diff options
Diffstat (limited to 'plugins/base')
-rw-r--r-- | plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt | 26 | ||||
-rw-r--r-- | plugins/base/src/test/kotlin/model/JavaTest.kt | 5 |
2 files changed, 14 insertions, 17 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() ) diff --git a/plugins/base/src/test/kotlin/model/JavaTest.kt b/plugins/base/src/test/kotlin/model/JavaTest.kt index 2545823b..a0cb68d7 100644 --- a/plugins/base/src/test/kotlin/model/JavaTest.kt +++ b/plugins/base/src/test/kotlin/model/JavaTest.kt @@ -336,10 +336,9 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") { ) { with((this / "java" / "Attribute").cast<DAnnotation>()) { with(extra[Annotations].assertNotNull("Annotations")) { - content counts 1 - with(content.first()) { + with(content.single()) { dri.classNames equals "Target" - params["value"].assertNotNull("value") equals "PsiArrayInitializerMemberValue:{ElementType.FIELD, ElementType.TYPE, ElementType.METHOD}" + params["value"].assertNotNull("value") equals "{ElementType.FIELD, ElementType.TYPE, ElementType.METHOD}" } } } |