Bug 384314 - Rename local variable refactoring preview doesn't understand ITDs
Summary: Rename local variable refactoring preview doesn't understand ITDs
Status: RESOLVED FIXED
Alias: None
Product: AJDT
Classification: Tools
Component: Core (show other bugs)
Version: 2.2.0   Edit
Hardware: PC Mac OS X
: P3 major (vote)
Target Milestone: 2.2.1   Edit
Assignee: Andrew Eisenberg CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-04 18:37 EDT by Daniel Serodio CLA
Modified: 2012-09-19 09:52 EDT (History)
2 users (show)

See Also:


Attachments
Example project for reproducing the bug (1.48 KB, application/zip)
2012-07-04 18:39 EDT, Daniel Serodio CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Daniel Serodio CLA 2012-07-04 18:37:18 EDT
Build Identifier: Version: Juno Release Build id: 20120614-1722

When I use Refactor > Rename on a local variable, and the method calls a method declared via Inter-Type Declarations (ITDs), the preview dialog finds compilation errors because it doesn't understand that.


Reproducible: Always

Steps to Reproduce:
1. Open attached sample project
2. Open the Bean class
3. Rename the local variable "i" to "x"
4. The preview dialog shows a "The method doSomething() is undefined for the type Bean" compilation error.
Comment 1 Daniel Serodio CLA 2012-07-04 18:39:47 EDT
Created attachment 218306 [details]
Example project for reproducing the bug
Comment 2 Andrew Eisenberg CLA 2012-09-04 17:41:25 EDT
Finally getting around to this.  Bumping up the priority since this problem is could be quite confusing for developers who are unaware of how ITDs are acting on their code.
Comment 3 Andrew Eisenberg CLA 2012-09-05 11:04:56 EDT
I've made some progress on this. I am now weaving into the Refactoring parser so that ITDs are pushed in before analyzing the code.  This will ensure that there are no compile problems during the checking of final conditions.  However, this is only part of the solution, I also need to alter source locations based on the pushed-in code or else we get all sorts of exceptions since the source location of the refactoring doesn't match with the source locations in the analysis.

There's more work to do, but there is progress.  And the fix for this bug may fix other related problems when analyzing code with ITDs during a refactoring.
Comment 4 Andrew Eisenberg CLA 2012-09-18 16:27:07 EDT
This turned out to be a bit more involved than I had originally hoped, but I now have this working with enough regression tests to make me feel that it is safely not affecting other features.

I had to add a new pointcut so that the correct AST is provided when analyzing the results of a rename local refactoring.  I also had to ensure that source locations are updated appropriately in the analyzed AST.

Fix will be available in next dev build in e42 branch.
Comment 5 Daniel Serodio CLA 2012-09-19 09:52:05 EDT
That's great news, thanks for the hard work.