diff options
author | Marcin Aman <marcin.aman@gmail.com> | 2021-01-20 10:30:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-20 10:30:50 +0100 |
commit | 93520158b4be59f98015d07e8fecaa7e5a49fd99 (patch) | |
tree | 24c57c752bb7f3125f6248ebae232a69bec8efb6 /plugins/kotlin-as-java/src/main/kotlin | |
parent | 9f7dc9cc0183c74fc77c63297eb73f936715d77d (diff) | |
download | dokka-93520158b4be59f98015d07e8fecaa7e5a49fd99.tar.gz dokka-93520158b4be59f98015d07e8fecaa7e5a49fd99.tar.bz2 dokka-93520158b4be59f98015d07e8fecaa7e5a49fd99.zip |
Bring back displaying jvm name when KaJ is not present (#1702)
Diffstat (limited to 'plugins/kotlin-as-java/src/main/kotlin')
-rw-r--r-- | plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameDocumentableTransformer.kt | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameDocumentableTransformer.kt b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameDocumentableTransformer.kt index 3fb26034..c49e08f0 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameDocumentableTransformer.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameDocumentableTransformer.kt @@ -1,6 +1,7 @@ package org.jetbrains.dokka.kotlinAsJava.transformers import org.jetbrains.dokka.model.* +import org.jetbrains.dokka.model.properties.PropertyContainer import org.jetbrains.dokka.plugability.DokkaContext import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer @@ -25,7 +26,8 @@ class JvmNameDocumentableTransformer : DocumentableTransformer { val name = jvmNameProvider.nameFor(this) copy( dri = documentable.dri.withCallableName(name), - name = name + name = name, + extra = extra.withoutJvmName() ) } is DProperty -> transformGetterAndSetter(this) @@ -42,6 +44,17 @@ class JvmNameDocumentableTransformer : DocumentableTransformer { } } as T + private fun PropertyContainer<DFunction>.withoutJvmName(): PropertyContainer<DFunction> { + val annotationsWithoutJvmName = get(Annotations)?.let { annotations -> + annotations.copy((annotations.directAnnotations).map { (sourceset, annotations) -> + sourceset to annotations.filterNot { it.isJvmName() } + }.toMap() + annotations.fileLevelAnnotations) + } + val extraWithoutAnnotations: PropertyContainer<DFunction> = minus(Annotations) + + return extraWithoutAnnotations.addAll(listOfNotNull(annotationsWithoutJvmName)) + } + private fun transformClassLike(documentable: DClasslike): DClasslike = with(documentable) { when (this) { @@ -80,7 +93,8 @@ class JvmNameDocumentableTransformer : DocumentableTransformer { setter?.let { setter -> setter.copy( dri = setter.dri.withCallableName(setterName), - name = setterName + name = setterName, + extra = setter.extra.withoutJvmName() ) } }, @@ -88,7 +102,8 @@ class JvmNameDocumentableTransformer : DocumentableTransformer { getter?.let { getter -> getter.copy( dri = getter.dri.withCallableName(getterName), - name = getterName + name = getterName, + extra = getter.extra.withoutJvmName() ) } }) |