Function: web-mode-javascript-calls-beginning-position
web-mode-javascript-calls-beginning-position is a natively compiled
function defined in web-mode.el.
Signature
(web-mode-javascript-calls-beginning-position POS &optional REG-BEG)
Source Code
;; Defined in /nix/store/2qgnz1rp30nzfz6w0apx4kdm14if1bbs-emacs-packages-deps/share/emacs/site-lisp/elpa/web-mode-20260831.219/web-mode.el
(defun web-mode-javascript-calls-beginning-position (pos &optional reg-beg)
(unless pos (setq pos (point)))
;;(message "pos=%S" pos)
(let ((char nil)
(dot-pos nil)
(blockside (get-text-property pos 'block-side))
(i 0)
(continue (not (null pos))))
(unless reg-beg
(setq reg-beg (if blockside
(web-mode-block-beginning-position pos)
(web-mode-part-beginning-position pos))))
(while continue
(setq char (char-after pos))
;;(message "%S| %S=%c" reg-beg pos char)
(cond
((> (setq i (1+ i)) 20000)
(message "javascript-calls-beginning-position ** warning (%S) **" pos)
(setq continue nil
pos nil))
((null pos)
(message "javascript-calls-beginning-position ** invalid pos **")
(setq continue nil))
((< pos reg-beg)
(setq continue nil
pos reg-beg))
((and blockside
(member (get-text-property pos 'block-token) '(string comment))
(eq (get-text-property pos 'block-token) (get-text-property (1- pos) 'block-token)))
(setq pos (web-mode-block-token-beginning-position pos)))
((and (not blockside)
(member (get-text-property pos 'part-token) '(string comment))
(eq (get-text-property pos 'part-token) (get-text-property (1- pos) 'part-token)))
(setq pos (web-mode-part-token-beginning-position pos)))
((and (not blockside)
(get-text-property pos 'block-side))
(when (setq pos (web-mode-block-beginning-position pos))
(setq pos (1- pos))))
((and (member char '(?\.)) (> i 1))
(setq dot-pos pos
pos (1- pos)))
((member char '(?\) ?\]))
(when (setq pos (web-mode-part-opening-paren-position pos reg-beg))
(setq pos (1- pos)))
)
((member char '(?\( ?\{ ?\} ?\[ ?\= ?\? ?\: ?\; ?\, ?\& ?\| ?\>))
(web-mode-looking-at ".[ \t\n]*" pos)
(setq pos (+ pos (length (match-string-no-properties 0)))
continue nil))
((web-mode-looking-at "\\(return\\|else\\|const\\)[ \n]" pos)
(setq pos (+ pos (length (match-string-no-properties 0)))
continue nil))
(t
(setq pos (web-mode-rsb-position pos "[\]\[}{)(=?:;,&|>.]\\|\\(return\\|else\\|const\\)" reg-beg))
(when (not pos)
(message "javascript-calls-beginning-position ** search failure **")
(setq pos reg-beg
continue nil))
) ;t
) ;cond
) ;while
;;(message "pos=%S dot-pos=%S" pos dot-pos)
(if (null pos) pos (cons pos dot-pos))
))