brokk_bifrost_cpp/
knowledge.rs1use brokk_bifrost_core::analyzer::Language;
4use brokk_bifrost_core::analyzer::language_knowledge::LanguageKnowledge;
5use brokk_bifrost_core::analyzer::language_knowledge::ParserFlavor;
6use brokk_bifrost_core::analyzer::structural::spec::StructuralSpec;
7
8pub struct CppKnowledge;
10
11impl LanguageKnowledge for CppKnowledge {
12 fn declared_type_is_referent_immutable(&self, _canonical_type: &str) -> bool {
13 false
14 }
15
16 fn language(&self) -> Language {
17 Language::Cpp
18 }
19
20 fn skips_local_declaration(&self, node: tree_sitter::Node<'_>, source: &str) -> bool {
21 match node.kind() {
22 "declaration" => {
23 crate::declarations::is_direct_recovered_exported_class_field_declaration(
24 node, source,
25 )
26 }
27 "init_declarator" => node.parent().is_some_and(|declaration| {
28 crate::declarations::is_direct_recovered_exported_class_field_declaration(
29 declaration,
30 source,
31 )
32 }),
33 _ => false,
34 }
35 }
36
37 fn package_separator(&self) -> &'static str {
38 "::"
39 }
40
41 fn qualified_call_separator(&self) -> &'static str {
42 "::"
43 }
44
45 fn parser_language(&self, _flavor: ParserFlavor) -> tree_sitter::Language {
46 tree_sitter_cpp::LANGUAGE.into()
47 }
48
49 fn structural_spec(&self) -> &'static dyn StructuralSpec {
50 &crate::structural::CPP_STRUCTURAL_SPEC
51 }
52
53 fn highlight_query(&self) -> Option<&'static str> {
54 Some(tree_sitter_cpp::HIGHLIGHT_QUERY)
55 }
56}