-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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
x/tools/gopls: Display struct methods #54008
Comments
We discussed this offline and agree that the option 1 is reasonable. Relevant code location: For people who love more concise hover docs, I think this should be controlled by an option but I will leave @findleyr for the guide. |
Change https://go.dev/cl/420714 mentions this issue: |
/assign |
Thanks @brianpursley. I commented on your CL, but I think we should use the type-checker to compute the method set for us, rather than trying to resolve it ourselves (resolving a method set is a surprisingly difficult task!).
You can get the type by looking it up in Other questions to answer:
|
Thanks @findleyr . I had some "issues" with my PR, but will work through them and have a better one soon 😅 Thanks for the advice too, I am new to the go/tools codebase, so it will be helpful to get my bearings and much appreciated. I'll consider your points and see what can be done for each of them. Regarding appearance, I was thinking to include the receiver, in case you want to know whether it is For what its worth, Goland does it like this:
My first thought was to just include the whole signature, but I don't feel too strongly in either direction though. I'll un-abandon my PR and mark it WIP until I can get it to a better place. |
Cool! This is a great place to contribute as the change is mostly isolated to hover.go (though our hover handling is a bit hard to follow). Something like what you propose looks good to me. IIRC if we use |
Another thought: it would be nice to link to the method locations using file:// links. Does not need to be done in the first pass though. |
I dont see this feature in action. Am i missing something? @MathiasHandle |
@ashu12318 This is in gopls/v0.10.0 milestone and gopls v0.10.0 isn't yet released.
|
@brianpursley Thanks for your working. BTW, I'd like to know why the hover does not show all methods (included those that are added via embedding). I think it will helpful to know the all available methods. |
Hmm, we could do that. I think we were being conservative about the amount of screen space used by hover. But now that I reconsider the question, I agree that showing all methods would be better. (I feel like I may have been the one to suggest concrete methods only, in which case it is my bad). |
Opened #61634. |
Is your feature request related to a problem? Please describe.
I have difficulties finding all available methods for given struct, hence this request.
Describe the solution you'd like
When on hover on struct I'd like to display all methods belonging to that struct.
This should work across files. As currently the outline view displays only types defined in currently opened file.
There are 2 solutions that come to my mind:
1) Display methods in hover docs (preferred solution)
2) Sort methods in outline view
Currently the outline view can be sorted by
1.) position
2.) Name
3.) Category
But the methods aren't visually assigned to struct they belong to.
![outline](https://user-images.githubusercontent.com/66034586/179404012-bbd5c04b-25e0-4d7e-af16-1f2ef91c02f5.png)
Additional context
These proposed changes don't make sense in this simple example, but in real project with a lot of types, methods, packages, etc.. it would make better & cleaner code navigation.
The text was updated successfully, but these errors were encountered: