use std::path::{Path, PathBuf};
const SUPPORTED_EXTENSIONS: &[&str] = &[
"rs", "py", "js", "ts", "tsx", "jsx", "go", "java", "c", "cpp", "h", "hpp", "rb", "swift",
"kt", "scala",
];
pub fn scan_source_files(root: &Path) -> Vec<PathBuf> {
let mut files = Vec::new();
let walker = ignore::WalkBuilder::new(root)
.hidden(true) .git_ignore(true) .git_global(true) .git_exclude(true) .require_git(false) .add_custom_ignore_filename(".colletignore") .max_depth(Some(20)) .build();
for entry in walker {
let entry = match entry {
Ok(e) => e,
Err(_) => continue,
};
if !entry.file_type().is_some_and(|ft| ft.is_file()) {
continue;
}
let path = entry.path();
if let Some(ext) = path.extension().and_then(|e| e.to_str())
&& SUPPORTED_EXTENSIONS.contains(&ext)
{
files.push(path.to_path_buf());
}
}
files.sort();
files
}