The function child_by_field_name() needs the field name for a node, but this name is very hard to find.
Example:
parser = Parser(CPP_LANGUAGE)
tree = parser.parse(b"void test();")
root = tree.root_node
print(f'{str(root)=}')
node = root.child(0)
# Node is named, but how to get the name?
print(f'{node.type=}, {node.is_named=}, {node.id=}, {node.kind_id=}, {str(node)=}')
The function
child_by_field_name()
needs the field name for a node, but this name is very hard to find.Example:
All these options do not work:
Is there an option I am missing? Would it make sense to add a
name
field to a node?