Skip to main content

LineCache

Struct LineCache 

Source
pub struct LineCache<L: LanguageLexer> { /* private fields */ }
Expand description

The incremental re-lex cache over any LanguageLexer. The LineState fixpoint made operational: re-lexing halts at the first line whose entry state and bytes both match the cache, so an edit costs O(changed lines + lines until the carried state re-converges), not O(document).

Zero-dependency by design (hikari-core’s invariant): the content compare is std str equality and the cache stores the line bytes. A hikari-* sibling may swap the Box<str> for a BLAKE3 row hash to drop the O(document) memory — that is a strictly-internal change behind this same object-safe trait.

Implementations§

Source§

impl<L: LanguageLexer> LineCache<L>

Source

pub fn new(lexer: L) -> Self

Trait Implementations§

Source§

impl<L: LanguageLexer> IncrementalHighlighter for LineCache<L>

Source§

fn highlight(&mut self, text: &str) -> Vec<HighlightSpan>

Re-highlight text, reusing cached per-line spans where the document is unchanged. &mut self because the cache advances.
Source§

fn last_relexed(&self) -> usize

How many lines the most recent highlight call actually re-lexed — 0 on a fully-cached (idle re-render) call. The seal’s idle-work witness: an unchanged document re-lexes nothing.

Auto Trait Implementations§

§

impl<L> Freeze for LineCache<L>
where L: Freeze,

§

impl<L> RefUnwindSafe for LineCache<L>

§

impl<L> Send for LineCache<L>

§

impl<L> Sync for LineCache<L>

§

impl<L> Unpin for LineCache<L>
where L: Unpin, <L as LanguageLexer>::LineState: Unpin,

§

impl<L> UnsafeUnpin for LineCache<L>
where L: UnsafeUnpin,

§

impl<L> UnwindSafe for LineCache<L>

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> 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, 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.