revive_solc_json_interface/standard_json/input/settings/selection/
mod.rs1pub mod file;
4
5use std::collections::BTreeMap;
6
7use serde::Deserialize;
8use serde::Serialize;
9
10use self::file::flag::Flag;
11use self::file::File as FileSelection;
12
13#[derive(Clone, Debug, Serialize, Deserialize, Default, PartialEq)]
15pub struct Selection {
16 #[serde(default, rename = "*", skip_serializing_if = "FileSelection::is_empty")]
18 all: FileSelection,
19
20 #[serde(skip_serializing_if = "BTreeMap::is_empty", flatten)]
21 pub files: BTreeMap<String, FileSelection>,
22}
23
24impl Selection {
25 pub fn new(flags: Vec<Flag>) -> Self {
27 Self {
28 all: FileSelection::new(flags),
29 files: Default::default(),
30 }
31 }
32
33 pub fn new_required() -> Self {
35 Self {
36 all: FileSelection::new_required(),
37 files: BTreeMap::new(),
38 }
39 }
40
41 pub fn new_required_for_tests() -> Self {
43 Self {
44 all: FileSelection::new_required_for_tests(),
45 files: BTreeMap::new(),
46 }
47 }
48
49 pub fn new_yul_validation() -> Self {
51 Self::new(vec![Flag::EVM])
52 }
53
54 pub fn extend(&mut self, other: Self) -> &mut Self {
56 self.all.extend(other.all);
57 self
58 }
59
60 pub fn selection_to_prune(&self) -> Self {
65 Self {
66 all: self.all.selection_to_prune(),
67 files: Default::default(),
68 }
69 }
70
71 pub fn contains(&self, flag: &Flag) -> bool {
73 self.all.contains(flag)
74 }
75}