Skip to main content

LanguageConfig

Trait LanguageConfig 

Source
pub trait LanguageConfig: Send + Sync {
    // Required methods
    fn language(&self) -> Language;
    fn extensions(&self) -> &'static [&'static str];
    fn symbols_query(&self) -> &'static str;
    fn calls_query(&self) -> &'static str;
    fn imports_query(&self) -> &'static str;
    fn comment_style(&self) -> CommentStyle;
    fn resolve_visibility(
        &self,
        modifiers: Option<&str>,
        name: &str,
    ) -> Visibility;

    // Provided methods
    fn map_capture_to_kind(&self, capture_suffix: &str) -> Option<SymbolKind> { ... }
    fn adjust_symbol(&self, sym: &mut Symbol, node: &Node<'_>, source: &[u8]) { ... }
    fn is_external_import(&self, module_path: &str) -> bool { ... }
}
Expand description

Configuration a language must supply so the generic QueryDrivenParser can extract symbols, calls, and imports.

Required Methods§

Source

fn language(&self) -> Language

The tree-sitter [Language] grammar.

Source

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

File extensions this language handles (without leading dot).

Source

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

Tree-sitter S-expression query that captures symbols.

Capture names must end with a kind suffix that default_kind_mapping (or an override of map_capture_to_kind) understands, e.g. @definition.function, @definition.class.

Source

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

Tree-sitter S-expression query that captures call-sites.

Source

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

Tree-sitter S-expression query that captures import statements.

Source

fn comment_style(&self) -> CommentStyle

The comment style used for doc-comments.

Source

fn resolve_visibility(&self, modifiers: Option<&str>, name: &str) -> Visibility

Resolve the visibility of a symbol from its modifier keywords and name.

Provided Methods§

Source

fn map_capture_to_kind(&self, capture_suffix: &str) -> Option<SymbolKind>

Map a tree-sitter capture suffix (e.g. "function") to a SymbolKind. The default delegates to default_kind_mapping.

Source

fn adjust_symbol(&self, sym: &mut Symbol, node: &Node<'_>, source: &[u8])

Post-process hook that can mutate a Symbol after extraction.

Override this when the generic engine cannot capture all details through queries alone (e.g. Rust pub(crate) modifiers).

Source

fn is_external_import(&self, module_path: &str) -> bool

Return true if module_path refers to an external dependency.

Paths starting with ., crate, self, or super are considered internal by default.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§