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.
[ 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".
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.
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
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
v.
The fix has been ported into the release67_fixes repository. http://hg.netbeans.org/release67_fixes/rev/a5b3457a1d7a
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