Skip to content

Commit

Permalink
Apply requested changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
BarkingBad committed Mar 14, 2022
1 parent bb746c9 commit fecb1c2
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion core/src/main/kotlin/model/JvmField.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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<DocumentationNode>.translatePropertyToDescription(): SourceSetDependent<DocumentationNode> {
fun SourceSetDependent<DocumentationNode>.translatePropertyTagToDescription(): SourceSetDependent<DocumentationNode> {
return this.mapValues { (_, value) ->
value.copy(children = value.children.map {
when (it) {
Expand All @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit fecb1c2

Please sign in to comment.