aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src
diff options
context:
space:
mode:
authorbors[bot] <bors[bot]@users.noreply.github.com>2019-01-25 19:49:54 +0000
committerbors[bot] <bors[bot]@users.noreply.github.com>2019-01-25 19:49:54 +0000
commite53eab3f25af2ebd381012f1b34f0bc52c6951eb (patch)
treefdb97e99f511d05aae145fe13ef3152883c24892 /crates/ra_ide_api/src
parent55906341a6f61e12df1dc0a4bda35dd9814ece8b (diff)
parent7a0bc2dd6402d681223be4198ec68ee7bb65d9ee (diff)
Merge #650
650: Add docs to struct fields r=matklad a=kjeremy Co-authored-by: Jeremy A. Kolb <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src')
-rw-r--r--crates/ra_ide_api/src/completion/complete_dot.rs8
-rw-r--r--crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap12
2 files changed, 14 insertions, 6 deletions
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 @@
1use hir::{Ty, AdtDef}; 1use hir::{Ty, AdtDef, Docs};
2 2
3use crate::completion::{CompletionContext, Completions, CompletionItem, CompletionItemKind}; 3use crate::completion::{CompletionContext, Completions, CompletionItem, CompletionItemKind};
4use crate::completion::completion_item::CompletionKind; 4use crate::completion::completion_item::CompletionKind;
@@ -38,6 +38,7 @@ fn complete_fields(acc: &mut Completions, ctx: &CompletionContext, receiver: Ty)
38 ) 38 )
39 .kind(CompletionItemKind::Field) 39 .kind(CompletionItemKind::Field)
40 .detail(field.ty(ctx.db).subst(substs).to_string()) 40 .detail(field.ty(ctx.db).subst(substs).to_string())
41 .set_documentation(field.docs(ctx.db))
41 .add_to(acc); 42 .add_to(acc);
42 } 43 }
43 } 44 }
@@ -107,7 +108,10 @@ mod tests {
107 check_ref_completion( 108 check_ref_completion(
108 "struct_field_completion_self", 109 "struct_field_completion_self",
109 r" 110 r"
110 struct A { the_field: (u32,) } 111 struct A {
112 /// This is the_field
113 the_field: (u32,)
114 }
111 impl A { 115 impl A {
112 fn foo(self) { 116 fn foo(self) {
113 self.<|> 117 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 @@
1--- 1---
2created: "2019-01-23T13:19:23.501297515+00:00" 2created: "2019-01-25T19:27:09.519688600+00:00"
3creator: [email protected] 3creator: [email protected]
4expression: kind_completions 4expression: kind_completions
5source: crates/ra_ide_api/src/completion/completion_item.rs 5source: crates/ra_ide_api/src/completion/completion_item.rs
@@ -14,11 +14,15 @@ source: crates/ra_ide_api/src/completion/completion_item.rs
14 detail: Some( 14 detail: Some(
15 "(u32,)" 15 "(u32,)"
16 ), 16 ),
17 documentation: None, 17 documentation: Some(
18 Documentation(
19 "This is the_field"
20 )
21 ),
18 lookup: None, 22 lookup: None,
19 insert_text: None, 23 insert_text: None,
20 insert_text_format: PlainText, 24 insert_text_format: PlainText,
21 source_range: [121; 121), 25 source_range: [187; 187),
22 text_edit: None 26 text_edit: None
23 }, 27 },
24 CompletionItem { 28 CompletionItem {
@@ -36,7 +40,7 @@ source: crates/ra_ide_api/src/completion/completion_item.rs
36 "foo()$0" 40 "foo()$0"
37 ), 41 ),
38 insert_text_format: Snippet, 42 insert_text_format: Snippet,
39 source_range: [121; 121), 43 source_range: [187; 187),
40 text_edit: None 44 text_edit: None
41 } 45 }
42] 46]