#[repr(C)]pub struct Node {
pub kind: u16,
pub flags: u16,
pub pos: u32,
pub end: u32,
pub data_index: u32,
}Expand description
A thin 16-byte node header for cache-efficient AST storage.
Layout (16 bytes total):
kind: 2 bytes (SyntaxKindvalue, supports 0-65535)flags: 2 bytes (packedNodeFlags)pos: 4 bytes (start position in source)end: 4 bytes (end position in source)data_index: 4 bytes (index into type-specific pool,u32::MAX= no data)
Fields§
§kind: u16SyntaxKind value (u16 to support extended kinds up to 400+)
flags: u16Packed node flags (subset of NodeFlags that fits in u16)
pos: u32Start position in source (character index)
end: u32End position in source (character index)
data_index: u32Index into the type-specific storage pool (u32::MAX = no data)
Implementations§
Source§impl Node
impl Node
pub const NO_DATA: u32 = u32::MAX
Sourcepub const fn new(kind: u16, pos: u32, end: u32) -> Self
pub const fn new(kind: u16, pos: u32, end: u32) -> Self
Create a new thin node with no associated data
Sourcepub const fn with_data(kind: u16, pos: u32, end: u32, data_index: u32) -> Self
pub const fn with_data(kind: u16, pos: u32, end: u32, data_index: u32) -> Self
Create a new thin node with data index
Source§impl Node
impl Node
Sourcepub const fn is_identifier(&self) -> bool
pub const fn is_identifier(&self) -> bool
Check if this is an identifier node
Sourcepub const fn is_string_literal(&self) -> bool
pub const fn is_string_literal(&self) -> bool
Check if this is a string literal
Sourcepub const fn is_numeric_literal(&self) -> bool
pub const fn is_numeric_literal(&self) -> bool
Check if this is a numeric literal
Sourcepub const fn is_function_declaration(&self) -> bool
pub const fn is_function_declaration(&self) -> bool
Check if this is a function declaration
Sourcepub const fn is_class_declaration(&self) -> bool
pub const fn is_class_declaration(&self) -> bool
Check if this is a class declaration
Sourcepub const fn is_function_like(&self) -> bool
pub const fn is_function_like(&self) -> bool
Check if this is any kind of function-like node
Sourcepub const fn is_binding_pattern(&self) -> bool
pub const fn is_binding_pattern(&self) -> bool
Check if this is a binding pattern (array or object destructuring)
Sourcepub fn is_statement(&self) -> bool
pub fn is_statement(&self) -> bool
Check if this is a statement
Sourcepub fn is_declaration(&self) -> bool
pub fn is_declaration(&self) -> bool
Check if this is a declaration
Sourcepub fn is_type_node(&self) -> bool
pub fn is_type_node(&self) -> bool
Check if this is a type node