py-tree-sitter icon indicating copy to clipboard operation
py-tree-sitter copied to clipboard

How to get some node's name?

Open killa1218 opened this issue 3 years ago • 1 comments

For example if we define field('var_name', $.identifier); in gramma.js. How can I get the name 'var_name' from an identifier node object? There is a property is_named to indicate whether current node has name, but no something like name or get_field_name().

killa1218 avatar Jan 12 '22 05:01 killa1218

If willing to use a cursor, may be the following sort of thing could work?

https://github.com/tree-sitter/py-tree-sitter/blob/b5dfe29b4ead51678bf72c5da47feaa56d4e2be1/tests/test_tree_sitter.py#L370

sogaiu avatar Jan 12 '22 06:01 sogaiu