From b0c7ff39b8277aaf80c93a83200dc732792bac7d Mon Sep 17 00:00:00 2001 From: Jake Heinz Date: Tue, 30 Nov 2021 04:50:09 +0000 Subject: [PATCH] remove one need for semantics --- crates/ide/src/navigation_target.rs | 5 ++--- crates/ide_db/src/symbol_index.rs | 17 +++++++---------- 2 files changed, 9 insertions(+), 13 deletions(-) diff --git a/crates/ide/src/navigation_target.rs b/crates/ide/src/navigation_target.rs index 76ec99ce9e..7deb6cae38 100644 --- a/crates/ide/src/navigation_target.rs +++ b/crates/ide/src/navigation_target.rs @@ -169,9 +169,8 @@ impl NavigationTarget { impl TryToNav for FileSymbol { fn try_to_nav(&self, db: &RootDatabase) -> Option { - 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, diff --git a/crates/ide_db/src/symbol_index.rs b/crates/ide_db/src/symbol_index.rs index 52c90a3744..f2629f69a0 100644 --- a/crates/ide_db/src/symbol_index.rs +++ b/crates/ide_db/src/symbol_index.rs @@ -382,28 +382,25 @@ impl DeclarationLocation { Some(self.ptr.to_node(&root)) } - pub fn original_range(&self, semantics: &Semantics<'_, RootDatabase>) -> Option { - find_original_file_range(semantics, self.hir_file_id, &self.ptr) + pub fn original_range(&self, db: &dyn HirDatabase) -> Option { + find_original_file_range(db, self.hir_file_id, &self.ptr) } - pub fn original_name_range( - &self, - semantics: &Semantics<'_, RootDatabase>, - ) -> Option { - find_original_file_range(semantics, self.hir_file_id, &self.name_ptr) + pub fn original_name_range(&self, db: &dyn HirDatabase) -> Option { + 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 { - 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)]