oak_solidity/parser/
element_type.rs1use oak_core::{ElementType, UniversalElementRole};
2
3#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
5#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
6pub enum SolidityElementType {
7 Root,
9 PragmaDirective,
11 ContractDefinition,
13 Error,
15}
16
17impl ElementType for SolidityElementType {
18 type Role = UniversalElementRole;
19
20 fn is_root(&self) -> bool {
21 matches!(self, Self::Root)
22 }
23
24 fn is_error(&self) -> bool {
25 matches!(self, Self::Error)
26 }
27
28 fn role(&self) -> Self::Role {
29 match self {
30 Self::Root => UniversalElementRole::Root,
31 Self::PragmaDirective | Self::ContractDefinition => UniversalElementRole::Definition,
32 Self::Error => UniversalElementRole::Error,
33 }
34 }
35}