Function: treesit-parser-range-on

treesit-parser-range-on is a byte-compiled function defined in treesit.el.gz.

Signature

(treesit-parser-range-on PARSER BEG &optional END)

Documentation

Check if PARSER's range covers the portion between BEG and END.

If it does, return the range covering that portion in the form of (RANGE-BEG . RANGE-END), if not, return nil. If nil or omitted, default END to BEG.

Source Code

;; Defined in /usr/src/emacs/lisp/treesit.el.gz
(defun treesit-parser-range-on (parser beg &optional end)
  "Check if PARSER's range covers the portion between BEG and END.

If it does, return the range covering that portion in the form
of (RANGE-BEG . RANGE-END), if not, return nil.  If nil or
omitted, default END to BEG."
  (let ((ranges (treesit-parser-included-ranges parser))
        (end (or end beg)))
    (if (null ranges)
        (cons (point-min) (point-max))
      (cl-loop for rng in ranges
               if (<= (car rng) beg end (cdr rng))
               return rng
               finally return nil))))