mirror of
https://github.com/rust-lang/rust.git
synced 2026-06-01 14:10:03 +03:00
introduce separate goto_defenition
This commit is contained in:
@@ -392,6 +392,13 @@ pub fn symbol_search(&self, query: Query) -> Cancelable<Vec<NavigationTarget>> {
|
||||
.collect();
|
||||
Ok(res)
|
||||
}
|
||||
pub fn goto_defenition(
|
||||
&self,
|
||||
position: FilePosition,
|
||||
) -> Cancelable<Option<Vec<NavigationTarget>>> {
|
||||
let r = self.approximately_resolve_symbol(position)?;
|
||||
Ok(r.map(|it| it.resolves_to))
|
||||
}
|
||||
/// Resolves reference to definition, but does not gurantee correctness.
|
||||
pub fn approximately_resolve_symbol(
|
||||
&self,
|
||||
|
||||
@@ -207,12 +207,11 @@ pub fn handle_goto_definition(
|
||||
params: req::TextDocumentPositionParams,
|
||||
) -> Result<Option<req::GotoDefinitionResponse>> {
|
||||
let position = params.try_conv_with(&world)?;
|
||||
let rr = match world.analysis().approximately_resolve_symbol(position)? {
|
||||
let navs = match world.analysis().goto_defenition(position)? {
|
||||
None => return Ok(None),
|
||||
Some(it) => it,
|
||||
};
|
||||
let res = rr
|
||||
.resolves_to
|
||||
let res = navs
|
||||
.into_iter()
|
||||
.map(|nav| nav.try_conv_with(&world))
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
|
||||
Reference in New Issue
Block a user