mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Merge #702
702: Go to Implementation r=matklad a=kjeremy First half of #620 Co-authored-by: Jeremy Kolb <kjeremy@gmail.com> Co-authored-by: kjeremy <kjeremy@gmail.com>
This commit is contained in:
commit
b704ce803b
14 changed files with 277 additions and 17 deletions
|
@ -229,6 +229,26 @@ pub fn handle_goto_definition(
|
|||
Ok(Some(req::GotoDefinitionResponse::Link(res)))
|
||||
}
|
||||
|
||||
pub fn handle_goto_implementation(
|
||||
world: ServerWorld,
|
||||
params: req::TextDocumentPositionParams,
|
||||
) -> Result<Option<req::GotoImplementationResponse>> {
|
||||
let position = params.try_conv_with(&world)?;
|
||||
let line_index = world.analysis().file_line_index(position.file_id);
|
||||
let nav_info = match world.analysis().goto_implementation(position)? {
|
||||
None => return Ok(None),
|
||||
Some(it) => it,
|
||||
};
|
||||
let nav_range = nav_info.range;
|
||||
let res = nav_info
|
||||
.info
|
||||
.into_iter()
|
||||
.map(|nav| RangeInfo::new(nav_range, nav))
|
||||
.map(|nav| to_location_link(&nav, &world, &line_index))
|
||||
.collect::<Result<Vec<_>>>()?;
|
||||
Ok(Some(req::GotoDefinitionResponse::Link(res)))
|
||||
}
|
||||
|
||||
pub fn handle_parent_module(
|
||||
world: ServerWorld,
|
||||
params: req::TextDocumentPositionParams,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue