generalize SourceAnalyzer to handle all defs with bodies

This commit is contained in:
Aleksey Kladov 2019-04-11 16:22:10 +03:00
parent 07cc047b4f
commit 5471c1ef4b
3 changed files with 51 additions and 11 deletions

View file

@ -454,6 +454,14 @@ impl DefWithBody {
db.body_hir(*self)
}
pub fn body_source_map(&self, db: &impl HirDatabase) -> Arc<BodySourceMap> {
match *self {
DefWithBody::Const(ref c) => c.body_source_map(db),
DefWithBody::Function(ref f) => f.body_source_map(db),
DefWithBody::Static(ref s) => s.body_source_map(db),
}
}
/// Builds a resolver for code inside this item.
pub fn resolver(&self, db: &impl HirDatabase) -> Resolver {
match *self {