pub trait LanguageExt: Language {
    // Required method
    fn get_ts_language(&self) -> TSLanguage;
    // Provided methods
    fn ast_grep<S: AsRef<str>>(&self, source: S) -> AstGrep<StrDoc<Self>> { ... }
    fn injectable_languages(&self) -> Option<&'static [&'static str]> { ... }
    fn extract_injections<L: LanguageExt>(
        &self,
        _root: Node<'_, StrDoc<L>>,
    ) -> HashMap<String, Vec<TSRange>> { ... }
}Expand description
tree-sitter specific language trait
Required Methods§
Sourcefn get_ts_language(&self) -> TSLanguage
 
fn get_ts_language(&self) -> TSLanguage
tree sitter language to parse the source
Provided Methods§
Sourcefn ast_grep<S: AsRef<str>>(&self, source: S) -> AstGrep<StrDoc<Self>>
 
fn ast_grep<S: AsRef<str>>(&self, source: S) -> AstGrep<StrDoc<Self>>
Create an AstGrep instance for the language
fn injectable_languages(&self) -> Option<&'static [&'static str]>
Sourcefn extract_injections<L: LanguageExt>(
    &self,
    _root: Node<'_, StrDoc<L>>,
) -> HashMap<String, Vec<TSRange>>
 
fn extract_injections<L: LanguageExt>( &self, _root: Node<'_, StrDoc<L>>, ) -> HashMap<String, Vec<TSRange>>
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.