1use bitflags::bitflags;
4
5use oxc_allocator::{Allocator, CloneIn, CloneInSemanticIds, Dummy};
6use oxc_ast_macros::ast;
7use oxc_index::define_nonmax_u32_index_type;
8
9use crate::semantic_id::SemanticId;
10
11define_nonmax_u32_index_type! {
12 #[ast]
14 #[clone_in(semantic_id)]
15 #[content_eq(skip)]
16 #[estree(skip)]
17 pub struct NodeId;
18}
19
20impl NodeId {
21 pub const DUMMY: Self = NodeId::new(0);
25
26 pub const ROOT: Self = NodeId::new(0);
28}
29
30impl Default for NodeId {
31 #[inline]
32 fn default() -> Self {
33 Self::DUMMY
34 }
35}
36
37impl<'a> Dummy<'a> for NodeId {
38 #[inline]
39 fn dummy(_: &'a Allocator) -> Self {
40 Self::DUMMY
41 }
42}
43
44impl<'alloc> CloneIn<'alloc> for NodeId {
45 type Cloned = Self;
46
47 #[expect(clippy::inline_always)]
48 #[inline(always)] fn clone_in_impl(&self, with_semantic_ids: CloneInSemanticIds, _: &'alloc Allocator) -> Self {
50 self.clone_id(with_semantic_ids)
51 }
52}
53
54impl SemanticId for NodeId {}
55
56bitflags! {
57 #[derive(Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash)]
59 pub struct NodeFlags: u8 {
60 const JSDoc = 1 << 0;
62 }
63}
64
65impl NodeFlags {
66 #[inline]
68 pub fn has_jsdoc(self) -> bool {
69 self.contains(Self::JSDoc)
70 }
71}