diff options
Diffstat (limited to 'crates/ra_ide/src/completion.rs')
-rw-r--r-- | crates/ra_ide/src/completion.rs | 25 |
1 files changed, 23 insertions, 2 deletions
diff --git a/crates/ra_ide/src/completion.rs b/crates/ra_ide/src/completion.rs index c378c2c62..a27e0fc15 100644 --- a/crates/ra_ide/src/completion.rs +++ b/crates/ra_ide/src/completion.rs | |||
@@ -33,6 +33,23 @@ pub use crate::completion::completion_item::{ | |||
33 | CompletionItem, CompletionItemKind, InsertTextFormat, | 33 | CompletionItem, CompletionItemKind, InsertTextFormat, |
34 | }; | 34 | }; |
35 | 35 | ||
36 | #[derive(Clone, Debug, PartialEq, Eq)] | ||
37 | pub struct CompletionOptions { | ||
38 | pub enable_postfix_completions: bool, | ||
39 | pub add_call_parenthesis: bool, | ||
40 | pub add_call_argument_snippets: bool, | ||
41 | } | ||
42 | |||
43 | impl Default for CompletionOptions { | ||
44 | fn default() -> Self { | ||
45 | CompletionOptions { | ||
46 | enable_postfix_completions: true, | ||
47 | add_call_parenthesis: true, | ||
48 | add_call_argument_snippets: true, | ||
49 | } | ||
50 | } | ||
51 | } | ||
52 | |||
36 | /// Main entry point for completion. We run completion as a two-phase process. | 53 | /// Main entry point for completion. We run completion as a two-phase process. |
37 | /// | 54 | /// |
38 | /// First, we look at the position and collect a so-called `CompletionContext. | 55 | /// First, we look at the position and collect a so-called `CompletionContext. |
@@ -55,8 +72,12 @@ pub use crate::completion::completion_item::{ | |||
55 | /// `foo` *should* be present among the completion variants. Filtering by | 72 | /// `foo` *should* be present among the completion variants. Filtering by |
56 | /// identifier prefix/fuzzy match should be done higher in the stack, together | 73 | /// identifier prefix/fuzzy match should be done higher in the stack, together |
57 | /// with ordering of completions (currently this is done by the client). | 74 | /// with ordering of completions (currently this is done by the client). |
58 | pub(crate) fn completions(db: &RootDatabase, position: FilePosition) -> Option<Completions> { | 75 | pub(crate) fn completions( |
59 | let ctx = CompletionContext::new(db, position)?; | 76 | db: &RootDatabase, |
77 | position: FilePosition, | ||
78 | opts: &CompletionOptions, | ||
79 | ) -> Option<Completions> { | ||
80 | let ctx = CompletionContext::new(db, position, opts)?; | ||
60 | 81 | ||
61 | let mut acc = Completions::default(); | 82 | let mut acc = Completions::default(); |
62 | 83 | ||