When refactoring a class name, Eclipse lately shows a very strange behavior. For example, let's look at one of our classes:
public class CampaignCSVPanel extends ContentPanel {
private FileUploadField uploadFieldCsv = new FileUploadField();
...
}
开发者_开发技巧
and I rename it to "CampaignCsvPanel", then the following happens:
public class CampaignCSVPanel extends ContentPanel{
private FileUploadField uploadFielCampaignCsvPanelploadField();
...
}
Strange - and it happens basically every time I perform a class rename. What's more:
- I already created a completely new workspace (and checked out the same projects again),
- and I installed a fresh version of Eclipse (i.e. it happens both in Eclipse 3.6 and 3.7).
I assume, it must have something to do with the projects in the workspace, because it only happens with the projects of one company I work for - not with other sets of projects I'm working on. Do you have any idea, what the reason could be?
(System specs:
- Ubuntu Linux 11.04, 64bit
- Eclipse 3.6/3.7
- Plugins: Subversive, m2eclipse, Google (GWT) plugin.
- I tried both OpenJDK and SunJDK (1.6.0_24). )
Try this:
Go to Windows -> Preferences -> Java and uncheck 'Rename in editor without dialogue'
(I'm looking at the recent release of Eclipse Indigo, I only assume the settings are the same on previous versions)
Now you can preview all of the changes it intends to make.
If you can do this and verify in that dialogue that it is doing some crazy replacements, then you should most definitely file a bug with Eclipse and provide the reproducible example. I would bet though, that once you look at the list of things it intends to replace you'll find some other explanation for the problem.
That's annoying. Obviously the refactoring engine knows that it has to replace something but replaces characters at a wrong position... - no answer but some additional ideas/tests
- Looks like you check out complete projects. Try to import sources only to a fresh project to check if the problem still occurs or if its gone.
- If project metadata has been checked in (it shouldn't, but we never know), clean the project right after checking the project out.
- Check the character encoding of that companies source files. Maybe there's some sort of mismatch which causes the editor to replace on wrong positions. And double check the source files for strange unprintable ascii bytes... again, we never know...
I found the problem: The project is using svn tags like $Date: $
When I remove them, the problem disappears. When I re-insert them manually (to make sure I don't insert invalid characters), the problem re-appears.
I experimented a little more, and the problem also disappears, when I switch the SVN connector from JavaHL to SVNKit.
精彩评论