Skip to main content

LanguageRegistry

Struct LanguageRegistry 

Source
pub struct LanguageRegistry { /* private fields */ }

Implementations§

Source§

impl LanguageRegistry

Source

pub fn syntactic_emphasis( entry: Option<&LangEntry>, file: &mut FileDiff, mark_reformat_only: bool, ) -> bool

Set emphasis on file’s diff lines from an AST diff of both sides. mark_reformat_only also flags paired lines that differ in layout alone. Returns false when the file cannot be diffed this way, so the caller falls back to the textual engine.

Source§

impl LanguageRegistry

Source

pub fn build() -> Self

Source

pub fn for_path(&self, path: &str) -> Option<&LangEntry>

By exact file name, then extension.

Source

pub fn for_file(&self, path: &str, content: &str) -> Option<&LangEntry>

Self::for_path, then a naming convention, then the #! line.

Source

pub fn by_name(&self, name: &str) -> Option<&LangEntry>

Source

pub fn names(&self) -> Vec<&'static str>

Source

pub fn for_token(&self, token: &str) -> Option<&LangEntry>

A markdown fence token, by grammar name then extension.

Source

pub fn config_for_injection( &self, lang: &str, ) -> Option<&HighlightConfiguration>

Source

pub fn markdown_inline_spans( &self, content: &str, ) -> Vec<(Range<usize>, &'static str)>

Inline markdown captures with their highlight name, narrowest first so a first-match renderer picks the most specific.

Source§

impl LanguageRegistry

Source

pub fn scope_index(&self, path: &str, content: &str) -> ScopeIndex

Empty when the file has no grammar or tags query, is too large, or fails to parse.

Source

pub fn scope_index_as(entry: Option<&LangEntry>, content: &str) -> ScopeIndex

Self::scope_index with content parsed as entry’s language.

Source§

impl LanguageRegistry

Source

pub fn symbols(&self, path: &str, content: &str) -> (Vec<Ident>, ScopeIndex)

Every identifier in content and its definition spans, from one parse. Without a parse we fall back to plain words, strings and comments included.

Trait Implementations§

Source§

impl Default for LanguageRegistry

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

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.