Skip to main content

find_calls_to

Function find_calls_to 

Source
pub fn find_calls_to<'a>(
    cpg: &'a CodePropertyGraph,
    func_name: &str,
) -> Vec<&'a Node>
Expand description

Returns all call sites that target a function with the given func_name.

The comparison is done only on the node’s name; no overload resolution is performed.

§Examples

use icb_graph::graph::{CodePropertyGraph, Node};
use icb_graph::query::find_calls_to;
use icb_common::NodeKind;

let mut cpg = CodePropertyGraph::new();
cpg.graph.add_node(Node {
    kind: NodeKind::CallSite,
    name: Some("foo".into()),
    usr: None,
    start_line: 1,
    end_line: 1,
});

let calls = find_calls_to(&cpg, "foo");
assert_eq!(calls.len(), 1);