From 255925bdc68e8361f7f9e49bf121b985f5a4fbd4 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak Date: Mon, 14 Mar 2022 10:24:41 +0100 Subject: [PATCH] Apply requested changes. --- core/api/core.api | 2 ++ core/src/main/kotlin/model/JvmField.kt | 2 +- .../documentables/PropertiesMergerTransformer.kt | 2 +- .../DefaultDescriptorToDocumentableTranslator.kt | 10 +++++----- .../src/test/kotlin/superFields/PsiSuperFieldsTest.kt | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/core/api/core.api b/core/api/core.api index 294851d1e7..c11acda133 100644 --- a/core/api/core.api +++ b/core/api/core.api @@ -1838,6 +1838,8 @@ public final class org/jetbrains/dokka/model/JavaVisibility$Public : org/jetbrai } public final class org/jetbrains/dokka/model/JvmFieldKt { + public static final field JVM_FIELD_CLASS_NAMES Ljava/lang/String; + public static final field JVM_FIELD_PACKAGE_NAME Ljava/lang/String; public static final fun isJvmField (Lorg/jetbrains/dokka/links/DRI;)Z public static final fun isJvmField (Lorg/jetbrains/dokka/model/Annotations$Annotation;)Z } diff --git a/core/src/main/kotlin/model/JvmField.kt b/core/src/main/kotlin/model/JvmField.kt index a2f140cd8c..623115e0bd 100644 --- a/core/src/main/kotlin/model/JvmField.kt +++ b/core/src/main/kotlin/model/JvmField.kt @@ -7,4 +7,4 @@ const val JVM_FIELD_CLASS_NAMES = "JvmField" fun DRI.isJvmField(): Boolean = packageName == JVM_FIELD_PACKAGE_NAME && classNames == JVM_FIELD_CLASS_NAMES -fun Annotations.Annotation.isJvmField(): Boolean = dri.isJvmName() +fun Annotations.Annotation.isJvmField(): Boolean = dri.isJvmField() diff --git a/plugins/base/src/main/kotlin/transformers/documentables/PropertiesMergerTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/PropertiesMergerTransformer.kt index b4732932e2..77c88285ef 100644 --- a/plugins/base/src/main/kotlin/transformers/documentables/PropertiesMergerTransformer.kt +++ b/plugins/base/src/main/kotlin/transformers/documentables/PropertiesMergerTransformer.kt @@ -63,7 +63,7 @@ class PropertiesMergerTransformer : PreMergeDocumentableTransformer { } /** - * This is losely copied from here + * This is loosely copied from here * [org.jetbrains.dokka.base.translators.psi.DefaultPsiToDocumentableTranslator.DokkaPsiParser.splitFunctionsAndAccessors] * we should consider if we could unify that. * TODO: Revisit that diff --git a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt index 930c6cc70c..59811bf8df 100644 --- a/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt +++ b/plugins/base/src/main/kotlin/translators/descriptors/DefaultDescriptorToDocumentableTranslator.kt @@ -439,7 +439,7 @@ private class DokkaDescriptorVisitor( * declared and inheritedFrom as the same DRI but truncated callable part. * Therefore, we set callable to null and take the DRI only if it is indeed coming from different class. */ - val inheritedFrom = dri.copy(callable = null).takeIf { parent.dri.classNames != dri.classNames } + val inheritedFrom = dri.copy(callable = null).takeIf { parent.dri.classNames != dri.classNames || parent.dri.packageName != dri.packageName } val descriptor = originalDescriptor.getConcreteDescriptor() val isExpect = descriptor.isExpect val isActual = descriptor.isActual @@ -499,7 +499,7 @@ private class DokkaDescriptorVisitor( * To avoid redundant docs, please visit [visitPropertyDescriptor] inheritedFrom * local val documentation. */ - val inheritedFrom = dri.copy(callable = null).takeIf { parent.dri.classNames != dri.classNames } + val inheritedFrom = dri.copy(callable = null).takeIf { parent.dri.classNames != dri.classNames || parent.dri.packageName != dri.packageName } val descriptor = originalDescriptor.getConcreteDescriptor() val isExpect = descriptor.isExpect val isActual = descriptor.isActual @@ -666,13 +666,13 @@ private class DokkaDescriptorVisitor( * Workaround for problem with inheriting TagWrappers. * There is an issue if one declare documentation in the class header for * property using this syntax: `@property` - * The compiler will propagate it withing this tag to property and to its getters and setters. + * The compiler will propagate the text wrapped in this tag to property and to its getters and setters. * * Actually, the problem impacts more of these tags, yet this particular tag was blocker for * some opens-source plugin creators. * TODO: Should rethink if we could fix it globally in dokka or in compiler itself. */ - fun SourceSetDependent.translatePropertyToDescription(): SourceSetDependent { + fun SourceSetDependent.translatePropertyTagToDescription(): SourceSetDependent { return this.mapValues { (_, value) -> value.copy(children = value.children.map { when (it) { @@ -689,7 +689,7 @@ private class DokkaDescriptorVisitor( isConstructor = false, parameters = parameters, visibility = descriptor.visibility.toDokkaVisibility().toSourceSetDependent(), - documentation = descriptor.resolveDescriptorData().translatePropertyToDescription(), + documentation = descriptor.resolveDescriptorData().translatePropertyTagToDescription(), type = descriptor.returnType!!.toBound(), generics = generics.await(), modifier = descriptor.modifier().toSourceSetDependent(), diff --git a/plugins/base/src/test/kotlin/superFields/PsiSuperFieldsTest.kt b/plugins/base/src/test/kotlin/superFields/PsiSuperFieldsTest.kt index 7d45f91099..257bd94683 100644 --- a/plugins/base/src/test/kotlin/superFields/PsiSuperFieldsTest.kt +++ b/plugins/base/src/test/kotlin/superFields/PsiSuperFieldsTest.kt @@ -4,6 +4,7 @@ import org.jetbrains.dokka.base.testApi.testRunner.BaseAbstractTest import org.jetbrains.dokka.links.DRI import org.jetbrains.dokka.model.Annotations import org.jetbrains.dokka.model.InheritedMember +import org.jetbrains.dokka.model.isJvmField import org.junit.jupiter.api.Disabled import org.junit.jupiter.api.Assertions.assertNotNull import org.junit.jupiter.api.Assertions.assertNull @@ -126,8 +127,7 @@ class PsiSuperFieldsTest : BaseAbstractTest() { assertNull(this.getter) assertNull(this.setter) assertNotNull(this.extra[Annotations]?.directAnnotations?.values?.single()?.find { - it.dri.packageName == "kotlin.jvm" && - it.dri.classNames == "JvmField" + it.isJvmField() }) this.extra[InheritedMember]?.inheritedFrom?.values?.single()?.run { assertEquals(