ide_assists/
assist_config.rs

1//! Settings for tweaking assists.
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//! assists if we are allowed to.
6
7use hir::FindPathConfig;
8use ide_db::{
9    SnippetCap,
10    assists::ExprFillDefaultMode,
11    imports::{import_assets::ImportPathConfig, insert_use::InsertUseConfig},
12};
13
14use crate::AssistKind;
15
16#[derive(Clone, Debug, PartialEq, Eq)]
17pub struct AssistConfig {
18    pub snippet_cap: Option<SnippetCap>,
19    pub allowed: Option<Vec<AssistKind>>,
20    pub insert_use: InsertUseConfig,
21    pub prefer_no_std: bool,
22    pub prefer_prelude: bool,
23    pub prefer_absolute: bool,
24    pub assist_emit_must_use: bool,
25    pub term_search_fuel: u64,
26    pub term_search_borrowck: bool,
27    pub code_action_grouping: bool,
28    pub expr_fill_default: ExprFillDefaultMode,
29    pub prefer_self_ty: bool,
30}
31
32impl AssistConfig {
33    pub fn import_path_config(&self) -> ImportPathConfig {
34        ImportPathConfig {
35            prefer_no_std: self.prefer_no_std,
36            prefer_prelude: self.prefer_prelude,
37            prefer_absolute: self.prefer_absolute,
38        }
39    }
40
41    pub fn find_path_config(&self, allow_unstable: bool) -> FindPathConfig {
42        FindPathConfig {
43            prefer_no_std: self.prefer_no_std,
44            prefer_prelude: self.prefer_prelude,
45            prefer_absolute: self.prefer_absolute,
46            allow_unstable,
47        }
48    }
49}