Function: php-ts-mode--anchor-prev-sibling

php-ts-mode--anchor-prev-sibling is a byte-compiled function defined in php-ts-mode.el.gz.

Signature

(php-ts-mode--anchor-prev-sibling NODE PARENT BOL &rest _)

Documentation

Return the start of the previous named sibling of NODE.

Return nil if a) there is no prev-sibling, or b) prev-sibling doesn't have a child.

PARENT is NODE's parent, BOL is the beginning of non-whitespace characters of the current line.

Source Code

;; Defined in /usr/src/emacs/lisp/progmodes/php-ts-mode.el.gz
;; adapted from c-ts-mode--anchor-prev-sibling
(defun php-ts-mode--anchor-prev-sibling (node parent bol &rest _)
  "Return the start of the previous named sibling of NODE.

Return nil if a) there is no prev-sibling, or b) prev-sibling
doesn't have a child.

PARENT is NODE's parent, BOL is the beginning of non-whitespace
characters of the current line."
  (when-let* ((prev-sibling
	       (or (treesit-node-prev-sibling node t)
		   (treesit-node-prev-sibling
		    (treesit-node-first-child-for-pos parent bol) t)
		   (treesit-node-child parent -1 t)))
	      (continue t))
    (save-excursion
      (while (and prev-sibling continue)
	(goto-char (treesit-node-start prev-sibling))
	(if (looking-back (rx bol (* whitespace))
			  (line-beginning-position))
	    (setq continue nil)
	  (setq prev-sibling
		(treesit-node-prev-sibling prev-sibling)))))
    (treesit-node-start prev-sibling)))