aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/completion/completion_item.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-21 22:27:07 +0000
committerAleksey Kladov <[email protected]>2018-12-21 22:42:26 +0000
commit25dda42f3773b1d002a5809c0182c2adc6c47027 (patch)
treecbfed6abbbd620a52443ddb6c8fecf4e80abd654 /crates/ra_analysis/src/completion/completion_item.rs
parentebb584ce669d04f109d5b21a08aca9d4e9acecc8 (diff)
introduce ComletionItemKind
Diffstat (limited to 'crates/ra_analysis/src/completion/completion_item.rs')
-rw-r--r--crates/ra_analysis/src/completion/completion_item.rs20
1 files changed, 16 insertions, 4 deletions
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 {
6 label: String, 6 label: String,
7 lookup: Option<String>, 7 lookup: Option<String>,
8 snippet: Option<String>, 8 snippet: Option<String>,
9 /// Used only internally in test, to check only specific kind of completion. 9 kind: Option<CompletionItemKind>,
10 /// Used only internally in tests, to check only specific kind of
11 /// completion.
10 completion_kind: CompletionKind, 12 completion_kind: CompletionKind,
11} 13}
12 14
@@ -15,6 +17,12 @@ pub enum InsertText {
15 Snippet { text: String }, 17 Snippet { text: String },
16} 18}
17 19
20#[derive(Debug, Clone, Copy, PartialEq, Eq)]
21pub enum CompletionItemKind {
22 Snippet,
23 Keyword,
24}
25
18#[derive(Debug, PartialEq, Eq)] 26#[derive(Debug, PartialEq, Eq)]
19pub(crate) enum CompletionKind { 27pub(crate) enum CompletionKind {
20 /// Parser-based keyword completion. 28 /// Parser-based keyword completion.
@@ -24,17 +32,16 @@ pub(crate) enum CompletionKind {
24 /// "Secret sauce" completions. 32 /// "Secret sauce" completions.
25 Magic, 33 Magic,
26 Snippet, 34 Snippet,
27 Unspecified,
28} 35}
29 36
30impl CompletionItem { 37impl CompletionItem {
31 pub(crate) fn new(label: impl Into<String>) -> Builder { 38 pub(crate) fn new(completion_kind: CompletionKind, label: impl Into<String>) -> Builder {
32 let label = label.into(); 39 let label = label.into();
33 Builder { 40 Builder {
34 label, 41 label,
35 lookup: None, 42 lookup: None,
36 snippet: None, 43 snippet: None,
37 completion_kind: CompletionKind::Unspecified, 44 completion_kind,
38 } 45 }
39 } 46 }
40 /// What user sees in pop-up in the UI. 47 /// What user sees in pop-up in the UI.
@@ -57,6 +64,10 @@ impl CompletionItem {
57 Some(it) => InsertText::Snippet { text: it.clone() }, 64 Some(it) => InsertText::Snippet { text: it.clone() },
58 } 65 }
59 } 66 }
67
68 pub fn kind(&self) -> Option<CompletionItemKind> {
69 self.kind
70 }
60} 71}
61 72
62/// A helper to make `CompletionItem`s. 73/// A helper to make `CompletionItem`s.
@@ -78,6 +89,7 @@ impl Builder {
78 label: self.label, 89 label: self.label,
79 lookup: self.lookup, 90 lookup: self.lookup,
80 snippet: self.snippet, 91 snippet: self.snippet,
92 kind: None,
81 completion_kind: self.completion_kind, 93 completion_kind: self.completion_kind,
82 } 94 }
83 } 95 }