1use zerodds_ast_core::NodeKindTag;
9
10#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
18pub enum NodeKind {
19 Module,
21 Type,
23 Member,
25 Case,
27 Enumerator,
29 BitValue,
31 Bitfield,
33 Const,
35 ConstExpr,
37 Interface,
39 Operation,
41 Param,
43 Attribute,
45 Exception,
47 AnnotationDef,
49 AnnotationMember,
51 Domain,
53 Topic,
55 QosProfile,
57 Participant,
59 Endpoint,
61 Library,
63}
64
65impl NodeKind {
66 pub const ALL: [Self; 22] = [
69 Self::Module,
70 Self::Type,
71 Self::Member,
72 Self::Case,
73 Self::Enumerator,
74 Self::BitValue,
75 Self::Bitfield,
76 Self::Const,
77 Self::ConstExpr,
78 Self::Interface,
79 Self::Operation,
80 Self::Param,
81 Self::Attribute,
82 Self::Exception,
83 Self::AnnotationDef,
84 Self::AnnotationMember,
85 Self::Domain,
86 Self::Topic,
87 Self::QosProfile,
88 Self::Participant,
89 Self::Endpoint,
90 Self::Library,
91 ];
92
93 #[must_use]
95 pub const fn tag(self) -> NodeKindTag {
96 NodeKindTag(match self {
97 Self::Module => 1,
98 Self::Type => 2,
99 Self::Member => 3,
100 Self::Case => 4,
101 Self::Enumerator => 5,
102 Self::BitValue => 6,
103 Self::Bitfield => 7,
104 Self::Const => 8,
105 Self::ConstExpr => 9,
106 Self::Interface => 10,
107 Self::Operation => 11,
108 Self::Param => 12,
109 Self::Attribute => 13,
110 Self::Exception => 14,
111 Self::AnnotationDef => 15,
112 Self::AnnotationMember => 16,
113 Self::Domain => 17,
114 Self::Topic => 18,
115 Self::QosProfile => 19,
116 Self::Participant => 20,
117 Self::Endpoint => 21,
118 Self::Library => 22,
119 })
120 }
121
122 #[must_use]
124 pub const fn from_tag(tag: NodeKindTag) -> Option<Self> {
125 Some(match tag.0 {
126 1 => Self::Module,
127 2 => Self::Type,
128 3 => Self::Member,
129 4 => Self::Case,
130 5 => Self::Enumerator,
131 6 => Self::BitValue,
132 7 => Self::Bitfield,
133 8 => Self::Const,
134 9 => Self::ConstExpr,
135 10 => Self::Interface,
136 11 => Self::Operation,
137 12 => Self::Param,
138 13 => Self::Attribute,
139 14 => Self::Exception,
140 15 => Self::AnnotationDef,
141 16 => Self::AnnotationMember,
142 17 => Self::Domain,
143 18 => Self::Topic,
144 19 => Self::QosProfile,
145 20 => Self::Participant,
146 21 => Self::Endpoint,
147 22 => Self::Library,
148 _ => return None,
149 })
150 }
151
152 #[must_use]
154 pub const fn as_str(self) -> &'static str {
155 match self {
156 Self::Module => "module",
157 Self::Type => "type",
158 Self::Member => "member",
159 Self::Case => "case",
160 Self::Enumerator => "enumerator",
161 Self::BitValue => "bit value",
162 Self::Bitfield => "bitfield",
163 Self::Const => "constant",
164 Self::ConstExpr => "constant expression",
165 Self::Interface => "interface",
166 Self::Operation => "operation",
167 Self::Param => "parameter",
168 Self::Attribute => "attribute",
169 Self::Exception => "exception",
170 Self::AnnotationDef => "annotation",
171 Self::AnnotationMember => "annotation member",
172 Self::Domain => "domain",
173 Self::Topic => "topic",
174 Self::QosProfile => "QoS profile",
175 Self::Participant => "participant",
176 Self::Endpoint => "endpoint",
177 Self::Library => "library",
178 }
179 }
180}