aboutsummaryrefslogtreecommitdiff
path: root/plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt
diff options
context:
space:
mode:
authorMarcin Aman <marcin.aman@gmail.com>2021-01-04 10:27:10 +0100
committerGitHub <noreply@github.com>2021-01-04 10:27:10 +0100
commit6b0cdf3102b1f1dd213ca0c2e2c333f8756be6b4 (patch)
tree173db191f3f48b93574ff5d1052c99f98469e0f4 /plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt
parent1bf2cda23362ccab60fb866e07e9b8f073254d2c (diff)
downloaddokka-6b0cdf3102b1f1dd213ca0c2e2c333f8756be6b4.tar.gz
dokka-6b0cdf3102b1f1dd213ca0c2e2c333f8756be6b4.tar.bz2
dokka-6b0cdf3102b1f1dd213ca0c2e2c333f8756be6b4.zip
JvmField annotation (#1678)
Diffstat (limited to 'plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt')
-rw-r--r--plugins/kotlin-as-java/src/main/kotlin/transformers/JvmNameProvider.kt13
1 files changed, 5 insertions, 8 deletions
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 <T> nameForSyntheticClass(entry: T): Name where T : WithSources, T : WithExtraProperties<out Documentable>, 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 <T> nameForSyntheticClass(entry: T): Name where T : WithSources, T : WithExtraProperties<out Documentable>, 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")
}