pub struct AstNode {
pub type: &'static str,
pub value: String,
pub span: Option<Span>,
pub field_name: Option<&'static str>,
pub children: Vec<AstNode>,
}Expand description
Information on an AST node.
Serialized as a flat object with snake_case keys: type, value,
span, field_name, children.
Fields§
§type: &'static strThe type of node
value: StringThe code associated to a node
span: Option<Span>The 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: Option<Span>,
children: Vec<AstNode>,
) -> Self
pub fn new( type: &'static str, value: String, span: Option<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.