Bug 145866 - [rename] rename on a Java identifier corrupts source
Summary: [rename] rename on a Java identifier corrupts source
Status: RESOLVED INVALID
Alias: None
Product: JDT
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.2   Edit
Hardware: PC other
: P3 major (vote)
Target Milestone: ---   Edit
Assignee: JDT-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2006-06-07 16:17 EDT by Dave Orme CLA
Modified: 2009-08-30 02:08 EDT (History)
2 users (show)

See Also:


Attachments
Yesterday's log stripped to just the relevent Eclipse session (170.20 KB, text/plain)
2006-06-08 11:03 EDT, Dave Orme CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dave Orme CLA 2006-06-07 16:17:46 EDT
I just did a Refactor | Rename on a variable name and testing code (in a plugin fragment) was renamed incorrectly, corrupting the source file.

The resulting source file now has methods like: 

   public void test_createPhone_shouldNeverReturnNull() throws Exception {
      Person person = new Person();
      Phone phone =updateOrCreatePhoneateOrCreatePhone(Phone.DAY_PHONE_CODE, "1234");
      assertNotNull("phone object should not be null.", phone);
   }

The trouble is that it's not mangled the same way each time.

Other examples of source corruption:

"PhoupdateOrCreatePhoneone"

"PhoneupdateOrCreatePhonerson"

      String expectedNumber = new String("1234updateOrCreatePhonePhone phone = person.updateOrCreatePhone(expectedCode, expectedNumber);

Notice how the string was mangled: lost its closing quote, etc.

Marking critical because we lose data whenever this happens.  Unfortunately, it doesn't happen all the time, but it's pretty regular and very disconcerting when it happens.
Comment 1 Dani Megert CLA 2006-06-08 02:18:45 EDT
Please provide more detailed steps. It works for me using 3.2 RC7.
Anything in .log? Which build?
Comment 2 Martin Aeschlimann CLA 2006-06-08 06:48:47 EDT
changing severity to 'major' until we know more.
Comment 3 Dave Orme CLA 2006-06-08 11:02:29 EDT
(In reply to comment #1)
> Please provide more detailed steps. It works for me using 3.2 RC7.
> Anything in .log? Which build?

RC6 is the build.  I got the build by downloading Platform and updating through the Callisto update site.

I can't reliably reproduce the bug myself so I'm sorry I can't supply more detailed steps to reproduce but I can answer any questions you might have about the configuration.

The one thing that is remarkable is that the source corruption always happens when I have two plugin projects where one is a fragment that extends the first.  (In my case, the fragment is always a unit test project, but I doubt that this is relevent.)  I perform the rename in the main plugin and the corruption always happens in the fragment.  Other plugins that reference the main plugin in which I'm working are okay.
Comment 4 Dave Orme CLA 2006-06-08 11:03:25 EDT
Created attachment 43864 [details]
Yesterday's log stripped to just the relevent Eclipse session
Comment 5 Markus Keller CLA 2006-06-14 05:47:12 EDT
Do you modify the affected files outside of Eclipse? The log contains a bunch of "ResourceException: Resource is out of sync with the file system", which could explain the corruptions. If so, please make sure you refresh the workspace after doing changes externally (or use the 'Refresh automatically' preference).

I could not reproduce the problem. Setting to REMIND, please reopen if you have steps to reproduce.
Comment 6 Denis Roy CLA 2009-08-30 02:08:16 EDT
As of now 'LATER' and 'REMIND' resolutions are no longer supported.
Please reopen this bug if it is still valid for you.