Cleanup
This commit is contained in:
parent
afce8e4426
commit
d3df80dfe4
7 changed files with 17 additions and 27 deletions
|
|
@ -76,11 +76,7 @@ impl Body {
|
|||
}
|
||||
|
||||
// needs arbitrary_self_types to be a method... or maybe move to the def?
|
||||
pub fn resolver_for_expr(
|
||||
body: Arc<Body>,
|
||||
db: &impl HirDatabase,
|
||||
expr_id: ExprId,
|
||||
) -> Resolver<'static> {
|
||||
pub fn resolver_for_expr(body: Arc<Body>, db: &impl HirDatabase, expr_id: ExprId) -> Resolver {
|
||||
let scopes = db.expr_scopes(body.owner);
|
||||
resolver_for_scope(body, db, scopes.scope_for(expr_id))
|
||||
}
|
||||
|
|
@ -89,7 +85,7 @@ pub fn resolver_for_scope(
|
|||
body: Arc<Body>,
|
||||
db: &impl HirDatabase,
|
||||
scope_id: Option<scope::ScopeId>,
|
||||
) -> Resolver<'static> {
|
||||
) -> Resolver {
|
||||
let mut r = body.owner.resolver(db);
|
||||
let scopes = db.expr_scopes(body.owner);
|
||||
let scope_chain = scopes.scope_chain_for(scope_id).collect::<Vec<_>>();
|
||||
|
|
|
|||
|
|
@ -25,8 +25,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
|
|||
use crate::{
|
||||
Module, ModuleDef,
|
||||
Path, PathKind, PersistentHirDatabase,
|
||||
Crate,
|
||||
Name,
|
||||
Crate, Name,
|
||||
module_tree::{ModuleId, ModuleTree},
|
||||
nameres::lower::{ImportId, LoweredModule, ImportData},
|
||||
};
|
||||
|
|
|
|||
|
|
@ -109,8 +109,6 @@ impl Resolver {
|
|||
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,
|
||||
})
|
||||
}
|
||||
|
|
@ -197,13 +195,13 @@ impl Scope {
|
|||
fn collect_names(&self, f: &mut FnMut(Name, PerNs<Resolution>)) {
|
||||
match self {
|
||||
Scope::ModuleScope(m) => {
|
||||
m.item_map[m.module.module_id]
|
||||
.entries()
|
||||
.for_each(|(name, res)| {
|
||||
f(name.clone(), res.def.map(|def| Resolution::Def { def }));
|
||||
})
|
||||
}
|
||||
Scope::ModuleScopeRef(m) => {
|
||||
// TODO: should we provide `self` here?
|
||||
// f(
|
||||
// Name::self_param(),
|
||||
// PerNs::types(Resolution::Def {
|
||||
// def: m.module.into(),
|
||||
// }),
|
||||
// );
|
||||
m.item_map[m.module.module_id]
|
||||
.entries()
|
||||
.for_each(|(name, res)| {
|
||||
|
|
|
|||
|
|
@ -203,7 +203,7 @@ pub fn macro_symbols(db: &impl HirDatabase, file_id: FileId) -> Vec<(SmolStr, Te
|
|||
res
|
||||
}
|
||||
|
||||
pub fn resolver_for_position(db: &impl HirDatabase, position: FilePosition) -> Resolver<'static> {
|
||||
pub fn resolver_for_position(db: &impl HirDatabase, position: FilePosition) -> Resolver {
|
||||
let file = db.parse(position.file_id);
|
||||
find_leaf_at_offset(file.syntax(), position.offset)
|
||||
.find_map(|node| {
|
||||
|
|
@ -230,11 +230,7 @@ pub fn resolver_for_position(db: &impl HirDatabase, position: FilePosition) -> R
|
|||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
pub fn resolver_for_node(
|
||||
db: &impl HirDatabase,
|
||||
file_id: FileId,
|
||||
node: &SyntaxNode,
|
||||
) -> Resolver<'static> {
|
||||
pub fn resolver_for_node(db: &impl HirDatabase, file_id: FileId, node: &SyntaxNode) -> Resolver {
|
||||
node.ancestors()
|
||||
.find_map(|node| {
|
||||
if ast::Expr::cast(node).is_some() || ast::Block::cast(node).is_some() {
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
use join_to_string::join;
|
||||
|
||||
use hir::{Docs, Resolution};
|
||||
|
||||
use crate::{
|
||||
completion::{CompletionItem, CompletionItemKind, Completions, CompletionKind, CompletionContext},
|
||||
};
|
||||
|
||||
use hir::Docs;
|
||||
|
||||
pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
|
||||
let path = match &ctx.path_prefix {
|
||||
Some(path) => path.clone(),
|
||||
|
|
@ -15,7 +15,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
|
|||
Some(Resolution::Def { def }) => def,
|
||||
_ => return,
|
||||
};
|
||||
match def_id {
|
||||
match def {
|
||||
hir::ModuleDef::Module(module) => {
|
||||
let module_scope = module.scope(ctx.db);
|
||||
for (name, res) in module_scope.entries() {
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ pub(crate) struct CompletionContext<'a> {
|
|||
pub(super) db: &'a db::RootDatabase,
|
||||
pub(super) offset: TextUnit,
|
||||
pub(super) leaf: &'a SyntaxNode,
|
||||
pub(super) resolver: Resolver<'static>,
|
||||
pub(super) resolver: Resolver,
|
||||
pub(super) module: Option<hir::Module>,
|
||||
pub(super) function: Option<hir::Function>,
|
||||
pub(super) function_syntax: Option<&'a ast::FnDef>,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use ra_syntax::{
|
|||
algo::find_node_at_offset,
|
||||
};
|
||||
use test_utils::tested_by;
|
||||
use hir::Resolution;
|
||||
|
||||
use crate::{FilePosition, NavigationTarget, db::RootDatabase, RangeInfo};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue