Community
Participate
Working Groups
This use-case is pretty wild, but it seems that the refactoring doesn't handle it well. Or at least it's not clear to me. Consider a java file containing following two class definitions: class A { public B b; // <- rename this public void method() { B.b.a.b = null; } } class B { public static B b; public A a; } Now use the refactoring functionality to rename the marked field (A.b) to something else, for example "c". No warnings in the preview, but you can see that the result is not compilable, as the field reference in method (which is pretty obfuscated) is not updated. BUT - if you now try to rename the field (now A.c) to "d", it goes fine... BUT no. 2 - if you now try to rename the field (now A.d) back to "b", you get a warning in the preview dialog. But if you proceed, the result is OK. Is this some issue of JDT or am _I_ seeing something wrong?
Move to JDT/UI
The problem is that the search engine doesn't report the reference to b to be renamed. Moving to JDT/Core for investigation.
Created attachment 10776 [details] Possible fix
Applied fix that consists in changing FieldLocator#resolveLevel(NameReference) to not stop of the first name in a qualified name reference if it doesn't match. Added regression test JavaSearchTests#testFieldReference7()
Verified in 200405281200