aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/completion/completion_item.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-12-21 22:37:11 +0000
committerAleksey Kladov <[email protected]>2018-12-21 22:42:26 +0000
commit328d123f5baeab8ff9a1f63a6744f6eec89818ab (patch)
tree673bdc09262b66ef825d7363ae05f79359555309 /crates/ra_analysis/src/completion/completion_item.rs
parent284e89406906b97eec8e0f91bce2955a5e94b880 (diff)
specify completion item kind
Diffstat (limited to 'crates/ra_analysis/src/completion/completion_item.rs')
-rw-r--r--crates/ra_analysis/src/completion/completion_item.rs18
1 files changed, 10 insertions, 8 deletions
diff --git a/crates/ra_analysis/src/completion/completion_item.rs b/crates/ra_analysis/src/completion/completion_item.rs
index 423d5a48b..89fbe62d8 100644
--- a/crates/ra_analysis/src/completion/completion_item.rs
+++ b/crates/ra_analysis/src/completion/completion_item.rs
@@ -3,13 +3,13 @@
3/// `CompletionItem`, use `new` method and the `Builder` struct. 3/// `CompletionItem`, use `new` method and the `Builder` struct.
4#[derive(Debug)] 4#[derive(Debug)]
5pub struct CompletionItem { 5pub struct CompletionItem {
6 /// Used only internally in tests, to check only specific kind of
7 /// completion.
8 completion_kind: CompletionKind,
6 label: String, 9 label: String,
7 lookup: Option<String>, 10 lookup: Option<String>,
8 snippet: Option<String>, 11 snippet: Option<String>,
9 kind: Option<CompletionItemKind>, 12 kind: Option<CompletionItemKind>,
10 /// Used only internally in tests, to check only specific kind of
11 /// completion.
12 completion_kind: CompletionKind,
13} 13}
14 14
15pub enum InsertText { 15pub enum InsertText {
@@ -38,10 +38,11 @@ impl CompletionItem {
38 pub(crate) fn new(completion_kind: CompletionKind, label: impl Into<String>) -> Builder { 38 pub(crate) fn new(completion_kind: CompletionKind, label: impl Into<String>) -> Builder {
39 let label = label.into(); 39 let label = label.into();
40 Builder { 40 Builder {
41 completion_kind,
41 label, 42 label,
42 lookup: None, 43 lookup: None,
43 snippet: None, 44 snippet: None,
44 completion_kind, 45 kind: None,
45 } 46 }
46 } 47 }
47 /// What user sees in pop-up in the UI. 48 /// What user sees in pop-up in the UI.
@@ -73,10 +74,11 @@ impl CompletionItem {
73/// A helper to make `CompletionItem`s. 74/// A helper to make `CompletionItem`s.
74#[must_use] 75#[must_use]
75pub(crate) struct Builder { 76pub(crate) struct Builder {
77 completion_kind: CompletionKind,
76 label: String, 78 label: String,
77 lookup: Option<String>, 79 lookup: Option<String>,
78 snippet: Option<String>, 80 snippet: Option<String>,
79 completion_kind: CompletionKind, 81 kind: Option<CompletionItemKind>,
80} 82}
81 83
82impl Builder { 84impl Builder {
@@ -89,7 +91,7 @@ impl Builder {
89 label: self.label, 91 label: self.label,
90 lookup: self.lookup, 92 lookup: self.lookup,
91 snippet: self.snippet, 93 snippet: self.snippet,
92 kind: None, 94 kind: self.kind,
93 completion_kind: self.completion_kind, 95 completion_kind: self.completion_kind,
94 } 96 }
95 } 97 }
@@ -101,8 +103,8 @@ impl Builder {
101 self.snippet = Some(snippet.into()); 103 self.snippet = Some(snippet.into());
102 self 104 self
103 } 105 }
104 pub(crate) fn kind(mut self, kind: CompletionKind) -> Builder { 106 pub(crate) fn kind(mut self, kind: CompletionItemKind) -> Builder {
105 self.completion_kind = kind; 107 self.kind = Some(kind);
106 self 108 self
107 } 109 }
108} 110}