aboutsummaryrefslogtreecommitdiff
path: root/crates/completion/src/completion_config.rs
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2020-10-18 11:41:46 +0100
committerGitHub <[email protected]>2020-10-18 11:41:46 +0100
commit886cfd68212bb0b4487d6a822476c350a6eb114f (patch)
tree5b144eabe1eaf62aa1ec5b804ee6fff00f5f84e9 /crates/completion/src/completion_config.rs
parent2067a410f31810f6e1941a86cdea0247c3b7d6f4 (diff)
parent9e7c952bbddc2e6763c49f0511a295362e9893d6 (diff)
Merge #6276
6276: Extract call_info and completion into separate crates r=matklad a=popzxc As it was discussed in [zulip](https://rust-lang.zulipchat.com/#narrow/stream/185405-t-compiler.2Fwg-rls-2.2E0/topic/Completion.20refactoring), we need to move `completions` into a separate crate. Unfortunately, the dependency on `call_info::ActiveParameter` doesn't look easy to get rid of, and it seems to be a topic for a separate PR, thus I also extracted `call_info` into a separate crate (on which both `ide` and `completion` crates depend). Additionally, a few `FIXME`s in doc-comments were resolved in order to make `tidy` happy. Co-authored-by: Igor Aleksanov <[email protected]>
Diffstat (limited to 'crates/completion/src/completion_config.rs')
-rw-r--r--crates/completion/src/completion_config.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/crates/completion/src/completion_config.rs b/crates/completion/src/completion_config.rs
new file mode 100644
index 000000000..71b49ace8
--- /dev/null
+++ b/crates/completion/src/completion_config.rs
@@ -0,0 +1,35 @@
1//! Settings for tweaking completion.
2//!
3//! The fun thing here is `SnippetCap` -- this type can only be created in this
4//! module, and we use to statically check that we only produce snippet
5//! completions if we are allowed to.
6
7#[derive(Clone, Debug, PartialEq, Eq)]
8pub struct CompletionConfig {
9 pub enable_postfix_completions: bool,
10 pub add_call_parenthesis: bool,
11 pub add_call_argument_snippets: bool,
12 pub snippet_cap: Option<SnippetCap>,
13}
14
15impl CompletionConfig {
16 pub fn allow_snippets(&mut self, yes: bool) {
17 self.snippet_cap = if yes { Some(SnippetCap { _private: () }) } else { None }
18 }
19}
20
21#[derive(Clone, Copy, Debug, PartialEq, Eq)]
22pub struct SnippetCap {
23 _private: (),
24}
25
26impl Default for CompletionConfig {
27 fn default() -> Self {
28 CompletionConfig {
29 enable_postfix_completions: true,
30 add_call_parenthesis: true,
31 add_call_argument_snippets: true,
32 snippet_cap: Some(SnippetCap { _private: () }),
33 }
34 }
35}