Skip to main content

fallow_engine/
trace_chain.rs

1//! Symbol trace types exposed through the engine boundary.
2
3use crate::{EngineError, EngineResult, session::AnalysisSession};
4
5use fallow_types::trace_chain::{SymbolChainQuery, SymbolChainTrace};
6
7#[path = "trace_chain_impl.rs"]
8mod trace_chain_impl;
9
10/// Run symbol-level call-chain tracing through an existing analysis session.
11///
12/// # Errors
13///
14/// Returns an error if parsing, graph construction, or retained module
15/// analysis fails.
16pub fn trace_symbol_chain_with_session(
17    session: &AnalysisSession,
18    query: SymbolChainQuery<'_>,
19) -> EngineResult<Option<SymbolChainTrace>> {
20    let output = session.analyze_dead_code_with_shared_artifacts(true, true)?;
21    let graph = output
22        .graph
23        .as_ref()
24        .ok_or_else(|| EngineError::new("trace requires a retained module graph"))?;
25    let modules = output.modules.as_deref().unwrap_or(&[]);
26    Ok(trace_chain_impl::trace_symbol_chain(
27        graph.as_graph(),
28        modules,
29        session.root(),
30        query,
31    ))
32}