-
Notifications
You must be signed in to change notification settings - Fork 81
Fix "go to label" in bazel LSP #100
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 "go to label" in bazel LSP #100
Conversation
When executing "go to definition" on a label, it would previously go to the correct file but not to the definition of that target. The reason was because we were searching for a function call where the name is the whole label. Now it parses the label to extract the name and searches using that. This doesn't work in a few cases, for example "//foo" and "@foo", where the name is implicit. However, I think to solve this we would need to implement a label parser. If one already exists, I could not find it. I imagine a lot of the code in `resolve_folder` could be simplified with the use of a label parser too.
|
Nice! Works well for local targets for me :) and handles |
|
That's strange. It works for going to external repositories for me, just not when in a file in an external repository. |
|
Good! My bad, I had the runfiles library as the abbreviated package-only label. With |
Instead of parsing labels ad-hoc in `resolve_folder`, this introduces a separate label parser. This allows re-using this when doing a "go to definition" for a label that is not in a load statement. See facebook#100 for more context.
|
With #101 I will be able to fix this problem |
Instead of parsing labels ad-hoc in `resolve_folder`, this introduces a separate label parser. This allows re-using this when doing a "go to definition" for a label that is not in a load statement. See facebook#100 for more context.
Summary: Instead of parsing labels ad-hoc in `resolve_folder`, this introduces a separate label parser. This allows re-using this when doing a "go to definition" for a label that is not in a load statement. See #100 for more context. Pull Request resolved: #101 Reviewed By: stepancheg Differential Revision: D52887102 Pulled By: ndmitchell fbshipit-source-id: e08c07b3d88c24d14030568dcc3ecf33ae8c243c
Summary: Instead of parsing labels ad-hoc in `resolve_folder`, this introduces a separate label parser. This allows re-using this when doing a "go to definition" for a label that is not in a load statement. See facebook/starlark-rust#100 for more context. X-link: facebook/starlark-rust#101 Reviewed By: stepancheg Differential Revision: D52887102 Pulled By: ndmitchell fbshipit-source-id: e08c07b3d88c24d14030568dcc3ecf33ae8c243c
|
Any reason not to undraft this? |
Yep I was waiting for the label parser to go in so I could use it here. I'll update this soon and undraft it. |
|
@ndmitchell This should be now good to go! |
|
@ndmitchell has imported this pull request. If you are a Meta employee, you can view this diff on Phabricator. |
Summary: When executing "go to definition" on a label, it would previously go to the correct file but not to the definition of that target. This was because we were searching for a function call where the name is the whole label. Now it parses the label, using the label parser introduced in facebook/starlark-rust#101, to extract the name and searches using that. X-link: facebook/starlark-rust#100 Reviewed By: wendy728 Differential Revision: D52954185 Pulled By: ndmitchell fbshipit-source-id: 937da257b7441d8abe313015ca1c8241c7967a10
|
@ndmitchell merged this pull request in 1f2fe80. |
When executing "go to definition" on a label, it would previously go to the correct file but not to the definition of that target. This was because we were searching for a function call where the name is the whole label. Now it parses the label, using the label parser introduced in #101, to extract the name and searches using that.