From 576625f0a1c6e54075d173db7e691d75077ca677 Mon Sep 17 00:00:00 2001 From: "Jeremy A. Kolb" Date: Wed, 23 Jan 2019 16:22:10 -0500 Subject: Add way of getting docs from the code model and use for completion --- crates/ra_ide_api/src/completion/complete_path.rs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide_api/src/completion/complete_path.rs') diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index 6bed299d2..aeb226847 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::{ completion::{CompletionItem, CompletionItemKind, Completions, CompletionKind, CompletionContext}, }; +use hir::Docs; + pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { let (path, module) = match (&ctx.path_prefix, &ctx.module) { (Some(path), Some(module)) => (path.clone(), module), @@ -27,13 +29,14 @@ pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { hir::Def::Enum(e) => { e.variants(ctx.db) .into_iter() - .for_each(|(variant_name, _variant)| { + .for_each(|(variant_name, variant)| { CompletionItem::new( CompletionKind::Reference, ctx.source_range(), variant_name.to_string(), ) .kind(CompletionItemKind::EnumVariant) + .set_documentation(variant.docs(ctx.db)) .add_to(acc) }); } -- cgit v1.2.3 From 30f0736e646fe7cf4e133c78f0417e5bd844c525 Mon Sep 17 00:00:00 2001 From: "Jeremy A. Kolb" Date: Wed, 23 Jan 2019 18:50:46 -0500 Subject: Fix snap --- crates/ra_ide_api/src/completion/complete_path.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'crates/ra_ide_api/src/completion/complete_path.rs') diff --git a/crates/ra_ide_api/src/completion/complete_path.rs b/crates/ra_ide_api/src/completion/complete_path.rs index aeb226847..e44b76c4a 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs @@ -119,7 +119,13 @@ mod tests { "reference_completion", " //- /lib.rs - enum E { Foo, Bar(i32) } + /// An enum + enum E { + /// Foo Variant + Foo, + /// Bar Variant with i32 + Bar(i32) + } fn foo() { let _ = E::<|> } ", ); -- cgit v1.2.3