Add references support for instance variables
Build on top of #2632 to add support for finding instance variable references.
Hi there! Still digging but I'd love to give this one a try!
Hello! Awesome. If you have any doubts or get blocked, let us know and we can help!
Hi @vinistock Sorry for the delay! I got completely distracted by the Factorio: Space Age 😅
I'm not certain if this functionality should narrow down the instance variable's context the way Go to Definition does. It took me some time to figure out how Go to Definition works.
Based on the LSP specification,
The references request is sent from the client to the server to resolve project-wide references for the symbol denoted by the given text document position.
I suppose finding all matched instance variables beyond context should be OK?
I’ve opened the PR and would appreciate your review! https://github.com/Shopify/ruby-lsp/pull/2787
It might be worth checking what other language servers do, but I suspect we shouldn't be matching on instance variables in other contexts, since they may be named co-incidentally, whereas for constants and class/module names, we can (generally) determine that they refer to the same thing.
@andyw8 Thanks for you suggestion!
Totally agree with you but I forget to mention that I did check latest Solargraph and RubyMine. For Solargraph in VSCode, Find All References lists all usages despite of context (even for Go to Definition).
And For RubyMine, it's more detailed and list all others as Untyped (potential) usage
(Solargraph v0.50.0 in VSCode)
(RubyMine 2024.1.6)