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)
| 141 | |
| 142 | |
| 143 | def 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 | |
| 159 | def match_from_span(node, blob: str) -> str: |
no outgoing calls
no test coverage detected