diff options
Diffstat (limited to 'plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameDocumentableTransformer.kt')
-rw-r--r-- | plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameDocumentableTransformer.kt | 54 |
1 files changed, 26 insertions, 28 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 c49e08f0..28cb3453 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameDocumentableTransformer.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameDocumentableTransformer.kt @@ -7,20 +7,18 @@ import org.jetbrains.dokka.transformers.documentation.DocumentableTransformer class JvmNameDocumentableTransformer : DocumentableTransformer { private val jvmNameProvider = JvmNameProvider() - private lateinit var context: DokkaContext override fun invoke(original: DModule, context: DokkaContext): DModule { - this.context = context - return original.copy(packages = original.packages.map { transform(it) }) + return original.copy(packages = original.packages.map { transform(it, context) }) } - private fun <T : Documentable> transform(documentable: T): T = + internal fun <T : Documentable> transform(documentable: T, context: DokkaContext): T = with(documentable) { when (this) { is DPackage -> copy( - functions = functions.map { transform(it) }, - properties = properties.map { transform(it) }, - classlikes = classlikes.map { transform(it) }, + functions = functions.map { transform(it, context) }, + properties = properties.map { transform(it, context) }, + classlikes = classlikes.map { transform(it, context) }, ) is DFunction -> { val name = jvmNameProvider.nameFor(this) @@ -31,11 +29,11 @@ class JvmNameDocumentableTransformer : DocumentableTransformer { ) } is DProperty -> transformGetterAndSetter(this) - is DClasslike -> transformClassLike(this) + is DClasslike -> transformClassLike(this, context) is DEnumEntry -> copy( - functions = functions.map { transform(it) }, - properties = properties.map { transform(it) }, - classlikes = classlikes.map { transform(it) }, + functions = functions.map { transform(it, context) }, + properties = properties.map { transform(it, context) }, + classlikes = classlikes.map { transform(it, context) }, ) else -> { context.logger.warn("Failed to translate a JvmName for ${this.javaClass.canonicalName}") @@ -55,33 +53,33 @@ class JvmNameDocumentableTransformer : DocumentableTransformer { return extraWithoutAnnotations.addAll(listOfNotNull(annotationsWithoutJvmName)) } - private fun transformClassLike(documentable: DClasslike): DClasslike = + private fun transformClassLike(documentable: DClasslike, context: DokkaContext): DClasslike = with(documentable) { when (this) { is DClass -> copy( - functions = functions.map { transform(it) }, - properties = properties.map { transform(it) }, - classlikes = classlikes.map { transform(it) }, + functions = functions.map { transform(it, context) }, + properties = properties.map { transform(it, context) }, + classlikes = classlikes.map { transform(it, context) }, ) is DAnnotation -> copy( - functions = functions.map { transform(it) }, - properties = properties.map { transform(it) }, - classlikes = classlikes.map { transform(it) }, + functions = functions.map { transform(it, context) }, + properties = properties.map { transform(it, context) }, + classlikes = classlikes.map { transform(it, context) }, ) is DObject -> copy( - functions = functions.map { transform(it) }, - properties = properties.map { transform(it) }, - classlikes = classlikes.map { transform(it) }, + functions = functions.map { transform(it, context) }, + properties = properties.map { transform(it, context) }, + classlikes = classlikes.map { transform(it, context) }, ) is DEnum -> copy( - functions = functions.map { transform(it) }, - properties = properties.map { transform(it) }, - classlikes = classlikes.map { transform(it) }, + functions = functions.map { transform(it, context) }, + properties = properties.map { transform(it, context) }, + classlikes = classlikes.map { transform(it, context) }, ) is DInterface -> copy( - functions = functions.map { transform(it) }, - properties = properties.map { transform(it) }, - classlikes = classlikes.map { transform(it) }, + functions = functions.map { transform(it, context) }, + properties = properties.map { transform(it, context) }, + classlikes = classlikes.map { transform(it, context) }, ) } } @@ -108,4 +106,4 @@ class JvmNameDocumentableTransformer : DocumentableTransformer { } }) } -}
\ No newline at end of file +} |