aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-05-21 11:29:22 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-05-26 11:32:03 +0200
commit77fa898e8abdc8e74169fa789f2ba0e32d8fa9d7 (patch)
tree9dde7add6b12ff8a366281787c7b7a9455c1d205
parentd47d386ad8c0ff4a2c3b9d5b4450a773bdcba2dc (diff)
downloaddokka-77fa898e8abdc8e74169fa789f2ba0e32d8fa9d7.tar.gz
dokka-77fa898e8abdc8e74169fa789f2ba0e32d8fa9d7.tar.bz2
dokka-77fa898e8abdc8e74169fa789f2ba0e32d8fa9d7.zip
Apply request changes
-rw-r--r--core/src/main/kotlin/model/Documentable.kt17
-rw-r--r--core/src/main/kotlin/model/aditionalExtras.kt10
-rw-r--r--core/src/main/kotlin/model/extraModifiers.kt60
-rw-r--r--plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt (renamed from plugins/base/src/main/kotlin/signatures/JvmSingatureUtils.kt)22
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt5
-rw-r--r--plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt9
-rw-r--r--plugins/base/src/main/kotlin/signatures/SignatureProvider.kt4
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt66
-rw-r--r--plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt6
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt17
-rw-r--r--plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt5
-rw-r--r--plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt26
-rw-r--r--plugins/base/src/test/kotlin/model/ClassesTest.kt10
-rw-r--r--plugins/base/src/test/kotlin/model/FunctionsTest.kt45
-rw-r--r--plugins/base/src/test/kotlin/model/JavaTest.kt10
-rw-r--r--plugins/base/src/test/kotlin/model/PropertyTest.kt2
-rw-r--r--plugins/base/src/test/kotlin/utils/contentUtils.kt38
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt35
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt7
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt11
20 files changed, 236 insertions, 169 deletions
diff --git a/core/src/main/kotlin/model/Documentable.kt b/core/src/main/kotlin/model/Documentable.kt
index b808e09c..a7dd0919 100644
--- a/core/src/main/kotlin/model/Documentable.kt
+++ b/core/src/main/kotlin/model/Documentable.kt
@@ -367,23 +367,6 @@ enum class FunctionModifiers {
NONE, FUNCTION, EXTENSION
}
-enum class ExtraModifiers {
- STATIC, INLINE, INFIX, SUSPEND, REIFIED, CROSSINLINE, NOINLINE,
- 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 {
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
index 05b88f48..2b9d481f 100644
--- a/core/src/main/kotlin/model/aditionalExtras.kt
+++ b/core/src/main/kotlin/model/aditionalExtras.kt
@@ -39,11 +39,11 @@ 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()
+data class AnnotationValue(val annotation: Annotations.Annotation) : AnnotationParameterValue()
+data class ArrayValue(val value: List<AnnotationParameterValue>) : AnnotationParameterValue()
+data class EnumValue(val enumName: String, val enumDri: DRI) : AnnotationParameterValue()
+data class ClassValue(val className: String, val classDRI: DRI) : AnnotationParameterValue()
+data class StringValue(val value: String) : AnnotationParameterValue()
object PrimaryConstructorExtra : ExtraProperty<DFunction>, ExtraProperty.Key<DFunction, PrimaryConstructorExtra> {
diff --git a/core/src/main/kotlin/model/extraModifiers.kt b/core/src/main/kotlin/model/extraModifiers.kt
new file mode 100644
index 00000000..093ce62a
--- /dev/null
+++ b/core/src/main/kotlin/model/extraModifiers.kt
@@ -0,0 +1,60 @@
+package org.jetbrains.dokka.model
+
+sealed class ExtraModifiers(val name: String) {
+
+ sealed class KotlinOnlyModifiers(name: String) : ExtraModifiers(name) {
+ object Inline : KotlinOnlyModifiers("inline")
+ object Infix : KotlinOnlyModifiers("infix")
+ object External : KotlinOnlyModifiers("external")
+ object Suspend : KotlinOnlyModifiers("suspend")
+ object Reified : KotlinOnlyModifiers("reified")
+ object CrossInline : KotlinOnlyModifiers("crossinline")
+ object NoInline : KotlinOnlyModifiers("noinline")
+ object Override : KotlinOnlyModifiers("override")
+ object Data : KotlinOnlyModifiers("data")
+ object Const : KotlinOnlyModifiers("const")
+ object Inner : KotlinOnlyModifiers("inner")
+ object LateInit : KotlinOnlyModifiers("lateinit")
+ object Operator : KotlinOnlyModifiers("operator")
+ object TailRec : KotlinOnlyModifiers("tailrec")
+ object VarArg : KotlinOnlyModifiers("vararg")
+ }
+
+ sealed class JavaOnlyModifiers(name: String) : ExtraModifiers(name) {
+ object Static : JavaOnlyModifiers("static")
+ object Native : JavaOnlyModifiers("native")
+ object Synchronized : JavaOnlyModifiers("synchronized")
+ object StrictFP : JavaOnlyModifiers("strictfp")
+ object Transient : JavaOnlyModifiers("transient")
+ object Volatile : JavaOnlyModifiers("volatile")
+ object Transitive : JavaOnlyModifiers("transitive")
+ }
+
+ companion object {
+ fun valueOf(str: String) = when(str) {
+ "inline" -> KotlinOnlyModifiers.Inline
+ "infix" -> KotlinOnlyModifiers.Infix
+ "external" -> KotlinOnlyModifiers.External
+ "suspend" -> KotlinOnlyModifiers.Suspend
+ "reified" -> KotlinOnlyModifiers.Reified
+ "crossinline" -> KotlinOnlyModifiers.CrossInline
+ "noinline" -> KotlinOnlyModifiers.NoInline
+ "override" -> KotlinOnlyModifiers.Override
+ "data" -> KotlinOnlyModifiers.Data
+ "const" -> KotlinOnlyModifiers.Const
+ "inner" -> KotlinOnlyModifiers.Inner
+ "lateinit" -> KotlinOnlyModifiers.LateInit
+ "operator" -> KotlinOnlyModifiers.Operator
+ "tailrec" -> KotlinOnlyModifiers.TailRec
+ "vararg" -> KotlinOnlyModifiers.VarArg
+ "static" -> JavaOnlyModifiers.Static
+ "native" -> JavaOnlyModifiers.Native
+ "synchronized" -> JavaOnlyModifiers.Synchronized
+ "strictfp" -> JavaOnlyModifiers.StrictFP
+ "transient" -> JavaOnlyModifiers.Transient
+ "volatile" -> JavaOnlyModifiers.Volatile
+ "transitive" -> JavaOnlyModifiers.Transitive
+ else -> throw IllegalArgumentException("There is no Extra Modifier for given name $str")
+ }
+ }
+} \ No newline at end of file
diff --git a/plugins/base/src/main/kotlin/signatures/JvmSingatureUtils.kt b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt
index dde553b9..0ae72109 100644
--- a/plugins/base/src/main/kotlin/signatures/JvmSingatureUtils.kt
+++ b/plugins/base/src/main/kotlin/signatures/JvmSignatureUtils.kt
@@ -1,11 +1,10 @@
package org.jetbrains.dokka.base.signatures
-import javaslang.Tuple2
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.properties.WithExtraProperties
-interface JvmSingatureUtils {
+interface JvmSignatureUtils {
fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: Documentable)
@@ -20,7 +19,7 @@ interface JvmSingatureUtils {
extra[Annotations]?.content ?: emptyList()
private fun Annotations.Annotation.toSignatureString(): String =
- "@${this.dri.classNames}(${this.params.entries.joinToString { it.key + "=" + it.value }})"
+ "@" + this.dri.classNames + "(" + this.params.entries.joinToString { it.key + "=" + it.value } + ")"
private fun PageContentBuilder.DocumentableContentBuilder.annotations(
d: Documentable,
@@ -45,15 +44,10 @@ interface JvmSingatureUtils {
}
} ?: Unit
- fun <T : Documentable> WithExtraProperties<T>.modifiersWithFilter(
- filter: Set<ExtraModifiers> = ExtraModifiers.values().toSet()
- ): Set<ExtraModifiers> =
- extra[AdditionalModifiers]?.content?.filter { it in filter }?.toSet() ?: emptySet()
-
fun PageContentBuilder.DocumentableContentBuilder.toSignatureString(
a: Annotations.Annotation,
renderAtStrategy: AtStrategy,
- listBrackets: Tuple2<Char, Char>,
+ listBrackets: Pair<Char, Char>,
classExtension: String
) {
when (renderAtStrategy) {
@@ -78,17 +72,17 @@ interface JvmSingatureUtils {
private fun PageContentBuilder.DocumentableContentBuilder.valueToSignature(
a: AnnotationParameterValue,
renderAtStrategy: AtStrategy,
- listBrackets: Tuple2<Char, Char>,
+ listBrackets: Pair<Char, Char>,
classExtension: String
): Unit = when (a) {
is AnnotationValue -> toSignatureString(a.annotation, renderAtStrategy, listBrackets, classExtension)
is ArrayValue -> {
- text(listBrackets._1.toString())
+ text(listBrackets.first.toString())
a.value.forEachIndexed { i, it ->
valueToSignature(it, renderAtStrategy, listBrackets, classExtension)
if (i != a.value.size - 1) text(", ")
}
- text(listBrackets._2.toString())
+ text(listBrackets.second.toString())
}
is EnumValue -> link(a.enumName, a.enumDri)
is ClassValue -> link(a.className + classExtension, a.classDRI)
@@ -99,7 +93,7 @@ interface JvmSingatureUtils {
d: Documentable,
ignored: Set<Annotations.Annotation>,
renderAtStrategy: AtStrategy,
- listBrackets: Tuple2<Char, Char>,
+ listBrackets: Pair<Char, Char>,
classExtension: String
) {
annotations(d, ignored) {
@@ -113,7 +107,7 @@ interface JvmSingatureUtils {
d: Documentable,
ignored: Set<Annotations.Annotation>,
renderAtStrategy: AtStrategy,
- listBrackets: Tuple2<Char, Char>,
+ listBrackets: Pair<Char, Char>,
classExtension: String
) {
annotations(d, ignored) {
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
index 4c689abc..33c82458 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureProvider.kt
@@ -6,7 +6,6 @@ import org.jetbrains.dokka.links.*
import org.jetbrains.dokka.model.*
import org.jetbrains.dokka.model.Nullable
import org.jetbrains.dokka.model.TypeConstructor
-import org.jetbrains.dokka.model.properties.ExtraProperty
import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.ContentKind
import org.jetbrains.dokka.pages.ContentNode
@@ -15,7 +14,7 @@ import org.jetbrains.dokka.utilities.DokkaLogger
import kotlin.text.Typography.nbsp
class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogger) : SignatureProvider,
- JvmSingatureUtils by KotlinSignatureUtils {
+ JvmSignatureUtils by KotlinSignatureUtils {
private val contentBuilder = PageContentBuilder(ctcc, this, logger)
private val ignoredVisibilities = setOf(JavaVisibility.Public, KotlinVisibility.Public)
@@ -69,7 +68,7 @@ class KotlinSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLog
if (c is DClass) {
platformText(c.modifier, sourceSets) {
if (it !in ignoredModifiers)
- if (c.extra[AdditionalModifiers]?.content?.contains(ExtraModifiers.DATA) == true) ""
+ if (c.extra[AdditionalModifiers]?.content?.contains(ExtraModifiers.KotlinOnlyModifiers.Data) == true) ""
else (if (it is JavaModifier.Empty) KotlinModifier.Open else it).let { it.name + " " }
else
""
diff --git a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
index 3ce4be0a..48cfe304 100644
--- a/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
+++ b/plugins/base/src/main/kotlin/signatures/KotlinSignatureUtils.kt
@@ -1,16 +1,15 @@
package org.jetbrains.dokka.base.signatures
-import javaslang.Tuple2
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
+import org.jetbrains.dokka.model.AdditionalModifiers
import org.jetbrains.dokka.model.Documentable
import org.jetbrains.dokka.model.ExtraModifiers
-import org.jetbrains.dokka.model.ExtraModifiers.Companion.kotlinOnlyModifiers
import org.jetbrains.dokka.model.properties.WithExtraProperties
-object KotlinSignatureUtils : JvmSingatureUtils {
+object KotlinSignatureUtils : JvmSignatureUtils {
private val strategy = OnlyOnce
- private val listBrackets = Tuple2('[', ']')
+ private val listBrackets = Pair('[', ']')
private val classExtension = "::class"
override fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: Documentable) =
@@ -20,5 +19,5 @@ object KotlinSignatureUtils : JvmSingatureUtils {
annotationsInlineWithIgnored(d, emptySet(), strategy, listBrackets, classExtension)
override fun <T : Documentable> WithExtraProperties<T>.modifiers() =
- modifiersWithFilter(kotlinOnlyModifiers)
+ extra[AdditionalModifiers]?.content?.filterIsInstance<ExtraModifiers.KotlinOnlyModifiers>()?.toSet() ?: emptySet()
} \ No newline at end of file
diff --git a/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt b/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt
index 7d7995b7..c04b6ecf 100644
--- a/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt
+++ b/plugins/base/src/main/kotlin/signatures/SignatureProvider.kt
@@ -1,11 +1,7 @@
package org.jetbrains.dokka.base.signatures
-import javaslang.Tuple2
-import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.model.*
-import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.ContentNode
-import org.jetbrains.dokka.pages.TextStyle
interface SignatureProvider {
fun signature(documentable: Documentable): ContentNode
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index c24a3384..65b83200 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -46,7 +46,7 @@ import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.TypeProjection
import org.jetbrains.kotlin.utils.addToStdlib.safeAs
import java.nio.file.Paths
-import java.lang.IllegalArgumentException
+import kotlin.IllegalArgumentException
import kotlin.reflect.jvm.internal.impl.resolve.constants.KClassValue
object DefaultDescriptorToDocumentableTranslator : SourceToDocumentableTranslator {
@@ -546,9 +546,7 @@ private class DokkaDescriptorVisitor(
is TypeParameterDescriptor -> OtherParameter(
declarationDRI = DRI.from(ctor.containingDeclaration),
name = ctor.name.asString()
- ).let {
- if (isMarkedNullable) Nullable(it) else it
- }
+ )
else -> TypeConstructor(
DRI.from(constructor.declarationDescriptor!!), // TODO: remove '!!'
arguments.map { it.toProjection() },
@@ -556,6 +554,8 @@ private class DokkaDescriptorVisitor(
else if (isFunctionType) FunctionModifiers.FUNCTION
else FunctionModifiers.NONE
)
+ }.let {
+ if (isMarkedNullable) Nullable(it) else it
}
}
@@ -593,43 +593,43 @@ private class DokkaDescriptorVisitor(
DescriptorDocumentableSource(this).toSourceSetDependent()
private fun FunctionDescriptor.additionalExtras() = listOfNotNull(
- ExtraModifiers.INFIX.takeIf { isInfix },
- ExtraModifiers.INLINE.takeIf { isInline },
- ExtraModifiers.SUSPEND.takeIf { isSuspend },
- ExtraModifiers.OPERATOR.takeIf { isOperator },
- ExtraModifiers.STATIC.takeIf { isJvmStaticInObjectOrClassOrInterface() },
- ExtraModifiers.TAILREC.takeIf { isTailrec },
- ExtraModifiers.EXTERNAL.takeIf { isExternal },
- ExtraModifiers.OVERRIDE.takeIf { DescriptorUtils.isOverride(this) }
+ ExtraModifiers.KotlinOnlyModifiers.Infix.takeIf { isInfix },
+ ExtraModifiers.KotlinOnlyModifiers.Inline.takeIf { isInline },
+ ExtraModifiers.KotlinOnlyModifiers.Suspend.takeIf { isSuspend },
+ ExtraModifiers.KotlinOnlyModifiers.Operator.takeIf { isOperator },
+ ExtraModifiers.JavaOnlyModifiers.Static.takeIf { isJvmStaticInObjectOrClassOrInterface() },
+ ExtraModifiers.KotlinOnlyModifiers.TailRec.takeIf { isTailrec },
+ ExtraModifiers.KotlinOnlyModifiers.External.takeIf { isExternal },
+ ExtraModifiers.KotlinOnlyModifiers.Override.takeIf { DescriptorUtils.isOverride(this) }
).toProperty()
private fun ClassDescriptor.additionalExtras() = listOfNotNull(
- ExtraModifiers.INLINE.takeIf { isInline },
- ExtraModifiers.EXTERNAL.takeIf { isExternal },
- ExtraModifiers.INNER.takeIf { isInner },
- ExtraModifiers.DATA.takeIf { isData }
+ ExtraModifiers.KotlinOnlyModifiers.Inline.takeIf { isInline },
+ ExtraModifiers.KotlinOnlyModifiers.External.takeIf { isExternal },
+ ExtraModifiers.KotlinOnlyModifiers.Inner.takeIf { isInner },
+ ExtraModifiers.KotlinOnlyModifiers.Data.takeIf { isData }
).toProperty()
private fun ValueParameterDescriptor.additionalExtras() =
listOfNotNull(
- ExtraModifiers.NOINLINE.takeIf { isNoinline },
- ExtraModifiers.CROSSINLINE.takeIf { isCrossinline },
- ExtraModifiers.CONST.takeIf { isConst },
- ExtraModifiers.LATEINIT.takeIf { isLateInit },
- ExtraModifiers.VARARG.takeIf { isVararg }
+ ExtraModifiers.KotlinOnlyModifiers.NoInline.takeIf { isNoinline },
+ ExtraModifiers.KotlinOnlyModifiers.CrossInline.takeIf { isCrossinline },
+ ExtraModifiers.KotlinOnlyModifiers.Const.takeIf { isConst },
+ ExtraModifiers.KotlinOnlyModifiers.LateInit.takeIf { isLateInit },
+ ExtraModifiers.KotlinOnlyModifiers.VarArg.takeIf { isVararg }
).toProperty()
private fun TypeParameterDescriptor.additionalExtras() =
listOfNotNull(
- ExtraModifiers.REIFIED.takeIf { isReified }
+ ExtraModifiers.KotlinOnlyModifiers.Reified.takeIf { isReified }
).toProperty()
private fun PropertyDescriptor.additionalExtras() = listOfNotNull(
- ExtraModifiers.CONST.takeIf { isConst },
- ExtraModifiers.LATEINIT.takeIf { isLateInit },
- ExtraModifiers.STATIC.takeIf { isJvmStaticInObjectOrClassOrInterface() },
- ExtraModifiers.EXTERNAL.takeIf { isExternal },
- ExtraModifiers.OVERRIDE.takeIf { DescriptorUtils.isOverride(this) }
+ ExtraModifiers.KotlinOnlyModifiers.Const.takeIf { isConst },
+ ExtraModifiers.KotlinOnlyModifiers.LateInit.takeIf { isLateInit },
+ ExtraModifiers.JavaOnlyModifiers.Static.takeIf { isJvmStaticInObjectOrClassOrInterface() },
+ ExtraModifiers.KotlinOnlyModifiers.External.takeIf { isExternal },
+ ExtraModifiers.KotlinOnlyModifiers.Override.takeIf { DescriptorUtils.isOverride(this) }
)
private fun List<ExtraModifiers>.toProperty() =
@@ -640,11 +640,12 @@ private class DokkaDescriptorVisitor(
private fun Annotated.getListOfAnnotations() = annotations.map { it.toAnnotation() }
private fun ConstantValue<*>.toValue(): AnnotationParameterValue = when (this) {
- is ConstantsAnnotationValue -> AnnotationValue(value.let { it.toAnnotation() })
+ is ConstantsAnnotationValue -> AnnotationValue(value.toAnnotation())
is ConstantsArrayValue -> ArrayValue(value.map { it.toValue() })
is ConstantsEnumValue -> EnumValue(
- enumEntryName.identifier,
- enumClassId.let { DRI(it.packageFqName.asString(), it.relativeClassName.asString()) })
+ fullEnumEntryName(),
+ DRI(enumClassId.packageFqName.asString(), fullEnumEntryName())
+ )
is ConstantsKtClassValue -> when(value) {
is NormalClass -> (value as NormalClass).value.classId.let {
ClassValue(
@@ -672,7 +673,7 @@ private class DokkaDescriptorVisitor(
private fun FieldDescriptor.getAnnotationsAsExtraModifiers() = getAnnotations().content.mapNotNull {
try {
- ExtraModifiers.valueOf(it.dri.classNames?.toUpperCase() ?: "")
+ ExtraModifiers.valueOf(it.dri.classNames?.toLowerCase() ?: "")
} catch (e: IllegalArgumentException) {
null
}
@@ -690,4 +691,7 @@ private class DokkaDescriptorVisitor(
Visibilities.PRIVATE -> KotlinVisibility.Private
else -> KotlinVisibility.Public
}
+
+ private fun ConstantsEnumValue.fullEnumEntryName() =
+ "${this.enumClassId.relativeClassName.asString()}.${this.enumEntryName.identifier}"
}
diff --git a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
index 658a86f2..5ff5a954 100644
--- a/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
+++ b/plugins/base/src/main/kotlin/translators/documentables/PageContentBuilder.kt
@@ -338,8 +338,10 @@ open class PageContentBuilder(
value: SourceSetDependent<T>,
platforms: Set<SourceSetData> = value.keys,
transform: (T) -> String
- ) = value.entries.filter { it.key in platforms }.forEach { (p, v) ->
- transform(v).takeIf { it.isNotBlank() }?.also { text(it, sourceSets = setOf(p)) }
+ ) = value.entries.filter { it.key in platforms }.mapNotNull { (p, v) ->
+ transform(v).takeIf { it.isNotBlank() }?.let { it to p }
+ }.groupBy({ it.first }) { it.second }.forEach {
+ text(it.key, sourceSets = it.value.toSet())
}
}
diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
index 0f8fc011..9c731528 100644
--- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
@@ -1,5 +1,6 @@
package org.jetbrains.dokka.base.translators.psi
+import com.intellij.icons.AllIcons.Nodes.Static
import com.intellij.lang.jvm.annotation.JvmAnnotationAttribute
import com.intellij.lang.jvm.JvmModifier
import com.intellij.lang.jvm.types.JvmReferenceType
@@ -275,18 +276,18 @@ object DefaultPsiToDocumentableTranslator : SourceToDocumentableTranslator {
private fun PsiModifierListOwner.additionalExtras() = AdditionalModifiers(
listOfNotNull(
- ExtraModifiers.STATIC.takeIf { hasModifier(JvmModifier.STATIC) },
- ExtraModifiers.NATIVE.takeIf { hasModifier(JvmModifier.NATIVE) },
- ExtraModifiers.SYNCHRONIZED.takeIf { hasModifier(JvmModifier.SYNCHRONIZED) },
- ExtraModifiers.STRICTFP.takeIf { hasModifier(JvmModifier.STRICTFP) },
- ExtraModifiers.TRANSIENT.takeIf { hasModifier(JvmModifier.TRANSIENT) },
- ExtraModifiers.VOLATILE.takeIf { hasModifier(JvmModifier.VOLATILE) },
- ExtraModifiers.TRANSITIVE.takeIf { hasModifier(JvmModifier.TRANSITIVE) }
+ ExtraModifiers.JavaOnlyModifiers.Static.takeIf { hasModifier(JvmModifier.STATIC) },
+ ExtraModifiers.JavaOnlyModifiers.Native.takeIf { hasModifier(JvmModifier.NATIVE) },
+ ExtraModifiers.JavaOnlyModifiers.Synchronized.takeIf { hasModifier(JvmModifier.SYNCHRONIZED) },
+ ExtraModifiers.JavaOnlyModifiers.StrictFP.takeIf { hasModifier(JvmModifier.STRICTFP) },
+ ExtraModifiers.JavaOnlyModifiers.Transient.takeIf { hasModifier(JvmModifier.TRANSIENT) },
+ ExtraModifiers.JavaOnlyModifiers.Volatile.takeIf { hasModifier(JvmModifier.VOLATILE) },
+ ExtraModifiers.JavaOnlyModifiers.Transitive.takeIf { hasModifier(JvmModifier.TRANSITIVE) }
).toSet()
)
private fun AdditionalModifiers.toListOfAnnotations() = this.content.map {
- if (it.name != "STATIC")
+ if (it !is ExtraModifiers.JavaOnlyModifiers.Static)
Annotations.Annotation(DRI("kotlin.jvm", it.name.toLowerCase().capitalize()), emptyMap())
else
Annotations.Annotation(DRI("kotlin.jvm", "JvmStatic"), emptyMap())
diff --git a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
index c4640824..98f572b4 100644
--- a/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
+++ b/plugins/base/src/test/kotlin/content/annotations/ContentForAnnotationsTest.kt
@@ -49,8 +49,9 @@ class ContentForAnnotationsTest : AbstractCoreTest() {
val page = module.children.single { it.name == "test" }
.children.single { it.name == "function" } as ContentPage
page.content.assertNode {
-
- header(1) { +"function" }
+ group {
+ header(1) { +"function" }
+ }
divergentGroup {
divergentInstance {
divergent {
diff --git a/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt b/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt
index 3f0edec3..68042fd4 100644
--- a/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt
+++ b/plugins/base/src/test/kotlin/content/signatures/ContentForSignaturesTest.kt
@@ -40,8 +40,9 @@ class ContentForSignaturesTest : AbstractCoreTest() {
val page = module.children.single { it.name == "test" }
.children.single { it.name == "function" } as ContentPage
page.content.assertNode {
-
- header(1) { +"function" }
+ group {
+ header(1) { +"function" }
+ }
divergentGroup {
divergentInstance {
divergent {
@@ -78,7 +79,9 @@ class ContentForSignaturesTest : AbstractCoreTest() {
val page = module.children.single { it.name == "test" }
.children.single { it.name == "function" } as ContentPage
page.content.assertNode {
- header(1) { +"function" }
+ group {
+ header(1) { +"function" }
+ }
divergentGroup {
divergentInstance {
divergent {
@@ -115,7 +118,9 @@ class ContentForSignaturesTest : AbstractCoreTest() {
val page = module.children.single { it.name == "test" }
.children.single { it.name == "function" } as ContentPage
page.content.assertNode {
- header(1) { +"function" }
+ group {
+ header(1) { +"function" }
+ }
divergentGroup {
divergentInstance {
divergent {
@@ -152,8 +157,9 @@ class ContentForSignaturesTest : AbstractCoreTest() {
val page = module.children.single { it.name == "test" }
.children.single { it.name == "function" } as ContentPage
page.content.assertNode {
-
- header(1) { +"function" }
+ group {
+ header(1) { +"function" }
+ }
divergentGroup {
divergentInstance {
divergent {
@@ -190,7 +196,9 @@ class ContentForSignaturesTest : AbstractCoreTest() {
val page = module.children.single { it.name == "test" }
.children.single { it.name == "function" } as ContentPage
page.content.assertNode {
- header(1) { +"function" }
+ group {
+ header(1) { +"function" }
+ }
divergentGroup {
divergentInstance {
divergent {
@@ -227,7 +235,9 @@ class ContentForSignaturesTest : AbstractCoreTest() {
val page = module.children.single { it.name == "test" }
.children.single { it.name == "function" } as ContentPage
page.content.assertNode {
- header(1) { +"function" }
+ group {
+ header(1) { +"function" }
+ }
divergentGroup {
divergentInstance {
divergent {
diff --git a/plugins/base/src/test/kotlin/model/ClassesTest.kt b/plugins/base/src/test/kotlin/model/ClassesTest.kt
index 405ec8b6..4ca34b00 100644
--- a/plugins/base/src/test/kotlin/model/ClassesTest.kt
+++ b/plugins/base/src/test/kotlin/model/ClassesTest.kt
@@ -152,7 +152,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
visibility.values allEquals KotlinVisibility.Public
with(extra[AdditionalModifiers].assertNotNull("Extras")) {
content counts 1
- content.first() equals ExtraModifiers.DATA
+ content.first() equals ExtraModifiers.KotlinOnlyModifiers.Data
}
}
}
@@ -185,7 +185,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
with(content.first()) {
dri.classNames equals "Deprecated"
params.entries counts 1
-// params["message"].assertNotNull("message") equals "should no longer be used"
+ (params["message"].assertNotNull("message") as StringValue).value equals "\"should no longer be used\""
}
}
}
@@ -275,7 +275,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
with((this / "D").cast<DClass>()) {
with(extra[AdditionalModifiers].assertNotNull("AdditionalModifiers")) {
content counts 1
- content.first() equals ExtraModifiers.INNER
+ content.first() equals ExtraModifiers.KotlinOnlyModifiers.Inner
}
}
}
@@ -426,9 +426,7 @@ class ClassesTest : AbstractModelTest("/src/main/kotlin/classes/Test.kt", "class
with((this / "classes" / "Foo").cast<DClass>()) {
with(extra[Annotations]?.content?.firstOrNull().assertNotNull("annotations")) {
dri.toString() equals "kotlin/Suppress///PointingToDeclaration/"
-// with(params["names"].assertNotNull("param")) {
-// this equals "[\"abc\"]"
-// }
+ (params["names"].assertNotNull("param") as ArrayValue).value equals listOf(StringValue("\"abc\""))
}
}
}
diff --git a/plugins/base/src/test/kotlin/model/FunctionsTest.kt b/plugins/base/src/test/kotlin/model/FunctionsTest.kt
index 6cbb84f7..38f64df5 100644
--- a/plugins/base/src/test/kotlin/model/FunctionsTest.kt
+++ b/plugins/base/src/test/kotlin/model/FunctionsTest.kt
@@ -1,5 +1,6 @@
package model
+import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.*
import org.junit.jupiter.api.Test
import utils.AbstractModelTest
@@ -145,7 +146,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
with(content.first()) {
dri.classNames equals "Suppress"
params.entries counts 1
-// params["names"].assertNotNull("names") equals "[\"FOO\"]"
+ (params["names"].assertNotNull("param") as ArrayValue).value equals listOf(StringValue("\"FOO\""))
}
}
}
@@ -161,7 +162,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
) {
with((this / "function" / "f").cast<DFunction>()) {
extra[AdditionalModifiers]?.content counts 1
- extra[AdditionalModifiers]?.content exists ExtraModifiers.INLINE
+ extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.Inline
}
}
}
@@ -175,7 +176,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
) {
with((this / "function" / "f").cast<DFunction>()) {
extra[AdditionalModifiers]?.content counts 1
- extra[AdditionalModifiers]?.content exists ExtraModifiers.SUSPEND
+ extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.Suspend
}
}
}
@@ -189,8 +190,8 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
) {
with((this / "function" / "f").cast<DFunction>()) {
extra[AdditionalModifiers]?.content counts 2
- extra[AdditionalModifiers]?.content exists ExtraModifiers.SUSPEND
- extra[AdditionalModifiers]?.content exists ExtraModifiers.INLINE
+ extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.Suspend
+ extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.Inline
}
}
}
@@ -205,8 +206,8 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
with((this / "function" / "f").cast<DFunction>()) {
with(extra[AdditionalModifiers].assertNotNull("AdditionalModifiers")) {
content counts 2
- content exists ExtraModifiers.SUSPEND
- content exists ExtraModifiers.INLINE
+ content exists ExtraModifiers.KotlinOnlyModifiers.Suspend
+ content exists ExtraModifiers.KotlinOnlyModifiers.Inline
}
}
}
@@ -229,10 +230,18 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
content counts 3
with(content.map { it.dri.classNames to it }.toMap()) {
with(this["Target"].assertNotNull("Target")) {
-// params["allowedTargets"].assertNotNull("allowedTargets") equals "[AnnotationTarget.VALUE_PARAMETER]"
+ (params["allowedTargets"].assertNotNull("allowedTargets") as ArrayValue).value equals listOf(
+ EnumValue(
+ "AnnotationTarget.VALUE_PARAMETER",
+ DRI("kotlin.annotation", "AnnotationTarget.VALUE_PARAMETER")
+ )
+ )
}
with(this["Retention"].assertNotNull("Retention")) {
-// params["value"].assertNotNull("value") equals "(kotlin/annotation/AnnotationRetention, SOURCE)"
+ (params["value"].assertNotNull("value") as EnumValue) equals EnumValue(
+ "AnnotationRetention.SOURCE",
+ DRI("kotlin.annotation", "AnnotationRetention.SOURCE")
+ )
}
this["MustBeDocumented"].assertNotNull("MustBeDocumented").params.entries counts 0
}
@@ -260,7 +269,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
) {
with((this / "function" / "f" / "notInlined").cast<DParameter>()) {
extra[AdditionalModifiers]?.content counts 1
- extra[AdditionalModifiers]?.content exists ExtraModifiers.NOINLINE
+ extra[AdditionalModifiers]?.content exists ExtraModifiers.KotlinOnlyModifiers.NoInline
}
}
}
@@ -291,10 +300,18 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
content counts 3
with(content.map { it.dri.classNames to it }.toMap()) {
with(this["Target"].assertNotNull("Target")) {
-// params["allowedTargets"].assertNotNull("allowedTargets") equals "[AnnotationTarget.VALUE_PARAMETER]"
+ (params["allowedTargets"].assertNotNull("allowedTargets") as ArrayValue).value equals listOf(
+ EnumValue(
+ "AnnotationTarget.VALUE_PARAMETER",
+ DRI("kotlin.annotation", "AnnotationTarget.VALUE_PARAMETER")
+ )
+ )
}
with(this["Retention"].assertNotNull("Retention")) {
-// params["value"].assertNotNull("value") equals "(kotlin/annotation/AnnotationRetention, SOURCE)"
+ (params["value"].assertNotNull("value") as EnumValue) equals EnumValue(
+ "AnnotationRetention.SOURCE",
+ DRI("kotlin.annotation", "AnnotationRetention.SOURCE")
+ )
}
this["MustBeDocumented"].assertNotNull("MustBeDocumented").params.entries counts 0
}
@@ -307,7 +324,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
with(content.first()) {
dri.classNames equals "Fancy"
params.entries counts 1
-// params["size"] equals "1"
+ (params["size"] as StringValue).value equals "1"
}
}
}
@@ -369,7 +386,7 @@ class FunctionTest : AbstractModelTest("/src/main/kotlin/function/Test.kt", "fun
with(content.first()) {
dri.classNames equals "SinceKotlin"
params.entries counts 1
-// params["version"].assertNotNull("version") equals "1.1"
+ (params["version"].assertNotNull("version") as StringValue).value equals "\"1.1\""
}
}
}
diff --git a/plugins/base/src/test/kotlin/model/JavaTest.kt b/plugins/base/src/test/kotlin/model/JavaTest.kt
index 07af7913..fd293b5c 100644
--- a/plugins/base/src/test/kotlin/model/JavaTest.kt
+++ b/plugins/base/src/test/kotlin/model/JavaTest.kt
@@ -1,9 +1,9 @@
package model
import org.jetbrains.dokka.base.transformers.documentables.InheritorsInfo
+import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.*
import org.junit.jupiter.api.Assertions.assertTrue
-import org.junit.jupiter.api.Disabled
import org.junit.jupiter.api.Test
import utils.AbstractModelTest
import utils.assertNotNull
@@ -297,7 +297,7 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
with((this / "java" / "C" / "foo").cast<DFunction>()) {
with(extra[AdditionalModifiers].assertNotNull("AdditionalModifiers")) {
content counts 1
- content.first() equals ExtraModifiers.STATIC
+ content.first() equals ExtraModifiers.JavaOnlyModifiers.Static
}
}
}
@@ -338,7 +338,11 @@ class JavaTest : AbstractModelTest("/src/main/kotlin/java/Test.java", "java") {
with(extra[Annotations].assertNotNull("Annotations")) {
with(content.single()) {
dri.classNames equals "Target"
-// params["value"].assertNotNull("value") equals "{ElementType.FIELD, ElementType.TYPE, ElementType.METHOD}"
+ (params["value"].assertNotNull("value") as ArrayValue).value equals listOf(
+ EnumValue("ElementType.FIELD", DRI("java.lang.annotation", "ElementType")),
+ EnumValue("ElementType.TYPE", DRI("java.lang.annotation", "ElementType")),
+ EnumValue("ElementType.METHOD", DRI("java.lang.annotation", "ElementType"))
+ )
}
}
}
diff --git a/plugins/base/src/test/kotlin/model/PropertyTest.kt b/plugins/base/src/test/kotlin/model/PropertyTest.kt
index 7429257b..90a9d782 100644
--- a/plugins/base/src/test/kotlin/model/PropertyTest.kt
+++ b/plugins/base/src/test/kotlin/model/PropertyTest.kt
@@ -155,7 +155,7 @@ class PropertyTest : AbstractModelTest("/src/main/kotlin/property/Test.kt", "pro
with(content.first()) {
dri.classNames equals "SinceKotlin"
params.entries counts 1
-// params["version"].assertNotNull("version") equals "1.1"
+ (params["version"].assertNotNull("version") as StringValue).value equals "\"1.1\""
}
}
}
diff --git a/plugins/base/src/test/kotlin/utils/contentUtils.kt b/plugins/base/src/test/kotlin/utils/contentUtils.kt
index a1141832..ec119ebb 100644
--- a/plugins/base/src/test/kotlin/utils/contentUtils.kt
+++ b/plugins/base/src/test/kotlin/utils/contentUtils.kt
@@ -139,26 +139,28 @@ fun ContentMatcherBuilder<*>.propertySignature(
header { +"Package test" }
}
group {
- skipAllNotMatching()
- header { +"Properties" }
- table {
- group {
- link { +name }
- platformHinted {
- group {
+ group {
+ skipAllNotMatching()
+ header { +"Properties" }
+ table {
+ group {
+ link { +name }
+ platformHinted {
group {
- annotations.entries.forEach {
- group {
- unwrapAnnotation(it)
+ group {
+ annotations.entries.forEach {
+ group {
+ unwrapAnnotation(it)
+ }
}
- }
- +("$visibility $modifier ${keywords.joinToString("") { "$it " }} $preposition")
- link { +name }
- if (type != null) {
- +(": ")
- group {
- link {
- +(type)
+ +("$visibility $modifier ${keywords.joinToString("") { "$it " }} $preposition")
+ link { +name }
+ if (type != null) {
+ +(": ")
+ group {
+ link {
+ +(type)
+ }
}
}
}
diff --git a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
index 8d9ac20d..8f20f942 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
@@ -47,7 +47,7 @@ internal fun DPackage.asJava(): DPackage {
generics = emptyList(),
supertypes = emptyMap(),
documentation = emptyMap(),
- modifier = sourceSets.map{ it to JavaModifier.Final}.toMap(),
+ modifier = sourceSets.map { it to JavaModifier.Final }.toMap(),
sourceSets = sourceSets,
extra = PropertyContainer.empty()
)
@@ -68,15 +68,15 @@ internal fun DProperty.asJava(isTopLevel: Boolean = false, relocateToClass: Stri
dri.withClass(relocateToClass)
},
modifier = if (setter == null) {
- sourceSets.map{it to JavaModifier.Final}.toMap()
+ sourceSets.map { it to JavaModifier.Final }.toMap()
} else {
- sourceSets.map{it to JavaModifier.Empty}.toMap()
+ sourceSets.map { it to JavaModifier.Empty }.toMap()
},
visibility = visibility.mapValues { JavaVisibility.Private },
type = type.asJava(), // TODO: check
setter = null,
getter = null, // Removing getters and setters as they will be available as functions
- extra = if (isTopLevel) extra.plus(extra.mergeAdditionalModifiers(setOf(ExtraModifiers.STATIC))) else extra
+ extra = if (isTopLevel) extra.plus(extra.mergeAdditionalModifiers(setOf(ExtraModifiers.JavaOnlyModifiers.Static))) else extra
)
internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClass: String? = null): List<DFunction> =
@@ -89,13 +89,13 @@ internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClas
},
name = "get" + name.capitalize(),
modifier = if (setter == null) {
- sourceSets.map{it to JavaModifier.Final}.toMap()
+ sourceSets.map { it to JavaModifier.Final }.toMap()
} else {
- sourceSets.map{it to JavaModifier.Empty}.toMap()
+ sourceSets.map { it to JavaModifier.Empty }.toMap()
},
visibility = visibility.mapValues { JavaVisibility.Public },
type = type.asJava(), // TODO: check
- extra = if (isTopLevel) getter!!.extra.plus(getter!!.extra.mergeAdditionalModifiers(setOf(ExtraModifiers.STATIC))) else getter!!.extra
+ extra = if (isTopLevel) getter!!.extra.plus(getter!!.extra.mergeAdditionalModifiers(setOf(ExtraModifiers.JavaOnlyModifiers.Static))) else getter!!.extra
),
setter?.copy(
dri = if (relocateToClass.isNullOrBlank()) {
@@ -105,13 +105,13 @@ internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClas
},
name = "set" + name.capitalize(),
modifier = if (setter == null) {
- sourceSets.map{it to JavaModifier.Final}.toMap()
+ sourceSets.map { it to JavaModifier.Final }.toMap()
} else {
- sourceSets.map{it to JavaModifier.Empty}.toMap()
+ sourceSets.map { it to JavaModifier.Empty }.toMap()
},
visibility = visibility.mapValues { JavaVisibility.Public },
type = type.asJava(), // TODO: check
- extra = if (isTopLevel) setter!!.extra.plus(setter!!.extra.mergeAdditionalModifiers(setOf(ExtraModifiers.STATIC))) else setter!!.extra
+ extra = if (isTopLevel) setter!!.extra.plus(setter!!.extra.mergeAdditionalModifiers(setOf(ExtraModifiers.JavaOnlyModifiers.Static))) else setter!!.extra
)
)
@@ -125,9 +125,9 @@ internal fun DFunction.asJava(containingClassName: String): DFunction {
// dri = dri.copy(callable = dri.callable?.asJava()),
name = newName,
type = type.asJava(),
- modifier = if(modifier.all{(_,v)-> v is KotlinModifier.Final} && isConstructor)
- sourceSets.map{it to JavaModifier.Empty}.toMap()
- else sourceSets.map{it to modifier.values.first()}.toMap(),
+ modifier = if (modifier.all { (_, v) -> v is KotlinModifier.Final } && isConstructor)
+ sourceSets.map { it to JavaModifier.Empty }.toMap()
+ else sourceSets.map { it to modifier.values.first() }.toMap(),
parameters = listOfNotNull(receiver?.asJava()) + parameters.map { it.asJava() },
receiver = null
) // TODO static if toplevel
@@ -151,8 +151,9 @@ internal fun DClass.asJava(): DClass = copy(
classlikes = classlikes.map { it.asJava() },
generics = generics.map { it.asJava() },
supertypes = supertypes.mapValues { it.value.map { it.possiblyAsJava() } },
- modifier = if (modifier.all{(_,v) -> v is KotlinModifier.Empty}) sourceSets.map{it to JavaModifier.Final}.toMap()
- else sourceSets.map{it to modifier.values.first()}.toMap()
+ modifier = if (modifier.all { (_, v) -> v is KotlinModifier.Empty }) sourceSets.map { it to JavaModifier.Final }
+ .toMap()
+ else sourceSets.map { it to modifier.values.first() }.toMap()
)
private fun DTypeParameter.asJava(): DTypeParameter = copy(
@@ -188,7 +189,7 @@ internal fun DObject.asJava(): DObject = copy(
properties = properties.map { it.asJava() } +
DProperty(
name = "INSTANCE",
- modifier = sourceSets.map{it to JavaModifier.Final}.toMap(),
+ modifier = sourceSets.map { it to JavaModifier.Final }.toMap(),
dri = dri.copy(callable = Callable("INSTANCE", null, emptyList())),
documentation = emptyMap(),
sources = emptyMap(),
@@ -202,7 +203,7 @@ internal fun DObject.asJava(): DObject = copy(
receiver = null,
generics = emptyList(),
expectPresentInSet = expectPresentInSet,
- extra = PropertyContainer.empty<DProperty>() + AdditionalModifiers(setOf(ExtraModifiers.STATIC))
+ extra = PropertyContainer.empty<DProperty>() + AdditionalModifiers(setOf(ExtraModifiers.JavaOnlyModifiers.Static))
),
classlikes = classlikes.map { it.asJava() },
supertypes = supertypes.mapValues { it.value.map { it.possiblyAsJava() } }
diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
index ec3221e2..a55f9339 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
@@ -1,15 +1,12 @@
package org.jetbrains.dokka.kotlinAsJava.signatures
-import org.jetbrains.dokka.base.signatures.JvmSingatureUtils
-import javaslang.Tuple2
-import org.jetbrains.dokka.base.signatures.All
+import org.jetbrains.dokka.base.signatures.JvmSignatureUtils
import org.jetbrains.dokka.base.signatures.SignatureProvider
import org.jetbrains.dokka.base.transformers.pages.comments.CommentsToContentConverter
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.links.sureClassNames
import org.jetbrains.dokka.model.*
-import org.jetbrains.dokka.model.properties.WithExtraProperties
import org.jetbrains.dokka.pages.ContentKind
import org.jetbrains.dokka.pages.ContentNode
import org.jetbrains.dokka.pages.TextStyle
@@ -17,7 +14,7 @@ import org.jetbrains.dokka.utilities.DokkaLogger
import kotlin.text.Typography.nbsp
class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogger) : SignatureProvider,
- JvmSingatureUtils by JavaSignatureUtils {
+ JvmSignatureUtils by JavaSignatureUtils {
private val contentBuilder = PageContentBuilder(ctcc, this, logger)
private val ignoredVisibilities = setOf(JavaVisibility.Default)
diff --git a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt
index 16c3f25a..e2f73bf9 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt
@@ -1,14 +1,13 @@
package org.jetbrains.dokka.kotlinAsJava.signatures
-import javaslang.Tuple2
+
import org.jetbrains.dokka.base.signatures.All
-import org.jetbrains.dokka.base.signatures.JvmSingatureUtils
+import org.jetbrains.dokka.base.signatures.JvmSignatureUtils
import org.jetbrains.dokka.base.translators.documentables.PageContentBuilder
import org.jetbrains.dokka.links.DRI
import org.jetbrains.dokka.model.*
-import org.jetbrains.dokka.model.ExtraModifiers.Companion.javaOnlyModifiers
import org.jetbrains.dokka.model.properties.WithExtraProperties
-object JavaSignatureUtils : JvmSingatureUtils {
+object JavaSignatureUtils : JvmSignatureUtils {
val ignoredAnnotations = setOf(
Annotations.Annotation(DRI("kotlin.jvm", "Transient"), emptyMap()),
@@ -19,7 +18,7 @@ object JavaSignatureUtils : JvmSingatureUtils {
)
private val strategy = All
- private val listBrackets = Tuple2('{', '}')
+ private val listBrackets = Pair('{', '}')
private val classExtension = ".class"
override fun PageContentBuilder.DocumentableContentBuilder.annotationsBlock(d: Documentable) =
@@ -29,6 +28,6 @@ object JavaSignatureUtils : JvmSingatureUtils {
annotationsInlineWithIgnored(d, ignoredAnnotations, strategy, listBrackets, classExtension)
override fun <T : Documentable> WithExtraProperties<T>.modifiers() =
- modifiersWithFilter(javaOnlyModifiers)
+ extra[AdditionalModifiers]?.content?.filterIsInstance<ExtraModifiers.JavaOnlyModifiers>()?.toSet() ?: emptySet()
} \ No newline at end of file