This commit is contained in:
Aleksey Kladov 2019-07-08 13:47:02 +03:00
parent 227bc0b6d4
commit b042faeb64
2 changed files with 20 additions and 23 deletions

View File

@ -412,6 +412,19 @@ fn try_conv_with(self, world: &WorldSnapshot) -> Result<LocationLink> {
}
}
impl TryConvWith for (FileId, RangeInfo<Vec<NavigationTarget>>) {
type Ctx = WorldSnapshot;
type Output = req::GotoDefinitionResponse;
fn try_conv_with(self, world: &WorldSnapshot) -> Result<req::GotoTypeDefinitionResponse> {
let (file_id, RangeInfo { range, info: navs }) = self;
let links = navs
.into_iter()
.map(|nav| (file_id, RangeInfo::new(range, nav)))
.try_conv_with_to_vec(world)?;
Ok(links.into())
}
}
pub fn to_location(
file_id: FileId,
range: TextRange,

View File

@ -9,8 +9,7 @@
TextDocumentIdentifier, TextEdit, WorkspaceEdit,
};
use ra_ide_api::{
AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo,
RunnableKind, Severity,
AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity,
};
use ra_prof::profile;
use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit};
@ -267,13 +266,8 @@ pub fn handle_goto_definition(
None => return Ok(None),
Some(it) => it,
};
let nav_range = nav_info.range;
let res = nav_info
.info
.into_iter()
.map(|nav| (position.file_id, RangeInfo::new(nav_range, nav)))
.try_conv_with_to_vec(&world)?;
Ok(Some(res.into()))
let res = (position.file_id, nav_info).try_conv_with(&world)?;
Ok(Some(res))
}
pub fn handle_goto_implementation(
@ -285,13 +279,8 @@ pub fn handle_goto_implementation(
None => return Ok(None),
Some(it) => it,
};
let nav_range = nav_info.range;
let res = nav_info
.info
.into_iter()
.map(|nav| (position.file_id, RangeInfo::new(nav_range, nav)))
.try_conv_with_to_vec(&world)?;
Ok(Some(res.into()))
let res = (position.file_id, nav_info).try_conv_with(&world)?;
Ok(Some(res))
}
pub fn handle_goto_type_definition(
@ -303,13 +292,8 @@ pub fn handle_goto_type_definition(
None => return Ok(None),
Some(it) => it,
};
let nav_range = nav_info.range;
let res = nav_info
.info
.into_iter()
.map(|nav| (position.file_id, RangeInfo::new(nav_range, nav)))
.try_conv_with_to_vec(&world)?;
Ok(Some(res.into()))
let res = (position.file_id, nav_info).try_conv_with(&world)?;
Ok(Some(res))
}
pub fn handle_parent_module(