aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/completion.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_analysis/src/completion.rs')
-rw-r--r--crates/ra_analysis/src/completion.rs13
1 files changed, 10 insertions, 3 deletions
diff --git a/crates/ra_analysis/src/completion.rs b/crates/ra_analysis/src/completion.rs
index fd7b78c2a..222b6854c 100644
--- a/crates/ra_analysis/src/completion.rs
+++ b/crates/ra_analysis/src/completion.rs
@@ -18,7 +18,7 @@ use crate::{
18 Cancelable, FilePosition 18 Cancelable, FilePosition
19}; 19};
20 20
21pub use crate::completion::completion_item::CompletionItem; 21pub use crate::completion::completion_item::{CompletionItem, InsertText};
22 22
23pub(crate) fn completions( 23pub(crate) fn completions(
24 db: &db::RootDatabase, 24 db: &db::RootDatabase,
@@ -109,13 +109,20 @@ mod tests {
109 109
110 use super::*; 110 use super::*;
111 111
112 fn is_snippet(completion_item: &CompletionItem) -> bool {
113 match completion_item.insert_text() {
114 InsertText::Snippet { .. } => true,
115 _ => false,
116 }
117 }
118
112 fn check_scope_completion(code: &str, expected_completions: &str) { 119 fn check_scope_completion(code: &str, expected_completions: &str) {
113 let (analysis, position) = single_file_with_position(code); 120 let (analysis, position) = single_file_with_position(code);
114 let completions = completions(&analysis.imp.db, position) 121 let completions = completions(&analysis.imp.db, position)
115 .unwrap() 122 .unwrap()
116 .unwrap() 123 .unwrap()
117 .into_iter() 124 .into_iter()
118 .filter(|c| c.snippet.is_none()) 125 .filter(|c| !is_snippet(c))
119 .collect::<Vec<_>>(); 126 .collect::<Vec<_>>();
120 assert_eq_dbg(expected_completions, &completions); 127 assert_eq_dbg(expected_completions, &completions);
121 } 128 }
@@ -126,7 +133,7 @@ mod tests {
126 .unwrap() 133 .unwrap()
127 .unwrap() 134 .unwrap()
128 .into_iter() 135 .into_iter()
129 .filter(|c| c.snippet.is_some()) 136 .filter(is_snippet)
130 .collect::<Vec<_>>(); 137 .collect::<Vec<_>>();
131 assert_eq_dbg(expected_completions, &completions); 138 assert_eq_dbg(expected_completions, &completions);
132 } 139 }