pub struct Entry<'node> {
pub reference: Node<'node>,
pub text: Cow<'node, str>,
pub start_position: Point,
pub end_position: Point,
pub kind_id: u16,
}
Expand description
A mapping between a tree-sitter node and the text it corresponds to
This is also all of the metadata the diff rendering interface has access to, and also defines the data that will be output by the JSON serializer.
Fields§
§reference: Node<'node>
The node an entry in the diff vector refers to
We keep a reference to the leaf node so that we can easily grab the text and other metadata surrounding the syntax
text: Cow<'node, str>
A reference to the text the node refers to
This is different from the source_text
that the [AstVector] refers to, as the
entry only holds a reference to the specific range of text that the node covers.
We use a Cow here instead of a direct string reference because we might have to rewrite the text based on input processing settings, but if we don’t have to there’s no need to allocate an extra string.
start_position: Point
The entry’s start position in the document.
end_position: Point
The entry’s end position in the document.
kind_id: u16
The cached kind_id from the TSNode reference.
Caching it here saves some time because it is queried repeatedly later. If we don’t store it inline then we have to cross the FFI boundary which incurs some overhead.
Implementations§
Source§impl<'a> Entry<'a>
impl<'a> Entry<'a>
Sourcepub fn start_position(&self) -> Point
pub fn start_position(&self) -> Point
Get the start position of an entry
Sourcepub fn end_position(&self) -> Point
pub fn end_position(&self) -> Point
Get the end position of an entry