aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/completion.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/completion.rs')
-rw-r--r--crates/ra_ide_api/src/completion.rs19
1 files changed, 8 insertions, 11 deletions
diff --git a/crates/ra_ide_api/src/completion.rs b/crates/ra_ide_api/src/completion.rs
index ce777a771..b03ddd74c 100644
--- a/crates/ra_ide_api/src/completion.rs
+++ b/crates/ra_ide_api/src/completion.rs
@@ -12,7 +12,7 @@ use ra_db::SyntaxDatabase;
12 12
13use crate::{ 13use crate::{
14 db, 14 db,
15 Cancelable, FilePosition, 15 FilePosition,
16 completion::{ 16 completion::{
17 completion_item::{Completions, CompletionKind}, 17 completion_item::{Completions, CompletionKind},
18 completion_context::CompletionContext, 18 completion_context::CompletionContext,
@@ -43,12 +43,9 @@ pub use crate::completion::completion_item::{CompletionItem, InsertText, Complet
43/// `foo` *should* be present among the completion variants. Filtering by 43/// `foo` *should* be present among the completion variants. Filtering by
44/// identifier prefix/fuzzy match should be done higher in the stack, together 44/// identifier prefix/fuzzy match should be done higher in the stack, together
45/// with ordering of completions (currently this is done by the client). 45/// with ordering of completions (currently this is done by the client).
46pub(crate) fn completions( 46pub(crate) fn completions(db: &db::RootDatabase, position: FilePosition) -> Option<Completions> {
47 db: &db::RootDatabase,
48 position: FilePosition,
49) -> Cancelable<Option<Completions>> {
50 let original_file = db.source_file(position.file_id); 47 let original_file = db.source_file(position.file_id);
51 let ctx = ctry!(CompletionContext::new(db, &original_file, position)?); 48 let ctx = CompletionContext::new(db, &original_file, position)?;
52 49
53 let mut acc = Completions::default(); 50 let mut acc = Completions::default();
54 51
@@ -57,11 +54,11 @@ pub(crate) fn completions(
57 complete_keyword::complete_use_tree_keyword(&mut acc, &ctx); 54 complete_keyword::complete_use_tree_keyword(&mut acc, &ctx);
58 complete_snippet::complete_expr_snippet(&mut acc, &ctx); 55 complete_snippet::complete_expr_snippet(&mut acc, &ctx);
59 complete_snippet::complete_item_snippet(&mut acc, &ctx); 56 complete_snippet::complete_item_snippet(&mut acc, &ctx);
60 complete_path::complete_path(&mut acc, &ctx)?; 57 complete_path::complete_path(&mut acc, &ctx);
61 complete_scope::complete_scope(&mut acc, &ctx)?; 58 complete_scope::complete_scope(&mut acc, &ctx);
62 complete_dot::complete_dot(&mut acc, &ctx)?; 59 complete_dot::complete_dot(&mut acc, &ctx);
63 60
64 Ok(Some(acc)) 61 Some(acc)
65} 62}
66 63
67#[cfg(test)] 64#[cfg(test)]
@@ -72,6 +69,6 @@ fn check_completion(code: &str, expected_completions: &str, kind: CompletionKind
72 } else { 69 } else {
73 single_file_with_position(code) 70 single_file_with_position(code)
74 }; 71 };
75 let completions = completions(&analysis.db, position).unwrap().unwrap(); 72 let completions = completions(&analysis.db, position).unwrap();
76 completions.assert_match(expected_completions, kind); 73 completions.assert_match(expected_completions, kind);
77} 74}