aboutsummaryrefslogtreecommitdiff
path: root/kotlin-analysis
diff options
context:
space:
mode:
Diffstat (limited to 'kotlin-analysis')
-rw-r--r--kotlin-analysis/src/main/kotlin/org/jetbrains/dokka/analysis/DRIFactory.kt28
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
)
}