Function: c-ts-mode--defun-name
c-ts-mode--defun-name is a byte-compiled function defined in
c-ts-mode.el.gz.
Signature
(c-ts-mode--defun-name NODE)
Documentation
Return the name of the defun NODE.
Return nil if NODE is not a defun node or doesn't have a name.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/c-ts-mode.el.gz
;;; Imenu
(defun c-ts-mode--defun-name (node)
"Return the name of the defun NODE.
Return nil if NODE is not a defun node or doesn't have a name."
(treesit-node-text
(pcase (treesit-node-type node)
((or "function_definition" "declaration")
(c-ts-mode--declarator-identifier
(treesit-node-child-by-field-name node "declarator")
t))
((or "struct_specifier" "enum_specifier"
"union_specifier" "class_specifier"
"namespace_definition"
"preproc_def" "preproc_function_def")
(treesit-node-child-by-field-name node "name"))
;; DEFUNs in Emacs sources.
("expression_statement"
(let* ((call-exp-1 (treesit-node-child node 0))
(call-exp-2 (treesit-node-child call-exp-1 0))
(arg-list (treesit-node-child call-exp-2 1))
(name (treesit-node-child arg-list 1 t)))
name)))
t))