diff options
author | Filip Zybała <fzybala@virtuslab.com> | 2020-03-20 15:27:30 +0100 |
---|---|---|
committer | Paweł Marks <Kordyjan@users.noreply.github.com> | 2020-03-26 12:36:03 +0100 |
commit | 8a87b5e0bd2eda12f4e44512e3f8856c72e53b3e (patch) | |
tree | 75b10c56bd933e2cfdcf0c32492ce9d6b61b1533 /plugins/kotlin-as-java/src/main | |
parent | 8ef04b5d6bb46a5fbd9cea9b8d08048bc9f03879 (diff) | |
download | dokka-8a87b5e0bd2eda12f4e44512e3f8856c72e53b3e.tar.gz dokka-8a87b5e0bd2eda12f4e44512e3f8856c72e53b3e.tar.bz2 dokka-8a87b5e0bd2eda12f4e44512e3f8856c72e53b3e.zip |
Changed modifier to PlatformDependent
Diffstat (limited to 'plugins/kotlin-as-java/src/main')
-rw-r--r-- | plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt | 23 | ||||
-rw-r--r-- | plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt | 4 |
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(" ") |