Align config's API with usage

The config now is mostly immutable, optimize for that.
This commit is contained in:
Aleksey Kladov 2021-01-06 20:43:46 +03:00
parent 7ae4b8bdb6
commit f8a0561178
22 changed files with 164 additions and 162 deletions

View file

@ -4,7 +4,7 @@
//! module, and we use to statically check that we only produce snippet
//! completions if we are allowed to.
use ide_db::helpers::insert_use::MergeBehavior;
use ide_db::helpers::{insert_use::MergeBehavior, SnippetCap};
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct CompletionConfig {
@ -15,27 +15,3 @@ pub struct CompletionConfig {
pub snippet_cap: Option<SnippetCap>,
pub merge: Option<MergeBehavior>,
}
impl CompletionConfig {
pub fn allow_snippets(&mut self, yes: bool) {
self.snippet_cap = if yes { Some(SnippetCap { _private: () }) } else { None }
}
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub struct SnippetCap {
_private: (),
}
impl Default for CompletionConfig {
fn default() -> Self {
CompletionConfig {
enable_postfix_completions: true,
enable_autoimport_completions: true,
add_call_parenthesis: true,
add_call_argument_snippets: true,
snippet_cap: Some(SnippetCap { _private: () }),
merge: Some(MergeBehavior::Full),
}
}
}