Please use the Apache issue tracking system for new NetBeans issues (https://issues.apache.org/jira/projects/NETBEANS0/issues) !!
Bug 167376 - [67cat] Quick Fix for "Local variable hides a field" picks wrong identifier to rename
[67cat] Quick Fix for "Local variable hides a field" picks wrong identifier t...
Status: VERIFIED FIXED
Product: java
Classification: Unclassified
Component: Editor
6.x
PC Windows XP
: P3 (vote)
: 6.x
Assigned To: Max Sauer
issues@java
67patch1-verified
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-06-19 16:02 UTC by swpalmer
Modified: 2009-07-16 17:09 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description swpalmer 2009-06-19 16:02:04 UTC
[ BUILD # : 200906142201 ]
[ JDK VERSION : 1.6.* ]

I hit Alt-Enter on a line with a "Local variable hides a field"
warning and selected the only choice, "Rename the field" 

There are two problems

1 - I think this is wrong... the fix should be to "Rename the local
variable" (worst case - give both choices as a possibility)
2 - the editor jumps back in the code to an unrelated field in the
previous function and enters "rename mode"

e.g.
class A {
 private int value = 0;
 private String somethingElse = "whatever";

 public void hello() {
   somethingElse = "hello";
   System.out.println(somethingElse); // the editor tries to rename
"somethingElse"
 }

 public void doit() {
   int value = 42; // this is the line that has the warning and is
where I hit Alt-enter
   System.out.println(value);
 }
}

In the above example code that approximates the case in my project, I
will see the idea bulb for "value" in "doit()" and I hit alt-enter,
then select "rename field".  The editor then jumps into the previous
method "hello()" and begins a rename operation on "somethingElse".
Comment 1 swpalmer 2009-06-19 16:07:40 UTC
While I reproduced this *many* times in a row before filing the bug, as soon as I tried again after reporting the bug, it 
worked as expected.  So this may be difficult to reproduce - buit trust me it happened.  I was actually going through a 
file applying many quick-fixes (mostly adding Overrides annotations) and then when I came to this issue it failed in the 
manner described.

Note also that the fix that is applied renames the *local* variable, so the text for the fix "Rename the field" is still 
wrong.
Comment 2 Max Sauer 2009-06-22 12:33:36 UTC
I've corrected the label. In case the first issue occurs again, please reopen this one with a sample source. Thanks.
---
http://hg.netbeans.org/jet-main/rev/e0ae7009cf37
Comment 3 Quality Engineering 2009-06-23 07:44:21 UTC
Integrated into 'main-golden', will be available in build *200906230201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/e0ae7009cf37
User: Max Sauer <msauer@netbeans.org>
Log: #167376: Field hidden by local variable label should reflect situation
Comment 4 Petr Blaha 2009-07-02 13:34:23 UTC
v.
Comment 5 pgebauer 2009-07-09 10:35:18 UTC
The fix has been ported into the release67_fixes repository.
http://hg.netbeans.org/release67_fixes/rev/a5b3457a1d7a
Comment 6 Jiri Prox 2009-07-16 17:09:17 UTC
v in 6.7.1

I cannot reproduce the renaming the wrong variable, it it occurs in 6.7.1 again, please file a new issue, thanks


By use of this website, you agree to the NetBeans Policies and Terms of Use. © 2014, Oracle Corporation and/or its affiliates. Sponsored by Oracle logo