aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java
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 /plugins/kotlin-as-java
parentd47d386ad8c0ff4a2c3b9d5b4450a773bdcba2dc (diff)
downloaddokka-77fa898e8abdc8e74169fa789f2ba0e32d8fa9d7.tar.gz
dokka-77fa898e8abdc8e74169fa789f2ba0e32d8fa9d7.tar.bz2
dokka-77fa898e8abdc8e74169fa789f2ba0e32d8fa9d7.zip
Apply request changes
Diffstat (limited to 'plugins/kotlin-as-java')
-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
3 files changed, 25 insertions, 28 deletions
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