mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
Use the new Resolver API for goto def
This commit is contained in:
parent
33ff7b56ff
commit
afce8e4426
6 changed files with 89 additions and 35 deletions
|
@ -9,7 +9,7 @@ use crate::{
|
|||
name::{Name, KnownName},
|
||||
nameres::{PerNs, ItemMap},
|
||||
generics::GenericParams,
|
||||
expr::{scope::{ExprScopes, ScopeId}, PatId},
|
||||
expr::{scope::{ExprScopes, ScopeId}, PatId, Body},
|
||||
impl_block::ImplBlock,
|
||||
path::Path,
|
||||
};
|
||||
|
@ -106,15 +106,21 @@ impl Resolver {
|
|||
}
|
||||
|
||||
fn module(&self) -> Option<(&ItemMap, Module)> {
|
||||
for scope in self.scopes.iter().rev() {
|
||||
match scope {
|
||||
Scope::ModuleScope(m) => {
|
||||
return Some((&m.item_map, m.module.clone()));
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
None
|
||||
self.scopes.iter().rev().find_map(|scope| match scope {
|
||||
Scope::ModuleScope(m) => Some((&*m.item_map, m.module.clone())),
|
||||
|
||||
Scope::ModuleScopeRef(m) => Some((m.item_map, m.module.clone())),
|
||||
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
|
||||
/// The body from which any `LocalBinding` resolutions in this resolver come.
|
||||
pub fn body(&self) -> Option<Arc<Body>> {
|
||||
self.scopes.iter().rev().find_map(|scope| match scope {
|
||||
Scope::ExprScope(expr_scope) => Some(expr_scope.expr_scopes.body()),
|
||||
_ => None,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue