diff options
author | Jeremy A. Kolb <[email protected]> | 2019-01-23 21:22:10 +0000 |
---|---|---|
committer | Jeremy A. Kolb <[email protected]> | 2019-01-23 21:32:04 +0000 |
commit | 576625f0a1c6e54075d173db7e691d75077ca677 (patch) | |
tree | 72c1fadf48265e7f5355eb72586de4bcdab43cec /crates/ra_ide_api/src/completion/complete_path.rs | |
parent | 6a6ce2bc959c346aed7a98c8509d1aa3d19ec8a9 (diff) |
Add way of getting docs from the code model and use for completion
Diffstat (limited to 'crates/ra_ide_api/src/completion/complete_path.rs')
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_path.rs | 5 |
1 files changed, 4 insertions, 1 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..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::{ | |||
2 | completion::{CompletionItem, CompletionItemKind, Completions, CompletionKind, CompletionContext}, | 2 | completion::{CompletionItem, CompletionItemKind, Completions, CompletionKind, CompletionContext}, |
3 | }; | 3 | }; |
4 | 4 | ||
5 | use hir::Docs; | ||
6 | |||
5 | pub(super) fn complete_path(acc: &mut Completions, ctx: &CompletionContext) { | 7 | pub(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 | } |