mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
generalize SourceAnalyzer to handle all defs with bodies
This commit is contained in:
parent
07cc047b4f
commit
5471c1ef4b
3 changed files with 51 additions and 11 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue