diff options
Diffstat (limited to 'crates/ra_ide/src/completion/completion_item.rs')
-rw-r--r-- | crates/ra_ide/src/completion/completion_item.rs | 22 |
1 files changed, 4 insertions, 18 deletions
diff --git a/crates/ra_ide/src/completion/completion_item.rs b/crates/ra_ide/src/completion/completion_item.rs index 19bbb2517..bc0f1aff5 100644 --- a/crates/ra_ide/src/completion/completion_item.rs +++ b/crates/ra_ide/src/completion/completion_item.rs | |||
@@ -13,7 +13,7 @@ pub struct CompletionItem { | |||
13 | /// Used only internally in tests, to check only specific kind of | 13 | /// Used only internally in tests, to check only specific kind of |
14 | /// completion (postfix, keyword, reference, etc). | 14 | /// completion (postfix, keyword, reference, etc). |
15 | #[allow(unused)] | 15 | #[allow(unused)] |
16 | completion_kind: CompletionKind, | 16 | pub(crate) completion_kind: CompletionKind, |
17 | /// Label in the completion pop up which identifies completion. | 17 | /// Label in the completion pop up which identifies completion. |
18 | label: String, | 18 | label: String, |
19 | /// Range of identifier that is being completed. | 19 | /// Range of identifier that is being completed. |
@@ -80,6 +80,9 @@ impl fmt::Debug for CompletionItem { | |||
80 | if self.deprecated { | 80 | if self.deprecated { |
81 | s.field("deprecated", &true); | 81 | s.field("deprecated", &true); |
82 | } | 82 | } |
83 | if self.trigger_call_info { | ||
84 | s.field("trigger_call_info", &true); | ||
85 | } | ||
83 | s.finish() | 86 | s.finish() |
84 | } | 87 | } |
85 | } | 88 | } |
@@ -318,20 +321,3 @@ impl Into<Vec<CompletionItem>> for Completions { | |||
318 | self.buf | 321 | self.buf |
319 | } | 322 | } |
320 | } | 323 | } |
321 | |||
322 | #[cfg(test)] | ||
323 | pub(crate) fn do_completion(code: &str, kind: CompletionKind) -> Vec<CompletionItem> { | ||
324 | use crate::completion::completions; | ||
325 | use crate::mock_analysis::{analysis_and_position, single_file_with_position}; | ||
326 | let (analysis, position) = if code.contains("//-") { | ||
327 | analysis_and_position(code) | ||
328 | } else { | ||
329 | single_file_with_position(code) | ||
330 | }; | ||
331 | let completions = completions(&analysis.db, position).unwrap(); | ||
332 | let completion_items: Vec<CompletionItem> = completions.into(); | ||
333 | let mut kind_completions: Vec<CompletionItem> = | ||
334 | completion_items.into_iter().filter(|c| c.completion_kind == kind).collect(); | ||
335 | kind_completions.sort_by_key(|c| c.label.clone()); | ||
336 | kind_completions | ||
337 | } | ||