Function: treesit--children-covering-range-recurse
treesit--children-covering-range-recurse is a byte-compiled function
defined in treesit.el.gz.
Signature
(treesit--children-covering-range-recurse NODE START END THRESHOLD &optional LIMIT)
Documentation
Return a list of children of NODE covering a range.
Recursively go down the parse tree and collect children, until all nodes in the returned list are smaller than THRESHOLD. The range is between START and END.
LIMIT is the recursion limit, which defaults to 100.
Source Code
;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit--children-covering-range-recurse
(node start end threshold &optional limit)
"Return a list of children of NODE covering a range.
Recursively go down the parse tree and collect children, until
all nodes in the returned list are smaller than THRESHOLD. The
range is between START and END.
LIMIT is the recursion limit, which defaults to 100."
(let* ((child (treesit-node-first-child-for-pos node start))
(limit (or limit 100))
result)
;; If LIMIT is exceeded, we are probably seeing the erroneously
;; tall tree, in that case, just give up.
(while (and (> limit 0) child (<= (treesit-node-start child) end))
;; If child still too large, recurse down. Otherwise collect
;; child.
(if (> (- (treesit-node-end child)
(treesit-node-start child))
threshold)
(dolist (r (treesit--children-covering-range-recurse
child start end threshold (1- limit)))
(push r result))
(push child result))
(setq child (treesit-node-next-sibling child)))
;; If NODE has no child, keep NODE. If LIMIT is exceeded, return
;; nil.
(or result (and (> limit 0) (list node)))))