Bug 61017 - Refactoring - test case that results in uncompilable source
Summary: Refactoring - test case that results in uncompilable source
Status: VERIFIED FIXED
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 minor (vote)
Target Milestone: 3.0 RC1   Edit
Assignee: Jerome Lanneluc CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-05-05 07:27 EDT by Ondrej Chylik CLA
Modified: 2004-05-28 15:27 EDT (History)
1 user (show)

See Also:


Attachments
Possible fix (1.10 KB, patch)
2004-05-18 12:16 EDT, Jerome Lanneluc CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Ondrej Chylik CLA 2004-05-05 07:27:11 EDT
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?
Comment 1 Olivier Thomann CLA 2004-05-05 09:30:05 EDT
Move to JDT/UI
Comment 2 Dirk Baeumer CLA 2004-05-05 12:20:04 EDT
The problem is that the search engine doesn't report the reference to b to be 
renamed. Moving to JDT/Core for investigation.
Comment 3 Jerome Lanneluc CLA 2004-05-18 12:16:17 EDT
Created attachment 10776 [details]
Possible fix
Comment 4 Jerome Lanneluc CLA 2004-05-24 11:48:46 EDT
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()
Comment 5 Olivier Thomann CLA 2004-05-28 15:27:24 EDT
Verified in 200405281200