From ffaa932127e2398c5cb050121f4f84f707e52af6 Mon Sep 17 00:00:00 2001 From: Leonid Pereverzin Date: Sun, 7 May 2023 16:06:26 +0300 Subject: [PATCH] CE fix --- .../src/main/kotlin/Build.kt | 4 ++-- .../src/main/kotlin/DependencyGraph.kt | 21 +++++++++++++++++-- 2 files changed, 21 insertions(+), 4 deletions(-) diff --git a/snark-document-builder/src/main/kotlin/Build.kt b/snark-document-builder/src/main/kotlin/Build.kt index aff99f6..b6a5ac8 100644 --- a/snark-document-builder/src/main/kotlin/Build.kt +++ b/snark-document-builder/src/main/kotlin/Build.kt @@ -1,6 +1,6 @@ package documentBuilder -public class GraphManager(private val graph: DependencyGraph) { +public class GraphManager(public val graph: DependencyGraph) { fun buildDocument(file: FileName) { val list = graph.nodes[file] if (list != null) { @@ -14,4 +14,4 @@ public class GraphManager(private val graph: DependencyGraph) { buildDocument(file) return graph.nodes[file]!!.mdAst } -} +} \ No newline at end of file diff --git a/snark-document-builder/src/main/kotlin/DependencyGraph.kt b/snark-document-builder/src/main/kotlin/DependencyGraph.kt index 864838a..0737713 100644 --- a/snark-document-builder/src/main/kotlin/DependencyGraph.kt +++ b/snark-document-builder/src/main/kotlin/DependencyGraph.kt @@ -1,6 +1,8 @@ package documentBuilder import kotlinx.coroutines.coroutineScope +import kotlin.collections.MutableList + public typealias FileName = String @@ -38,14 +40,29 @@ public data class IncludeDependency( ) : DependencyGraphEdge { override fun visit(graphManager: GraphManager) { val parent = parentNode + val childs: MutableList = mutableListOf() for (file in includeList) { graphManager.buildDocument(file) - parent.children.add(graphManager.graph.nodes[file].mdAst) + childs.addAll(graphManager.graph.nodes[file]!!.mdAst.children) } - dependentNode = parent + val elements: MutableList = parent.children.toMutableList() + val index = parent.children.indexOf(dependentNode) + elements.removeAt(index) + elements.addAll(index, childs) + parent.children = elements } } +// parent - List -------------------------------------- +// | \ +// | \ +// \ \ +// | \ +// | \ +// dependentNode - MdAstElement \ +// | +// List -> List --> List> ===> List + /** * Whole dependency graph. *