Use the new Resolver API in completion

This commit is contained in:
Florian Diebold 2019-01-27 20:50:57 +01:00
parent 6b076f1931
commit 33ff7b56ff
11 changed files with 190 additions and 106 deletions

View file

@ -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);
}