Skip to content

Commit 88f78bd

Browse files
Merge #7991
7991: Simplify hir_def TestDB r=jonas-schievink a=jonas-schievink bors r+ Co-authored-by: Jonas Schievink <[email protected]>
2 parents 5368e2c + 2b5ea5c commit 88f78bd

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

crates/hir_def/src/test_db.rs

+2-7
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ use rustc_hash::FxHashSet;
1515
use syntax::{algo, ast, AstNode, TextRange, TextSize};
1616
use test_utils::extract_annotations;
1717

18-
use crate::{db::DefDatabase, nameres::DefMap, Lookup, ModuleDefId, ModuleId};
18+
use crate::{db::DefDatabase, nameres::DefMap, src::HasSource, Lookup, ModuleDefId, ModuleId};
1919

2020
#[salsa::database(
2121
base_db::SourceDatabaseExtStorage,
@@ -115,14 +115,9 @@ impl TestDB {
115115
if file_id != position.file_id.into() {
116116
continue;
117117
}
118-
let root = self.parse_or_expand(file_id).unwrap();
119-
let ast_map = self.ast_id_map(file_id);
120-
let item_tree = self.item_tree(file_id);
121118
for decl in module.scope.declarations() {
122119
if let ModuleDefId::FunctionId(it) = decl {
123-
let ast =
124-
ast_map.get(item_tree[it.lookup(self).id.value].ast_id).to_node(&root);
125-
let range = ast.syntax().text_range();
120+
let range = it.lookup(self).source(self).value.syntax().text_range();
126121

127122
if !range.contains(position.offset) {
128123
continue;

0 commit comments

Comments
 (0)