From 9a1434d583b931671e2c5e9c5275af725938d503 Mon Sep 17 00:00:00 2001 From: Andrzej Ratajczak <32793002+BarkingBad@users.noreply.github.com> Date: Thu, 17 Feb 2022 16:27:28 +0100 Subject: Refactor Ancestry Graphs (#2326) --- core/src/main/kotlin/model/additionalExtras.kt | 2 +- core/src/main/kotlin/model/ancestryNode.kt | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 core/src/main/kotlin/model/ancestryNode.kt (limited to 'core/src') diff --git a/core/src/main/kotlin/model/additionalExtras.kt b/core/src/main/kotlin/model/additionalExtras.kt index bc9135dd..d708d137 100644 --- a/core/src/main/kotlin/model/additionalExtras.kt +++ b/core/src/main/kotlin/model/additionalExtras.kt @@ -123,4 +123,4 @@ data class ConstructorValues(val values: SourceSetDependent>) : } override val key: ExtraProperty.Key = ConstructorValues -} \ No newline at end of file +} 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, +) { + fun allImplementedInterfaces(): List { + fun traverseInterfaces(ancestry: AncestryNode): List = + ancestry.interfaces.flatMap { listOf(it.typeConstructor) + traverseInterfaces(it) } + + (ancestry.superclass?.let(::traverseInterfaces) ?: emptyList()) + return traverseInterfaces(this).distinct() + } +} -- cgit