diff options
4 files changed, 17 insertions, 12 deletions
diff --git a/crates/ra_analysis/src/completion.rs b/crates/ra_analysis/src/completion.rs index 2d61a3aef..d742d6295 100644 --- a/crates/ra_analysis/src/completion.rs +++ b/crates/ra_analysis/src/completion.rs | |||
@@ -18,7 +18,7 @@ use crate::{ | |||
18 | }, | 18 | }, |
19 | }; | 19 | }; |
20 | 20 | ||
21 | pub use crate::completion::completion_item::{CompletionItem, InsertText}; | 21 | pub use crate::completion::completion_item::{CompletionItem, InsertText, CompletionItemKind}; |
22 | 22 | ||
23 | /// Main entry point for copmletion. We run comletion as a two-phase process. | 23 | /// Main entry point for copmletion. We run comletion as a two-phase process. |
24 | /// | 24 | /// |
diff --git a/crates/ra_analysis/src/completion/complete_keyword.rs b/crates/ra_analysis/src/completion/complete_keyword.rs index 2c7891920..5427fcb11 100644 --- a/crates/ra_analysis/src/completion/complete_keyword.rs +++ b/crates/ra_analysis/src/completion/complete_keyword.rs | |||
@@ -5,10 +5,11 @@ use ra_syntax::{ | |||
5 | SyntaxKind::*, SyntaxNodeRef, | 5 | SyntaxKind::*, SyntaxNodeRef, |
6 | }; | 6 | }; |
7 | 7 | ||
8 | use crate::completion::{CompletionContext, CompletionItem, Completions, CompletionKind}; | 8 | use crate::completion::{CompletionContext, CompletionItem, Completions, CompletionKind, CompletionItemKind}; |
9 | 9 | ||
10 | fn keyword(kw: &str, snippet: &str) -> CompletionItem { | 10 | fn keyword(kw: &str, snippet: &str) -> CompletionItem { |
11 | CompletionItem::new(CompletionKind::Keyword, kw) | 11 | CompletionItem::new(CompletionKind::Keyword, kw) |
12 | .kind(CompletionItemKind::Keyword) | ||
12 | .snippet(snippet) | 13 | .snippet(snippet) |
13 | .build() | 14 | .build() |
14 | } | 15 | } |
diff --git a/crates/ra_analysis/src/completion/complete_snippet.rs b/crates/ra_analysis/src/completion/complete_snippet.rs index 1feb332b9..91de8ca37 100644 --- a/crates/ra_analysis/src/completion/complete_snippet.rs +++ b/crates/ra_analysis/src/completion/complete_snippet.rs | |||
@@ -1,7 +1,9 @@ | |||
1 | use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionContext, completion_item::Builder}; | 1 | use crate::completion::{CompletionItem, Completions, CompletionKind, CompletionItemKind, CompletionContext, completion_item::Builder}; |
2 | 2 | ||
3 | fn snippet(label: &str, snippet: &str) -> Builder { | 3 | fn snippet(label: &str, snippet: &str) -> Builder { |
4 | CompletionItem::new(CompletionKind::Snippet, label).snippet(snippet) | 4 | CompletionItem::new(CompletionKind::Snippet, label) |
5 | .snippet(snippet) | ||
6 | .kind(CompletionItemKind::Keyword) | ||
5 | } | 7 | } |
6 | 8 | ||
7 | pub(super) fn complete_expr_snippet(acc: &mut Completions, ctx: &CompletionContext) { | 9 | pub(super) fn complete_expr_snippet(acc: &mut Completions, ctx: &CompletionContext) { |
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)] |
5 | pub struct CompletionItem { | 5 | pub 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 | ||
15 | pub enum InsertText { | 15 | pub 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] |
75 | pub(crate) struct Builder { | 76 | pub(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 | ||
82 | impl Builder { | 84 | impl 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 | } |