mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Use the new Resolver API in completion
This commit is contained in:
parent
6b076f1931
commit
33ff7b56ff
11 changed files with 190 additions and 106 deletions
|
@ -72,11 +72,23 @@ impl Body {
|
|||
}
|
||||
|
||||
// needs arbitrary_self_types to be a method... or maybe move to the def?
|
||||
#[allow(dead_code)]
|
||||
pub fn resolver_for_expr(body: Arc<Body>, db: &impl HirDatabase, expr_id: ExprId) -> Resolver {
|
||||
pub fn resolver_for_expr(
|
||||
body: Arc<Body>,
|
||||
db: &impl HirDatabase,
|
||||
expr_id: ExprId,
|
||||
) -> Resolver<'static> {
|
||||
let scopes = db.expr_scopes(body.owner);
|
||||
resolver_for_scope(body, db, scopes.scope_for(expr_id))
|
||||
}
|
||||
|
||||
pub fn resolver_for_scope(
|
||||
body: Arc<Body>,
|
||||
db: &impl HirDatabase,
|
||||
scope_id: Option<scope::ScopeId>,
|
||||
) -> Resolver<'static> {
|
||||
let mut r = body.owner.resolver(db);
|
||||
let scopes = db.expr_scopes(body.owner);
|
||||
let scope_chain = scopes.scope_chain_for(expr_id).collect::<Vec<_>>();
|
||||
let scope_chain = scopes.scope_chain_for(scope_id).collect::<Vec<_>>();
|
||||
for scope in scope_chain.into_iter().rev() {
|
||||
r = r.push_expr_scope(Arc::clone(&scopes), scope);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue