Skip to main content

SyntaxHighlighter

Struct SyntaxHighlighter 

Source
pub struct SyntaxHighlighter { /* private fields */ }
Expand description

Syntax analysis engine providing real-time Tree-Sitter AST tokenization, incremental parsing, and structural navigation.

Implementations§

Source§

impl SyntaxHighlighter

Source

pub fn new() -> Self

Source

pub fn with_language(lang: Language) -> Self

Source

pub fn set_language(&mut self, lang: Language)

Source

pub fn language(&self) -> Language

Source

pub fn tree(&self) -> Option<&Tree>

Accesses the active Tree-Sitter AST tree, if parsed.

Source

pub fn parse(&mut self, source: &str)

Parses a complete source text into a Tree-Sitter AST.

Source

pub fn edit(&mut self, edit: &InputEdit)

Informs the Tree-Sitter AST of an edit for subsequent incremental parsing.

Source

pub fn parse_incremental(&mut self, source: &str)

Re-parses the document incrementally using the edited previous AST.

Source

pub fn highlight_line(&self, line: &str, lang: Language) -> Vec<SyntaxToken>

Tokenizes a single line for high-speed incremental viewport rendering.

Source

pub fn highlight_line_ast( &self, line_idx: usize, line: &str, ) -> Vec<SyntaxToken>

Extracts syntax tokens for a line directly from the active Tree-Sitter AST.

Source

pub fn tokenize_line_lexical(line: &str, lang: Language) -> Vec<SyntaxToken>

Fast lexical tokenizer fallback for languages without a Tree-Sitter grammar.

Source

pub fn root_node(&self) -> Option<Node<'_>>

Returns the root node of the active Tree-Sitter syntax tree, if available.

Source

pub fn node_at_position(&self, line: usize, col: usize) -> Option<Node<'_>>

Finds the finest AST node at the given 0-indexed row and column.

Source

pub fn enclosing_scope_range( &self, line: usize, col: usize, ) -> Option<(usize, usize)>

Finds the enclosing scope or block range (start_line, end_line) containing the given position.

Source

pub fn find_matching_bracket( &self, buffer: &LineBuffer, pos: Position, ) -> Option<Position>

Finds matching open or close bracket for delimiter at position pos.

Source

pub fn compute_fold_ranges(&self, buffer: &LineBuffer) -> Vec<FoldRange>

Scans buffer or Tree-Sitter AST to locate multi-line code folding regions.

Source

pub fn compute_auto_indent(&self, buffer: &LineBuffer, line_idx: usize) -> usize

Computes indentation column spaces for a newly created newline following line line_idx.

Trait Implementations§

Source§

impl Clone for SyntaxHighlighter

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for SyntaxHighlighter

Source§

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

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

impl Default for SyntaxHighlighter

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

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 = !

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

fn try_from(value: U) -> Result<T, !>

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.