aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_hir/src/code_model_api.rs24
-rw-r--r--crates/ra_ide_api/src/completion/completion_item.rs30
-rw-r--r--crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap20
3 files changed, 54 insertions, 20 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs
index 333d117f1..3ff07bd60 100644
--- a/crates/ra_hir/src/code_model_api.rs
+++ b/crates/ra_hir/src/code_model_api.rs
@@ -394,6 +394,12 @@ impl Const {
394 } 394 }
395} 395}
396 396
397impl Docs for Const {
398 fn docs(&self, db: &impl HirDatabase) -> Option<Documentation> {
399 docs_from_ast(&*self.source(db).1)
400 }
401}
402
397#[derive(Debug, Clone, PartialEq, Eq, Hash)] 403#[derive(Debug, Clone, PartialEq, Eq, Hash)]
398pub struct Static { 404pub struct Static {
399 pub(crate) def_id: DefId, 405 pub(crate) def_id: DefId,
@@ -409,6 +415,12 @@ impl Static {
409 } 415 }
410} 416}
411 417
418impl Docs for Static {
419 fn docs(&self, db: &impl HirDatabase) -> Option<Documentation> {
420 docs_from_ast(&*self.source(db).1)
421 }
422}
423
412#[derive(Debug, Clone, PartialEq, Eq, Hash)] 424#[derive(Debug, Clone, PartialEq, Eq, Hash)]
413pub struct Trait { 425pub struct Trait {
414 pub(crate) def_id: DefId, 426 pub(crate) def_id: DefId,
@@ -428,6 +440,12 @@ impl Trait {
428 } 440 }
429} 441}
430 442
443impl Docs for Trait {
444 fn docs(&self, db: &impl HirDatabase) -> Option<Documentation> {
445 docs_from_ast(&*self.source(db).1)
446 }
447}
448
431#[derive(Debug, Clone, PartialEq, Eq, Hash)] 449#[derive(Debug, Clone, PartialEq, Eq, Hash)]
432pub struct Type { 450pub struct Type {
433 pub(crate) def_id: DefId, 451 pub(crate) def_id: DefId,
@@ -446,3 +464,9 @@ impl Type {
446 db.generic_params(self.def_id) 464 db.generic_params(self.def_id)
447 } 465 }
448} 466}
467
468impl Docs for Type {
469 fn docs(&self, db: &impl HirDatabase) -> Option<Documentation> {
470 docs_from_ast(&*self.source(db).1)
471 }
472}
diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs
index 8e0be4c4b..18c151932 100644
--- a/crates/ra_ide_api/src/completion/completion_item.rs
+++ b/crates/ra_ide_api/src/completion/completion_item.rs
@@ -210,35 +210,35 @@ impl Builder {
210 resolution: &hir::Resolution, 210 resolution: &hir::Resolution,
211 ) -> Builder { 211 ) -> Builder {
212 let resolved = resolution.def_id.map(|d| d.resolve(ctx.db)); 212 let resolved = resolution.def_id.map(|d| d.resolve(ctx.db));
213 let kind = match resolved { 213 let (kind, docs) = match resolved {
214 PerNs { 214 PerNs {
215 types: Some(hir::Def::Module(..)), 215 types: Some(hir::Def::Module(..)),
216 .. 216 ..
217 } => CompletionItemKind::Module, 217 } => (CompletionItemKind::Module, None),
218 PerNs { 218 PerNs {
219 types: Some(hir::Def::Struct(..)), 219 types: Some(hir::Def::Struct(s)),
220 .. 220 ..
221 } => CompletionItemKind::Struct, 221 } => (CompletionItemKind::Struct, s.docs(ctx.db)),
222 PerNs { 222 PerNs {
223 types: Some(hir::Def::Enum(..)), 223 types: Some(hir::Def::Enum(e)),
224 .. 224 ..
225 } => CompletionItemKind::Enum, 225 } => (CompletionItemKind::Enum, e.docs(ctx.db)),
226 PerNs { 226 PerNs {
227 types: Some(hir::Def::Trait(..)), 227 types: Some(hir::Def::Trait(t)),
228 .. 228 ..
229 } => CompletionItemKind::Trait, 229 } => (CompletionItemKind::Trait, t.docs(ctx.db)),
230 PerNs { 230 PerNs {
231 types: Some(hir::Def::Type(..)), 231 types: Some(hir::Def::Type(t)),
232 .. 232 ..
233 } => CompletionItemKind::TypeAlias, 233 } => (CompletionItemKind::TypeAlias, t.docs(ctx.db)),
234 PerNs { 234 PerNs {
235 values: Some(hir::Def::Const(..)), 235 values: Some(hir::Def::Const(c)),
236 .. 236 ..
237 } => CompletionItemKind::Const, 237 } => (CompletionItemKind::Const, c.docs(ctx.db)),
238 PerNs { 238 PerNs {
239 values: Some(hir::Def::Static(..)), 239 values: Some(hir::Def::Static(s)),
240 .. 240 ..
241 } => CompletionItemKind::Static, 241 } => (CompletionItemKind::Static, s.docs(ctx.db)),
242 PerNs { 242 PerNs {
243 values: Some(hir::Def::Function(function)), 243 values: Some(hir::Def::Function(function)),
244 .. 244 ..
@@ -246,6 +246,8 @@ impl Builder {
246 _ => return self, 246 _ => return self,
247 }; 247 };
248 self.kind = Some(kind); 248 self.kind = Some(kind);
249 self.documentation = docs;
250
249 self 251 self
250 } 252 }
251 253
diff --git a/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap b/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap
index 0180a4f44..9779541b3 100644
--- a/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap
+++ b/crates/ra_ide_api/src/completion/snapshots/completion_item__reference_completion.snap
@@ -1,6 +1,6 @@
1--- 1---
2created: "2019-01-22T14:45:00.717917+00:00" 2created: "2019-01-23T21:14:09.186661600+00:00"
3creator: insta@0.4.0 3creator: insta@0.5.1
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"
6--- 6---
@@ -12,11 +12,15 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs"
12 EnumVariant 12 EnumVariant
13 ), 13 ),
14 detail: None, 14 detail: None,
15 documentation: None, 15 documentation: Some(
16 Documentation(
17 "This is foo"
18 )
19 ),
16 lookup: None, 20 lookup: None,
17 insert_text: None, 21 insert_text: None,
18 insert_text_format: PlainText, 22 insert_text_format: PlainText,
19 source_range: [47; 47), 23 source_range: [109; 109),
20 text_edit: None 24 text_edit: None
21 }, 25 },
22 CompletionItem { 26 CompletionItem {
@@ -26,11 +30,15 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs"
26 EnumVariant 30 EnumVariant
27 ), 31 ),
28 detail: None, 32 detail: None,
29 documentation: None, 33 documentation: Some(
34 Documentation(
35 "Use when we need an `i32`"
36 )
37 ),
30 lookup: None, 38 lookup: None,
31 insert_text: None, 39 insert_text: None,
32 insert_text_format: PlainText, 40 insert_text_format: PlainText,
33 source_range: [47; 47), 41 source_range: [109; 109),
34 text_edit: None 42 text_edit: None
35 } 43 }
36] 44]