Re-think the way we locate nodes as targets and how addons declare the ones they are interested in.
Description
As first mentioned here.:
This is because of https://github.com/Shopify/ruby-lsp/pull/1981. We need to re-think the way we locate nodes as targets and how addons can accurately declare the ones they are interested in.
To correctly identify targets, there are many cases where you need two layers of information: a surrounding parent node (like the
before_savecall node) and the symbol argument.Currently, if you register for call nodes, you can identify the callback properly, but it assigns the go to definition behaviour to the method call identifier. However, if you register for handling symbol nodes (or arguments node), then you don't have access to the surrounding call node. I think we need to create a specialized
Prism::Dispatcherthat not only allows you to register for events, but keeps track of the "current context" of where a node is inserted.
Additional comment from @vinistock:
We need to think of a way for listener to say something like this:
method_call(:symbol) ^ attached behaviour when this is clicked ^ but include the method call so that we can verify that it's the method we're interested > in