Skip to content
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

Small issue with Go to Definition for callbacks #371

Closed
andyw8 opened this issue May 4, 2024 · 3 comments
Closed

Small issue with Go to Definition for callbacks #371

andyw8 opened this issue May 4, 2024 · 3 comments
Labels
bug Something isn't working

Comments

@andyw8
Copy link
Contributor

andyw8 commented May 4, 2024

When using Go To Definition on code such as:

before_save :foo

It works fine on the callback name before_save, but try it on the symbol name :foo fails. Both should jump to the foo method definition.

I don't think it behaved like that previously, so this may be a regression.

@andyw8 andyw8 added the bug Something isn't working label May 4, 2024
@vinistock
Copy link
Member

This is because of Shopify/ruby-lsp#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_save call 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::Dispatcher that not only allows you to register for events, but keeps track of the "current context" of where a node is inserted.

@andyw8
Copy link
Contributor Author

andyw8 commented May 10, 2024

For the above: Shopify/ruby-lsp#2036

@vinistock
Copy link
Member

This has already been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants