Node โ
Overview โ
Node { tree: *const Tree, index: u32 } โ two words, zero ownership. Every method below is allocation-free. Source: src/tree/node.zig.
Identity and type โ
zig
pub fn symbol(self: Node) u16
pub fn nodeType(self: Node) []const u8
pub fn eql(a: Node, b: Node) bool
pub fn isNull(self: Node) boolFlags โ
zig
pub fn isNamed(self: Node) bool
pub fn isMissing(self: Node) bool
pub fn isExtra(self: Node) bool
pub fn isError(self: Node) bool
pub fn hasError(self: Node) boolSpans โ
zig
pub fn startByte(self: Node) u32
pub fn endByte(self: Node) u32
pub fn startPoint(self: Node) Point
pub fn endPoint(self: Node) Point
pub fn byteRange(self: Node) struct { start: u32, end: u32 }
pub fn range(self: Node) Range
pub fn text(self: Node) []const u8text() slices the tree's owned source; out-of-range spans safely yield "".
Children โ
zig
pub fn childCount(self: Node) u32
pub fn namedChildCount(self: Node) u32
pub fn descendantCount(self: Node) u32
pub fn children(self: Node) []const u32
pub fn child(self: Node, i: u32) ?Node
pub fn namedChild(self: Node, i: u32) ?NodeFamily navigation โ
zig
pub fn parent(self: Node) ?Node
pub fn nextSibling(self: Node) ?Node
pub fn prevSibling(self: Node) ?Node
pub fn nextNamedSibling(self: Node) ?Node
pub fn prevNamedSibling(self: Node) ?Nodeparent() is null at the root.
Fields โ
zig
pub fn childByFieldName(self: Node, name: []const u8) ?Node
pub fn fieldNameForChild(self: Node, child_index: u32) ?[]const u8Range lookup โ
zig
pub fn descendantForByteRange(self: Node, start: u32, end: u32) ?Node
pub fn namedDescendantForByteRange(self: Node, start: u32, end: u32) ?NodeOwnership โ
Borrows the tree. No deinit.
