Struct Entry

Source
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>

Source

pub fn start_position(&self) -> Point

Get the start position of an entry

Source

pub fn end_position(&self) -> Point

Get the end position of an entry

Trait Implementations§

Source§

impl<'node> Clone for Entry<'node>

Source§

fn clone(&self) -> Entry<'node>

Returns a duplicate of the value. Read more
1.0.0 · Source§

const fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'node> Debug for Entry<'node>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> From<VectorLeaf<'a>> for Entry<'a>

Source§

fn from(leaf: VectorLeaf<'a>) -> Self

Converts to this type from the input type.
Source§

impl<'a> FromIterator<&'a Entry<'a>> for HunkAppender<'a>

Source§

fn from_iter<T>(iter: T) -> Self
where T: IntoIterator<Item = &'a Entry<'a>>,

Create an instance of Hunks from an iterator over entries.

The user is responsible for making sure that the hunks are in proper order, otherwise this constructor may panic.

Source§

impl<'a> PartialEq for Entry<'a>

Source§

fn eq(&self, other: &Entry<'_>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

const fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<'node> Serialize for Entry<'node>

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl<'a> Eq for Entry<'a>

Auto Trait Implementations§

§

impl<'node> Freeze for Entry<'node>

§

impl<'node> RefUnwindSafe for Entry<'node>

§

impl<'node> Send for Entry<'node>

§

impl<'node> Sync for Entry<'node>

§

impl<'node> Unpin for Entry<'node>

§

impl<'node> UnwindSafe for Entry<'node>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.