refactor(joinir): Phase 223 cleanup - impl consolidation & comment cleanup
Improves code organization and readability after Phase 223-3 implementation. ## Task R-1: impl Block Consolidation **loop_body_cond_promoter.rs**: - Merged 2 separate impl blocks into single unified impl - Added section headers for better organization: - Public API (extract_continue_condition, try_promote_for_condition) - Private Helpers (contains_continue) - Improved logical flow and discoverability ## Task R-2: Phase Comment Cleanup **pattern4_with_continue.rs**: - Simplified Phase 223-3 comments (removed redundant phase numbers) - Added concise section header explaining LoopBodyLocal promotion - Clarified inline comments for better understanding - Maintained implementation intent while reducing noise ## Impact - No functional changes - All tests PASS (5 cond_promoter tests, 8 pattern4 tests) - Better code organization for future maintenance - Cleaner git history for Phase 223 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -85,6 +85,10 @@ pub enum ConditionPromotionResult {
|
||||
pub struct LoopBodyCondPromoter;
|
||||
|
||||
impl LoopBodyCondPromoter {
|
||||
// ========================================================================
|
||||
// Public API
|
||||
// ========================================================================
|
||||
|
||||
/// Extract continue condition from loop body
|
||||
///
|
||||
/// Finds the first if statement with continue in then-branch and returns its condition.
|
||||
@ -123,33 +127,6 @@ impl LoopBodyCondPromoter {
|
||||
None
|
||||
}
|
||||
|
||||
/// Check if statements contain a continue statement
|
||||
fn contains_continue(stmts: &[ASTNode]) -> bool {
|
||||
for stmt in stmts {
|
||||
match stmt {
|
||||
ASTNode::Continue { .. } => return true,
|
||||
ASTNode::If {
|
||||
then_body,
|
||||
else_body,
|
||||
..
|
||||
} => {
|
||||
if Self::contains_continue(then_body) {
|
||||
return true;
|
||||
}
|
||||
if let Some(else_stmts) = else_body {
|
||||
if Self::contains_continue(else_stmts) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
impl LoopBodyCondPromoter {
|
||||
/// Try to promote LoopBodyLocal variables in conditions
|
||||
///
|
||||
/// ## P0 Requirements (Category A-3)
|
||||
@ -223,6 +200,35 @@ impl LoopBodyCondPromoter {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ========================================================================
|
||||
// Private Helpers
|
||||
// ========================================================================
|
||||
|
||||
/// Check if statements contain a continue statement
|
||||
fn contains_continue(stmts: &[ASTNode]) -> bool {
|
||||
for stmt in stmts {
|
||||
match stmt {
|
||||
ASTNode::Continue { .. } => return true,
|
||||
ASTNode::If {
|
||||
then_body,
|
||||
else_body,
|
||||
..
|
||||
} => {
|
||||
if Self::contains_continue(then_body) {
|
||||
return true;
|
||||
}
|
||||
if let Some(else_stmts) = else_body {
|
||||
if Self::contains_continue(else_stmts) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
|
||||
Reference in New Issue
Block a user