MCPcopy Index your code
hub / github.com/FSoft-AI4Code/CodeText-parser / get_node_text

Function get_node_text

src/codetext/parser/language_parser.py:143–156  ·  view source on GitHub ↗

Get text of a tree-sitter Node. Can be use to replace `match_from_span`. Args: root (tree_sitter.Node): Tree sitter node to get text Return: str: text of `root`

(root: tree_sitter.Node)

Source from the content-addressed store, hash-verified

141
142
143def get_node_text(root: tree_sitter.Node) -> str:
144 """
145 Get text of a tree-sitter Node. Can be use to replace `match_from_span`.
146
147 Args:
148 root (tree_sitter.Node): Tree sitter node to get text
149
150 Return:
151 str: text of `root`
152 """
153 assert type(root) == tree_sitter.Node, f"Expect `root` to be `tree_sitter.Node`, get {type(root)}"
154
155 text = root.text.decode()
156 return text
157
158
159def match_from_span(node, blob: str) -> str:

Callers 15

parse_fileFunction · 0.85
get_docstringMethod · 0.85
get_function_metadataMethod · 0.85
get_class_metadataMethod · 0.85
get_docstringMethod · 0.85
get_class_metadataMethod · 0.85
get_function_metadataMethod · 0.85
get_docstringMethod · 0.85
get_function_metadataMethod · 0.85
get_class_metadataMethod · 0.85
get_docstringMethod · 0.85
get_function_metadataMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected