diff options
author | Andrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com> | 2022-02-17 16:27:28 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-17 18:27:28 +0300 |
commit | 9a1434d583b931671e2c5e9c5275af725938d503 (patch) | |
tree | d1db2de7c5eb5bde0529c9f8d1a3c47f914fb2af /core/src/main/kotlin/model/ancestryNode.kt | |
parent | 13b87181219f5a96e499c6bda230f6bcd2ed3bc0 (diff) | |
download | dokka-9a1434d583b931671e2c5e9c5275af725938d503.tar.gz dokka-9a1434d583b931671e2c5e9c5275af725938d503.tar.bz2 dokka-9a1434d583b931671e2c5e9c5275af725938d503.zip |
Refactor Ancestry Graphs (#2326)
Diffstat (limited to 'core/src/main/kotlin/model/ancestryNode.kt')
-rw-r--r-- | core/src/main/kotlin/model/ancestryNode.kt | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/core/src/main/kotlin/model/ancestryNode.kt b/core/src/main/kotlin/model/ancestryNode.kt new file mode 100644 index 00000000..5c3c077b --- /dev/null +++ b/core/src/main/kotlin/model/ancestryNode.kt @@ -0,0 +1,14 @@ +package org.jetbrains.dokka.model + +data class AncestryNode( + val typeConstructor: TypeConstructor, + val superclass: AncestryNode?, + val interfaces: List<AncestryNode>, +) { + fun allImplementedInterfaces(): List<TypeConstructor> { + fun traverseInterfaces(ancestry: AncestryNode): List<TypeConstructor> = + ancestry.interfaces.flatMap { listOf(it.typeConstructor) + traverseInterfaces(it) } + + (ancestry.superclass?.let(::traverseInterfaces) ?: emptyList()) + return traverseInterfaces(this).distinct() + } +} |