You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/emacs-tree-sitter.org
+12-11Lines changed: 12 additions & 11 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -630,26 +630,27 @@ These functions are high-level APIs that allow traversing the syntax tree in dep
630
630
631
631
When dealing with a large number of nodes, working with node objects creates a huge pressure on the garbage collector. For better performance, it's advisable to extract and work with individual node properties.
632
632
633
-
- ~tsc-do-tree~ /~(vars tree-or-node) body~/ :: Evaluate ~body~ with ~vars~ bound to corresponding properties of each traversed node.
633
+
- ~tsc-traverse-do~ /~(vars tree-or-node) body~/ :: Evaluate ~body~ with ~vars~ bound to corresponding properties of each traversed node.
634
634
#+begin_src emacs-lisp
635
-
(tsc-do-tree ([type depth named-p] tree)
635
+
(tsc-traverse-do ([type depth named-p] tree)
636
636
(when named-p ;AST
637
637
(insert (make-string depth \? ) ;indentation
638
638
(format "%S" type) "\n")))
639
639
#+end_src
640
-
- ~tsc-traverse-depth-first-native~ /~tree-or-node fn [props]~/ :: Call ~fn~ for each traversed node, passing the node as the argument. If the vector of keywords ~props~ is specified, ~fn~ receives a vector containing the node's properties instead. *Do not keep a reference to the vector*, as it is reused across invocations. Use ~pcase-let~ to extract the properties.
640
+
- ~tsc-traverse-mapc~ /~func tree-or-node [props]~/ :: Call ~func~ for each traversed node, passing the node as the argument. If the vector of keywords ~props~ is specified, ~func~ receives a vector containing the node's properties instead. *Do not keep a reference to the vector*, as it is reused across invocations. Use ~pcase-let~ to extract the properties.
641
641
#+begin_src emacs-lisp
642
-
(tsc-traverse-depth-first-native
643
-
tree (lambda (props)
644
-
(pcase-let ((`[,type ,depth ,named-p] props))
645
-
(when named-p ;AST
646
-
(insert (make-string depth \? ) ;indentation
647
-
(format "%S" type) "\n"))))
642
+
(tsc-traverse-mapc
643
+
(lambda (props)
644
+
(pcase-let ((`[,type ,depth ,named-p] props))
645
+
(when named-p ;AST
646
+
(insert (make-string depth \? ) ;indentation
647
+
(format "%S" type) "\n"))))
648
+
tree
648
649
[:type :depth :named-p])
649
650
#+end_src
650
-
- ~tsc-traverse-depth-first-iterator~ /~tree-or-node [props]~/ :: Create an iterator that yields traversed nodes. If the vector of keywords ~props~ is specified, the iterator yields a vector containing the node's properties instead. *Do not keep a reference to the vector*, as it is reused across iterations. Use ~pcase-let~ to extract the properties.
651
+
- ~tsc-traverse-iter~ /~tree-or-node [props]~/ :: Create an iterator that yields traversed nodes. If the vector of keywords ~props~ is specified, the iterator yields a vector containing the node's properties instead. *Do not keep a reference to the vector*, as it is reused across iterations. Use ~pcase-let~ to extract the properties.
0 commit comments