Skip to main content

dk_engine/parser/langs/
bash.rs

1//! Bash language configuration for the query-driven parser.
2
3use crate::parser::lang_config::{CommentStyle, LanguageConfig};
4use dk_core::Visibility;
5use tree_sitter::Language;
6
7/// Bash language configuration for [`QueryDrivenParser`](crate::parser::engine::QueryDrivenParser).
8pub struct BashConfig;
9
10impl LanguageConfig for BashConfig {
11    fn language(&self) -> Language {
12        tree_sitter_bash::LANGUAGE.into()
13    }
14
15    fn extensions(&self) -> &'static [&'static str] {
16        &["sh", "bash"]
17    }
18
19    fn symbols_query(&self) -> &'static str {
20        include_str!("../queries/bash_symbols.scm")
21    }
22
23    fn calls_query(&self) -> &'static str {
24        include_str!("../queries/bash_calls.scm")
25    }
26
27    fn imports_query(&self) -> &'static str {
28        // Bash uses `source` / `.` for includes, which are regular commands.
29        // We leave imports empty since they can't be reliably distinguished
30        // from other commands via tree-sitter queries.
31        include_str!("../queries/bash_imports.scm")
32    }
33
34    fn comment_style(&self) -> CommentStyle {
35        CommentStyle::Hash
36    }
37
38    fn resolve_visibility(&self, _modifiers: Option<&str>, _name: &str) -> Visibility {
39        // Bash has no visibility concept — all functions are global.
40        Visibility::Public
41    }
42
43    fn is_external_import(&self, _module_path: &str) -> bool {
44        true
45    }
46}