diff options
Diffstat (limited to 'crates/ra_hir_def/src/nameres/per_ns.rs')
-rw-r--r-- | crates/ra_hir_def/src/nameres/per_ns.rs | 74 |
1 files changed, 0 insertions, 74 deletions
diff --git a/crates/ra_hir_def/src/nameres/per_ns.rs b/crates/ra_hir_def/src/nameres/per_ns.rs deleted file mode 100644 index 717ed1ef9..000000000 --- a/crates/ra_hir_def/src/nameres/per_ns.rs +++ /dev/null | |||
@@ -1,74 +0,0 @@ | |||
1 | //! FIXME: write short doc here | ||
2 | |||
3 | use hir_expand::MacroDefId; | ||
4 | |||
5 | use crate::ModuleDefId; | ||
6 | |||
7 | #[derive(Debug, Copy, Clone, PartialEq, Eq, Hash)] | ||
8 | pub struct PerNs { | ||
9 | pub types: Option<ModuleDefId>, | ||
10 | pub values: Option<ModuleDefId>, | ||
11 | /// Since macros has different type, many methods simply ignore it. | ||
12 | /// We can only use special method like `get_macros` to access it. | ||
13 | pub macros: Option<MacroDefId>, | ||
14 | } | ||
15 | |||
16 | impl Default for PerNs { | ||
17 | fn default() -> Self { | ||
18 | PerNs { types: None, values: None, macros: None } | ||
19 | } | ||
20 | } | ||
21 | |||
22 | impl PerNs { | ||
23 | pub fn none() -> PerNs { | ||
24 | PerNs { types: None, values: None, macros: None } | ||
25 | } | ||
26 | |||
27 | pub fn values(t: ModuleDefId) -> PerNs { | ||
28 | PerNs { types: None, values: Some(t), macros: None } | ||
29 | } | ||
30 | |||
31 | pub fn types(t: ModuleDefId) -> PerNs { | ||
32 | PerNs { types: Some(t), values: None, macros: None } | ||
33 | } | ||
34 | |||
35 | pub fn both(types: ModuleDefId, values: ModuleDefId) -> PerNs { | ||
36 | PerNs { types: Some(types), values: Some(values), macros: None } | ||
37 | } | ||
38 | |||
39 | pub fn macros(macro_: MacroDefId) -> PerNs { | ||
40 | PerNs { types: None, values: None, macros: Some(macro_) } | ||
41 | } | ||
42 | |||
43 | pub fn is_none(&self) -> bool { | ||
44 | self.types.is_none() && self.values.is_none() && self.macros.is_none() | ||
45 | } | ||
46 | |||
47 | pub fn is_all(&self) -> bool { | ||
48 | self.types.is_some() && self.values.is_some() && self.macros.is_some() | ||
49 | } | ||
50 | |||
51 | pub fn take_types(self) -> Option<ModuleDefId> { | ||
52 | self.types | ||
53 | } | ||
54 | |||
55 | pub fn take_values(self) -> Option<ModuleDefId> { | ||
56 | self.values | ||
57 | } | ||
58 | |||
59 | pub fn get_macros(&self) -> Option<MacroDefId> { | ||
60 | self.macros | ||
61 | } | ||
62 | |||
63 | pub fn only_macros(&self) -> PerNs { | ||
64 | PerNs { types: None, values: None, macros: self.macros } | ||
65 | } | ||
66 | |||
67 | pub fn or(self, other: PerNs) -> PerNs { | ||
68 | PerNs { | ||
69 | types: self.types.or(other.types), | ||
70 | values: self.values.or(other.values), | ||
71 | macros: self.macros.or(other.macros), | ||
72 | } | ||
73 | } | ||
74 | } | ||