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: add codelens to show number of references to each symbol #40862
Comments
I believe that this feature is supported in GOPATH mode, but is not yet available via the language server. I have been hesitant to add it, since users should just be able to call "Find References" on a symbol to get this information. I would be curious to hear input from others before we move forward with this. |
@stamblerre, i tried following for the GOPATH mode.
i still dont see the codelens. |
The codelens is off by default, so you will need to turn it on explicitly.
But, if you are using the language server, why not use the |
@hyangah , thanks for the help |
@sanket-bhalerao Is your goal to simply check whether the variable or function is used or not (boolean decision), or you use it to really find all the locations they are used? For former, I think we can do better with color or other visualization than with codelens. For latter, maybe we should discuss more. |
@hyangah for variables its the boolean decision (as golang shows unused var as errors this part is already covered) |
@sanket-bhalerao Thanks! I will transfer this to gopls issue tracker. |
Thanks for the feature request, @sanket-bhalerao. I'd like to hear from others about the benefits of this feature. Currently, my preference would be to add the 'unused' checks from staticcheck (#36602), which might make this feature a little redundant. |
references is a quick insight into how many times a function is being called an generally would allow the end click to create a view into where the functions / etc are being used for quick looks. I think this is much more valuable than what is being shown here. And completely different from staticcheck. Just look at elm language server for instance |
This feature is already available by right-clicking an identifier and selecting "Find all references". The code lens would make it easy to tell if a symbol is referenced, which is typically used to see if it is used anywhere in the workspace--much like the staticcheck 'unused' check. |
I guess a workaround to get this feature would just have the client implementation make the request automatically rather than having to click and request them. |
I think we would be open to this feature being added in |
We implemented this feature in our extension, tooltitude. We focus on augmenting gopls with convenience and productivity features. For example on screenshot you could see the usages of Join in the "stirngs" on kubernetes repo. It computed all reference counts in around 500ms on my M1 Max Macbook pro. On smaller files, and projects it's much faster. On machines with more cores the perf is even better. P.S. You could read more about it here: https://www.tooltitude.com/ You could install from here: https://marketplace.visualstudio.com/items?itemName=tooltitudeteam.tooltitude cc @TerminalFi @stamblerre @hyangah @sanket-bhalerao P.S. Updated check time value to reflect a fix of a bug. |
Looks cool! I am a ST User, and maintain LSP-gopls. I see this is closed source. That is too bad |
@TerminalFi In theory nothing prevents it working from within ST. It's mostly LSP, with some additional requests and notifications to improve integration with VSCode. At some point we will consider it, taking into account that sublime is closed source too and people happily pay for performance (i.e. they are more likely than vscode users to be interested in commercial extension). |
Issue Type: Feature Request
it would be nice to see if a function is referenced in the code or not.
click on the codelens and see all the places the variable, function being referenced.
variable:

functions:

Extension version: 2020.8.1301
VS Code version: Code - Insiders 1.49.0-insider (bd08768fd310d34cdd4423a53e5f3ca77340fea5, 2020-08-14T05:56:40.601Z)
OS version: Windows_NT x64 10.0.18363
The text was updated successfully, but these errors were encountered: