diff options
author | Aleksey Kladov <[email protected]> | 2019-01-23 20:14:13 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-24 10:29:19 +0000 |
commit | 3ab1519cb27b927074ed7fbbb18a856e6e7fabb8 (patch) | |
tree | 692c7a256604e188d38890966290bd1637d7dd60 /crates/ra_ide_api/src/completion/complete_path.rs | |
parent | cfb085ded8d61d7b744d0a83ecbb3da254f6ab9f (diff) |
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
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_path.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_path.rs | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index e44b76c4a..0d7942496 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs | |||
@@ -13,8 +13,8 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { | |||
13 | Some(it) => it, | 13 | Some(it) => it, |
14 | None => return, | 14 | None => return, |
15 | }; | 15 | }; |
16 | match def_id.resolve(ctx.db) { | 16 | match def_id { |
17 | hir::Def::Module(module) => { | 17 | hir::ModuleDef::Module(module) => { |
18 | let module_scope = module.scope(ctx.db); | 18 | let module_scope = module.scope(ctx.db); |
19 | for (name, res) in module_scope.entries() { | 19 | for (name, res) in module_scope.entries() { |
20 | CompletionItem::new( | 20 | CompletionItem::new( |
@@ -26,21 +26,24 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { | |||
26 | .add_to(acc); | 26 | .add_to(acc); |
27 | } | 27 | } |
28 | } | 28 | } |
29 | hir::Def::Enum(e) => { | 29 | |
30 | e.variants(ctx.db) | 30 | hir::ModuleDef::Def(def_id) => match def_id.resolve(ctx.db) { |
31 | .into_iter() | 31 | hir::Def::Enum(e) => { |
32 | .for_each(|(variant_name, variant)| { | 32 | e.variants(ctx.db) |
33 | CompletionItem::new( | 33 | .into_iter() |
34 | CompletionKind::Reference, | 34 | .for_each(|(variant_name, variant)| { |
35 | ctx.source_range(), | 35 | CompletionItem::new( |
36 | variant_name.to_string(), | 36 | CompletionKind::Reference, |
37 | ) | 37 | ctx.source_range(), |
38 | .kind(CompletionItemKind::EnumVariant) | 38 | variant_name.to_string(), |
39 | .set_documentation(variant.docs(ctx.db)) | 39 | ) |
40 | .add_to(acc) | 40 | .kind(CompletionItemKind::EnumVariant) |
41 | }); | 41 | .set_documentation(variant.docs(ctx.db)) |
42 | } | 42 | .add_to(acc) |
43 | _ => return, | 43 | }); |
44 | } | ||
45 | _ => return, | ||
46 | }, | ||
44 | }; | 47 | }; |
45 | } | 48 | } |
46 | 49 | ||