codegraph_parser_api/relationships/
calls.rs

1use serde::{Deserialize, Serialize};
2
3/// Represents a function call relationship
4#[derive(Debug, Clone, PartialEq, Eq, Hash, Serialize, Deserialize)]
5pub struct CallRelation {
6    /// Caller function name
7    pub caller: String,
8
9    /// Callee function name
10    pub callee: String,
11
12    /// Line number where the call occurs
13    pub call_site_line: usize,
14
15    /// Is this a direct call or indirect (e.g., through function pointer)?
16    pub is_direct: bool,
17}
18
19impl CallRelation {
20    pub fn new(caller: impl Into<String>, callee: impl Into<String>, line: usize) -> Self {
21        Self {
22            caller: caller.into(),
23            callee: callee.into(),
24            call_site_line: line,
25            is_direct: true,
26        }
27    }
28
29    pub fn indirect(mut self) -> Self {
30        self.is_direct = false;
31        self
32    }
33}