#![cfg_attr(coverage_nightly, coverage(off))]
use std::collections::{HashMap, HashSet};
use crate::services::complexity::{
ComplexityMetrics, FileComplexityMetrics, FunctionComplexity, HalsteadMetrics,
};
use super::types::{
ActorInfo, DeadlockWarning, MessageFlow, RuchyActorAnalysis, RuchyAst, RuchyDeadCode,
RuchyImport, RuchyToken, RuchyType,
};
pub struct RuchyComplexityAnalyzer {
pub(super) current_complexity: ComplexityMetrics,
pub(super) nesting_level: u8,
pub(super) functions: Vec<FunctionComplexity>,
pub(super) classes: Vec<crate::services::complexity::ClassComplexity>,
pub(super) operators: HashSet<String>,
pub(super) operands: HashSet<String>,
pub(super) operator_count: u32,
pub(super) operand_count: u32,
pub(super) defined_functions: HashSet<String>,
pub(super) called_functions: HashSet<String>,
pub(super) defined_variables: HashSet<String>,
pub(super) used_variables: HashSet<String>,
#[allow(dead_code)]
pub(super) type_environment: HashMap<String, RuchyType>,
pub(super) imports: Vec<RuchyImport>,
pub(super) exports: HashSet<String>,
pub(super) actors: Vec<ActorInfo>,
pub(super) current_actor: Option<String>,
pub(super) message_flows: Vec<MessageFlow>,
pub(super) _spawn_calls: Vec<(String, String, u32)>,
}
impl Default for RuchyComplexityAnalyzer {
fn default() -> Self {
Self::new()
}
}
impl RuchyComplexityAnalyzer {
#[must_use]
pub fn new() -> Self {
Self {
current_complexity: ComplexityMetrics::default(),
nesting_level: 0,
functions: Vec::new(),
classes: Vec::new(),
operators: HashSet::new(),
operands: HashSet::new(),
operator_count: 0,
operand_count: 0,
defined_functions: HashSet::new(),
called_functions: HashSet::new(),
defined_variables: HashSet::<String>::new(),
used_variables: HashSet::new(),
type_environment: HashMap::new(),
imports: Vec::new(),
exports: HashSet::new(),
actors: Vec::new(),
current_actor: None,
message_flows: Vec::new(),
_spawn_calls: Vec::new(),
}
}
}
include!("complexity_halstead.rs");
include!("complexity_accessors.rs");
include!("complexity_analysis.rs");