|
1 | | -//! Handles adding a successfully parsed action to the list or logging skips in Pass 1. |
| 1 | +//! Handles adding a successfully parsed action to the list. |
2 | 2 |
|
3 | 3 | use crate::core_types::Action; |
4 | 4 | use std::collections::HashSet; |
5 | 5 |
|
6 | | -/// Adds the action if found, sets its original position, and marks the header as processed. |
7 | | -/// Logs a skip message if no action was found and the block wasn't skipped for other reasons. |
8 | | -#[allow(clippy::too_many_arguments)] |
9 | | -pub(crate) fn add_action_or_log_skip( |
10 | | - current_action: Option<Action>, |
11 | | - header_line_start_pos_rel: Option<usize>, |
| 6 | +/// Adds the action, sets its final original position, and marks the header as processed. |
| 7 | +pub(crate) fn add_action( |
| 8 | + mut action: Action, |
| 9 | + header_start_rel: usize, |
12 | 10 | action_source: &str, |
13 | 11 | parse_offset: usize, |
14 | | - block_content_start: usize, |
15 | | - original_block_start: usize, |
16 | 12 | actions_with_pos: &mut Vec<(usize, Action)>, |
17 | 13 | processed_header_starts: &mut HashSet<usize>, |
18 | 14 | ) { |
19 | | - if let (Some(mut action), Some(header_start_rel)) = (current_action, header_line_start_pos_rel) |
20 | | - { |
21 | | - let original_pos = header_start_rel + parse_offset; |
22 | | - // Ensure original_pos wasn't already set by wrapped header logic |
23 | | - if action.original_pos == 0 { |
24 | | - action.original_pos = original_pos; |
25 | | - } |
26 | | - println!( |
27 | | - " -> Adding action from source '{}' with original_pos {}", |
28 | | - action_source, action.original_pos |
29 | | - ); |
30 | | - actions_with_pos.push((action.original_pos, action)); // Use final original_pos for sorting |
31 | | - processed_header_starts.insert(original_pos); // Mark header associated with action |
32 | | - } else if action_source == "unknown" { |
33 | | - // Only log skip if no action was attempted from any source. |
34 | | - // Check if the block was skipped because of an *ignored* internal header |
35 | | - // (which would have been marked in processed_header_starts by handle_internal_header). |
36 | | - let first_line_start_original = block_content_start + parse_offset; |
37 | | - if !processed_header_starts.contains(&first_line_start_original) { |
38 | | - println!( |
39 | | - " Code block at original pos {} has no associated action header (checked external, wrapped, internal). Skipping.", |
40 | | - original_block_start |
41 | | - ); |
42 | | - } |
| 15 | + let original_pos = header_start_rel + parse_offset; |
| 16 | + // Ensure original_pos wasn't already set by wrapped header logic |
| 17 | + if action.original_pos == 0 { |
| 18 | + action.original_pos = original_pos; |
43 | 19 | } |
44 | | - // If action_source is known but current_action is None, it means a potential header |
45 | | - // was found but ignored (e.g., invalid path, wrapped header without next block), |
46 | | - // and the warning/info message was already printed by the respective handler. |
| 20 | + println!( |
| 21 | + " -> Adding action from source '{}' with original_pos {}", |
| 22 | + action_source, action.original_pos |
| 23 | + ); |
| 24 | + actions_with_pos.push((action.original_pos, action)); // Use final original_pos for sorting |
| 25 | + processed_header_starts.insert(original_pos); // Mark header associated with action |
47 | 26 | } |
0 commit comments