ForEachNamedChild iterates over a node's named children in a depth-first manner, calling the supplied function for each node
(fn func(*Node))
| 350 | // ForEachNamedChild iterates over a node's named children in a |
| 351 | // depth-first manner, calling the supplied function for each node |
| 352 | func (n *Node) ForEachNamedChild(fn func(*Node)) { |
| 353 | it := sitter.NewNamedIterator(n.node, sitter.DFSMode) |
| 354 | |
| 355 | it.ForEach(func(sn *sitter.Node) error { |
| 356 | fn(NewNode(sn, n.source)) |
| 357 | return nil |
| 358 | }) |
| 359 | } |
| 360 | |
| 361 | // Format outputs a nicely formatted version of the source code for the |
| 362 | // Node. Formatting is done by https://github.com/ditashi/jsbeautifier-go/ |