aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/translators
diff options
context:
space:
mode:
authorIgnat Beresnev <ignat.beresnev@jetbrains.com>2022-06-30 16:03:56 +0200
committerGitHub <noreply@github.com>2022-06-30 16:03:56 +0200
commite3c76cba8e9838b3ab2635261e3c143690fbc0c8 (patch)
tree4bf5884f7cabfb37ba60bb05335f152c4d3ba1e2 /plugins/base/src/main/kotlin/translators
parent76334ec6e8d66b377fc9c37187725f8d267d5ba2 (diff)
downloaddokka-e3c76cba8e9838b3ab2635261e3c143690fbc0c8.tar.gz
dokka-e3c76cba8e9838b3ab2635261e3c143690fbc0c8.tar.bz2
dokka-e3c76cba8e9838b3ab2635261e3c143690fbc0c8.zip
Mark synthetic methods generated for Java enums as obvious (#2554)
Fixes #2548
Diffstat (limited to 'plugins/base/src/main/kotlin/translators')
-rw-r--r--plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt13
1 files changed, 9 insertions, 4 deletions
diff --git a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
index f64eb261..500b0728 100644
--- a/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
+++ b/plugins/base/src/main/kotlin/translators/psi/DefaultPsiToDocumentableTranslator.kt
@@ -112,9 +112,6 @@ class DefaultPsiToDocumentableTranslator(
private val PsiClassType.shouldBeIgnored: Boolean
get() = isClass("java.lang.Enum") || isClass("java.lang.Object")
- private val DRI.isObvious: Boolean
- get() = packageName == "java.lang" && (classNames == "Object" || classNames == "Enum")
-
private fun PsiClassType.isClass(qName: String): Boolean {
val shortName = qName.substringAfterLast('.')
if (className == shortName) {
@@ -446,7 +443,7 @@ class DefaultPsiToDocumentableTranslator(
(psi.annotations.toList()
.toListOfAnnotations() + it.toListOfAnnotations()).toSourceSetDependent()
.toAnnotations(),
- ObviousMember.takeIf { inheritedFrom != null && inheritedFrom.isObvious },
+ ObviousMember.takeIf { psi.isObvious(inheritedFrom) },
psi.throwsList.toDriList().takeIf { it.isNotEmpty() }
?.let { CheckedExceptions(it.toSourceSetDependent()) }
)
@@ -454,6 +451,14 @@ class DefaultPsiToDocumentableTranslator(
)
}
+ private fun PsiMethod.isObvious(inheritedFrom: DRI? = null): Boolean {
+ return this is SyntheticElement || inheritedFrom?.isObvious() == true
+ }
+
+ private fun DRI.isObvious(): Boolean {
+ return packageName == "java.lang" && (classNames == "Object" || classNames == "Enum")
+ }
+
private fun PsiReferenceList.toDriList() = referenceElements.mapNotNull { it?.resolve()?.let { DRI.from(it) } }
private fun PsiModifierListOwner.additionalExtras() = listOfNotNull(