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 - Hint 'Possible fall-through into case' should also include option to add 'break' statement
Summary: Hint 'Possible fall-through into case' should also include option to add 'bre...
Status: NEW
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: Dev
Hardware: PC All
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-07-12 10:20 UTC by MCEmperor
Modified: 2017-07-12 10:20 UTC (History)
0 users

See Also:
Issue Type: ENHANCEMENT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
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;
}