From 9b7a59cdc93a6dcd9ab0623f6f476abf92d9427d Mon Sep 17 00:00:00 2001 From: Szymon Świstun Date: Mon, 2 Mar 2020 11:07:47 +0100 Subject: Add information about modifiers to Documentables' extra properties --- core/src/main/kotlin/model/Documentable.kt | 7 +++++-- core/src/main/kotlin/model/aditionalExtras.kt | 11 +++++++++++ core/src/main/kotlin/model/properties/properties.kt | 13 +++++++------ 3 files changed, 23 insertions(+), 8 deletions(-) create mode 100644 core/src/main/kotlin/model/aditionalExtras.kt (limited to 'core/src') diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index 3bc1690b..9de06ba7 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -3,8 +3,6 @@ package org.jetbrains.dokka.model import com.intellij.psi.PsiNamedElement import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.doc.DocumentationNode -import org.jetbrains.dokka.model.properties.ExtraProperty -import org.jetbrains.dokka.model.properties.MergeStrategy import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.model.properties.WithExtraProperties import org.jetbrains.dokka.pages.PlatformData @@ -335,6 +333,11 @@ sealed class Projection { data class Nullable(val inner: Projection) : Projection() } +enum class ExtraModifiers { + STATIC, INLINE, INFIX, SUSPEND, REIFIED, CROSSINLINE, NOINLINE, + OVERRIDE, DATA, CONST, DYNAMIC, EXTERNAL, INNER, LATEINIT, OPERATOR, TAILREC, VARARG +} + private fun String.shorten(maxLength: Int) = lineSequence().first().let { if (it.length != length || it.length > maxLength) it.take(maxLength - 3) + "..." else it } diff --git a/core/src/main/kotlin/model/aditionalExtras.kt b/core/src/main/kotlin/model/aditionalExtras.kt new file mode 100644 index 00000000..69e89a2a --- /dev/null +++ b/core/src/main/kotlin/model/aditionalExtras.kt @@ -0,0 +1,11 @@ +package org.jetbrains.dokka.model + +import org.jetbrains.dokka.model.properties.ExtraProperty + +class AdditionalModifiers(val content: List) : ExtraProperty { + object AdditionalKey : ExtraProperty.Key + + override fun equals(other: Any?): Boolean = if (other is AdditionalModifiers) other.content == content else false + override fun hashCode() = content.hashCode() + override val key: ExtraProperty.Key = AdditionalKey +} \ No newline at end of file diff --git a/core/src/main/kotlin/model/properties/properties.kt b/core/src/main/kotlin/model/properties/properties.kt index 83f8d63d..7010d0df 100644 --- a/core/src/main/kotlin/model/properties/properties.kt +++ b/core/src/main/kotlin/model/properties/properties.kt @@ -1,21 +1,22 @@ package org.jetbrains.dokka.model.properties interface ExtraProperty { - interface Key { + interface Key { fun mergeStrategyFor(left: T, right: T): MergeStrategy = MergeStrategy.Fail { throw NotImplementedError("Property merging for $this is not implemented") } } + val key: Key } -interface CalculatedProperty: ExtraProperty.Key { +interface CalculatedProperty : ExtraProperty.Key { fun calculate(subject: C): T } sealed class MergeStrategy { - class Replace(val newProperty: ExtraProperty): MergeStrategy() - object Remove: MergeStrategy() - class Full(val merger: (preMerged: C, left: C, right: C) -> C): MergeStrategy() - class Fail(val error: () -> Nothing): MergeStrategy() + class Replace(val newProperty: ExtraProperty) : MergeStrategy() + object Remove : MergeStrategy() + class Full(val merger: (preMerged: C, left: C, right: C) -> C) : MergeStrategy() + class Fail(val error: () -> Nothing) : MergeStrategy() } -- cgit