Skip to content

Commit a855a2b

Browse files
committed
wip
1 parent 51aa8e0 commit a855a2b

File tree

2 files changed

+19
-130
lines changed

2 files changed

+19
-130
lines changed

module/core/former/plan.md

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -101,22 +101,30 @@ Refactor the `former_for_enum` function in `former_meta/src/derive_former/former
101101
* **Rule Adherence Checkpoint:** Confirm strict adherence to `code/gen` instructions, Design Rules, and **especially Codestyle Rules (overriding existing style)** during implementation. Ensure no semantic changes.
102102
* **Crucial Design Rules:** Code clarity, maintainability.
103103
* **Verification Strategy:** Compile checks (`cargo check --package former_meta`). Run enum tests (`cargo test --package former --test former_enum_test`). **Analyze logs critically**. Ensure no regressions were introduced during cleanup.
104-
***Increment 9: Verify `standalone_constructors` logic.**
105-
* Detailed Plan Step 1: Review the implementation of standalone constructor generation within each handler function (added in Increments 3-8).
104+
***Increment 9: Define `EnumVariantHandlerContext` struct.** (New)
105+
***Increment 10: Refactor `former_for_enum` dispatcher to use context struct.** (New)
106+
***Increment 11: Refactor `handle_unit_variant` to use context struct.** (New)
107+
***Increment 12: Refactor `handle_tuple_zero_variant` to use context struct.** (New)
108+
***Increment 13: Refactor `handle_struct_zero_variant` to use context struct.** (New)
109+
***Increment 14: Refactor `handle_tuple_non_zero_variant` to use context struct.** (New)
110+
***Increment 15: Refactor `handle_struct_non_zero_variant` to use context struct.** (New)
111+
***Increment 16: Verify `standalone_constructors` logic.** (Was 9)
112+
* Detailed Plan Step 1: Review the implementation of standalone constructor generation within each handler function (now accessed via the context struct).
106113
* Detailed Plan Step 2: Ensure the logic correctly handles the `#[standalone_constructors]` struct attribute and the `#[arg_for_constructor]` field attribute according to the "Option 2" rules (return `Self` if all fields are args, otherwise return `Former`).
107114
* Detailed Plan Step 3: Manually inspect generated code snippets (using `#[debug]` if necessary) for a few representative enum variants to confirm correctness.
108115
* **Rule Adherence Checkpoint:** Confirm strict adherence to `code/gen` instructions, Design Rules, and **especially Codestyle Rules (overriding existing style)** during implementation. Ensure no semantic changes.
109116
* **Crucial Design Rules:** Correctness, adherence to specified constructor logic.
110117
* **Verification Strategy:** Compile checks (`cargo check --package former_meta`). Run tests specifically targeting standalone constructors (`cargo test --package former --test former_standalone_constructor_test` - assuming such tests exist or are added). **Analyze logs critically**.
111-
***Increment 10: Final review, cleanup, and documentation updates.**
112-
* Detailed Plan Step 1: Run `cargo clippy --package former_meta --fix --allow-dirty` to address lints.
113-
* Detailed Plan Step 2: Run the full test suite (`cargo test --all-targets` in workspace root or relevant crates) one last time.
114-
* Detailed Plan Step 3: Review all code changes made during the refactoring for clarity, consistency, and adherence to rules.
115-
* Detailed Plan Step 4: Update the documentation comments within the refactored code (e.g., the "Refactoring Plan" comment in `former_enum.rs`, comments in handlers).
116-
* Detailed Plan Step 5: Check if `Readme.md` or `advanced.md` in the `former` crate need updates (unlikely for this internal refactor, but good practice to check).
117-
* **Rule Adherence Checkpoint:** Confirm strict adherence to `code/gen` instructions, Design Rules, and **especially Codestyle Rules (overriding existing style)** during implementation. Ensure no semantic changes.
118+
***Increment 17: Apply strict codestyle, remove temporary comments, address clippy warnings, add documentation.** (Updated)
119+
* Detailed Plan Step 1: Run `cargo clippy --package former_meta --fix --allow-dirty` to automatically fix simpler lints.
120+
* Detailed Plan Step 2: Review remaining `cargo clippy --package former_meta` warnings and manually address them, ensuring adherence to codestyle and design rules.
121+
* Detailed Plan Step 3: Review all refactored files (`former_enum.rs` and handlers in `former_enum/`) for strict adherence to codestyle rules (spacing, newlines, etc.).
122+
* Detailed Plan Step 4: Remove temporary comments (e.g., `// qqq`, `// xxx`, `// FIX:`) from the refactored files. Preserve task comments (`// TODO:`).
123+
* Detailed Plan Step 5: Add/update documentation comments for the new `EnumVariantHandlerContext` struct and the refactored handler functions, explaining the context struct approach and rationale.
124+
* **Rule Adherence Checkpoint:** Confirm strict adherence to `code/gen` instructions, Design Rules, and **especially Codestyle Rules (overriding existing style)** during implementation. Ensure no semantic changes were introduced by clippy fixes or manual changes.
118125
* **Crucial Design Rules:** [Lints and warnings](#lints-and-warnings), [Comments and Documentation](#comments-and-documentation).
119-
* **Verification Strategy:** All tests pass (`cargo test --all-targets`). Clippy passes (`cargo clippy`). Manual code review confirms quality and documentation updates.
126+
* **Verification Strategy:** Compile checks (`cargo check --package former_meta`). Clippy passes (`cargo clippy --package former_meta`). Manual code review confirms quality, documentation updates, and comment cleanup.
127+
***Increment 18: Final review and verification.** (New)
120128

121129
## Notes & Insights
122130

@@ -142,4 +150,4 @@ Refactor the `former_for_enum` function in `former_meta/src/derive_former/former
142150
* **[2024-04-30/Increment 6] Insight:** Verified that the existing implementation for handling non-zero tuple variants in `tuple_non_zero.rs` is correct and passes tests. Removed an unused import in `tuple_non_zero.rs` as part of cleanup. Verified with `cargo check`.
143151
* **[2024-04-30/Increment 7] Insight:** Verified that the existing implementation for handling non-zero struct variants in `struct_non_zero.rs` is correct and passes tests. Verified with `cargo check` and `cargo test`.
144152
* **[2024-04-30/Increment 8] Insight:** Refactored the main `former_for_enum` function to act as a dispatcher, removing the code blocks that were moved to the handler functions. Verified with `cargo check` and `cargo test`.
145-
* **Insight:** Debugging revealed syntax errors in generated code related to comma placement in generic argument lists (e.g., `< () Enum<> >` vs `< (), Enum<> >`) and function signatures (trailing comma in `call` parameters). Careful construction of generic lists in `quote!` is crucial, especially when combining potentially empty enum generics with other parameters. Don't miss comma!
153+
* **Insight:** Debugging revealed syntax errors in generated code related to comma placement in generic argument lists (e.g., `< () Enum<> >` vs `< (), Enum<> >`) and function signatures (trailing comma in `call` parameters). Careful construction of generic lists in `quote!` is crucial, especially when combining potentially empty enum generics with other parameters. Don't miss comma!

0 commit comments

Comments
 (0)