Skip to content

Commit

Permalink
Unify InheritedMember DRI logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
BarkingBad committed Feb 24, 2022
1 parent c72b96b commit a97934e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -430,10 +430,8 @@ private class DokkaDescriptorVisitor(
originalDescriptor: PropertyDescriptor,
parent: DRIWithPlatformInfo
): DProperty {
val (dri, inheritedFrom) = originalDescriptor.createDRI().let {
if (it.second != null) (it.second to it.first) as Pair<DRI, DRI?>
else it
}
val (dri, overridenBy) = originalDescriptor.createDRI()
val inheritedFrom = dri.copy(callable = null).takeIf { parent.dri.classNames != dri.classNames }
val descriptor = originalDescriptor.getConcreteDescriptor()
val isExpect = descriptor.isExpect
val isActual = descriptor.isActual
Expand Down Expand Up @@ -471,7 +469,7 @@ private class DokkaDescriptorVisitor(
(descriptor.getAnnotationsWithBackingField() + descriptor.fileLevelAnnotations()).toSourceSetDependent()
.toAnnotations(),
descriptor.getDefaultValue()?.let { DefaultValue(it) },
InheritedMember(inheritedFrom.toSourceSetDependent()),
inheritedFrom?.let { InheritedMember(it.toSourceSetDependent()) },
)
)
)
Expand All @@ -488,10 +486,8 @@ private class DokkaDescriptorVisitor(
originalDescriptor: FunctionDescriptor,
parent: DRIWithPlatformInfo
): DFunction {
val (dri, inheritedFrom) = originalDescriptor.createDRI().let {
if (it.second != null) (it.second to it.first) as Pair<DRI, DRI?>
else it
}
val (dri, _) = originalDescriptor.createDRI()
val inheritedFrom = dri.copy(callable = null).takeIf { parent.dri.classNames != dri.classNames }
val descriptor = originalDescriptor.getConcreteDescriptor()
val isExpect = descriptor.isExpect
val isActual = descriptor.isActual
Expand Down Expand Up @@ -521,7 +517,7 @@ private class DokkaDescriptorVisitor(
sourceSets = setOf(sourceSet),
isExpectActual = (isExpect || isActual),
extra = PropertyContainer.withAll(
InheritedMember(inheritedFrom.toSourceSetDependent()),
inheritedFrom?.let { InheritedMember(it.toSourceSetDependent()) },
descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(),
(descriptor.getAnnotations() + descriptor.fileLevelAnnotations()).toSourceSetDependent()
.toAnnotations(),
Expand Down Expand Up @@ -601,10 +597,9 @@ private class DokkaDescriptorVisitor(
descriptor: PropertyAccessorDescriptor,
propertyDescriptor: PropertyDescriptor,
parent: DRI,
parentInheritedFrom: DRI? = null
inheritedFrom: DRI? = null
): DFunction {
val dri = parent.copy(callable = Callable.from(descriptor))
val inheritedFrom = parentInheritedFrom?.copy(callable = Callable.from(descriptor))
val isGetter = descriptor is PropertyGetterDescriptor
val isExpect = descriptor.isExpect
val isActual = descriptor.isActual
Expand Down Expand Up @@ -689,7 +684,7 @@ private class DokkaDescriptorVisitor(
extra = PropertyContainer.withAll(
descriptor.additionalExtras().toSourceSetDependent().toAdditionalModifiers(),
descriptor.getAnnotations().toSourceSetDependent().toAnnotations(),
InheritedMember(inheritedFrom.toSourceSetDependent())
inheritedFrom?.let { InheritedMember(it.toSourceSetDependent()) }
)
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -438,7 +438,7 @@ class DefaultPsiToDocumentableTranslator(
false,
psi.additionalExtras().let {
PropertyContainer.withAll(
InheritedMember(inheritedFrom.toSourceSetDependent()),
inheritedFrom?.let { InheritedMember(it.toSourceSetDependent()) },
it.toSourceSetDependent().toAdditionalModifiers(),
(psi.annotations.toList()
.toListOfAnnotations() + it.toListOfAnnotations()).toSourceSetDependent()
Expand Down Expand Up @@ -635,7 +635,7 @@ class DefaultPsiToDocumentableTranslator(
false,
psi.additionalExtras().let {
PropertyContainer.withAll(
InheritedMember(inheritedFrom.toSourceSetDependent()),
inheritedFrom?.let { InheritedMember(it.toSourceSetDependent()) },
it.toSourceSetDependent().toAdditionalModifiers(),
(psi.annotations.toList().toListOfAnnotations() +
it.toListOfAnnotations() +
Expand Down

0 comments on commit a97934e

Please sign in to comment.