//! Utilities for mapping between hir IDs and the surface syntax. use hir_expand::InFile; use ra_arena::map::ArenaMap; use ra_syntax::AstNode; use crate::{db::DefDatabase, AssocItemLoc, ItemLoc}; pub trait HasSource { type Value; fn source(&self, db: &dyn DefDatabase) -> InFile; } impl HasSource for AssocItemLoc { type Value = N; fn source(&self, db: &dyn DefDatabase) -> InFile { let node = self.ast_id.to_node(db.upcast()); InFile::new(self.ast_id.file_id, node) } } impl HasSource for ItemLoc { type Value = N; fn source(&self, db: &dyn DefDatabase) -> InFile { let node = self.ast_id.to_node(db.upcast()); InFile::new(self.ast_id.file_id, node) } } pub trait HasChildSource { type ChildId; type Value; fn child_source(&self, db: &dyn DefDatabase) -> InFile>; }