From 25dda42f3773b1d002a5809c0182c2adc6c47027 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 22 Dec 2018 01:27:07 +0300 Subject: introduce ComletionItemKind --- crates/ra_analysis/src/completion/completion_item.rs | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'crates/ra_analysis/src/completion/completion_item.rs') diff --git a/crates/ra_analysis/src/completion/completion_item.rs b/crates/ra_analysis/src/completion/completion_item.rs index 30581c8a5..423d5a48b 100644 --- a/crates/ra_analysis/src/completion/completion_item.rs +++ b/crates/ra_analysis/src/completion/completion_item.rs @@ -6,7 +6,9 @@ pub struct CompletionItem { label: String, lookup: Option, snippet: Option, - /// Used only internally in test, to check only specific kind of completion. + kind: Option, + /// Used only internally in tests, to check only specific kind of + /// completion. completion_kind: CompletionKind, } @@ -15,6 +17,12 @@ pub enum InsertText { Snippet { text: String }, } +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +pub enum CompletionItemKind { + Snippet, + Keyword, +} + #[derive(Debug, PartialEq, Eq)] pub(crate) enum CompletionKind { /// Parser-based keyword completion. @@ -24,17 +32,16 @@ pub(crate) enum CompletionKind { /// "Secret sauce" completions. Magic, Snippet, - Unspecified, } impl CompletionItem { - pub(crate) fn new(label: impl Into) -> Builder { + pub(crate) fn new(completion_kind: CompletionKind, label: impl Into) -> Builder { let label = label.into(); Builder { label, lookup: None, snippet: None, - completion_kind: CompletionKind::Unspecified, + completion_kind, } } /// What user sees in pop-up in the UI. @@ -57,6 +64,10 @@ impl CompletionItem { Some(it) => InsertText::Snippet { text: it.clone() }, } } + + pub fn kind(&self) -> Option { + self.kind + } } /// A helper to make `CompletionItem`s. @@ -78,6 +89,7 @@ impl Builder { label: self.label, lookup: self.lookup, snippet: self.snippet, + kind: None, completion_kind: self.completion_kind, } } -- cgit v1.2.3