aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main
diff options
context:
space:
mode:
authorCharlesG-Branch <43424788+CharlesG-Branch@users.noreply.github.com>2022-02-18 07:39:33 -0500
committerGitHub <noreply@github.com>2022-02-18 15:39:33 +0300
commitdf4780c31026aaa626746f49f0e6fa3fa0278a05 (patch)
tree5d562bcbf2240d8a1bd50ef5f97040088b68f781 /plugins/base/src/main
parent9a1434d583b931671e2c5e9c5275af725938d503 (diff)
downloaddokka-df4780c31026aaa626746f49f0e6fa3fa0278a05.tar.gz
dokka-df4780c31026aaa626746f49f0e6fa3fa0278a05.tar.bz2
dokka-df4780c31026aaa626746f49f0e6fa3fa0278a05.zip
Fix java getter / setter name generation (#2356)
Kotlin has special rules for conversion around properties that start with "is" For more info see: https://kotlinlang.org/docs/java-interop.html#getters-and-setters https://kotlinlang.org/docs/java-to-kotlin-interop.html#properties
Diffstat (limited to 'plugins/base/src/main')
-rw-r--r--plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt20
1 files changed, 18 insertions, 2 deletions
diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
index 96bd2fc0..f636f984 100644
--- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt
@@ -616,9 +616,25 @@ private class DokkaDescriptorVisitor(
)
val name = run {
- val modifier = if (isGetter) "get" else "set"
val rawName = propertyDescriptor.name.asString()
- "$modifier${rawName.capitalize()}"
+ /*
+ * Kotlin has special rules for conversion around properties that
+ * start with "is" For more info see:
+ * https://kotlinlang.org/docs/java-interop.html#getters-and-setters
+ * https://kotlinlang.org/docs/java-to-kotlin-interop.html#properties
+ *
+ * Based on our testing, this rule only applies when the letter after
+ * the "is" is *not* lowercase. This means that words like "issue" won't
+ * have the rule applied but "is_foobar" and "is1of" will have the rule applied.
+ */
+ val specialCaseIs = rawName.startsWith("is")
+ && rawName.getOrNull(2)?.isLowerCase() == false
+
+ if (specialCaseIs) {
+ if (isGetter) rawName else rawName.replaceFirst("is", "set")
+ } else {
+ if (isGetter) "get${rawName.capitalize()}" else "set${rawName.capitalize()}"
+ }
}
val parameters =