Skip to content

Commit

Permalink
Fix "go to label" in bazel LSP (#100)
Browse files Browse the repository at this point in the history
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 #101, to extract the name and searches using that.

Pull Request resolved: #100

Reviewed By: wendy728

Differential Revision: D52954185

Pulled By: ndmitchell

fbshipit-source-id: 937da257b7441d8abe313015ca1c8241c7967a10
  • Loading branch information
cameron-martin authored and facebook-github-bot committed Jan 22, 2024
1 parent 70fcb24 commit 1f2fe80
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions starlark_bin/bin/bazel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -745,10 +745,12 @@ impl LspContext for BazelContext {
location_finder: if same_filename {
None
} else {
let literal = literal.to_owned();
Some(Box::new(move |ast| {
Ok(ast.find_function_call_with_name(&literal))
}))
match Label::parse(literal) {
Err(_) => None,
Ok(label) => Some(Box::new(move |ast| {
Ok(ast.find_function_call_with_name(&label.name))
})),
}
},
})
})
Expand Down

0 comments on commit 1f2fe80

Please sign in to comment.