pub struct RedNode<K: Copy> {
    pub green: Arc<GreenNode<K>>,
    pub offset: usize,
}Expand description
A red node that wraps a green node with absolute offset information.
Red nodes represent kind tree nodes with computed absolute positions, making them suitable for incremental parsing and position-based operations.
Fields§
§green: Arc<GreenNode<K>>The underlying green node that contains the structural information
offset: usizeThe absolute byte offset of this node in the source text
Implementations§
Source§impl<K: Copy> RedNode<K>
 
impl<K: Copy> RedNode<K>
Sourcepub fn span(&self) -> Range<usize>
 
pub fn span(&self) -> Range<usize>
Returns the absolute byte span of this red node.
The span is computed from the node’s offset and the length of the underlying green node.
§Returns
A Range<usize> representing the absolute byte positions
Sourcepub fn child(&self, idx: usize) -> Option<RedTree<K>>
 
pub fn child(&self, idx: usize) -> Option<RedTree<K>>
Gets the child element at the specified index.
§Arguments
- idx- The index of the child element to retrieve
§Returns
An Option<RedTree<K>> containing the child element if it exists,
or None if the index is out of bounds
Sourcepub fn children(&self) -> RedChildren<'_, K> ⓘ
 
pub fn children(&self) -> RedChildren<'_, K> ⓘ
Returns an iterator over all child elements.
§Returns
A RedChildren<K> iterator that yields all child elements
in order
Source§impl<K: Copy> RedNode<K>
 
impl<K: Copy> RedNode<K>
Sourcepub fn child_index_at_offset(&self, offset: usize) -> Option<usize>
 
pub fn child_index_at_offset(&self, offset: usize) -> Option<usize>
Finds the index of the child element that contains the given absolute offset.
This method is essential for incremental parsing, allowing efficient location of affected regions when source text changes.
§Arguments
- offset- The absolute byte offset to search for
§Returns
An Option<usize> containing the child index if found, or None
if the offset is outside this node’s span
Sourcepub fn offset_of_child(&self, idx: usize) -> Option<usize>
 
pub fn offset_of_child(&self, idx: usize) -> Option<usize>
Gets the absolute starting offset of the child element at the given index.
§Arguments
- idx- The index of the child element
§Returns
An Option<usize> containing the absolute offset if the index is valid
Sourcepub fn overlapping_indices(&self, span: Range<usize>) -> Vec<usize>
 
pub fn overlapping_indices(&self, span: Range<usize>) -> Vec<usize>
Collects indices of child elements that overlap with the given span.
This method is crucial for incremental parsing, identifying which child elements are affected by a text change.
§Arguments
- span- The byte range to check for overlaps
§Returns
A Vec<usize> containing indices of all overlapping child elements