1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#![cfg_attr(coverage_nightly, coverage(off))]
//! Swift Source File Analysis Support for PMAT
//!
//! This module provides Swift-specific analysis capabilities using lexical analysis
//! and partial AST extraction for Swift files within static analysis constraints.
#[cfg(feature = "swift-ast")]
use crate::services::context::AstItem;
use std::path::{Path, PathBuf};
/// Swift source analyzer that extracts Swift-specific information
pub struct SwiftSourceAnalyzer {
items: Vec<AstItem>,
_file_path: PathBuf,
source_name: String,
function_count: usize,
class_count: usize,
method_count: usize,
}
/// Swift complexity analyzer for Swift-specific metrics (complexity ≤10)
pub struct SwiftComplexityAnalyzer {
cyclomatic_complexity: u32,
cognitive_complexity: u32,
}
impl Default for SwiftComplexityAnalyzer {
fn default() -> Self {
Self::new()
}
}
// SwiftSourceAnalyzer implementation: constructor, analysis, and extraction methods
include!("swift_analysis.rs");
// SwiftComplexityAnalyzer implementation: constructor and complexity analysis
include!("swift_complexity.rs");
// Unit tests for Swift analysis and complexity
include!("swift_tests.rs");