aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java/src
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-05-28 21:12:50 +0200
committerPaweł Marks <pmarks@virtuslab.com>2020-06-12 14:15:24 +0200
commitdd44b839eac1b7b647e97f2cc73dd96bd054713b (patch)
tree6ab5a393c2a7d926519626f5f45f5c8b8cd60505 /plugins/kotlin-as-java/src
parentd7be30c841cb925fd0d6322ccdd9877169730b92 (diff)
downloaddokka-dd44b839eac1b7b647e97f2cc73dd96bd054713b.tar.gz
dokka-dd44b839eac1b7b647e97f2cc73dd96bd054713b.tar.bz2
dokka-dd44b839eac1b7b647e97f2cc73dd96bd054713b.zip
Refactor of Annotations and ExtraModifiers to be platform depedent
Diffstat (limited to 'plugins/kotlin-as-java/src')
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt29
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt8
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt4
3 files changed, 31 insertions, 10 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 8f20f942..693fffac 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/converters/KotlinToJavaConverter.kt
@@ -76,7 +76,13 @@ internal fun DProperty.asJava(isTopLevel: Boolean = false, relocateToClass: Stri
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.JavaOnlyModifiers.Static))) else extra
+ extra = if (isTopLevel) extra +
+ extra.mergeAdditionalModifiers(
+ sourceSets.map {
+ it to setOf(ExtraModifiers.JavaOnlyModifiers.Static)
+ }.toMap()
+ )
+ else extra
)
internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClass: String? = null): List<DFunction> =
@@ -95,7 +101,13 @@ internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClas
},
visibility = visibility.mapValues { JavaVisibility.Public },
type = type.asJava(), // TODO: check
- extra = if (isTopLevel) getter!!.extra.plus(getter!!.extra.mergeAdditionalModifiers(setOf(ExtraModifiers.JavaOnlyModifiers.Static))) else getter!!.extra
+ extra = if (isTopLevel) getter!!.extra +
+ getter!!.extra.mergeAdditionalModifiers(
+ sourceSets.map {
+ it to setOf(ExtraModifiers.JavaOnlyModifiers.Static)
+ }.toMap()
+ )
+ else getter!!.extra
),
setter?.copy(
dri = if (relocateToClass.isNullOrBlank()) {
@@ -111,7 +123,12 @@ internal fun DProperty.javaAccessors(isTopLevel: Boolean = false, relocateToClas
},
visibility = visibility.mapValues { JavaVisibility.Public },
type = type.asJava(), // TODO: check
- extra = if (isTopLevel) setter!!.extra.plus(setter!!.extra.mergeAdditionalModifiers(setOf(ExtraModifiers.JavaOnlyModifiers.Static))) else setter!!.extra
+ extra = if (isTopLevel) setter!!.extra + setter!!.extra.mergeAdditionalModifiers(
+ sourceSets.map {
+ it to setOf(ExtraModifiers.JavaOnlyModifiers.Static)
+ }.toMap()
+ )
+ else setter!!.extra
)
)
@@ -203,7 +220,9 @@ internal fun DObject.asJava(): DObject = copy(
receiver = null,
generics = emptyList(),
expectPresentInSet = expectPresentInSet,
- extra = PropertyContainer.empty<DProperty>() + AdditionalModifiers(setOf(ExtraModifiers.JavaOnlyModifiers.Static))
+ extra = PropertyContainer.withAll(sourceSets.map {
+ mapOf(it to setOf(ExtraModifiers.JavaOnlyModifiers.Static)).toAdditionalModifiers()
+ })
),
classlikes = classlikes.map { it.asJava() },
supertypes = supertypes.mapValues { it.value.map { it.possiblyAsJava() } }
@@ -248,7 +267,7 @@ internal fun ClassId.toDRI(dri: DRI?): DRI = DRI(
target = PointingToDeclaration
)
-private fun PropertyContainer<out Documentable>.mergeAdditionalModifiers(second: Set<ExtraModifiers>) =
+private fun PropertyContainer<out Documentable>.mergeAdditionalModifiers(second: SourceSetDependent<Set<ExtraModifiers>>) =
this[AdditionalModifiers]?.squash(AdditionalModifiers(second)) ?: AdditionalModifiers(second)
private fun AdditionalModifiers.squash(second: AdditionalModifiers) =
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 a55f9339..5c4985ac 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureProvider.kt
@@ -41,7 +41,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
if (c is DClass) {
platformText(c.modifier) { it.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " " }
- text(c.modifiers().toSignatureString())
+ platformText(c.modifiers()) { it.toSignatureString() }
}
when (c) {
@@ -71,7 +71,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
annotationsBlock(p)
platformText(p.visibility) { (it.takeIf { it !in ignoredVisibilities }?.name ?: "") + " " }
platformText(p.modifier) { it.name + " " }
- text(p.modifiers().toSignatureString())
+ platformText(p.modifiers()) { it.toSignatureString() }
signatureForProjection(p.type)
text(nbsp.toString())
link(p.name, p.dri)
@@ -82,7 +82,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
group(styles = setOf(TextStyle.Block)) {
annotationsBlock(f)
platformText(f.modifier) { it.takeIf { it !in ignoredModifiers }?.name.orEmpty() + " " }
- text(f.modifiers().toSignatureString())
+ platformText(f.modifiers()) { it.toSignatureString() }
val returnType = f.type
signatureForProjection(returnType)
text(nbsp.toString())
@@ -92,7 +92,7 @@ class JavaSignatureProvider(ctcc: CommentsToContentConverter, logger: DokkaLogge
}
list(f.parameters, "(", ")") {
annotationsInline(it)
- text(it.modifiers().toSignatureString())
+ platformText(it.modifiers()) { it.toSignatureString() }
signatureForProjection(it.type)
text(nbsp.toString())
link(it.name!!, it.dri)
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 e2f73bf9..b4245834 100644
--- a/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt
+++ b/plugins/kotlin-as-java/src/main/kotlin/signatures/JavaSignatureUtils.kt
@@ -28,6 +28,8 @@ object JavaSignatureUtils : JvmSignatureUtils {
annotationsInlineWithIgnored(d, ignoredAnnotations, strategy, listBrackets, classExtension)
override fun <T : Documentable> WithExtraProperties<T>.modifiers() =
- extra[AdditionalModifiers]?.content?.filterIsInstance<ExtraModifiers.JavaOnlyModifiers>()?.toSet() ?: emptySet()
+ extra[AdditionalModifiers]?.content?.entries?.map {
+ it.key to it.value.filterIsInstance<ExtraModifiers.JavaOnlyModifiers>().toSet()
+ }?.toMap() ?: emptyMap()
} \ No newline at end of file