SNRK-82: Add code from another repository
This commit is contained in:
parent
14c1e650b9
commit
a13c4a8e8c
17
snark-document-builder/src/main/kotlin/Build.kt
Normal file
17
snark-document-builder/src/main/kotlin/Build.kt
Normal file
@ -0,0 +1,17 @@
|
||||
package documentBuilder
|
||||
|
||||
internal class GraphManager(private val graph: DependencyGraph) {
|
||||
fun buildDocument(file: FileName) {
|
||||
val list = graph.nodes[file]
|
||||
if (list != null) {
|
||||
for (element in list.dependencies) {
|
||||
element.visit(this)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fun getAstRootDocument(file: FileName): MdAstRoot {
|
||||
buildDocument(file)
|
||||
return graph.nodes[file]!!.mdAst
|
||||
}
|
||||
}
|
@ -1,5 +1,7 @@
|
||||
package documentBuilder
|
||||
|
||||
import kotlinx.coroutines.coroutineScope
|
||||
|
||||
public typealias FileName = String
|
||||
|
||||
/**
|
||||
@ -19,6 +21,7 @@ public data class DependencyGraphNode(
|
||||
* Interface of all dependency edges.
|
||||
*/
|
||||
public sealed interface DependencyGraphEdge {
|
||||
public fun visit(graphManager: GraphManager)
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,7 +35,16 @@ public data class IncludeDependency(
|
||||
val parentNode: MdAstParent,
|
||||
val dependentNode: MdAstElement,
|
||||
val includeList: List<FileName>
|
||||
) : DependencyGraphEdge
|
||||
) : DependencyGraphEdge {
|
||||
override fun visit(graphManager: GraphManager) {
|
||||
val parent = parentNode
|
||||
for (file in includeList) {
|
||||
graphManager.buildDocument(file)
|
||||
parent.children.add(graphManager.graph.nodes[file].mdAst)
|
||||
}
|
||||
dependentNode = parent
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whole dependency graph.
|
||||
|
Loading…
Reference in New Issue
Block a user