Function: json-ts--get-path-at-node
json-ts--get-path-at-node is a byte-compiled function defined in
json-ts-mode.el.gz.
Signature
(json-ts--get-path-at-node NODE)
Documentation
Get the path from the root of the JSON tree to NODE.
Return a list of keys (strings) and indices (numbers). NODE is a tree-sitter node.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/json-ts-mode.el.gz
(defun json-ts--get-path-at-node (node)
"Get the path from the root of the JSON tree to NODE.
Return a list of keys (strings) and indices (numbers).
NODE is a tree-sitter node."
(let ((path nil)
(parent nil))
(while (setq parent (treesit-node-parent node))
(let ((type (treesit-node-type parent)))
(cond
((equal type "array")
(push (treesit-node-index node t) path))
((equal type "pair")
(let ((key (treesit-node-child-by-field-name parent "key")))
(push (treesit-node-text key t) path)))))
(setq node parent))
path))