diff options
author | Andrzej Ratajczak <andrzej.ratajczak98@gmail.com> | 2020-05-04 13:53:10 +0200 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-05-26 11:32:03 +0200 |
commit | d47d386ad8c0ff4a2c3b9d5b4450a773bdcba2dc (patch) | |
tree | 364724f661349211f053ea80db1a7feb283f48ba /core/src | |
parent | b1e3033fca65ac1e8e312e51d2eed4f278ddb076 (diff) | |
download | dokka-d47d386ad8c0ff4a2c3b9d5b4450a773bdcba2dc.tar.gz dokka-d47d386ad8c0ff4a2c3b9d5b4450a773bdcba2dc.tar.bz2 dokka-d47d386ad8c0ff4a2c3b9d5b4450a773bdcba2dc.zip |
Enhance signature presentation. Support presetnation Java as Kotlin and Kotlin as Java. Refactor annotations creation from PSI/Descriptors. Add proper rendering of annotation signatures in both kotlin syntax and java syntax. Tests for annotations
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/main/kotlin/model/Documentable.kt | 16 | ||||
-rw-r--r-- | core/src/main/kotlin/model/aditionalExtras.kt | 11 | ||||
-rw-r--r-- | core/src/main/kotlin/pages/ContentNodes.kt | 2 |
3 files changed, 25 insertions, 4 deletions
diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt index 9f17638c..b808e09c 100644 --- a/core/src/main/kotlin/model/Documentable.kt +++ b/core/src/main/kotlin/model/Documentable.kt @@ -361,6 +361,7 @@ data class Variance(val kind: Kind, val inner: Bound) : Projection() { data class PrimitiveJavaType(val name: String) : Bound() object Void : Bound() object JavaObject : Bound() +object Dynamic : Bound() enum class FunctionModifiers { NONE, FUNCTION, EXTENSION @@ -368,8 +369,19 @@ enum class FunctionModifiers { enum class ExtraModifiers { STATIC, INLINE, INFIX, SUSPEND, REIFIED, CROSSINLINE, NOINLINE, - OVERRIDE, DATA, CONST, DYNAMIC, EXTERNAL, INNER, LATEINIT, OPERATOR, TAILREC, VARARG, - NATIVE, SYNCHRONIZED, STRICTFP, TRANSIENT, VOLATILE, TRANSITIVE + OVERRIDE, DATA, CONST, EXTERNAL, INNER, LATEINIT, OPERATOR, TAILREC, VARARG, + NATIVE, SYNCHRONIZED, STRICTFP, TRANSIENT, VOLATILE, TRANSITIVE; + + companion object { + val kotlinOnlyModifiers = setOf( + INLINE, INFIX, EXTERNAL, SUSPEND, REIFIED, CROSSINLINE, NOINLINE, OVERRIDE, DATA, CONST, INNER, LATEINIT, OPERATOR, + TAILREC, VARARG + ) + + val javaOnlyModifiers = setOf( + STATIC, NATIVE, SYNCHRONIZED, STRICTFP, TRANSIENT, VOLATILE, TRANSITIVE + ) + } } private fun String.shorten(maxLength: Int) = lineSequence().first().let { diff --git a/core/src/main/kotlin/model/aditionalExtras.kt b/core/src/main/kotlin/model/aditionalExtras.kt index 27ad8a55..05b88f48 100644 --- a/core/src/main/kotlin/model/aditionalExtras.kt +++ b/core/src/main/kotlin/model/aditionalExtras.kt @@ -3,6 +3,7 @@ package org.jetbrains.dokka.model import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.properties.ExtraProperty import org.jetbrains.dokka.model.properties.MergeStrategy +import org.jetbrains.kotlin.psi.KtClass class AdditionalModifiers(val content: Set<ExtraModifiers>) : ExtraProperty<Documentable> { companion object : ExtraProperty.Key<Documentable, AdditionalModifiers> { @@ -27,7 +28,7 @@ class Annotations(val content: List<Annotation>) : ExtraProperty<Documentable> { override val key: ExtraProperty.Key<Documentable, *> = Annotations - data class Annotation(val dri: DRI, val params: Map<String, String>) { + data class Annotation(val dri: DRI, val params: Map<String, AnnotationParameterValue>) { override fun equals(other: Any?): Boolean = when (other) { is Annotation -> dri == other.dri else -> false @@ -37,6 +38,14 @@ class Annotations(val content: List<Annotation>) : ExtraProperty<Documentable> { } } +sealed class AnnotationParameterValue +class AnnotationValue(val annotation: Annotations.Annotation) : AnnotationParameterValue() +class ArrayValue(val value: List<AnnotationParameterValue>) : AnnotationParameterValue() +class EnumValue(val enumName: String, val enumDri: DRI) : AnnotationParameterValue() +class ClassValue(val className: String, val classDRI: DRI) : AnnotationParameterValue() // TODO Investigate if KtClassValue can be parameter of annotation +class StringValue(val value: String) : AnnotationParameterValue() + + object PrimaryConstructorExtra : ExtraProperty<DFunction>, ExtraProperty.Key<DFunction, PrimaryConstructorExtra> { override val key: ExtraProperty.Key<DFunction, *> = this } diff --git a/core/src/main/kotlin/pages/ContentNodes.kt b/core/src/main/kotlin/pages/ContentNodes.kt index 2a668e09..7b702841 100644 --- a/core/src/main/kotlin/pages/ContentNodes.kt +++ b/core/src/main/kotlin/pages/ContentNodes.kt @@ -217,7 +217,7 @@ enum class ContentKind : Kind { } enum class TextStyle : Style { - Bold, Italic, Strong, Strikethrough, Paragraph, Block, Monospace, Indented + Bold, Italic, Strong, Strikethrough, Paragraph, Block, Span, Monospace, Indented } enum class ContentStyle : Style { |