mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
simplify
This commit is contained in:
parent
227bc0b6d4
commit
b042faeb64
2 changed files with 20 additions and 23 deletions
|
@ -412,6 +412,19 @@ impl TryConvWith for (FileId, RangeInfo<NavigationTarget>) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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(
|
pub fn to_location(
|
||||||
file_id: FileId,
|
file_id: FileId,
|
||||||
range: TextRange,
|
range: TextRange,
|
||||||
|
|
|
@ -9,8 +9,7 @@ use lsp_types::{
|
||||||
TextDocumentIdentifier, TextEdit, WorkspaceEdit,
|
TextDocumentIdentifier, TextEdit, WorkspaceEdit,
|
||||||
};
|
};
|
||||||
use ra_ide_api::{
|
use ra_ide_api::{
|
||||||
AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, RangeInfo,
|
AssistId, Cancelable, FileId, FilePosition, FileRange, FoldKind, Query, RunnableKind, Severity,
|
||||||
RunnableKind, Severity,
|
|
||||||
};
|
};
|
||||||
use ra_prof::profile;
|
use ra_prof::profile;
|
||||||
use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit};
|
use ra_syntax::{AstNode, SyntaxKind, TextRange, TextUnit};
|
||||||
|
@ -267,13 +266,8 @@ pub fn handle_goto_definition(
|
||||||
None => return Ok(None),
|
None => return Ok(None),
|
||||||
Some(it) => it,
|
Some(it) => it,
|
||||||
};
|
};
|
||||||
let nav_range = nav_info.range;
|
let res = (position.file_id, nav_info).try_conv_with(&world)?;
|
||||||
let res = nav_info
|
Ok(Some(res))
|
||||||
.info
|
|
||||||
.into_iter()
|
|
||||||
.map(|nav| (position.file_id, RangeInfo::new(nav_range, nav)))
|
|
||||||
.try_conv_with_to_vec(&world)?;
|
|
||||||
Ok(Some(res.into()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_goto_implementation(
|
pub fn handle_goto_implementation(
|
||||||
|
@ -285,13 +279,8 @@ pub fn handle_goto_implementation(
|
||||||
None => return Ok(None),
|
None => return Ok(None),
|
||||||
Some(it) => it,
|
Some(it) => it,
|
||||||
};
|
};
|
||||||
let nav_range = nav_info.range;
|
let res = (position.file_id, nav_info).try_conv_with(&world)?;
|
||||||
let res = nav_info
|
Ok(Some(res))
|
||||||
.info
|
|
||||||
.into_iter()
|
|
||||||
.map(|nav| (position.file_id, RangeInfo::new(nav_range, nav)))
|
|
||||||
.try_conv_with_to_vec(&world)?;
|
|
||||||
Ok(Some(res.into()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_goto_type_definition(
|
pub fn handle_goto_type_definition(
|
||||||
|
@ -303,13 +292,8 @@ pub fn handle_goto_type_definition(
|
||||||
None => return Ok(None),
|
None => return Ok(None),
|
||||||
Some(it) => it,
|
Some(it) => it,
|
||||||
};
|
};
|
||||||
let nav_range = nav_info.range;
|
let res = (position.file_id, nav_info).try_conv_with(&world)?;
|
||||||
let res = nav_info
|
Ok(Some(res))
|
||||||
.info
|
|
||||||
.into_iter()
|
|
||||||
.map(|nav| (position.file_id, RangeInfo::new(nav_range, nav)))
|
|
||||||
.try_conv_with_to_vec(&world)?;
|
|
||||||
Ok(Some(res.into()))
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn handle_parent_module(
|
pub fn handle_parent_module(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue