1use bitflags::bitflags;
4
5use oxc_allocator::{Allocator, CloneIn, Dummy};
6use oxc_ast_macros::ast;
7use oxc_index::define_nonmax_u32_index_type;
8
9define_nonmax_u32_index_type! {
10 #[ast]
12 #[clone_in(default)]
13 #[content_eq(skip)]
14 #[estree(skip)]
15 pub struct NodeId;
16}
17
18impl NodeId {
19 pub const DUMMY: Self = NodeId::new(0);
23
24 pub const ROOT: Self = NodeId::new(0);
26}
27
28impl Default for NodeId {
29 #[inline]
30 fn default() -> Self {
31 Self::DUMMY
32 }
33}
34
35impl<'a> Dummy<'a> for NodeId {
36 #[inline]
37 fn dummy(_: &'a Allocator) -> Self {
38 Self::DUMMY
39 }
40}
41
42impl<'alloc> CloneIn<'alloc> for NodeId {
43 type Cloned = Self;
44
45 fn clone_in(&self, _: &'alloc Allocator) -> Self {
46 unreachable!();
48 }
49
50 #[inline]
51 fn clone_in_with_semantic_ids(&self, _: &'alloc Allocator) -> Self {
52 *self
53 }
54}
55
56bitflags! {
57 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
59 pub struct NodeFlags: u8 {
60 const JSDoc = 1 << 0;
62 const Class = 1 << 1;
64 const HasYield = 1 << 2;
66 const ExportSpecifier = 1 << 3;
68 }
69}
70
71impl NodeFlags {
72 #[inline]
74 pub fn has_jsdoc(self) -> bool {
75 self.contains(Self::JSDoc)
76 }
77
78 #[inline]
80 pub fn has_class(self) -> bool {
81 self.contains(Self::Class)
82 }
83
84 #[inline]
86 pub fn has_yield(self) -> bool {
87 self.contains(Self::HasYield)
88 }
89
90 #[inline]
92 pub fn has_export_specifier(self) -> bool {
93 self.contains(Self::ExportSpecifier)
94 }
95}