GNU bug report logs - #70614
Wrong simple imenu definition for java

Previous Next

Package: emacs;

Reported by: Benjamin Leis <benjamin.leis <at> servicenow.com>

Date: Sat, 27 Apr 2024 22:28:01 UTC

Severity: normal

Tags: pending

Full log


Message #8 received at 70614 <at> debbugs.gnu.org (full text, mbox):

From: Yuan Fu <casouri <at> gmail.com>
To: Benjamin Leis <benjamin.leis <at> servicenow.com>
Cc: Theodor Thornhill <theo <at> thornhill.no>, 70614 <at> debbugs.gnu.org
Subject: Re: bug#70614: Wrong simple imenu definition for java
Date: Mon, 29 Apr 2024 22:06:30 -0700

> On Apr 27, 2024, at 11:45 AM, Benjamin Leis via Bug reports for GNU Emacs, the Swiss army knife of text editors <bug-gnu-emacs <at> gnu.org> wrote:
> 
> I noticed the treesitter imenu definitions for java in java-ts-mode.el have the following:
>    ;; Imenu.
>   (setq-local treesit-simple-imenu-settings
>               '(("Class" \\`class_declaration\\' nil nil)
>                 ("Interface" \\`interface_declaration\\' nil nil)
>                 ("Enum" \\`record_declaration\\' nil nil)
>                 ("Method" \\`method_declaration\\' nil nil)))
>   (treesit-major-mode-setup))
>    The 3rd definition for enums should either be for “Record” if that was the intention or match against \\`enum_declaration   if it really was meant for enums.
>  Ben

Thanks for reporting that! Is that you who posted this post on reddit?

https://www.reddit.com/r/emacs/comments/1cej9fr/hierarchical_treesitter_based_imenulist_with_java/

It looks pretty nice, do you want to just put it in Emacs? Also, there’s a chance that your code can be simplified by using treesit-induce-sparse-tree. You can look at treesit-simple-imenu for now it’s used. Basically we use treesit-induce-sparse-tree to find all the interesting nodes in the buffer, and go through the returned tree to convert nodes into imenu labels.

Also CCing Theo; Theo, WDYT?

Yuan



This bug report was last modified 199 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.