use dk_core::{Symbol, SymbolKind, Visibility};
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum CommentStyle {
TripleSlash,
Hash,
SlashSlash,
DashDash,
}
pub trait LanguageConfig: Send + Sync {
fn language(&self) -> tree_sitter::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;
fn map_capture_to_kind(&self, capture_suffix: &str) -> Option<SymbolKind> {
default_kind_mapping(capture_suffix)
}
#[allow(unused_variables)]
fn adjust_symbol(&self, sym: &mut Symbol, node: &tree_sitter::Node, source: &[u8]) {
}
fn is_external_import(&self, module_path: &str) -> bool {
!module_path.starts_with('.')
&& !module_path.starts_with("crate")
&& !module_path.starts_with("self")
&& !module_path.starts_with("super")
}
}
pub fn default_kind_mapping(capture_suffix: &str) -> Option<SymbolKind> {
match capture_suffix {
"function" | "method" => Some(SymbolKind::Function),
"class" => Some(SymbolKind::Class),
"struct" => Some(SymbolKind::Struct),
"enum" => Some(SymbolKind::Enum),
"trait" => Some(SymbolKind::Trait),
"impl" => Some(SymbolKind::Impl),
"interface" => Some(SymbolKind::Interface),
"type_alias" | "type" => Some(SymbolKind::TypeAlias),
"const" | "expression" => Some(SymbolKind::Const),
"static" => Some(SymbolKind::Static),
"module" => Some(SymbolKind::Module),
"variable" => Some(SymbolKind::Variable),
_ => None,
}
}