aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java/src
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/kotlin-as-java/src')
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt23
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt4
2 files changed, 15 insertions, 12 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 6de3f121..dac937c0 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 = PlatformDependent.empty(),
documentation = PlatformDependent.empty(),
- modifier = JavaModifier.Final,
+ modifier = PlatformDependent(map = platformData.map{ it to JavaModifier.Final}.toMap()),
platformData = platformData,
extra = PropertyContainer.empty()
)
@@ -68,9 +68,9 @@ internal fun DProperty.asJava(isTopLevel: Boolean = false, relocateToClass: Stri
dri.withClass(relocateToClass)
},
modifier = if (setter == null) {
- JavaModifier.Final
+ PlatformDependent(map = platformData.map{it to JavaModifier.Final}.toMap())
} else {
- JavaModifier.Empty
+ PlatformDependent(map = platformData.map{it to JavaModifier.Empty}.toMap())
},
visibility = visibility.copy(
map = visibility.mapValues { JavaVisibility.Private }
@@ -91,9 +91,9 @@ internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClas
},
name = "get" + name.capitalize(),
modifier = if (setter == null) {
- JavaModifier.Final
+ PlatformDependent(map = platformData.map{it to JavaModifier.Final}.toMap())
} else {
- JavaModifier.Empty
+ PlatformDependent(map = platformData.map{it to JavaModifier.Empty}.toMap())
},
visibility = visibility.copy(
map = visibility.mapValues { JavaVisibility.Public }
@@ -109,9 +109,9 @@ internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClas
},
name = "set" + name.capitalize(),
modifier = if (setter == null) {
- JavaModifier.Final
+ PlatformDependent(map = platformData.map{it to JavaModifier.Final}.toMap())
} else {
- JavaModifier.Empty
+ PlatformDependent(map = platformData.map{it to JavaModifier.Empty}.toMap())
},
visibility = visibility.copy(
map = visibility.mapValues { JavaVisibility.Public }
@@ -131,7 +131,9 @@ internal fun DFunction.asJava(containingClassName: String): DFunction {
// dri = dri.copy(callable = dri.callable?.asJava()),
name = newName,
type = type.asJava(),
- modifier = if(modifier is KotlinModifier.Final && isConstructor) JavaModifier.Empty else modifier,
+ modifier = if(modifier.all{(_,v)-> v is KotlinModifier.Final} && isConstructor)
+ PlatformDependent(map = platformData.map{it to JavaModifier.Empty}.toMap())
+ else PlatformDependent(map = platformData.map{it to modifier.allValues.first()}.toMap()),
parameters = listOfNotNull(receiver?.asJava()) + parameters.map { it.asJava() },
receiver = null
) // TODO static if toplevel
@@ -157,7 +159,8 @@ internal fun DClass.asJava(): DClass = copy(
supertypes = supertypes.copy(
map = supertypes.mapValues { it.value.map { it.possiblyAsJava() } }
),
- modifier = if (modifier is KotlinModifier.Empty) JavaModifier.Final else modifier
+ modifier = if (modifier.all{(_,v) -> v is KotlinModifier.Empty}) PlatformDependent(map = platformData.map{it to JavaModifier.Final}.toMap())
+ else PlatformDependent(map = platformData.map{it to modifier.allValues.first()}.toMap())
)
private fun DTypeParameter.asJava(): DTypeParameter = copy(
@@ -195,7 +198,7 @@ internal fun DObject.asJava(): DObject = copy(
properties = properties.map { it.asJava() } +
DProperty(
name = "INSTANCE",
- modifier = JavaModifier.Final,
+ modifier = PlatformDependent(map = platformData.map{it to JavaModifier.Final}.toMap()),
dri = dri.copy(callable = Callable("INSTANCE", null, emptyList())),
documentation = PlatformDependent.empty(),
sources = PlatformDependent.empty(),
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 6a571660..54bf663d 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
@@ -33,7 +33,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
platformText(c.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
if (c is DClass) {
- text(c.modifier.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " ")
+ platformText(c.modifier){ it.takeIf{it !in ignoredModifiers}?.name.orEmpty() + " "}
}
when (c) {
@@ -63,7 +63,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
}
private fun signature(f: DFunction) = contentBuilder.contentFor(f, ContentKind.Symbol, setOf(TextStyle.Monospace)) {
- text(f.modifier.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " ")
+ platformText(f.modifier){ it.takeIf{it !in ignoredModifiers}?.name.orEmpty() + " "}
val returnType = f.type
signatureForProjection(returnType)
text(" ")