From 2b5ea5c730b36cab9396cffd87384d7fd3b8a39b Mon Sep 17 00:00:00 2001 From: Jonas Schievink Date: Sat, 13 Mar 2021 02:23:47 +0100 Subject: Simplify hir_def TestDB --- crates/hir_def/src/test_db.rs | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/crates/hir_def/src/test_db.rs b/crates/hir_def/src/test_db.rs index eda982c85..10977761c 100644 --- a/crates/hir_def/src/test_db.rs +++ b/crates/hir_def/src/test_db.rs @@ -15,7 +15,7 @@ use rustc_hash::FxHashSet; use syntax::{algo, ast, AstNode, TextRange, TextSize}; use test_utils::extract_annotations; -use crate::{db::DefDatabase, nameres::DefMap, Lookup, ModuleDefId, ModuleId}; +use crate::{db::DefDatabase, nameres::DefMap, src::HasSource, Lookup, ModuleDefId, ModuleId}; #[salsa::database( base_db::SourceDatabaseExtStorage, @@ -115,14 +115,9 @@ impl TestDB { if file_id != position.file_id.into() { continue; } - let root = self.parse_or_expand(file_id).unwrap(); - let ast_map = self.ast_id_map(file_id); - let item_tree = self.item_tree(file_id); for decl in module.scope.declarations() { if let ModuleDefId::FunctionId(it) = decl { - let ast = - ast_map.get(item_tree[it.lookup(self).id.value].ast_id).to_node(&root); - let range = ast.syntax().text_range(); + let range = it.lookup(self).source(self).value.syntax().text_range(); if !range.contains(position.offset) { continue; -- cgit v1.2.3