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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//! Dead code detection with cross-reference analysis
//!
//! This module provides advanced dead code detection capabilities through multi-level
//! reachability analysis, cross-language reference tracking, and dynamic dispatch resolution.
//! It identifies unreachable code segments, unused functions, and unreferenced variables
//! across multiple programming languages.
//!
//! # Architecture
//!
//! The dead code analyzer consists of several key components:
//! - **`HierarchicalBitSet`**: Efficient bitmap-based reachability tracking using Roaring bitmaps
//! - **`CrossLangReferenceGraph`**: Graph structure for tracking references across languages
//! - **`VTableResolver`**: Dynamic dispatch resolution for object-oriented languages
//! - **`DeadCodeAnalyzer`**: Main analysis engine that orchestrates the detection process
//!
//! # Analysis Process
//!
//! 1. **Build Reference Graph**: Constructs a cross-language reference graph from AST nodes
//! 2. **Mark Entry Points**: Identifies entry points (main functions, exported symbols, etc.)
//! 3. **Reachability Analysis**: Performs breadth-first traversal to mark reachable code
//! 4. **Dynamic Resolution**: Resolves virtual calls and dynamic dispatch targets
//! 5. **Dead Code Identification**: Reports unreachable code segments
//!
//! # Features
//!
//! - Cross-language reference tracking (Rust, Python, JavaScript, etc.)
//! - Dynamic dispatch resolution for OOP languages
//! - Hierarchical bitmap for efficient memory usage
//! - Confidence scoring for uncertain references
//! - Integration with dependency graphs and AST analysis
//!
//! # Example Usage
//!
//! ```rust
//! use pmat::services::dead_code_analyzer::DeadCodeAnalyzer;
//! use pmat::models::unified_ast::AstDag;
//!
//! // Create analyzer with node capacity
//! let mut analyzer = DeadCodeAnalyzer::new(1000);
//!
//! // Create AST DAG for analysis
//! let ast_dag = AstDag::new();
//!
//! // Perform dead code analysis
//! let report = analyzer.analyze(&ast_dag);
//!
//! if report.dead_functions.is_empty() {
//! println!("No dead code found!");
//! } else {
//! println!("Found {} dead functions", report.dead_functions.len());
//! for func in &report.dead_functions {
//! println!(" - {} at {}:{}", func.name, func.file_path, func.line_number);
//! }
//! }
//! ```
// Re-export all public items from submodules
pub use ;
pub use DeadCodeAnalyzer;
pub use ;