Function: php-ts-mode--array-element-heuristic

php-ts-mode--array-element-heuristic is a byte-compiled function defined in php-ts-mode.el.gz.

Signature

(php-ts-mode--array-element-heuristic NODE PARENT BOL &rest _)

Documentation

Return of the position of the first element of the array.

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
(defun php-ts-mode--array-element-heuristic (_node parent _bol &rest _)
  "Return of the position of the first element of the array.

PARENT is NODE's parent, BOL is the beginning of non-whitespace
characters of the current line."
  (let ((parent-start
         (treesit-node-start parent))
        (parent-first-child-start
         (treesit-node-start (treesit-node-child parent 2))))
    (if (equal
         (line-number-at-pos parent-start)
         (line-number-at-pos parent-first-child-start))
        ;; if array_creation_expression and the first
        ;; array_element_initializer are on the same same line
        parent-first-child-start
      ;; else return parent-bol plus the offset
      (save-excursion
        (goto-char (treesit-node-start parent))
        (back-to-indentation)
        (+ (point) php-ts-mode-indent-offset)))))