resolve_path works with DefIds

This commit is contained in:
Aleksey Kladov 2018-11-27 19:56:03 +03:00
parent aa7fd563a4
commit 192e2bbb0e
3 changed files with 46 additions and 11 deletions

View file

@ -13,6 +13,7 @@ use crate::{
descriptors::{
module::{ModuleDescriptor},
function::FnScopes,
Def,
Path,
},
Cancelable
@ -156,10 +157,14 @@ fn complete_path(
return Ok(());
}
path.segments.pop();
let target_module = match module.resolve_path(db, path)? {
let def_id = match module.resolve_path(db, path)? {
None => return Ok(()),
Some(it) => it,
};
let target_module = match def_id.resolve(db)? {
Def::Module(it) => it,
Def::Item => return Ok(()),
};
let module_scope = target_module.scope(db)?;
let completions = module_scope.entries().map(|(name, _res)| CompletionItem {
label: name.to_string(),