diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 9 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/complete_dot.rs | 8 | ||||
-rw-r--r-- | crates/ra_ide_api/src/completion/snapshots/completion_item__struct_field_completion_self.snap | 12 | ||||
-rw-r--r-- | crates/ra_syntax/src/ast/generated.rs | 1 | ||||
-rw-r--r-- | crates/ra_syntax/src/grammar.ron | 2 | ||||
-rw-r--r-- | crates/ra_syntax/src/parser_impl/event.rs | 2 |
6 files changed, 26 insertions, 8 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs index 1e88bff8b..41bac05c6 100644 --- a/crates/ra_hir/src/code_model_api.rs +++ b/crates/ra_hir/src/code_model_api.rs | |||
@@ -216,6 +216,15 @@ impl StructField { | |||
216 | } | 216 | } |
217 | } | 217 | } |
218 | 218 | ||
219 | impl Docs for StructField { | ||
220 | fn docs(&self, db: &impl HirDatabase) -> Option<Documentation> { | ||
221 | match self.source(db).1 { | ||
222 | FieldSource::Named(named) => docs_from_ast(&*named), | ||
223 | FieldSource::Pos(..) => return None, | ||
224 | } | ||
225 | } | ||
226 | } | ||
227 | |||
219 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | 228 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] |
220 | pub struct Struct { | 229 | pub struct Struct { |
221 | pub(crate) id: StructId, | 230 | pub(crate) id: StructId, |
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 @@ | |||
1 | use hir::{Ty, AdtDef}; | 1 | use hir::{Ty, AdtDef, Docs}; |
2 | 2 | ||
3 | use crate::completion::{CompletionContext, Completions, CompletionItem, CompletionItemKind}; | 3 | use crate::completion::{CompletionContext, Completions, CompletionItem, CompletionItemKind}; |
4 | use crate::completion::completion_item::CompletionKind; | 4 | use 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 | --- |
2 | created: "2019-01-23T13:19:23.501297515+00:00" | 2 | created: "2019-01-25T19:27:09.519688600+00:00" |
3 | creator: [email protected] | 3 | creator: [email protected] |
4 | expression: kind_completions | 4 | expression: kind_completions |
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | 5 | source: 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 | ] |
diff --git a/crates/ra_syntax/src/ast/generated.rs b/crates/ra_syntax/src/ast/generated.rs index 7da19d782..e936c2a6d 100644 --- a/crates/ra_syntax/src/ast/generated.rs +++ b/crates/ra_syntax/src/ast/generated.rs | |||
@@ -2248,6 +2248,7 @@ impl ToOwned for NamedFieldDef { | |||
2248 | impl ast::VisibilityOwner for NamedFieldDef {} | 2248 | impl ast::VisibilityOwner for NamedFieldDef {} |
2249 | impl ast::NameOwner for NamedFieldDef {} | 2249 | impl ast::NameOwner for NamedFieldDef {} |
2250 | impl ast::AttrsOwner for NamedFieldDef {} | 2250 | impl ast::AttrsOwner for NamedFieldDef {} |
2251 | impl ast::DocCommentsOwner for NamedFieldDef {} | ||
2251 | impl NamedFieldDef { | 2252 | impl NamedFieldDef { |
2252 | pub fn type_ref(&self) -> Option<&TypeRef> { | 2253 | pub fn type_ref(&self) -> Option<&TypeRef> { |
2253 | super::child_opt(self) | 2254 | super::child_opt(self) |
diff --git a/crates/ra_syntax/src/grammar.ron b/crates/ra_syntax/src/grammar.ron index cb5d6cde8..a92d9bbda 100644 --- a/crates/ra_syntax/src/grammar.ron +++ b/crates/ra_syntax/src/grammar.ron | |||
@@ -268,7 +268,7 @@ Grammar( | |||
268 | ] | 268 | ] |
269 | ), | 269 | ), |
270 | "NamedFieldDefList": (collections: [["fields", "NamedFieldDef"]]), | 270 | "NamedFieldDefList": (collections: [["fields", "NamedFieldDef"]]), |
271 | "NamedFieldDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner"], options: ["TypeRef"] ), | 271 | "NamedFieldDef": ( traits: ["VisibilityOwner", "NameOwner", "AttrsOwner", "DocCommentsOwner"], options: ["TypeRef"] ), |
272 | "PosFieldList": (collections: [["fields", "PosField"]]), | 272 | "PosFieldList": (collections: [["fields", "PosField"]]), |
273 | "PosField": ( traits: ["VisibilityOwner", "AttrsOwner"], options: ["TypeRef"]), | 273 | "PosField": ( traits: ["VisibilityOwner", "AttrsOwner"], options: ["TypeRef"]), |
274 | "EnumDef": ( traits: [ | 274 | "EnumDef": ( traits: [ |
diff --git a/crates/ra_syntax/src/parser_impl/event.rs b/crates/ra_syntax/src/parser_impl/event.rs index bd77fee89..33e10ef85 100644 --- a/crates/ra_syntax/src/parser_impl/event.rs +++ b/crates/ra_syntax/src/parser_impl/event.rs | |||
@@ -250,7 +250,7 @@ fn n_attached_trivias<'a>( | |||
250 | ) -> usize { | 250 | ) -> usize { |
251 | match kind { | 251 | match kind { |
252 | CONST_DEF | TYPE_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF | TRAIT_DEF | 252 | CONST_DEF | TYPE_DEF | STRUCT_DEF | ENUM_DEF | ENUM_VARIANT | FN_DEF | TRAIT_DEF |
253 | | MODULE => { | 253 | | MODULE | NAMED_FIELD_DEF => { |
254 | let mut res = 0; | 254 | let mut res = 0; |
255 | for (i, (kind, text)) in trivias.enumerate() { | 255 | for (i, (kind, text)) in trivias.enumerate() { |
256 | match kind { | 256 | match kind { |