brokk_bifrost_python/
knowledge.rs1use brokk_bifrost_core::analyzer::CodeUnit;
4use brokk_bifrost_core::analyzer::Language;
5use brokk_bifrost_core::analyzer::ProjectFile;
6use brokk_bifrost_core::analyzer::language_knowledge::LanguageKnowledge;
7use brokk_bifrost_core::analyzer::language_knowledge::ParserFlavor;
8use brokk_bifrost_core::analyzer::project::Project;
9use brokk_bifrost_core::analyzer::structural::spec::StructuralSpec;
10
11pub struct PythonKnowledge;
13
14impl LanguageKnowledge for PythonKnowledge {
15 fn declared_type_is_referent_immutable(&self, _canonical_type: &str) -> bool {
16 false
17 }
18
19 fn call_applicability_may_select_callee(&self) -> bool {
22 false
23 }
24
25 fn callable_result_is_applicability_independent(&self) -> bool {
29 true
30 }
31
32 fn keyed_property_reads_container_element(&self) -> bool {
33 true
34 }
35
36 fn language(&self) -> Language {
37 Language::Python
38 }
39
40 fn path_synthetic_module_unit(
41 &self,
42 project: &dyn Project,
43 file: &ProjectFile,
44 ) -> Option<CodeUnit> {
45 use crate::declarations::module_code_unit;
46 module_code_unit(project, file)
47 }
48
49 fn parser_language(&self, _flavor: ParserFlavor) -> tree_sitter::Language {
50 tree_sitter_python::LANGUAGE.into()
51 }
52
53 fn structural_spec(&self) -> &'static dyn StructuralSpec {
54 &crate::structural::PYTHON_STRUCTURAL_SPEC
55 }
56
57 fn highlight_query(&self) -> Option<&'static str> {
58 Some(tree_sitter_python::HIGHLIGHTS_QUERY)
59 }
60}