Skip to content

Feature Request: Bulk Removal of Enum Case in Swift #78118

Open
@shishawn

Description

@shishawn

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:

  1. Manually identifying all places where the enum case is referenced.
  2. 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:

  1. Allows a developer to select an enum case for removal.
  2. Automatically identifies and updates all references to the case across the codebase.
  3. Removes references where appropriate, specifically:
    a. In switch statements, remove the corresponding reference.
    b. Remove the entire switch statement if the removed case was its sole clause.
  4. Replaces references with placeholders for manual intervention when they cannot be safely removed or modified automatically.

Alternatives considered

N/A

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    SourceKitArea → source tooling: SourceKitfeatureA feature request or implementationrefactoringArea → source tooling: refactoringsource toolingArea: IDE support, SourceKit, and other source tooling

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions