aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/completion.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2020-03-10 17:39:17 +0000
committerAleksey Kladov <[email protected]>2020-03-10 17:40:22 +0000
commit2347c03dcd717fbc0648c1e4e3d64a886217de5d (patch)
treec778877ddc5e17ee7adca15324fe3f5a417f062a /crates/ra_ide/src/completion.rs
parent6b9d66bbee865bd4337366f1540f8e5aa8d82c18 (diff)
Introduce CompletionOptions
Diffstat (limited to 'crates/ra_ide/src/completion.rs')
-rw-r--r--crates/ra_ide/src/completion.rs25
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)]
37pub struct CompletionOptions {
38 pub enable_postfix_completions: bool,
39 pub add_call_parenthesis: bool,
40 pub add_call_argument_snippets: bool,
41}
42
43impl 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).
58pub(crate) fn completions(db: &RootDatabase, position: FilePosition) -> Option<Completions> { 75pub(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