diff options
author | vmishenev <vad-mishenev@yandex.ru> | 2021-09-21 21:38:44 +0300 |
---|---|---|
committer | vmishenev <vad-mishenev@yandex.ru> | 2021-09-21 21:40:12 +0300 |
commit | 1ada27414d66e58b19e20a968834356e81dd26b2 (patch) | |
tree | 41a1f463df9f261fc8c0a7569088263310c227de /kotlin-analysis/src/main/kotlin/org | |
parent | 2c6169ad8c3f97e7b9f833879967497efd54ac2e (diff) | |
download | dokka-1ada27414d66e58b19e20a968834356e81dd26b2.tar.gz dokka-1ada27414d66e58b19e20a968834356e81dd26b2.tar.bz2 dokka-1ada27414d66e58b19e20a968834356e81dd26b2.zip |
Fix link to javadoc enum entry (#2131)
Diffstat (limited to 'kotlin-analysis/src/main/kotlin/org')
-rw-r--r-- | kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt | 28 |
1 files changed, 17 insertions, 11 deletions
diff --git a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt index 3dd28fed..5f74c429 100644 --- a/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt +++ b/kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt @@ -1,10 +1,9 @@ package org.jetbrains.dokka.analysis import com.intellij.psi.* -import org.jetbrains.dokka.links.Callable -import org.jetbrains.dokka.links.DRI -import org.jetbrains.dokka.links.DriTarget +import org.jetbrains.dokka.links.* import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.impl.EnumEntrySyntheticClassDescriptor import org.jetbrains.kotlin.psi.psiUtil.parentsWithSelf import org.jetbrains.kotlin.resolve.descriptorUtil.parentsWithSelf import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull @@ -14,13 +13,16 @@ fun DRI.Companion.from(descriptor: DeclarationDescriptor) = descriptor.parentsWi val callable = parameter?.containingDeclaration ?: firstIsInstanceOrNull<CallableDescriptor>() DRI( - firstIsInstanceOrNull<PackageFragmentDescriptor>()?.fqName?.asString() ?: "", - (filterIsInstance<ClassDescriptor>() + filterIsInstance<TypeAliasDescriptor>()).toList() + packageName = firstIsInstanceOrNull<PackageFragmentDescriptor>()?.fqName?.asString() ?: "", + classNames = (filterIsInstance<ClassDescriptor>() + filterIsInstance<TypeAliasDescriptor>()).toList() .takeIf { it.isNotEmpty() } ?.asReversed() ?.joinToString(separator = ".") { it.name.asString() }, - callable?.let { Callable.from(it) }, - DriTarget.from(parameter ?: descriptor) + callable = callable?.let { Callable.from(it) }, + target = DriTarget.from(parameter ?: descriptor), + extra = if (descriptor is EnumEntrySyntheticClassDescriptor) + DRIExtraContainer().also { it[EnumEntryDRIExtra] = EnumEntryDRIExtra }.encode() + else null ) } @@ -30,9 +32,13 @@ fun DRI.Companion.from(psi: PsiElement) = psi.parentsWithSelf.run { val classes = filterIsInstance<PsiClass>().filterNot { it is PsiTypeParameter } .toList() // We only want exact PsiClass types, not PsiTypeParameter subtype DRI( - classes.lastOrNull()?.qualifiedName?.substringBeforeLast('.', "") ?: "", - classes.toList().takeIf { it.isNotEmpty() }?.asReversed()?.mapNotNull { it.name }?.joinToString("."), - psiMethod?.let { Callable.from(it) } ?: psiField?.let { Callable.from(it) }, - DriTarget.from(psi) + packageName = classes.lastOrNull()?.qualifiedName?.substringBeforeLast('.', "") ?: "", + classNames = classes.toList().takeIf { it.isNotEmpty() }?.asReversed()?.mapNotNull { it.name } + ?.joinToString("."), + callable = psiMethod?.let { Callable.from(it) } ?: psiField?.let { Callable.from(it) }, + target = DriTarget.from(psi), + extra = if (psi is PsiEnumConstant) + DRIExtraContainer().also { it[EnumEntryDRIExtra] = EnumEntryDRIExtra }.encode() + else null ) } |