remove one need for semantics

This commit is contained in:
Jake Heinz 2021-11-30 04:50:09 +00:00
parent 54fc98920b
commit b0c7ff39b8
2 changed files with 9 additions and 13 deletions

View file

@ -169,9 +169,8 @@ impl NavigationTarget {
impl TryToNav for FileSymbol {
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
let semantics = Semantics::new(db);
let full_range = self.loc.original_range(&semantics)?;
let name_range = self.loc.original_name_range(&semantics)?;
let full_range = self.loc.original_range(db)?;
let name_range = self.loc.original_name_range(db)?;
Some(NavigationTarget {
file_id: full_range.file_id,

View file

@ -382,28 +382,25 @@ impl DeclarationLocation {
Some(self.ptr.to_node(&root))
}
pub fn original_range(&self, semantics: &Semantics<'_, RootDatabase>) -> Option<FileRange> {
find_original_file_range(semantics, self.hir_file_id, &self.ptr)
pub fn original_range(&self, db: &dyn HirDatabase) -> Option<FileRange> {
find_original_file_range(db, self.hir_file_id, &self.ptr)
}
pub fn original_name_range(
&self,
semantics: &Semantics<'_, RootDatabase>,
) -> Option<FileRange> {
find_original_file_range(semantics, self.hir_file_id, &self.name_ptr)
pub fn original_name_range(&self, db: &dyn HirDatabase) -> Option<FileRange> {
find_original_file_range(db, self.hir_file_id, &self.name_ptr)
}
}
fn find_original_file_range(
semantics: &Semantics<'_, RootDatabase>,
db: &dyn HirDatabase,
file_id: HirFileId,
ptr: &SyntaxNodePtr,
) -> 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 = 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)]