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 /core/src/main | |
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 'core/src/main')
-rw-r--r-- | core/src/main/kotlin/links/DRI.kt | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/src/main/kotlin/links/DRI.kt b/core/src/main/kotlin/links/DRI.kt index 25b9546f..c646934d 100644 --- a/core/src/main/kotlin/links/DRI.kt +++ b/core/src/main/kotlin/links/DRI.kt @@ -1,7 +1,10 @@ package org.jetbrains.dokka.links +import com.fasterxml.jackson.annotation.JsonIgnore import com.fasterxml.jackson.annotation.JsonTypeInfo import com.fasterxml.jackson.annotation.JsonTypeInfo.Id.CLASS +import com.fasterxml.jackson.databind.ObjectMapper +import com.fasterxml.jackson.module.kotlin.readValue /** * [DRI] stands for DokkaResourceIdentifier @@ -23,6 +26,24 @@ data class DRI( } } +object EnumEntryDRIExtra: DRIExtraProperty<EnumEntryDRIExtra>() + +abstract class DRIExtraProperty<T> { + val key: String = this::class.qualifiedName + ?: (this.javaClass.let { it.`package`.name + "." + it.simpleName.ifEmpty { "anonymous" } }) +} + +class DRIExtraContainer(val data: String? = null) { + val map: MutableMap<String, Any> = if (data != null) ObjectMapper().readValue(data) else mutableMapOf() + inline operator fun <reified T> get(prop: DRIExtraProperty<T>): T? = + map[prop.key]?.let { prop as? T } + + inline operator fun <reified T> set(prop: DRIExtraProperty<T>, value: T) = + value.also { map[prop.key] = it as Any } + + fun encode(): String = ObjectMapper().writeValueAsString(map) +} + val DriOfUnit = DRI("kotlin", "Unit") val DriOfAny = DRI("kotlin", "Any") |