mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 13:51:31 +00:00
Teach CompletionItem about documentation
This commit is contained in:
parent
b59334e67a
commit
5d110c0ee2
2 changed files with 26 additions and 2 deletions
|
@ -15,6 +15,7 @@ pub struct CompletionItem {
|
|||
label: String,
|
||||
kind: Option<CompletionItemKind>,
|
||||
detail: Option<String>,
|
||||
documentation: Option<String>,
|
||||
lookup: Option<String>,
|
||||
insert_text: Option<String>,
|
||||
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<String>,
|
||||
insert_text_format: InsertTextFormat,
|
||||
detail: Option<String>,
|
||||
documentation: Option<String>,
|
||||
lookup: Option<String>,
|
||||
kind: Option<CompletionItemKind>,
|
||||
text_edit: Option<TextEdit>,
|
||||
|
@ -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<String>) -> Builder {
|
||||
self.set_documentation(Some(docs))
|
||||
}
|
||||
pub(crate) fn set_documentation(mut self, docs: Option<impl Into<String>>) -> Builder {
|
||||
self.documentation = docs.map(Into::into);
|
||||
self
|
||||
}
|
||||
pub(super) fn from_resolution(
|
||||
mut self,
|
||||
ctx: &CompletionContext,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue