mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 05:45:12 +00:00
add completion detail
This commit is contained in:
parent
c2b8aa1ce5
commit
ddf2a8a948
2 changed files with 13 additions and 0 deletions
|
@ -11,6 +11,7 @@ pub struct CompletionItem {
|
|||
/// completion.
|
||||
completion_kind: CompletionKind,
|
||||
label: String,
|
||||
detail: Option<String>,
|
||||
lookup: Option<String>,
|
||||
snippet: Option<String>,
|
||||
kind: Option<CompletionItemKind>,
|
||||
|
@ -51,6 +52,7 @@ impl CompletionItem {
|
|||
Builder {
|
||||
completion_kind,
|
||||
label,
|
||||
detail: None,
|
||||
lookup: None,
|
||||
snippet: None,
|
||||
kind: None,
|
||||
|
@ -60,6 +62,10 @@ impl CompletionItem {
|
|||
pub fn label(&self) -> &str {
|
||||
&self.label
|
||||
}
|
||||
/// Short one-line additional information, like a type
|
||||
pub fn detail(&self) -> Option<&str> {
|
||||
self.detail.as_ref().map(|it| it.as_str())
|
||||
}
|
||||
/// What string is used for filtering.
|
||||
pub fn lookup(&self) -> &str {
|
||||
self.lookup
|
||||
|
@ -87,6 +93,7 @@ impl CompletionItem {
|
|||
pub(crate) struct Builder {
|
||||
completion_kind: CompletionKind,
|
||||
label: String,
|
||||
detail: Option<String>,
|
||||
lookup: Option<String>,
|
||||
snippet: Option<String>,
|
||||
kind: Option<CompletionItemKind>,
|
||||
|
@ -100,6 +107,7 @@ impl Builder {
|
|||
pub(crate) fn build(self) -> CompletionItem {
|
||||
CompletionItem {
|
||||
label: self.label,
|
||||
detail: self.detail,
|
||||
lookup: self.lookup,
|
||||
snippet: self.snippet,
|
||||
kind: self.kind,
|
||||
|
@ -118,6 +126,10 @@ impl Builder {
|
|||
self.kind = Some(kind);
|
||||
self
|
||||
}
|
||||
pub(crate) fn detail(mut self, detail: impl Into<String>) -> Builder {
|
||||
self.detail = Some(detail.into());
|
||||
self
|
||||
}
|
||||
pub(super) fn from_resolution(
|
||||
mut self,
|
||||
ctx: &CompletionContext,
|
||||
|
|
|
@ -75,6 +75,7 @@ impl Conv for CompletionItem {
|
|||
fn conv(self) -> <Self as Conv>::Output {
|
||||
let mut res = ::languageserver_types::CompletionItem {
|
||||
label: self.label().to_string(),
|
||||
detail: self.detail().map(|it| it.to_string()),
|
||||
filter_text: Some(self.lookup().to_string()),
|
||||
kind: self.kind().map(|it| it.conv()),
|
||||
..Default::default()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue