Function: ruby-ts-add-log-current-function
ruby-ts-add-log-current-function is a byte-compiled function defined
in ruby-ts-mode.el.gz.
Signature
(ruby-ts-add-log-current-function)
Documentation
Return the current method name as a string.
The hash (#) is for instance methods only which are methods
"defined on a class" -- which is 99% of methods. Otherwise, a
dot (.) is used. Double colon (::) is used between classes. The
leading double colon is not added.
Source Code
;; Defined in /usr/src/emacs/lisp/progmodes/ruby-ts-mode.el.gz
(defun ruby-ts-add-log-current-function ()
"Return the current method name as a string.
The hash (#) is for instance methods only which are methods
\"defined on a class\" -- which is 99% of methods. Otherwise, a
dot (.) is used. Double colon (::) is used between classes. The
leading double colon is not added."
(let* ((node (treesit-node-at (point)))
(method-pred
(lambda (node)
(and (<= (treesit-node-start node) (point))
(>= (treesit-node-end node) (point))
(string-match-p ruby-ts--method-regex (treesit-node-type node)))))
(method (treesit-parent-until node method-pred t))
(class (or method node))
(result nil)
(sep "#")
(method-list nil)
(class-list nil)
(method-name nil))
(when method
(setq method-list (ruby-ts--method-name method))
(unless (= 1 (length method-list))
(setq sep ".")))
(while (setq class (treesit-parent-until class
(ruby-ts--type-pred
ruby-ts--class-or-module-regex)))
(setq class-list (append (ruby-ts--class-name class) class-list)))
(setq method-name (car (last method-list))
method-list (butlast method-list))
(when (equal (car method-list) (car (last class-list)))
(setq method-list (cdr method-list)))
(dolist (ele (append class-list method-list))
(cond
((equal "self" ele)
(setq sep "."))
((string-match-p "\\`[^A-Z]" ele) ;not a class
(setq sep "."
result (if result
(concat result "::" ele)
ele)))
(t (setq result (if result
(concat result "::" ele)
ele)))))
(if method-name
(concat result sep method-name)
result)))