Exhaustive Switch Completion from SourceKit-LSP

Xcode has a nice completion for an exhaustive switch statement. I was wondering it this is implemented and available in sourcekit-lsp / sourcekit?

enum Message {
    case a
    case b
    case c
}

func great(message: Message) {

    // switch m -> Expandable to:
    switch message {
    case .a:
        <#code#>
    case .b:
        <#code#>
    case .c:
        <#code#>
    }
}
1 Like

This code completion is implemented in Xcode, not sourcekitd or sourcekit-lsp so it currently isn’t available in editors that use sourcekit-lsp.

There is a refactoring action to add cases for all enums cases, on the switch keyword.

2 Likes

Thanks @ahoppen. The code action for adding missing cases/all cases works for my use case.

Is there a page / source code link where people can find the complete list of contextual code actions?

There is not. If I remember correctly, this one is actually a Fix-It for the error that you’re seeing and not a refactoring in the strict sense.