Make ItemTreeId its own type

This commit is contained in:
Jonas Schievink 2021-03-13 00:34:01 +01:00
parent 5632e61f79
commit 759f8c83e5
8 changed files with 77 additions and 37 deletions

View file

@ -14,12 +14,12 @@ impl<N: ItemTreeNode> HasSource for AssocItemLoc<N> {
type Value = N::Source;
fn source(&self, db: &dyn DefDatabase) -> InFile<N::Source> {
let tree = db.item_tree(self.id.file_id);
let ast_id_map = db.ast_id_map(self.id.file_id);
let root = db.parse_or_expand(self.id.file_id).unwrap();
let tree = self.id.item_tree(db);
let ast_id_map = db.ast_id_map(self.id.file_id());
let root = db.parse_or_expand(self.id.file_id()).unwrap();
let node = &tree[self.id.value];
InFile::new(self.id.file_id, ast_id_map.get(node.ast_id()).to_node(&root))
InFile::new(self.id.file_id(), ast_id_map.get(node.ast_id()).to_node(&root))
}
}
@ -27,12 +27,12 @@ impl<N: ItemTreeNode> HasSource for ItemLoc<N> {
type Value = N::Source;
fn source(&self, db: &dyn DefDatabase) -> InFile<N::Source> {
let tree = db.item_tree(self.id.file_id);
let ast_id_map = db.ast_id_map(self.id.file_id);
let root = db.parse_or_expand(self.id.file_id).unwrap();
let tree = self.id.item_tree(db);
let ast_id_map = db.ast_id_map(self.id.file_id());
let root = db.parse_or_expand(self.id.file_id()).unwrap();
let node = &tree[self.id.value];
InFile::new(self.id.file_id, ast_id_map.get(node.ast_id()).to_node(&root))
InFile::new(self.id.file_id(), ast_id_map.get(node.ast_id()).to_node(&root))
}
}