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 243393 - No "Convert to switch" hint offered for primitive datatypes
Summary: No "Convert to switch" hint offered for primitive datatypes
Status: RESOLVED FIXED
Alias: None
Product: java
Classification: Unclassified
Component: Hints (show other bugs)
Version: 8.0
Hardware: PC Mac OS X
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-03-31 08:04 UTC by host
Modified: 2015-04-23 02:10 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 host 2014-03-31 08:04:53 UTC
For

    String value;
    if (value.equals("0")) {
      // Test 0
    } else if (value.equals("1")) {
      // Test 1
    }

the "Convert to switch" hint is offered.

But for 

    int value;
    if (value == 0) {
      // Test 0
    } else if (value == 1) {
      // Test 1
    }

*no* hint is offered.

The same applies if you use any other primitive datatype where also no hint is offered.
Comment 1 Svata Dedic 2015-04-07 13:16:19 UTC
:) the Convert to Switch was done specifically to promote new JDK7 feature, but a generic hint/suggestion can be made with some threshold on number of if-elseif branches. More branches would trigger the hint.
Comment 2 Svata Dedic 2015-04-21 15:37:05 UTC
Implemented in jet-main#3df66d0ab7d4
Comment 3 Quality Engineering 2015-04-23 02:10:47 UTC
Integrated into 'main-silver', will be available in build *201504230001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)

Changeset: http://hg.netbeans.org/main-silver/rev/3df66d0ab7d4
User: Svata Dedic <sdedic@netbeans.org>
Log: #243393: convert to switch suggestion implemented for primitives and enums