diff options
author | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-25 17:55:29 +0000 |
---|---|---|
committer | bors[bot] <bors[bot]@users.noreply.github.com> | 2019-01-25 17:55:29 +0000 |
commit | cc73d3ccbc6bc066e7580ece0e64808c8c8056e7 (patch) | |
tree | dcb396d86fff5fe40c6360030706c2181dd6562e /crates/ra_ide_api/src/completion | |
parent | daaba4be17cae9ee32a2e151e256ef71f600814e (diff) | |
parent | 65885791165c42b48fa2deaed32c4f35c17c62f5 (diff) |
Merge #646
646: Add module documentation support r=matklad a=kjeremy
Co-authored-by: Jeremy A. Kolb <[email protected]>
Diffstat (limited to 'crates/ra_ide_api/src/completion')
3 files changed, 43 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 172aedf95..b33ddcde5 100644 --- a/crates/ra_ide_api/src/completion/complete_path.rs +++ b/crates/ra_ide_api/src/completion/complete_path.rs | |||
@@ -66,6 +66,22 @@ mod tests { | |||
66 | } | 66 | } |
67 | 67 | ||
68 | #[test] | 68 | #[test] |
69 | fn completes_mod_with_docs() { | ||
70 | check_reference_completion( | ||
71 | "mod_with_docs", | ||
72 | r" | ||
73 | use self::my<|>; | ||
74 | |||
75 | /// Some simple | ||
76 | /// docs describing `mod my`. | ||
77 | mod my { | ||
78 | struct Bar; | ||
79 | } | ||
80 | ", | ||
81 | ); | ||
82 | } | ||
83 | |||
84 | #[test] | ||
69 | fn completes_use_item_starting_with_self() { | 85 | fn completes_use_item_starting_with_self() { |
70 | check_reference_completion( | 86 | check_reference_completion( |
71 | "use_item_starting_with_self", | 87 | "use_item_starting_with_self", |
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index b2b047766..b16ac2b28 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs | |||
@@ -215,7 +215,7 @@ impl Builder { | |||
215 | Some(it) => it, | 215 | Some(it) => it, |
216 | }; | 216 | }; |
217 | let (kind, docs) = match def { | 217 | let (kind, docs) = match def { |
218 | hir::ModuleDef::Module(_) => (CompletionItemKind::Module, None), | 218 | hir::ModuleDef::Module(it) => (CompletionItemKind::Module, it.docs(ctx.db)), |
219 | hir::ModuleDef::Function(func) => return self.from_function(ctx, func), | 219 | hir::ModuleDef::Function(func) => return self.from_function(ctx, func), |
220 | hir::ModuleDef::Struct(it) => (CompletionItemKind::Struct, it.docs(ctx.db)), | 220 | hir::ModuleDef::Struct(it) => (CompletionItemKind::Struct, it.docs(ctx.db)), |
221 | hir::ModuleDef::Enum(it) => (CompletionItemKind::Enum, it.docs(ctx.db)), | 221 | hir::ModuleDef::Enum(it) => (CompletionItemKind::Enum, it.docs(ctx.db)), |
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__mod_with_docs.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__mod_with_docs.snap new file mode 100644 index 000000000..3db7119a7 --- /dev/null +++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__mod_with_docs.snap | |||
@@ -0,0 +1,26 @@ | |||
1 | --- | ||
2 | created: "2019-01-25T17:49:28.949186500+00:00" | ||
3 | creator: [email protected] | ||
4 | expression: kind_completions | ||
5 | source: crates/ra_ide_api/src/completion/completion_item.rs | ||
6 | --- | ||
7 | [ | ||
8 | CompletionItem { | ||
9 | completion_kind: Reference, | ||
10 | label: "my", | ||
11 | kind: Some( | ||
12 | Module | ||
13 | ), | ||
14 | detail: None, | ||
15 | documentation: Some( | ||
16 | Documentation( | ||
17 | "Some simple\ndocs describing `mod my`." | ||
18 | ) | ||
19 | ), | ||
20 | lookup: None, | ||
21 | insert_text: None, | ||
22 | insert_text_format: PlainText, | ||
23 | source_range: [23; 25), | ||
24 | text_edit: None | ||
25 | } | ||
26 | ] | ||