Skip to main content

CstNode

Struct CstNode 

Source
pub struct CstNode {
Show 14 fields pub kind: CstNodeKind, pub span: Span, pub content_span: Span, pub children: Vec<NodeId>, pub parent: Option<NodeId>, pub field_name: Option<Span>, pub field_value: Option<Span>, pub section_keyword: Option<Span>, pub section_arg: Option<Span>, pub condition_keyword: Option<Span>, pub condition_expr: Option<Span>, pub leading_trivia: Vec<TriviaPiece>, pub trailing_trivia: Vec<TriviaPiece>, pub indent: usize,
}
Expand description

A single node in the CST arena.

Fields§

§kind: CstNodeKind

What kind of syntax element this node represents.

§span: Span

Full byte span of this node in the source, including leading trivia.

§content_span: Span

Span of just the meaningful content (excluding leading/trailing trivia that belongs to this node).

§children: Vec<NodeId>

Children of this node (indices into the arena).

§parent: Option<NodeId>

Parent node (None only for the Root).

§field_name: Option<Span>

For Field / Import nodes: span of the field name.

§field_value: Option<Span>

For Field / Import nodes: span of the field value (first line only; continuation lines are child ValueLine nodes).

§section_keyword: Option<Span>

For Section nodes: span of the section keyword.

§section_arg: Option<Span>

For Section nodes: span of the section argument (e.g. my-exe).

§condition_keyword: Option<Span>

For Conditional nodes: span of the keyword (if / elif).

§condition_expr: Option<Span>

For Conditional nodes: span of the condition expression text.

§leading_trivia: Vec<TriviaPiece>

Leading trivia pieces (whitespace, newlines, comments) that precede this node’s content.

§trailing_trivia: Vec<TriviaPiece>

Trailing trivia pieces (typically a newline at the end of the line).

§indent: usize

The indentation level (visual column) of this node.

Implementations§

Source§

impl CstNode

Source

pub fn new(kind: CstNodeKind, span: Span) -> Self

Create a new node with the given kind, defaulting all optional fields to None / empty.

Trait Implementations§

Source§

impl Clone for CstNode

Source§

fn clone(&self) -> CstNode

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CstNode

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.