-
Notifications
You must be signed in to change notification settings - Fork 62
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
fix: jump to definition on dotted definition #92
fix: jump to definition on dotted definition #92
Conversation
In cases where you try to go-to-definition on a dotted identifier, e.g. `foo.bar.baz`, the LSP will try to find where `foo` is defined, and check if it's a `struct` definition with a property named `bar`, and jump to that. However, in cases where this location cannot be resolved, an `unwrap_or_default` would result in jumping to to the top of the file. Instead, in such cases, jump to the definition of the variable `foo` itself, which is better than jumping to the top of the file. Fixes facebook#90
Nice 👍 . Verified on top of pull/82.
Any segment of
Clicking |
Yeah, this PR is really just fixing a broken case. Ideally you'd have special handling for
Again, not sure if that fits in the project, but also not really something that (at the moment) is easy to add when you're implementing the There's also more room for improvement. The jump to definition on dotted definitions |
@ndmitchell has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Thanks for the fix - this is clearly an improvement! At some point we're going to need some good unit tests for the LSP. We (at Meta) didn't write them, so I'm not going to insist on them. But I do worry that without those tests someone might break these features inadvertently. As for how to implement |
Summary: In cases where you try to go-to-definition on a dotted identifier, e.g. `foo.bar.baz`, the LSP will try to find where `foo` is defined, and check if it's a `struct` definition with a property named `bar`, and jump to that. However, in cases where this location cannot be resolved, an `unwrap_or_default` would result in jumping to to the top of the file. Instead, in such cases, jump to the definition of the variable `foo` itself, which is better than jumping to the top of the file. Fixes facebook/starlark-rust#90 X-link: facebook/starlark-rust#92 Reviewed By: JakobDegen Differential Revision: D48863997 Pulled By: ndmitchell fbshipit-source-id: 07015bd7484d0c2d5e74544a9a91fcfbbd76c046
@ndmitchell merged this pull request in 335e74d. |
In cases where you try to go-to-definition on a dotted identifier, e.g.
foo.bar.baz
, the LSP will try to find wherefoo
is defined, and check if it's astruct
definition with a property namedbar
, and jump to that. However, in cases where this location cannot be resolved, anunwrap_or_default
would result in jumping to to the top of the file. Instead, in such cases, jump to the definition of the variablefoo
itself, which is better than jumping to the top of the file.Fixes #90