This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 271077

Summary: Hint 'Possible fall-through into case' should also include option to add 'break' statement
Product: java Reporter: MCEmperor
Component: HintsAssignee: Svata Dedic <sdedic>
Status: NEW ---    
Severity: normal    
Priority: P3    
Version: Dev   
Hardware: PC   
OS: All   
Issue Type: ENHANCEMENT Exception Reporter:

Description MCEmperor 2017-07-12 10:20:30 UTC
When I have the code

int a = 2;
switch (a) {
    case 1:
        System.out.println("one");
    case 2:
        System.out.println("two");
        break;
    default:
        System.out.println("other");
        break;
}

Netbeans will hint me about the fall-through with the message "[fallthrough] Possible fall-through into case", which is the desired behavior. However, when I open the quick-fix menu by clicking on the warning or typing Alt + Enter, the only quick fix available is "Suppress Warning - fallthrough".

There should also be an option to add the 'break' statement:

"Add break statement"

The code, of course, becomes this:

int a = 2;
switch (a) {
    case 1:
        System.out.println("one");
        break;
    case 2:
        System.out.println("two");
        break;
    default:
        System.out.println("other");
        break;
}