mirror of
git://git.sv.gnu.org/emacs.git
synced 2025-12-15 10:30:25 -08:00
ruby-ts-mode: Fix/simplify Imenu index generation
* lisp/progmodes/ruby-ts-mode.el (ruby-ts--full-name): Drop '#' from the end of resulting string when the node is not a method. Support 'singleton_method' nodes. (ruby-ts--imenu-helper): Simplify, to create a "flat" list of entries, rather than a nested one. The previous implementation had problems (like producing a nested structure of full-qualified names, thus creating a lot of textual repetition), seems easier to just follow ruby-mode's example here, at least for Emacs 29's release. * test/lisp/progmodes/ruby-ts-mode-tests.el (ruby-ts-imenu-index): New test.
This commit is contained in:
parent
a0d5fba74a
commit
cbef1422fe
2 changed files with 47 additions and 24 deletions
|
|
@ -281,6 +281,31 @@ The whitespace before and including \"|\" on each line is removed."
|
|||
(file-truename
|
||||
(expand-file-name (format "ruby-mode-resources/%s" ,file))))))
|
||||
|
||||
(ert-deftest ruby-ts-imenu-index ()
|
||||
(ruby-ts-with-temp-buffer
|
||||
(ruby-ts-test-string
|
||||
"module Foo
|
||||
| class Blub
|
||||
| def hi
|
||||
| 'Hi!'
|
||||
| end
|
||||
|
|
||||
| def bye
|
||||
| 'Bye!'
|
||||
| end
|
||||
|
|
||||
| private def self.hiding
|
||||
| 'You can't see me'
|
||||
| end
|
||||
| end
|
||||
|end")
|
||||
(should (equal (mapcar #'car (ruby-ts--imenu))
|
||||
'("Foo"
|
||||
"Foo::Blub"
|
||||
"Foo::Blub#hi"
|
||||
"Foo::Blub#bye"
|
||||
"Foo::Blub.hiding")))))
|
||||
|
||||
(defmacro ruby-ts-deftest-indent (file)
|
||||
`(ert-deftest ,(intern (format "ruby-ts-indent-test/%s" file)) ()
|
||||
;; :tags '(:expensive-test)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue