|
From: | Dmitry Gutov |
Subject: | Re: Adding support for xref jumping to headers/interfaces |
Date: | Sun, 5 Nov 2023 00:43:49 +0200 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.13.0 |
On 23/06/2023 18:03, João Távora wrote:
2. if we're willing to add another level of hierarchy to the current*xref* buffer and segregate results by file and category instead of just by file as is done currently. Or make this configurable so the user can segregate just by category. Or present the category as a tag. Many ways to skin this cat.
Adding multiple levels of grouping is definitely an option. I'm not sure it's ideal, though (usability issues like +1 extra level of indentation, and if there are enough elements in a group, you scroll down and don't see the group's heading anymore unless you make it "sticky").
Note that actually Elisp's find-definitions output is already "annotated" with categories: the first symbol in the summary (defun/defvar/defface/cl-defmethod) unambiguously denotes the definition type. I wonder how often that is the case with the other backends.
Maybe Xref backends for C/C++ (etags/clang/lsp) just show the line where the definition resides, which depending on the style might or might not include the beginning of the definition. I think for those langs, the main cases where there would be multiples definitions, is in the case of inheritance (also in Java), and it would either should the definition in a superclass, or definitions in subclasses with overrides. In Java, at least, those would be usually disambiguated by the file name (conventionally, they correspond to class names more or less 1-to-1).
All that aside, a "sufficiently smart" backends for any of those languages would be able to render the Xref summary string in any fashion they want (for definitions, the summary doesn't need to copy any physical line). E.g. prepending "@override " for overrides. Not sure how realistic that is for LSP, but something more rough could likely be done. E.g. specific words attenuated with color prepended to the summary for the "special" definitions. [type] <typeDefinition Xref's summary>. Something to try out, anyway, if
[Prev in Thread] | Current Thread | [Next in Thread] |