Function: js--parse-state-at-point

js--parse-state-at-point is a byte-compiled function defined in js.el.gz.

Signature

(js--parse-state-at-point)

Documentation

Parse the JavaScript program state at point.

Return a list of js--pitem instances that apply to point, most specific first. In the worst case, the current toplevel instance will be returned.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/js.el.gz
(defun js--parse-state-at-point ()
  "Parse the JavaScript program state at point.
Return a list of `js--pitem' instances that apply to point, most
specific first.  In the worst case, the current toplevel instance
will be returned."
  (save-excursion
    (save-restriction
      (widen)
      (js--ensure-cache)
      (let ((pstate (or (save-excursion
                          (js--backward-pstate))
                        (list js--initial-pitem))))

        ;; Loop until we either hit a pitem at BOB or pitem ends after
        ;; point (or at point if we're at eob)
        (cl-loop for pitem = (car pstate)
                 until (or (eq (js--pitem-type pitem)
                               'toplevel)
                           (js--inside-pitem-p pitem))
                 do (pop pstate))

        pstate))))