From d47d386ad8c0ff4a2c3b9d5b4450a773bdcba2dc Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Mon, 4 May 2020 13:53:10 +0200 Subject: 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 --- core/src/main/kotlin/model/Documentable.kt | 16 ++++++++++++++-- core/src/main/kotlin/model/aditionalExtras.kt | 11 ++++++++++- core/src/main/kotlin/pages/ContentNodes.kt | 2 +- 3 files changed, 25 insertions(+), 4 deletions(-) (limited to 'core/src/main') 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) : ExtraProperty { companion object : ExtraProperty.Key { @@ -27,7 +28,7 @@ class Annotations(val content: List) : ExtraProperty { override val key: ExtraProperty.Key = Annotations - data class Annotation(val dri: DRI, val params: Map) { + data class Annotation(val dri: DRI, val params: Map) { override fun equals(other: Any?): Boolean = when (other) { is Annotation -> dri == other.dri else -> false @@ -37,6 +38,14 @@ class Annotations(val content: List) : ExtraProperty { } } +sealed class AnnotationParameterValue +class AnnotationValue(val annotation: Annotations.Annotation) : AnnotationParameterValue() +class ArrayValue(val value: List) : 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, ExtraProperty.Key { override val key: ExtraProperty.Key = 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 { -- cgit