From 7c44db1ef0075e2b80a4723e0747bbf57c32e775 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com> Date: Thu, 27 Jan 2022 10:39:56 +0100 Subject: Fix resolving DRIs of Enum Entries (#2305) * Fix resolving DRIs of Enum Entries * Unify DRIs for Kotlin and Java enums. Add EnumEntry linking tests * Updates EnumEntry extras in documentable translators * Fix tests * Apply requested changes * Apply requested changes --- core/src/main/kotlin/links/DRI.kt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'core/src/main/kotlin/links/DRI.kt') diff --git a/core/src/main/kotlin/links/DRI.kt b/core/src/main/kotlin/links/DRI.kt index 2cbae8cc..a1322ef6 100644 --- a/core/src/main/kotlin/links/DRI.kt +++ b/core/src/main/kotlin/links/DRI.kt @@ -56,9 +56,19 @@ fun DRI.withClass(name: String) = copy(classNames = if (classNames.isNullOrBlank fun DRI.withTargetToDeclaration() = copy(target = PointingToDeclaration) +fun DRI.withEnumEntryExtra() = copy( + extra = DRIExtraContainer(this.extra).also { it[EnumEntryDRIExtra] = EnumEntryDRIExtra }.encode() +) + val DRI.parent: DRI get() = when { - extra != null -> copy(extra = null) + extra != null -> when { + DRIExtraContainer(extra)[EnumEntryDRIExtra] != null -> copy( + classNames = classNames?.substringBeforeLast(".", "")?.takeIf { it.isNotBlank() }, + extra = null + ) + else -> copy(extra = null) + } target != PointingToDeclaration -> copy(target = PointingToDeclaration) callable != null -> copy(callable = null) classNames != null -> copy(classNames = classNames.substringBeforeLast(".", "").takeIf { it.isNotBlank() }) -- cgit