From 6b0cdf3102b1f1dd213ca0c2e2c333f8756be6b4 Mon Sep 17 00:00:00 2001 From: Marcin Aman Date: Mon, 4 Jan 2021 10:27:10 +0100 Subject: JvmField annotation (#1678) --- .../src/main/kotlin/transformers/JvmNameProvider.kt | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt') diff --git a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt index 4e0ff7d7..31252ae0 100644 --- a/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt +++ b/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt @@ -1,12 +1,12 @@ package org.jetbrains.dokka.kotlinAsJava.transformers import org.jetbrains.dokka.kotlinAsJava.directlyAnnotatedJvmName +import org.jetbrains.dokka.kotlinAsJava.fileLevelJvmName import org.jetbrains.dokka.kotlinAsJava.jvmNameAsString import org.jetbrains.dokka.model.* import org.jetbrains.dokka.model.properties.WithExtraProperties -import org.jetbrains.kotlin.utils.addToStdlib.firstNotNullResult -data class Name(val fqName: String){ +data class Name(val fqName: String) { val name = fqName.substringAfterLast(".") } @@ -16,12 +16,9 @@ class JvmNameProvider { ?: entry.name ?: throw IllegalStateException("Failed to provide a name for ${entry.javaClass.canonicalName}") - fun nameForSyntheticClass(entry: T): Name where T : WithSources, T : WithExtraProperties, T: Documentable { - val name = entry.extra[Annotations]?.let { - it.fileLevelAnnotations.entries.firstNotNullResult { (_, annotations) -> - annotations.jvmNameAnnotation()?.jvmNameAsString() - } - } ?: entry.sources.entries.first().value.path.split("/").last().split(".").first().capitalize() + "Kt" + fun nameForSyntheticClass(entry: T): Name where T : WithSources, T : WithExtraProperties, T : Documentable { + val name: String = (entry.fileLevelJvmName()?.params?.get("name") as? StringValue)?.value + ?: entry.sources.entries.first().value.path.split("/").last().split(".").first().capitalize() + "Kt" return Name("${entry.dri.packageName}.$name") } -- cgit