diff options
author | gfreezy <[email protected]> | 2019-01-19 16:38:34 +0000 |
---|---|---|
committer | gfreezy <[email protected]> | 2019-01-19 16:38:34 +0000 |
commit | 94d96b60f334e662f516bd0f04cc4191d7a804e6 (patch) | |
tree | 34ed5b9da22c938a5f7a3cac7a09de5812fa819f /crates/ra_ide_api/src/completion/complete_path.rs | |
parent | 64342599ca43fb72d0db8e79802a1018f480b5f5 (diff) |
refactor to use `remove_range` and `replace_range` instead of TextEdit
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_path.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_path.rs | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 7413c71e8..513a2ee89 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs | |||
@@ -15,18 +15,26 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { | |||
15 | hir::Def::Module(module) => { | 15 | hir::Def::Module(module) => { |
16 | let module_scope = module.scope(ctx.db); | 16 | let module_scope = module.scope(ctx.db); |
17 | for (name, res) in module_scope.entries() { | 17 | for (name, res) in module_scope.entries() { |
18 | CompletionItem::new(CompletionKind::Reference, ctx, name.to_string()) | 18 | CompletionItem::new( |
19 | .from_resolution(ctx, res) | 19 | CompletionKind::Reference, |
20 | .add_to(acc); | 20 | ctx.leaf_range(), |
21 | name.to_string(), | ||
22 | ) | ||
23 | .from_resolution(ctx, res) | ||
24 | .add_to(acc); | ||
21 | } | 25 | } |
22 | } | 26 | } |
23 | hir::Def::Enum(e) => { | 27 | hir::Def::Enum(e) => { |
24 | e.variants(ctx.db) | 28 | e.variants(ctx.db) |
25 | .into_iter() | 29 | .into_iter() |
26 | .for_each(|(variant_name, _variant)| { | 30 | .for_each(|(variant_name, _variant)| { |
27 | CompletionItem::new(CompletionKind::Reference, ctx, variant_name.to_string()) | 31 | CompletionItem::new( |
28 | .kind(CompletionItemKind::EnumVariant) | 32 | CompletionKind::Reference, |
29 | .add_to(acc) | 33 | ctx.leaf_range(), |
34 | variant_name.to_string(), | ||
35 | ) | ||
36 | .kind(CompletionItemKind::EnumVariant) | ||
37 | .add_to(acc) | ||
30 | }); | 38 | }); |
31 | } | 39 | } |
32 | _ => return, | 40 | _ => return, |