From 7a0bc2dd6402d681223be4198ec68ee7bb65d9ee Mon Sep 17 00:00:00 2001 From: "Jeremy A. Kolb" Date: Fri, 25 Jan 2019 14:29:56 -0500 Subject: Add docs to struct fields --- crates/ra_ide_api/src/completion/complete_dot.rs | 8 ++++++-- .../completion_item__struct_field_completion_self.snap | 12 ++++++++---- 2 files changed, 14 insertions(+), 6 deletions(-) (limited to 'crates/ra_ide_api/src') diff --git a/crates/ra_ide_api/src/completion/complete_dot.rs b/crates/ra_ide_api/src/completion/complete_dot.rs index 060a46c5e..bad51cc51 100644 --- a/crates/ra_ide_api/src/completion/complete_dot.rs +++ b/crates/ra_ide_api/src/completion/complete_dot.rs @@ -1,4 +1,4 @@ -use hir::{Ty, AdtDef}; +use hir::{Ty, AdtDef, Docs}; use crate::completion::{CompletionContext, Completions, CompletionItem, CompletionItemKind}; use crate::completion::completion_item::CompletionKind; @@ -38,6 +38,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty) ) .kind(CompletionItemKind::Field) .detail(field.ty(ctx.db).subst(substs).to_string()) + .set_documentation(field.docs(ctx.db)) .add_to(acc); } } @@ -107,7 +108,10 @@ mod tests { check_ref_completion( "struct_field_completion_self", r" - struct A { the_field: (u32,) } + struct A { + /// This is the_field + the_field: (u32,) + } impl A { fn foo(self) { self.<|> diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap index 80e8f3df5..580e92a90 100644 --- a/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap @@ -1,5 +1,5 @@ --- -created: "2019-01-23T13:19:23.501297515+00:00" +created: "2019-01-25T19:27:09.519688600+00:00" creator: insta@0.5.2 expression: kind_completions source: crates/ra_ide_api/src/completion/completion_item.rs @@ -14,11 +14,15 @@ source: crates/ra_ide_api/src/completion/completion_item.rs detail: Some( "(u32,)" ), - documentation: None, + documentation: Some( + Documentation( + "This is the_field" + ) + ), lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [121; 121), + source_range: [187; 187), text_edit: None }, CompletionItem { @@ -36,7 +40,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs "foo()$0" ), insert_text_format: Snippet, - source_range: [121; 121), + source_range: [187; 187), text_edit: None } ] -- cgit v1.2.3