struct Tree;
A tree that represents the syntactic structure of a source code file.
TSTree* tstree;
internal TsTree
nothrow @nogc this(TSTree* tstree);
Create a new Tree
nothrow @nogc this(return ref scope Tree otherTree);
inout nothrow @nogc this(return ref scope inout Tree otherTree);
Create a shallow copy of the syntax tree. This is very fast.
You need to copy a syntax tree in order to use it on more than one thread at a time, as syntax trees are not thread safe.
static nothrow @nogc auto create_empty();
Create an empty Tree
const nothrow @nogc auto root_node();
Get the root node of the syntax tree.
const nothrow @nogc auto language();
Get the language that was used to parse the syntax tree.
nothrow @nogc auto edit(const InputEdit* edit);
Edit the syntax tree to keep it in sync with source code that has been edited.
You must describe the edit both in terms of byte offsets and in terms of row/column coordinates.
const nothrow @nogc auto walk();
Create a new [TreeCursor] starting from the root of the tree.
const void traverse(TreeVisitor visitor);
const void traverse_nothrow(TreeVisitor visitor);
NOTE: if you are sure that TreeVisitor is nothrow
const nothrow auto changed_ranges(Tree other);
Compare this old edited syntax tree to a new syntax tree representing the same document, returning a sequence of ranges whose syntactic structure has changed.
For this to work correctly, this syntax tree must have been edited such that its ranges match up to the new tree. Generally, youl want to call this method right after calling one of the [Parser::parse] functions. Call it on the old tree that was passed to parse, and pass the new tree that was returned from parse.
const void print_dot_graph(File file);
Write a DOT graph describing the syntax tree to the given file.
const auto dot_graph();
Get a DOT graph describing the syntax tree as a string