use std::path::Path;
use super::parser::parse_source;
use crate::analysis_config::AnalysisConfig;
use crate::analyzer::LanguageAnalyzer;
use crate::code_unit::CodeUnit;
use std::error::Error;
pub struct RustAnalyzer;
impl RustAnalyzer {
#[must_use]
pub const fn new() -> Self {
Self
}
}
impl Default for RustAnalyzer {
fn default() -> Self {
Self::new()
}
}
impl LanguageAnalyzer for RustAnalyzer {
fn is_test_code(&self, unit: &CodeUnit) -> bool {
unit.is_test
}
fn file_extensions(&self) -> &[&str] {
&["rs"]
}
fn parse_file(
&self,
path: &Path,
source: &str,
config: &AnalysisConfig,
) -> Result<Vec<CodeUnit>, Box<dyn Error + Send + Sync>> {
parse_source(path, source, config.min_nodes, config.min_lines)
.map_err(|e| -> Box<dyn Error + Send + Sync> { e.into() })
}
}