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 185293 - Delete "Negate if condition" hint
Summary: Delete "Negate if condition" hint
Status: RESOLVED WONTFIX
Alias: None
Product: contrib
Classification: Unclassified
Component: Code (show other bugs)
Version: 6.x
Hardware: PC Linux
: P3 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-04-29 22:53 UTC by Jesse Glick
Modified: 2010-05-04 04:35 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Jesse Glick 2010-04-29 22:53:36 UTC
I'm not sure what this "hint" is for - it is not really a hint about something you are doing wrong - but it seems rather dangerous. If you have

if (a != b) doWhatever();

and you see "doWhatever();" underlined, you will think: "ah, if-statement without braces; I will use Alt-ENTER ENTER to accept the suggested fix". And usually this works. But depending on timing of your keystrokes, sometimes "Negate if condition" comes first, so that rather than

if (a != b) {
    doWhatever();
}

you wind up with

if (a == b) doWhatever();

! If you are not paying close attention, you can introduce subtle logic bugs into your code this way.

Please consider deleting the "Negate if condition" context menu item; surely typing an exclamation point is easier than accepting this hint anyway. (You're not going to have menu items to "Add 1 to number", are you?)
Comment 1 Jan Lahoda 2010-05-03 11:51:58 UTC
This is a special kind of "hints", called suggestions. It does not say that something is wrong, but rather allows the user to do something simply by using a fix rather then by hand. There are more such suggestions, e.g. Assign Result to a New Variable, Convert Annonymous to Inner, etc. Tranditionally, there was no UI for suggestions, and so some of them where incorrectly listed under General category in Hints. I have created a special category for the suggestions under the Hint tab in options for now:
http://hg.netbeans.org/jet-main/rev/10e41de42089
So the suggestions can be disabled in the same way as hints. I have also put this particular fix below other "normal" fixes:
http://hg.netbeans.org/main/contrib/rev/0c330887b652

While typing '!' is simple, moving caret to the correct place, wrapping the condition with parentheses if needed and possibly applying De Morgan's laws (to simplify the expression) can be more work than pressing Alt-Enter and so I still think the suggestion is meaningful.
Comment 2 Quality Engineering 2010-05-04 04:35:12 UTC
Integrated into 'main-golden', will be available in build *201005040200* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/
User: 
Log: