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.rs26
1 files changed, 5 insertions, 21 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
index d2f65310f..74ea8d600 100644
--- a/crates/ra_ide_api/src/completion/complete_path.rs
+++ b/crates/ra_ide_api/src/completion/complete_path.rs
@@ -1,9 +1,8 @@
1use join_to_string::join; 1use hir::{Resolution};
2use hir::{Docs, Resolution};
3use ra_syntax::{AstNode, ast::NameOwner}; 2use ra_syntax::{AstNode, ast::NameOwner};
4use test_utils::tested_by; 3use test_utils::tested_by;
5 4
6use crate::completion::{CompletionItem, CompletionItemKind, Completions, CompletionKind, CompletionContext}; 5use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionContext};
7 6
8pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { 7pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
9 let path = match &ctx.path_prefix { 8 let path = match &ctx.path_prefix {
@@ -39,24 +38,9 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
39 } 38 }
40 } 39 }
41 hir::ModuleDef::Enum(e) => { 40 hir::ModuleDef::Enum(e) => {
42 e.variants(ctx.db).into_iter().for_each(|variant| { 41 for variant in e.variants(ctx.db) {
43 if let Some(name) = variant.name(ctx.db) { 42 acc.add_enum_variant(ctx, variant);
44 let detail_types = 43 }
45 variant.fields(ctx.db).into_iter().map(|field| field.ty(ctx.db));
46 let detail =
47 join(detail_types).separator(", ").surround_with("(", ")").to_string();
48
49 CompletionItem::new(
50 CompletionKind::Reference,
51 ctx.source_range(),
52 name.to_string(),
53 )
54 .kind(CompletionItemKind::EnumVariant)
55 .set_documentation(variant.docs(ctx.db))
56 .set_detail(Some(detail))
57 .add_to(acc)
58 }
59 });
60 } 44 }
61 hir::ModuleDef::Struct(s) => { 45 hir::ModuleDef::Struct(s) => {
62 let ty = s.ty(ctx.db); 46 let ty = s.ty(ctx.db);