Tree represents the syntactic structure of a source code file. Trees are immutable but can be edited to reflect changes in the source code.
Accessing Nodes
root_node
root_node_with_offset
usize
required
The byte offset to shift the node’s position
Point
required
The row/column offset to shift the node’s position
Language Information
language
Tree Editing
edit
&InputEdit
required
A description of the edit made to the source code
Tree Traversal
walk
TreeCursor starting from the root of the tree. This is equivalent to calling tree.root_node().walk().
Comparing Trees
changed_ranges
Parser::parse functions. Call it on the old tree that was passed to parse, and pass the new tree that was returned from parse.
&Tree
required
The new tree to compare against
Range Information
included_ranges
Debugging
print_dot_graph
dot(1) process in order to generate SVG output.
&impl AsRawFd
required
The file descriptor to write the graph to
This method is only available on Unix platforms with the
std feature enabled.Cloning
TheTree struct implements Clone, allowing you to create copies of syntax trees:
InputEdit
TheInputEdit struct describes a change to a text document:
usize
The byte offset where the edit begins
usize
The byte offset where the edit ends in the old text
usize
The byte offset where the edit ends in the new text
Point
The row/column position where the edit begins
Point
The row/column position where the edit ends in the old text
Point
The row/column position where the edit ends in the new text
edit_point
&mut Point
required
The point to update
&mut usize
required
The byte offset to update
edit_range
&mut Range
required
The range to update