From 7b548de63405a07c1a4aa6aedb3e1993fe6b1e6c Mon Sep 17 00:00:00 2001 From: "Jeremy A. Kolb" Date: Wed, 23 Jan 2019 17:46:14 -0500 Subject: Add a bunch of new documentation to completions --- .../ra_ide_api/src/completion/completion_item.rs | 30 ++++++++++++---------- .../completion_item__reference_completion.snap | 20 ++++++++++----- 2 files changed, 30 insertions(+), 20 deletions(-) (limited to 'crates/ra_ide_api/src') 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 { resolution: &hir::Resolution, ) -> Builder { let resolved = resolution.def_id.map(|d| d.resolve(ctx.db)); - let kind = match resolved { + let (kind, docs) = match resolved { PerNs { types: Some(hir::Def::Module(..)), .. - } => CompletionItemKind::Module, + } => (CompletionItemKind::Module, None), PerNs { - types: Some(hir::Def::Struct(..)), + types: Some(hir::Def::Struct(s)), .. - } => CompletionItemKind::Struct, + } => (CompletionItemKind::Struct, s.docs(ctx.db)), PerNs { - types: Some(hir::Def::Enum(..)), + types: Some(hir::Def::Enum(e)), .. - } => CompletionItemKind::Enum, + } => (CompletionItemKind::Enum, e.docs(ctx.db)), PerNs { - types: Some(hir::Def::Trait(..)), + types: Some(hir::Def::Trait(t)), .. - } => CompletionItemKind::Trait, + } => (CompletionItemKind::Trait, t.docs(ctx.db)), PerNs { - types: Some(hir::Def::Type(..)), + types: Some(hir::Def::Type(t)), .. - } => CompletionItemKind::TypeAlias, + } => (CompletionItemKind::TypeAlias, t.docs(ctx.db)), PerNs { - values: Some(hir::Def::Const(..)), + values: Some(hir::Def::Const(c)), .. - } => CompletionItemKind::Const, + } => (CompletionItemKind::Const, c.docs(ctx.db)), PerNs { - values: Some(hir::Def::Static(..)), + values: Some(hir::Def::Static(s)), .. - } => CompletionItemKind::Static, + } => (CompletionItemKind::Static, s.docs(ctx.db)), PerNs { values: Some(hir::Def::Function(function)), .. @@ -246,6 +246,8 @@ impl Builder { _ => return self, }; self.kind = Some(kind); + self.documentation = docs; + self } 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 @@ --- -created: "2019-01-22T14:45:00.717917+00:00" -creator: insta@0.4.0 +created: "2019-01-23T21:14:09.186661600+00:00" +creator: insta@0.5.1 expression: kind_completions source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" --- @@ -12,11 +12,15 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" EnumVariant ), detail: None, - documentation: None, + documentation: Some( + Documentation( + "This is foo" + ) + ), lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [47; 47), + source_range: [109; 109), text_edit: None }, CompletionItem { @@ -26,11 +30,15 @@ source: "crates\\ra_ide_api\\src\\completion\\completion_item.rs" EnumVariant ), detail: None, - documentation: None, + documentation: Some( + Documentation( + "Use when we need an `i32`" + ) + ), lookup: None, insert_text: None, insert_text_format: PlainText, - source_range: [47; 47), + source_range: [109; 109), text_edit: None } ] -- cgit v1.2.3