ruby-lsp icon indicating copy to clipboard operation
ruby-lsp copied to clipboard

Add references support for instance variables

Open vinistock opened this issue 1 year ago • 2 comments

Build on top of #2632 to add support for finding instance variable references.

vinistock avatar Oct 01 '24 14:10 vinistock

Hi there! Still digging but I'd love to give this one a try!

monkeyWzr avatar Oct 19 '24 17:10 monkeyWzr

Hello! Awesome. If you have any doubts or get blocked, let us know and we can help!

vinistock avatar Oct 21 '24 21:10 vinistock

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

monkeyWzr avatar Oct 30 '24 13:10 monkeyWzr

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 avatar Oct 30 '24 14:10 andyw8

@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)

monkeyWzr avatar Oct 30 '24 15:10 monkeyWzr