#![cfg_attr(coverage_nightly, coverage(off))]
#[cfg(feature = "kotlin-ast")]
use crate::services::context::AstItem;
#[cfg(feature = "kotlin-ast")]
use std::path::{Path, PathBuf};
#[cfg(feature = "kotlin-ast")]
pub struct KotlinAstVisitor {
items: Vec<AstItem>,
_file_path: PathBuf,
package_name: String,
class_count: usize,
coroutine_count: usize,
}
#[cfg(feature = "kotlin-ast")]
pub struct KotlinComplexityAnalyzer {
cyclomatic_complexity: u32,
cognitive_complexity: u32,
coroutine_complexity: u32,
}
include!("kotlin_visitor.rs");
include!("kotlin_complexity.rs");
#[cfg(feature = "kotlin-ast")]
pub async fn analyze_kotlin_file(file_path: &Path) -> anyhow::Result<Vec<AstItem>> {
let source = std::fs::read_to_string(file_path)?;
let visitor = KotlinAstVisitor::new(file_path);
visitor
.analyze_kotlin_source(&source)
.map_err(|e| anyhow::anyhow!("{e}"))
}
#[cfg(not(feature = "kotlin-ast"))]
pub async fn analyze_kotlin_file(
_file_path: &std::path::Path,
) -> anyhow::Result<Vec<crate::services::context::AstItem>> {
Ok(Vec::new())
}
include!("kotlin_tests.rs");