pub fn find_by_kind(cpg: &CodePropertyGraph, kind: NodeKind) -> Vec<&Node>Expand description
Returns all nodes of the given kind.
Traverses the entire graph and collects every node whose
NodeKind matches the requested kind.
ยงExamples
use icb_graph::graph::{CodePropertyGraph, Node};
use icb_graph::query::find_by_kind;
use icb_common::NodeKind;
let mut cpg = CodePropertyGraph::new();
cpg.graph.add_node(Node {
kind: NodeKind::Function,
name: Some("main".into()),
usr: None,
start_line: 1,
end_line: 5,
});
let functions = find_by_kind(&cpg, NodeKind::Function);
assert_eq!(functions.len(), 1);