aboutsummaryrefslogtreecommitdiff
path: root/plugins/base/src/main/kotlin/transformers/documentables
diff options
context:
space:
mode:
authorAndrzej Ratajczak <andrzej.ratajczak98@gmail.com>2020-04-15 14:21:53 +0200
committerPaweł Marks <Kordyjan@users.noreply.github.com>2020-04-23 13:30:00 +0200
commitf55620e397aa4db4c208996d1662f610cad58db5 (patch)
treedfa6f33348e53e4e29553196386d438ffe604cae /plugins/base/src/main/kotlin/transformers/documentables
parentdf980fe67ba49b959163ae96c54711550368d153 (diff)
downloaddokka-f55620e397aa4db4c208996d1662f610cad58db5.tar.gz
dokka-f55620e397aa4db4c208996d1662f610cad58db5.tar.bz2
dokka-f55620e397aa4db4c208996d1662f610cad58db5.zip
Fix inheritors transformer
Diffstat (limited to 'plugins/base/src/main/kotlin/transformers/documentables')
-rw-r--r--plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt34
1 files changed, 24 insertions, 10 deletions
diff --git a/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt b/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt
index 8c014a29..9cc09d89 100644
--- a/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt
+++ b/plugins/base/src/main/kotlin/transformers/documentables/InheritorsExtractorTransformer.kt
@@ -17,21 +17,35 @@ class InheritorsExtractorTransformer : DocumentableTransformer {
when (this) {
is DModule -> copy(packages = packages.map { it.appendInheritors(inheritanceMap) as DPackage })
is DPackage -> copy(classlikes = classlikes.map { it.appendInheritors(inheritanceMap) as DClasslike })
- is DClass -> copy(
- extra = extra + info,
- classlikes = classlikes.map { it.appendInheritors(inheritanceMap) as DClasslike })
- is DEnum -> copy(
- extra = extra + info,
- classlikes = classlikes.map { it.appendInheritors(inheritanceMap) as DClasslike })
- is DInterface -> copy(
- extra = extra + info,
- classlikes = classlikes.map { it.appendInheritors(inheritanceMap) as DClasslike })
+ is DClass -> if (info.isNotEmpty()) {
+ copy(
+ extra = extra + info,
+ classlikes = classlikes.map { it.appendInheritors(inheritanceMap) as DClasslike })
+ } else {
+ copy(classlikes = classlikes.map { it.appendInheritors(inheritanceMap) as DClasslike })
+ }
+ is DEnum -> if (info.isNotEmpty()) {
+ copy(
+ extra = extra + info,
+ classlikes = classlikes.map { it.appendInheritors(inheritanceMap) as DClasslike })
+ } else {
+ copy(classlikes = classlikes.map { it.appendInheritors(inheritanceMap) as DClasslike })
+ }
+ is DInterface -> if (info.isNotEmpty()) {
+ copy(
+ extra = extra + info,
+ classlikes = classlikes.map { it.appendInheritors(inheritanceMap) as DClasslike })
+ } else {
+ copy(classlikes = classlikes.map { it.appendInheritors(inheritanceMap) as DClasslike })
+ }
is DObject -> copy(classlikes = classlikes.map { it.appendInheritors(inheritanceMap) as DClasslike })
is DAnnotation -> copy(classlikes = classlikes.map { it.appendInheritors(inheritanceMap) as DClasslike })
else -> this
}
}
+ private fun InheritorsInfo.isNotEmpty() = this.value.allValues.fold(0) { acc, list -> acc + list.size } > 0
+
private fun Map<PlatformData, Map<DRI, List<DRI>>>.getForDRI(dri: DRI) =
PlatformDependent(map { (v, k) ->
v to k[dri]
@@ -42,7 +56,7 @@ class InheritorsExtractorTransformer : DocumentableTransformer {
.map { (k, v) ->
k to v.flatMap { p -> p.groupBy({ it.first }) { it.second }.toList() }
.groupBy({ it.first }) { it.second }.map { (k2, v2) -> k2 to v2.flatten() }.toMap()
- }.filter{ it.second.values.isEmpty() }.toMap()
+ }.filter { it.second.values.isNotEmpty() }.toMap()
private fun <T : Documentable> T.getInheritanceEntriesRec(): List<Pair<PlatformData, List<Pair<DRI, DRI>>>> =
this.toInheritanceEntries() + children.flatMap { it.getInheritanceEntriesRec() }