Function: ruby-ts--parent-call-or-bol
ruby-ts--parent-call-or-bol is a byte-compiled function defined in
ruby-ts-mode.el.gz.
Signature
(ruby-ts--parent-call-or-bol NOT PARENT BOL &rest _)
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/ruby-ts-mode.el.gz
(defun ruby-ts--parent-call-or-bol (_not parent _bol &rest _)
(let* ((parent-bol (save-excursion
(goto-char (treesit-node-start parent))
(back-to-indentation)
(point)))
(found
(treesit-parent-until
parent
(lambda (node)
(or (< (treesit-node-start node) parent-bol)
(string-match-p "\\`array\\|hash\\'" (treesit-node-type node))
;; Method call on same line.
(equal (treesit-node-type node) "argument_list"))))))
(cond
((null found)
parent-bol)
;; No paren/curly/brace found on the same line.
((< (treesit-node-start found) parent-bol)
parent-bol)
;; Nesting of brackets args.
((and
(not (eq ruby-bracketed-args-indent t))
(string-match-p "\\`array\\|hash\\'" (treesit-node-type parent))
(or (equal (treesit-node-parent parent) found)
;; When the array/hash is part of a pair (keyword argument),
;; check if the pair's parent is the found node.
(and (equal (treesit-node-type (treesit-node-parent parent)) "pair")
(equal (treesit-node-parent (treesit-node-parent parent)) found)))
;; Grandparent is not a parenless call.
(or (not (equal (treesit-node-type found) "argument_list"))
(equal (treesit-node-type (treesit-node-child found 0))
"(")))
parent-bol)
;; Hash or array opener on the same line.
((string-match-p "\\`array\\|hash\\'" (treesit-node-type found))
(save-excursion
(goto-char (treesit-node-start (treesit-node-child found 1)))
(point)))
;; Parenless call found: indent to stmt with offset.
((not ruby-parenless-call-arguments-indent)
(save-excursion
(goto-char (treesit-node-start
(ruby-ts--statement-ancestor found)))
;; (**) Same.
(+ (point) ruby-indent-level)))
;; Call with parens -- ident to first arg.
((equal (treesit-node-type (treesit-node-child found 0))
"(")
(save-excursion
(goto-char (treesit-node-start (treesit-node-child found 1)))
(point)))
;; Indent to the parenless call args beginning.
(t
(save-excursion
(goto-char (treesit-node-start found))
(point))))))