From 5d110c0ee2ec50009eb7c552888a73ce8380d34a Mon Sep 17 00:00:00 2001 From: Jeremy Kolb Date: Mon, 21 Jan 2019 21:41:39 -0500 Subject: Teach CompletionItem about documentation --- crates/ra_ide_api/src/completion/completion_item.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'crates/ra_ide_api/src/completion') diff --git a/crates/ra_ide_api/src/completion/completion_item.rs b/crates/ra_ide_api/src/completion/completion_item.rs index c892ad846..672c7ed0e 100644 --- a/crates/ra_ide_api/src/completion/completion_item.rs +++ b/crates/ra_ide_api/src/completion/completion_item.rs @@ -15,6 +15,7 @@ pub struct CompletionItem { label: String, kind: Option, detail: Option, + documentation: Option, lookup: Option, insert_text: Option, insert_text_format: InsertTextFormat, @@ -77,6 +78,7 @@ impl CompletionItem { insert_text: None, insert_text_format: InsertTextFormat::PlainText, detail: None, + documentation: None, lookup: None, kind: None, text_edit: None, @@ -90,6 +92,10 @@ impl CompletionItem { pub fn detail(&self) -> Option<&str> { self.detail.as_ref().map(|it| it.as_str()) } + /// A doc-comment + pub fn documentation(&self) -> Option<&str> { + self.documentation.as_ref().map(|it| it.as_str()) + } /// What string is used for filtering. pub fn lookup(&self) -> &str { self.lookup @@ -127,6 +133,7 @@ pub(crate) struct Builder { insert_text: Option, insert_text_format: InsertTextFormat, detail: Option, + documentation: Option, lookup: Option, kind: Option, text_edit: Option, @@ -142,6 +149,7 @@ impl Builder { source_range: self.source_range, label: self.label, detail: self.detail, + documentation: self.documentation, insert_text_format: self.insert_text_format, lookup: self.lookup, kind: self.kind, @@ -184,6 +192,14 @@ impl Builder { self.detail = detail.map(Into::into); self } + #[allow(unused)] + pub(crate) fn documentation(self, docs: impl Into) -> Builder { + self.set_documentation(Some(docs)) + } + pub(crate) fn set_documentation(mut self, docs: Option>) -> Builder { + self.documentation = docs.map(Into::into); + self + } pub(super) fn from_resolution( mut self, ctx: &CompletionContext, -- cgit v1.2.3