Open
Description
Motivation
Enumerations are widely used in Swift for type safety and clean code. However, removing a case from an enum can be challenging, as it requires:
- Manually identifying all places where the enum case is referenced.
- Updating these references to handle the removal appropriately, either by replacing them with a default behavior or removing unreachable code.
This process is error-prone, especially in large codebases where enums are used extensively.
Proposed solution
Update Swift’s refactoring capabilities with a "Remove Enum Case" functionality that:
- Allows a developer to select an enum case for removal.
- Automatically identifies and updates all references to the case across the codebase.
- Removes references where appropriate, specifically:
a. Inswitch
statements, remove the corresponding reference.
b. Remove the entireswitch
statement if the removed case was its sole clause. - Replaces references with placeholders for manual intervention when they cannot be safely removed or modified automatically.
Alternatives considered
N/A
Additional information
No response