Skip to content

Commit 1f2fe80

Browse files
cameron-martinfacebook-github-bot
authored andcommitted
Fix "go to label" in bazel LSP (#100)
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
1 parent 70fcb24 commit 1f2fe80

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

starlark_bin/bin/bazel.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -745,10 +745,12 @@ impl LspContext for BazelContext {
745745
location_finder: if same_filename {
746746
None
747747
} else {
748-
let literal = literal.to_owned();
749-
Some(Box::new(move |ast| {
750-
Ok(ast.find_function_call_with_name(&literal))
751-
}))
748+
match Label::parse(literal) {
749+
Err(_) => None,
750+
Ok(label) => Some(Box::new(move |ast| {
751+
Ok(ast.find_function_call_with_name(&label.name))
752+
})),
753+
}
752754
},
753755
})
754756
})

0 commit comments

Comments
 (0)