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.rs13
1 files changed, 11 insertions, 2 deletions
diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs
index 6bed299d2..e44b76c4a 100644
--- a/crates/ra_ide_api/src/completion/complete_path.rs
+++ b/crates/ra_ide_api/src/completion/complete_path.rs
@@ -2,6 +2,8 @@ use crate::{
2 completion::{CompletionItem, CompletionItemKind, Completions, CompletionKind, CompletionContext}, 2 completion::{CompletionItem, CompletionItemKind, Completions, CompletionKind, CompletionContext},
3}; 3};
4 4
5use hir::Docs;
6
5pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { 7pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
6 let (path, module) = match (&ctx.path_prefix, &ctx.module) { 8 let (path, module) = match (&ctx.path_prefix, &ctx.module) {
7 (Some(path), Some(module)) => (path.clone(), module), 9 (Some(path), Some(module)) => (path.clone(), module),
@@ -27,13 +29,14 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) {
27 hir::Def::Enum(e) => { 29 hir::Def::Enum(e) => {
28 e.variants(ctx.db) 30 e.variants(ctx.db)
29 .into_iter() 31 .into_iter()
30 .for_each(|(variant_name, _variant)| { 32 .for_each(|(variant_name, variant)| {
31 CompletionItem::new( 33 CompletionItem::new(
32 CompletionKind::Reference, 34 CompletionKind::Reference,
33 ctx.source_range(), 35 ctx.source_range(),
34 variant_name.to_string(), 36 variant_name.to_string(),
35 ) 37 )
36 .kind(CompletionItemKind::EnumVariant) 38 .kind(CompletionItemKind::EnumVariant)
39 .set_documentation(variant.docs(ctx.db))
37 .add_to(acc) 40 .add_to(acc)
38 }); 41 });
39 } 42 }
@@ -116,7 +119,13 @@ mod tests {
116 "reference_completion", 119 "reference_completion",
117 " 120 "
118 //- /lib.rs 121 //- /lib.rs
119 enum E { Foo, Bar(i32) } 122 /// An enum
123 enum E {
124 /// Foo Variant
125 Foo,
126 /// Bar Variant with i32
127 Bar(i32)
128 }
120 fn foo() { let _ = E::<|> } 129 fn foo() { let _ = E::<|> }
121 ", 130 ",
122 ); 131 );