Skip to content

[CodeAction] Add missing cases to a match statementΒ #350

@ghostbuster91

Description

@ghostbuster91

Is your feature request related to a problem? Please describe.

Let's imagine that we have a following match statement over some ADT:

enum Tree{
  case Int
  case String
}

//... 

tree match {
  case Tree.Int => println(1)
  case Tree.String => println(2)
}

We then modify ADT by adding two more cases - Double and Float.
Now, the compiler warns/emits error (depending on the project settings) that the match might not be exhaustive.

Describe the solution you'd like

I would like to have a code action that can be invoked on the mentioned match statement, that, when accepted, would add missing cases with ??? as implementation.

tree match {
  case Tree.Int => println(1)
  case Tree.String => println(2)
  case Tree.Double => ???
  case Tree.Float =>  ???
}

Describe alternatives you've considered

Write each missing case taking advantage from completions.

Additional context

No response

Search terms

code-action match case

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions