class TreeSitter::Tree

Overview

A Tree represents the syntax tree of an entire source code file. It contains Node instances that indicate the structure of the source code. It can also be edited and used to produce a new Tree in the event that the source code changes.

Defined in:

tree_sitter/tree.cr

Instance Method Summary

Instance Method Detail

def changed_ranges(old_tree : Tree) : Range::Iterator #

[View source]
def copy : Tree #

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.


[View source]
def root_node : Node #

Get the root node of the syntax tree.


[View source]
def save_dot(io : IO::FileDescriptor) #

Write a DOT graph describing the syntax tree to the given file.


[View source]
def save_dot(file : Path | String) #

Write a DOT graph describing the syntax tree to the given file.


[View source]
def save_png(file : Path | String) : Nil #

Write a PNG graph describing the syntax tree to the given file.


[View source]