introduce separate goto_defenition
This commit is contained in:
parent
ad2a5da259
commit
4551155073
2 changed files with 9 additions and 3 deletions
|
@ -392,6 +392,13 @@ impl Analysis {
|
|||
.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<_>>>()?;
|
||||
|
|
Loading…
Reference in a new issue