-
Notifications
You must be signed in to change notification settings - Fork 59
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
C struct members and enum values are not shown on type hover #959
Comments
(transferred as this isn't editor specific) We don't show bodies of classes/enums/functions etc by policy, because they are often/usually large and it's hard to draw the line. It's unlikely we'd change this I think. The Possible alternatives:
What do you think of these? |
Alright, yes they can get quite large, so that sounds like a reasonable policy. Although, the difference from eg. functions, is that functions have their parameters in the hover information, both as part of the source code line, and in a formatted text above, potentially with more description from comments. So I guess that would be an argument for creating a formatted list of members or something like that for structs. But like you say, that could be very long, but should be smaller than the actual body of the struct source code, since that will likely contain eg. comments. Yes, the So I would probably in that case go for no Also, it's weird that structs have the newline in between the curly braces, but the enum does not. |
I wrote a patch that modifies clangd's behaviour to print public struct fields and enum members in hovers: llvm/llvm-project#89557. I think limiting the patch to these cases (as opposed to e.g. printing all class members including methods, printing function bodies etc.) should address at least part of the concern about length. Granted, there are also enums with many members and structs with many public fields, and the patch will result in long hover contents for these, but on the whole I think would be an acceptable tradeoff: long hovers aren't a terrible user experience (they just become scrollable), and in the more common case of structs/enums with a few members, being able to see the members at a glance is quite useful. |
I have noticed in my project that if I hover on a struct type, it does give me some information on the struct definition, but only the name of the struct. I would really like it if the hover would show the definition of the members of the struct. The same goes for enums, the hover only shows the name, not the named possible values.
Current hover of a struct (in this case I am hovering over the
update_counter
part of the variable declaration):When I use the variable later I do get suggestions when doing
my_variable.something
, and go to definition also work as expected.Similarily for enums, go to definition works, and
my_enum = ...
gives me good suggestions:Is this information available in the hover response, but is a conscious decision to not show this? Or is it VS Code not allowing it? Or is it not part of the hover response?
Clangd version: Ubuntu clangd version 12.0.0-3ubuntu1~20.04.4
VS Code version: 1.63.2
VS Code clangd extension version: v0.1.13
The text was updated successfully, but these errors were encountered: