aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion/complete_path.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_path.rs')
-rw-r--r--crates/ra_ide_api/src/completion/complete_path.rs39
1 files changed, 5 insertions, 34 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
index 8713fb0f0..8e453b0e0 100644
--- a/crates/ra_ide_api/src/completion/complete_path.rs
+++ b/crates/ra_ide_api/src/completion/complete_path.rs
@@ -1,8 +1,8 @@
1use hir::Resolution; 1use hir::Resolution;
2use ra_syntax::{AstNode, ast::NameOwner}; 2use ra_syntax::AstNode;
3use test_utils::tested_by; 3use test_utils::tested_by;
4 4
5use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionContext}; 5use crate::completion::{Completions, CompletionContext};
6 6
7pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { 7pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
8 let path = match &ctx.path_prefix { 8 let path = match &ctx.path_prefix {
@@ -27,14 +27,7 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
27 } 27 }
28 } 28 }
29 } 29 }
30 30 acc.add_resolution(ctx, name.to_string(), &res.def.map(hir::Resolution::Def));
31 CompletionItem::new(
32 CompletionKind::Reference,
33 ctx.source_range(),
34 name.to_string(),
35 )
36 .from_resolution(ctx, &res.def.map(hir::Resolution::Def))
37 .add_to(acc);
38 } 31 }
39 } 32 }
40 hir::ModuleDef::Enum(e) => { 33 hir::ModuleDef::Enum(e) => {
@@ -52,30 +45,8 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
52 acc.add_function(ctx, func); 45 acc.add_function(ctx, func);
53 } 46 }
54 } 47 }
55 hir::ImplItem::Const(ct) => { 48 hir::ImplItem::Const(ct) => acc.add_const(ctx, ct),
56 let source = ct.source(ctx.db); 49 hir::ImplItem::Type(ty) => acc.add_type(ctx, ty),
57 if let Some(name) = source.1.name() {
58 CompletionItem::new(
59 CompletionKind::Reference,
60 ctx.source_range(),
61 name.text().to_string(),
62 )
63 .from_const(ctx, ct)
64 .add_to(acc);
65 }
66 }
67 hir::ImplItem::Type(ty) => {
68 let source = ty.source(ctx.db);
69 if let Some(name) = source.1.name() {
70 CompletionItem::new(
71 CompletionKind::Reference,
72 ctx.source_range(),
73 name.text().to_string(),
74 )
75 .from_type(ctx, ty)
76 .add_to(acc);
77 }
78 }
79 } 50 }
80 None::<()> 51 None::<()>
81 }); 52 });