pub trait LanguageExt: Language {
// Required method
fn get_ts_language(&self) -> Language;
// Provided methods
fn ast_grep<S>(&self, source: S) -> Root<StrDoc<Self>>
where S: AsRef<str> { ... }
fn injectable_languages(&self) -> Option<&'static [&'static str]> { ... }
fn extract_injections<L>(
&self,
_root: Node<'_, StrDoc<L>>,
) -> HashMap<String, Vec<Range>>
where L: LanguageExt { ... }
}
Expand description
tree-sitter specific language trait
Required Methods§
Sourcefn get_ts_language(&self) -> Language
fn get_ts_language(&self) -> Language
tree sitter language to parse the source
Provided Methods§
Sourcefn ast_grep<S>(&self, source: S) -> Root<StrDoc<Self>>
fn ast_grep<S>(&self, source: S) -> Root<StrDoc<Self>>
Create an AstGrep
instance for the language
fn injectable_languages(&self) -> Option<&'static [&'static str]>
Sourcefn extract_injections<L>(
&self,
_root: Node<'_, StrDoc<L>>,
) -> HashMap<String, Vec<Range>>where
L: LanguageExt,
fn extract_injections<L>(
&self,
_root: Node<'_, StrDoc<L>>,
) -> HashMap<String, Vec<Range>>where
L: LanguageExt,
get injected language regions in the root document. e.g. get JavaScripts in HTML it will return a list of tuples of (language, regions). The first item is the embedded region language, e.g. javascript The second item is a list of regions in tree_sitter. also see https://tree-sitter.github.io/tree-sitter/using-parsers#multi-language-documents
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.