diff options
author | Szymon Świstun <sswistun@virtuslab.com> | 2020-03-02 11:07:47 +0100 |
---|---|---|
committer | Kamil Doległo <kamilok1965@interia.pl> | 2020-03-04 13:19:17 +0100 |
commit | 9b7a59cdc93a6dcd9ab0623f6f476abf92d9427d (patch) | |
tree | 4c6c0f730c6480f824d6e92949c77940929241a1 /core | |
parent | ac590359174995a16a116a96dbb9df5dafa042f5 (diff) | |
download | dokka-9b7a59cdc93a6dcd9ab0623f6f476abf92d9427d.tar.gz dokka-9b7a59cdc93a6dcd9ab0623f6f476abf92d9427d.tar.bz2 dokka-9b7a59cdc93a6dcd9ab0623f6f476abf92d9427d.zip |
Add information about modifiers to Documentables' extra properties
Diffstat (limited to 'core')
-rw-r--r-- | core/src/main/kotlin/model/Documentable.kt | 7 | ||||
-rw-r--r-- | core/src/main/kotlin/model/aditionalExtras.kt | 11 | ||||
-rw-r--r-- | core/src/main/kotlin/model/properties/properties.kt | 13 |
3 files changed, 23 insertions, 8 deletions
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<ExtraModifiers>) : ExtraProperty<Documentable> { + object AdditionalKey : ExtraProperty.Key<Documentable, AdditionalModifiers> + + 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<Documentable, *> = 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<in C : Any> { - interface Key<in C: Any, T: Any> { + interface Key<in C : Any, T : Any> { fun mergeStrategyFor(left: T, right: T): MergeStrategy<C> = MergeStrategy.Fail { throw NotImplementedError("Property merging for $this is not implemented") } } + val key: Key<C, *> } -interface CalculatedProperty<in C: Any, T: Any>: ExtraProperty.Key<C, T> { +interface CalculatedProperty<in C : Any, T : Any> : ExtraProperty.Key<C, T> { fun calculate(subject: C): T } sealed class MergeStrategy<in C> { - class Replace<in C : Any>(val newProperty: ExtraProperty<C>): MergeStrategy<C>() - object Remove: MergeStrategy<Any>() - class Full<C: Any>(val merger: (preMerged: C, left: C, right: C) -> C): MergeStrategy<C>() - class Fail(val error: () -> Nothing): MergeStrategy<Any>() + class Replace<in C : Any>(val newProperty: ExtraProperty<C>) : MergeStrategy<C>() + object Remove : MergeStrategy<Any>() + class Full<C : Any>(val merger: (preMerged: C, left: C, right: C) -> C) : MergeStrategy<C>() + class Fail(val error: () -> Nothing) : MergeStrategy<Any>() } |