Skip to main content

code_analyze_core/languages/
fortran.rs

1/// Tree-sitter query for extracting Fortran elements (functions and subroutines).
2///
3/// Module constructs are omitted: `module_statement` has no `name` field in
4/// tree-sitter-fortran 0.5.1, so `@class` captures would be counted in
5/// `analyze_directory` but produce no names in `analyze_file`. Modules will
6/// be added here once the grammar exposes a `name` field.
7pub const ELEMENT_QUERY: &str = r"
8(subroutine
9  (subroutine_statement) @function)
10
11(function
12  (function_statement) @function)
13";
14
15/// Tree-sitter query for extracting Fortran function calls.
16pub const CALL_QUERY: &str = r"
17(subroutine_call
18  (identifier) @call)
19
20(call_expression
21  (identifier) @call)
22";
23
24/// Tree-sitter query for extracting Fortran type references.
25pub const REFERENCE_QUERY: &str = r"
26(name) @type_ref
27";
28
29/// Tree-sitter query for extracting Fortran imports (USE statements).
30pub const IMPORT_QUERY: &str = r"
31(use_statement
32  (module_name) @import_path)
33";
34
35use tree_sitter::Node;
36
37/// Extract inheritance information from a Fortran node.
38/// Fortran does not have classical inheritance; return empty.
39#[must_use]
40pub fn extract_inheritance(_node: &Node, _source: &str) -> Vec<String> {
41    Vec::new()
42}