#[provable_contracts_macros::contract("pmat-core.yaml", equation = "path_exists")]
pub async fn discover_project_functions(project_path: &Path) -> Result<Vec<FunctionId>> {
eprintln!("\u{1f4c2} Discovering functions in project...");
let mut function_ids = Vec::new();
let mut file_count = 0;
use crate::services::file_discovery::{FileDiscoveryConfig, ProjectFileDiscovery};
let discovery = ProjectFileDiscovery::new(project_path.to_path_buf())
.with_config(FileDiscoveryConfig::default());
let files = discovery.discover_files()?;
for path in files {
let ext = path.extension().and_then(|e| e.to_str()).unwrap_or("");
if matches!(ext, "rs" | "ts" | "js" | "py" | "c" | "cpp" | "h" | "hpp") {
file_count += 1;
let relative_path = path
.strip_prefix(project_path)
.unwrap_or(&path)
.to_string_lossy()
.to_string();
function_ids.push(FunctionId {
file_path: relative_path.clone(),
function_name: "main".to_string(),
line_number: 1,
});
function_ids.push(FunctionId {
file_path: relative_path,
function_name: "test".to_string(),
line_number: 10,
});
}
}
eprintln!("\u{1f4ca} Found {file_count} source files");
Ok(function_ids)
}