Function: combobulate-js-ts-pretty-print
combobulate-js-ts-pretty-print is a natively compiled function defined
in combobulate-js-ts.el.
Signature
(combobulate-js-ts-pretty-print NODE DEFAULT-NAME)
Documentation
Pretty printer for JS and JSX nodes
Source Code
;; Defined in /nix/store/b5fvrwzi3zvkabyzx0in6gw1cj963z46-emacs-packages-deps/share/emacs/site-lisp/combobulate-js-ts.el
(defun combobulate-js-ts-pretty-print (node default-name)
"Pretty printer for JS and JSX nodes"
(cl-flet ((make-tag-text (node &optional before after)
(concat "<" (or before "") (combobulate-node-text node) (or after "") ">"))
(get-name (node) (combobulate-node-child-by-field node "name")))
(pcase (combobulate-node-type node)
;; Turn JSX elements into something resembling an SGML-styled
;; tag as the default name is too generic to be useful.
("jsx_self_closing_element" (make-tag-text (get-name node) nil "/"))
("jsx_opening_element" (make-tag-text (get-name node)))
("jsx_closing_element" (make-tag-text (get-name node) "/"))
("jsx_element" (concat
(make-tag-text
(get-name (combobulate-node-child-by-field node "open_tag")))))
("jsx_attribute" (combobulate-string-truncate
(concat (combobulate-node-text (combobulate-node-child node 0)) "="
(combobulate-node-text (combobulate-node-child node 1)))
40))
("function_declaration" (combobulate-js-ts--get-function-name node))
("lexical_declaration" (combobulate-js-ts--get-declaration-name node))
(_ default-name))))