Trait SupportedLanguage

Source
pub trait SupportedLanguage: Send + Sync {
    // Required methods
    fn name(&self) -> &'static str;
    fn file_exts(&self) -> &'static [&'static str];
    fn language(&self) -> Language;
    fn query(&self, name: &str) -> String;
}

Required Methods§

Source

fn name(&self) -> &'static str

The name of this language

Source

fn file_exts(&self) -> &'static [&'static str]

The list of file extensions used for this language.

Source

fn language(&self) -> Language

The tree_sitter::Language for this language

Source

fn query(&self, name: &str) -> String

Given an identifier(name) this should produce a string that is the sexp of a query that finds all matches of function-like things with given name

§Example:
fn query(name: &str) -> String {
    format!("((function_item
  name: (identifier) @method-name)
  @method-definition
(#eq? @method-name {name}))
((let_declaration
  pattern: (identifier) @method-name
  value: (closure_expression)) @method-definition
(#eq? @method-name {name}))
((const_item
  name: (identifier) @method-name
  value: (closure_expression)) @method-definition
(#eq? @method-name {name}))
((static_item
  name: (identifier) @method-name
  value: (closure_expression)) @method-definition
(#eq? @method-name {name}))")
}

Implementors§