pub struct AstNode {
pub type: &'static str,
pub value: String,
pub span: Span,
pub field_name: Option<&'static str>,
pub children: Vec<AstNode>,
}Expand description
Information on an AST node.
Fields§
§type: &'static strThe type of node
value: StringThe code associated to a node
span: SpanThe start and end positions of a node in a code
field_name: Option<&'static str>Tree-sitter grammar field name through which the parent reaches
this node (e.g. left, right, name, body).
None for the root node, anonymous tokens (punctuation, keywords),
and any child that does not occupy a named grammar field. Consumers
of the JSON output rely on this to distinguish structurally
equivalent children without grammar-specific positional knowledge.
children: Vec<AstNode>The children of a node
Implementations§
Source§impl AstNode
impl AstNode
Sourcepub fn new(
type: &'static str,
value: String,
span: Span,
children: Vec<AstNode>,
) -> Self
pub fn new( type: &'static str, value: String, span: Span, children: Vec<AstNode>, ) -> Self
Builds an AstNode with the supplied type, value, span, and
children. The field_name is set to None; use
AstNode::with_field_name to record the tree-sitter grammar
field through which the parent reaches this node.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for AstNode
impl RefUnwindSafe for AstNode
impl Send for AstNode
impl Sync for AstNode
impl Unpin for AstNode
impl UnsafeUnpin for AstNode
impl UnwindSafe for AstNode
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more