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 192562 - [70cat][hints] Creating a Local Variable when missing a preceeding '{' can cause invalid declaration.
Summary: [70cat][hints] Creating a Local Variable when missing a preceeding '{' can ca...
Status: RESOLVED INCOMPLETE
Alias: None
Product: editor
Classification: Unclassified
Component: Hints & Annotations (show other bugs)
Version: 7.0
Hardware: All All
: P3 normal (vote)
Assignee: Jan Lahoda
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-11-27 04:16 UTC by esmithbss
Modified: 2010-12-02 08:46 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 esmithbss 2010-11-27 04:16:30 UTC
Product Version = NetBeans IDE Dev (Build 201011250001)
Operating System = Windows XP version 5.1 running on x86
Java; VM; Vendor = 1.6.0_20
Runtime = Java HotSpot(TM) Client VM 16.3-b01

In the event that a developer misses an open brace for a code block and the hint indicates the first line of the block to be incorrect with a hint of:

     Create Local Variable <name>

If the line already contains the proper type declaration, the type declaration is duplicated.

ex: For the code segment:

    if ( name != null )
      String normalized = name.trim().toUpperCase();

If the "Create Local Variable normalized" hint for the invalid code line beginning with "String normalized" is taken, the resulting code is:

    if ( name != null )
      StringString normalized = name.trim().toUpperCase();
Comment 1 Jan Lahoda 2010-11-29 07:46:11 UTC
Sorry, I do not understand the purpose of this bug - bug #192561 claims that the fixes should not be shown (I agree). The behavior of the fix in such case is irrelevant, IMO.
Comment 2 esmithbss 2010-11-29 07:52:41 UTC
The issue is that the hint to "create a local variable" is being raised within an invalid scope.  The hint is being provided to a developer who has already declared the local variable, albeit incorrectly in this case.

The hint should not be provided when the code line in question is the proper result of the hint prior to applying the hint.
Comment 3 Jan Lahoda 2010-11-29 08:01:30 UTC
But this is what bug #192561 says. Is it really necessary to create three bugs for one problem?
Comment 4 esmithbss 2010-11-29 08:25:19 UTC
#192561 is about the (parsing/code error/decision tree) behind the hints.  I.e.  The hints should be about the { and not the variable declaration.

#192562 (this issue) is about the specific hint within the context of the variable declaration being a useless hint.  In this situation, the code that the hint if properly applied would generate, is the code that is already in the file.

#192563 is about hints generating invalid code.  Hints, when applied, should never generate invalid code.

There may be 1 fix for all three, 2 fixes, 3 fixes, or there may be more.  I don't know.  However, IMO there are 3 separate and distinct issues so I filed 3 separate reports.
Comment 5 esmithbss 2010-11-29 08:30:46 UTC
If I had identified these three issues, one each on a different hint based on a different line of code, then I should have different examples.  In this case, all three were apparent for the single line of code in the issue reports.

#192562 and #192563 (IMO) probably apply to more than just this hint, but are apparent in the code example.  

#192561 AKAIK is strictly for the code provided.
Comment 6 Jan Lahoda 2010-11-29 09:17:00 UTC
Very well. I am going to fix bug #192561 - as soon as that happens, this bug and #192563 are likely to become incomplete, awaiting reproducible test case from you.
Comment 7 Jan Lahoda 2010-12-02 08:46:28 UTC
I do not see the fix in daily build 201011250001 - could you please provide steps to reproduce on this or newer build? Thanks.