MCPcopy Create free account
hub / github.com/CodeBendKit/codeseek / execute_callers

Function execute_callers

rust-core/src/main.rs:499–546  ·  view source on GitHub ↗
(
    graph: &PetCodeGraph,
    symbol: &str,
    json: bool,
)

Source from the content-addressed store, hash-verified

497}
498
499fn execute_callers(
500 graph: &PetCodeGraph,
501 symbol: &str,
502 json: bool,
503) -> Result<String, Box<dyn std::error::Error>> {
504 let functions = graph.find_functions_by_name(symbol);
505 let mut output = String::new();
506
507 if json {
508 let mut results = Vec::new();
509 for func in &functions {
510 for (caller, relation) in graph.get_callers(&func.id) {
511 results.push(serde_json::json!({
512 "caller": caller.name,
513 "caller_file": caller.file_path,
514 "caller_line": relation.line_number,
515 "target": func.name,
516 }));
517 }
518 }
519 output = serde_json::to_string_pretty(&results)?;
520 } else {
521 for func in &functions {
522 let callers = graph.get_callers(&func.id);
523 if callers.is_empty() {
524 output.push_str(&format!("No callers for '{}'\n", func.name));
525 } else {
526 output.push_str(&format!("Callers of '{}':\n", func.name));
527 for (caller, relation) in callers {
528 output.push_str(&format!(
529 " {} ({}:{})\n",
530 caller.name,
531 caller.file_path.display(),
532 relation.line_number
533 ));
534 }
535 }
536 }
537 }
538
539 if functions.is_empty() {
540 if json {
541 output = "[]".to_string();
542 }
543 }
544
545 Ok(output)
546}
547
548fn execute_callees(
549 graph: &PetCodeGraph,

Callers 1

mainFunction · 0.85

Calls 3

to_stringMethod · 0.80
get_callersMethod · 0.45

Tested by

no test coverage detected