Skip to main content

scc_cli/
resolve.rs

1//! `scc resolve --lsp`: upgrade EXTRACTED call edges to RESOLVED through
2//! every available semantic backend (Wave 4 ยง23): .py -> pyright, TS/JS ->
3//! typescript-language-server. Requires an existing index; missing tools
4//! degrade with a hint (exit 0).
5
6use crate::open_store;
7use std::path::Path;
8
9pub const MAX_CALL_SITES: usize = scc_indexer::resolver::MAX_CALL_SITES;
10
11/// `scc resolve --lsp` โ€” delegates to the shared language-aware dispatcher.
12pub fn cmd_resolve_lsp(root: &Path) -> crate::Result<()> {
13    let store = open_store(root)?;
14    if store.latest_snapshot()?.is_none() {
15        return Err(crate::CliError::Other(
16            "no index found โ€” run `scc index` before `scc resolve --lsp`".to_string(),
17        ));
18    }
19    let report =
20        scc_indexer::resolver::resolve_repository(&store, root, MAX_CALL_SITES)
21            .map_err(crate::CliError::Other)?;
22    if report.remaining_candidates == 0 && report.backends_used.is_empty() {
23        println!("no EXTRACTED call edges to resolve");
24        return Ok(());
25    }
26    for missing in &report.backends_missing {
27        println!("{missing} not found โ€” install to resolve that language");
28    }
29    println!(
30        "lsp ({}): {} upgraded, {} unresolved, {} errors; {} file(s) still candidate",
31        report.backends_used.join("+"),
32        report.upgraded,
33        report.unresolved,
34        report.errors,
35        report.remaining_candidates
36    );
37    Ok(())
38}