eclipse-jdt / eclipse.jdt.ui

Eclipse Public License 2.0
32 stars 79 forks source link

Quickfix for empty switch should propose to add a default branch as an expression #1459

Closed nlisker closed 2 weeks ago

nlisker commented 1 month ago

From https://github.com/eclipse-jdt/eclipse.jdt.core/issues/2565.

sealed interface Type {

    final class A implements Type {}
    final class B implements Type {}

    default void a() {
        Type t;
        switch (t) {
        }
    }
}

A quickfix option for the empty switch proposes to add a default branch. That default branch is added as a switch statement (with default: break) rather than an expression (default -> {}), which users might not want as the default completion. Probably the solution is to add an option to add it as an expression.