Change ids strategy

this is a part of larghish hir refactoring which aims to

* replace per-source-root module trees with per crate trees
* switch from a monotyped DedId to type-specific ids
This commit is contained in:
Aleksey Kladov 2019-01-23 23:14:13 +03:00
parent cfb085ded8
commit 3ab1519cb2
26 changed files with 365 additions and 430 deletions

View file

@ -13,8 +13,8 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
Some(it) => it,
None => return,
};
match def_id.resolve(ctx.db) {
hir::Def::Module(module) => {
match def_id {
hir::ModuleDef::Module(module) => {
let module_scope = module.scope(ctx.db);
for (name, res) in module_scope.entries() {
CompletionItem::new(
@ -26,21 +26,24 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
.add_to(acc);
}
}
hir::Def::Enum(e) => {
e.variants(ctx.db)
.into_iter()
.for_each(|(variant_name, variant)| {
CompletionItem::new(
CompletionKind::Reference,
ctx.source_range(),
variant_name.to_string(),
)
.kind(CompletionItemKind::EnumVariant)
.set_documentation(variant.docs(ctx.db))
.add_to(acc)
});
}
_ => return,
hir::ModuleDef::Def(def_id) => match def_id.resolve(ctx.db) {
hir::Def::Enum(e) => {
e.variants(ctx.db)
.into_iter()
.for_each(|(variant_name, variant)| {
CompletionItem::new(
CompletionKind::Reference,
ctx.source_range(),
variant_name.to_string(),
)
.kind(CompletionItemKind::EnumVariant)
.set_documentation(variant.docs(ctx.db))
.add_to(acc)
});
}
_ => return,
},
};
}