mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
remove one need for semantics
This commit is contained in:
parent
54fc98920b
commit
b0c7ff39b8
2 changed files with 9 additions and 13 deletions
|
@ -169,9 +169,8 @@ impl NavigationTarget {
|
||||||
|
|
||||||
impl TryToNav for FileSymbol {
|
impl TryToNav for FileSymbol {
|
||||||
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
|
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
|
||||||
let semantics = Semantics::new(db);
|
let full_range = self.loc.original_range(db)?;
|
||||||
let full_range = self.loc.original_range(&semantics)?;
|
let name_range = self.loc.original_name_range(db)?;
|
||||||
let name_range = self.loc.original_name_range(&semantics)?;
|
|
||||||
|
|
||||||
Some(NavigationTarget {
|
Some(NavigationTarget {
|
||||||
file_id: full_range.file_id,
|
file_id: full_range.file_id,
|
||||||
|
|
|
@ -382,28 +382,25 @@ impl DeclarationLocation {
|
||||||
Some(self.ptr.to_node(&root))
|
Some(self.ptr.to_node(&root))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn original_range(&self, semantics: &Semantics<'_, RootDatabase>) -> Option<FileRange> {
|
pub fn original_range(&self, db: &dyn HirDatabase) -> Option<FileRange> {
|
||||||
find_original_file_range(semantics, self.hir_file_id, &self.ptr)
|
find_original_file_range(db, self.hir_file_id, &self.ptr)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn original_name_range(
|
pub fn original_name_range(&self, db: &dyn HirDatabase) -> Option<FileRange> {
|
||||||
&self,
|
find_original_file_range(db, self.hir_file_id, &self.name_ptr)
|
||||||
semantics: &Semantics<'_, RootDatabase>,
|
|
||||||
) -> Option<FileRange> {
|
|
||||||
find_original_file_range(semantics, self.hir_file_id, &self.name_ptr)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn find_original_file_range(
|
fn find_original_file_range(
|
||||||
semantics: &Semantics<'_, RootDatabase>,
|
db: &dyn HirDatabase,
|
||||||
file_id: HirFileId,
|
file_id: HirFileId,
|
||||||
ptr: &SyntaxNodePtr,
|
ptr: &SyntaxNodePtr,
|
||||||
) -> Option<FileRange> {
|
) -> Option<FileRange> {
|
||||||
let root = semantics.parse_or_expand(file_id)?;
|
let root = db.parse_or_expand(file_id)?;
|
||||||
let node = ptr.to_node(&root);
|
let node = ptr.to_node(&root);
|
||||||
let node = InFile::new(file_id, &node);
|
let node = InFile::new(file_id, &node);
|
||||||
|
|
||||||
Some(node.original_file_range(semantics.db.upcast()))
|
Some(node.original_file_range(db.upcast()))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
|
#[derive(PartialEq, Eq, Hash, Clone, Copy, Debug)]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue