diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_path.rs | 62 |
1 files changed, 31 insertions, 31 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 74ea8d600..8713fb0f0 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs | |||
@@ -1,4 +1,4 @@ | |||
1 | use hir::{Resolution}; | 1 | use hir::Resolution; |
2 | use ra_syntax::{AstNode, ast::NameOwner}; | 2 | use ra_syntax::{AstNode, ast::NameOwner}; |
3 | use test_utils::tested_by; | 3 | use test_utils::tested_by; |
4 | 4 | ||
@@ -44,40 +44,40 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { | |||
44 | } | 44 | } |
45 | hir::ModuleDef::Struct(s) => { | 45 | hir::ModuleDef::Struct(s) => { |
46 | let ty = s.ty(ctx.db); | 46 | let ty = s.ty(ctx.db); |
47 | ty.iterate_impl_items(ctx.db, |item| match item { | 47 | ty.iterate_impl_items(ctx.db, |item| { |
48 | hir::ImplItem::Method(func) => { | 48 | match item { |
49 | let sig = func.signature(ctx.db); | 49 | hir::ImplItem::Method(func) => { |
50 | if !sig.has_self_param() { | 50 | let sig = func.signature(ctx.db); |
51 | acc.add_function(ctx, func); | 51 | if !sig.has_self_param() { |
52 | acc.add_function(ctx, func); | ||
53 | } | ||
52 | } | 54 | } |
53 | None::<()> | 55 | hir::ImplItem::Const(ct) => { |
54 | } | 56 | let source = ct.source(ctx.db); |
55 | hir::ImplItem::Const(ct) => { | 57 | if let Some(name) = source.1.name() { |
56 | let source = ct.source(ctx.db); | 58 | CompletionItem::new( |
57 | if let Some(name) = source.1.name() { | 59 | CompletionKind::Reference, |
58 | CompletionItem::new( | 60 | ctx.source_range(), |
59 | CompletionKind::Reference, | 61 | name.text().to_string(), |
60 | ctx.source_range(), | 62 | ) |
61 | name.text().to_string(), | 63 | .from_const(ctx, ct) |
62 | ) | 64 | .add_to(acc); |
63 | .from_const(ctx, ct) | 65 | } |
64 | .add_to(acc); | ||
65 | } | 66 | } |
66 | None::<()> | 67 | hir::ImplItem::Type(ty) => { |
67 | } | 68 | let source = ty.source(ctx.db); |
68 | hir::ImplItem::Type(ty) => { | 69 | if let Some(name) = source.1.name() { |
69 | let source = ty.source(ctx.db); | 70 | CompletionItem::new( |
70 | if let Some(name) = source.1.name() { | 71 | CompletionKind::Reference, |
71 | CompletionItem::new( | 72 | ctx.source_range(), |
72 | CompletionKind::Reference, | 73 | name.text().to_string(), |
73 | ctx.source_range(), | 74 | ) |
74 | name.text().to_string(), | 75 | .from_type(ctx, ty) |
75 | ) | 76 | .add_to(acc); |
76 | .from_type(ctx, ty) | 77 | } |
77 | .add_to(acc); | ||
78 | } | 78 | } |
79 | None::<()> | ||
80 | } | 79 | } |
80 | None::<()> | ||
81 | }); | 81 | }); |
82 | } | 82 | } |
83 | _ => return, | 83 | _ => return, |