Basic resolution for ADT

This commit is contained in:
kjeremy 2019-04-23 14:11:27 -04:00
parent a094d5c621
commit 7125192c1e
5 changed files with 99 additions and 2 deletions

View file

@ -288,6 +288,26 @@ pub fn handle_goto_implementation(
Ok(Some(req::GotoDefinitionResponse::Link(res)))
}
pub fn handle_goto_type_definition(
world: ServerWorld,
params: req::TextDocumentPositionParams,
) -> Result<Option<req::GotoTypeDefinitionResponse>> {
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_type_definition(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,