fillDependencies is implemented
This commit is contained in:
parent
cd85fcf329
commit
225b7346a8
@ -27,7 +27,7 @@ private suspend fun buildNodes(folder: Directory, nodes: HashMap<FileName, Depen
|
||||
assert(!nodes.containsKey(pathString))
|
||||
|
||||
val rootDcoument = folder.get(DEFAULT_DOCUMENT_ROOT)
|
||||
nodes.put(pathString, buildDependencyGraphNode(rootDcoument.readAll()))
|
||||
nodes.put(pathString, buildDependencyGraphNode(rootDcoument.readAll(), folder.path))
|
||||
|
||||
val dependencies = getDependencies(nodes.getValue(pathString))
|
||||
|
||||
|
@ -2,6 +2,7 @@ package documentBuilder
|
||||
|
||||
import com.fasterxml.jackson.module.kotlin.jacksonObjectMapper
|
||||
import com.fasterxml.jackson.module.kotlin.readValue
|
||||
import java.nio.file.Path
|
||||
|
||||
private val MARKDOWN_PARSER = "../nodejs/MarkdownParser.js"
|
||||
|
||||
@ -13,30 +14,39 @@ public suspend fun parseMd(mdFile: ByteArray): MdAstRoot {
|
||||
.start().inputStream.bufferedReader().readText())
|
||||
}
|
||||
|
||||
public suspend fun buildDependencyGraphNode(mdFile: ByteArray): DependencyGraphNode {
|
||||
public suspend fun buildDependencyGraphNode(mdFile: ByteArray, path: Path): DependencyGraphNode {
|
||||
val treeRoot = parseMd(mdFile)
|
||||
val dependencies = mutableListOf<DependencyGraphEdge>()
|
||||
|
||||
fillDependencies(treeRoot, dependencies)
|
||||
fillDependencies(treeRoot, dependencies, path)
|
||||
|
||||
return DependencyGraphNode(treeRoot, dependencies)
|
||||
}
|
||||
|
||||
private suspend fun fillDependencies(
|
||||
internal suspend fun fillDependencies(
|
||||
currentNode: MdAstElement,
|
||||
dependencies: MutableList<DependencyGraphEdge>) {
|
||||
// when (currentNode) {
|
||||
// is MdAstParent -> {
|
||||
// val iterator = currentNode.children.listIterator()
|
||||
dependencies: MutableList<DependencyGraphEdge>,
|
||||
path: Path) {
|
||||
when (currentNode) {
|
||||
is MdAstParent -> {
|
||||
for (child in currentNode.children) {
|
||||
if (child is MdAstText) {
|
||||
val includeList = getIncludeFiles(child.value).toMutableList()
|
||||
|
||||
// while (iterator.hasNext()) {
|
||||
if (includeList.size > 0) {
|
||||
includeList.replaceAll { path.toString() + "/" + it }
|
||||
|
||||
dependencies += IncludeDependency(currentNode, child, includeList)
|
||||
}
|
||||
} else {
|
||||
fillDependencies(child, dependencies, path)
|
||||
}
|
||||
}
|
||||
}
|
||||
else -> {}
|
||||
}
|
||||
}
|
||||
|
||||
// iterator.next()
|
||||
// }
|
||||
|
||||
// }
|
||||
// else -> {}
|
||||
// }
|
||||
public suspend fun getIncludeFiles(string: String): List<FileName> {
|
||||
TODO()
|
||||
}
|
Loading…
Reference in New Issue
Block a user