MCPcopy Create free account
hub / github.com/FSoft-AI4Code/CodeText-parser / node_parent

Function node_parent

src/codetext/parser/language_parser.py:91–100  ·  view source on GitHub ↗
(tree, node)

Source from the content-addressed store, hash-verified

89
90
91def node_parent(tree, node):
92 to_visit = [tree.root_node]
93 while len(to_visit) > 0:
94 next_node = to_visit.pop()
95 for child in next_node.children:
96 if nodes_are_equal(child, node):
97 return next_node
98 else:
99 to_visit.extend(next_node.children)
100 raise ValueError("Could not find node in tree.")
101
102
103def traverse(node, results: List) -> None:

Callers 1

Calls 1

nodes_are_equalFunction · 0.85

Tested by

no test coverage detected