This commit is contained in:
Leonid Pereverzin 2023-05-07 16:06:26 +03:00
parent 4f9fba5237
commit ffaa932127
2 changed files with 21 additions and 4 deletions

View File

@ -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) {

View File

@ -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<MdAstElement> = 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<MdAstElement> = parent.children.toMutableList()
val index = parent.children.indexOf(dependentNode)
elements.removeAt(index)
elements.addAll(index, childs)
parent.children = elements
}
}
// parent - List<MdAstElement> --------------------------------------
// | \
// | \
// \ \
// | \
// | \
// dependentNode - MdAstElement \
// |
// List<FileName> -> List<MdAstRoot> --> List<List<MdAstElement>> ===> List<MdAstElement>
/**
* Whole dependency graph.
*