[英]Eclipse: “Refactor - Rename” completely messed up, replacing arbitrary characters in file
When refactoring a class name, Eclipse lately shows a very strange behavior.在重构 class 名称时,Eclipse 最近表现出非常奇怪的行为。 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:我将其重命名为“CampaignCsvPanel”,然后发生以下情况:
public class CampaignCSVPanel extends ContentPanel{
private FileUploadField uploadFielCampaignCsvPanelploadField();
...
}
Strange - and it happens basically every time I perform a class rename.奇怪 -基本上每次我执行 class 重命名时都会发生这种情况。 What's more:
更重要的是:
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: (系统规格:
Try this:尝试这个:
Go to Windows -> Preferences -> Java and uncheck 'Rename in editor without dialogue' Go 到 Windows -> 首选项 -> Java 并取消选中“在编辑器中重命名而不使用对话”
(I'm looking at the recent release of Eclipse Indigo, I only assume the settings are the same on previous versions) (我正在查看最近发布的 Eclipse Indigo,我只假设之前版本的设置相同)
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.如果您可以这样做并在该对话中验证它正在执行一些疯狂的替换,那么您绝对应该使用 Eclipse 提交错误并提供可重现的示例。 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
显然,重构引擎知道它必须替换某些东西,但会替换错误的 position 处的字符...... - 没有答案,但有一些额外的想法/测试
I found the problem: The project is using svn tags like $Date: $
When I remove them, the problem disappears.我发现了问题:该项目正在使用 svn 标签,例如
$Date: $
当我删除它们时,问题就消失了。 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.我进行了更多实验,当我将 SVN 连接器从 JavaHL 切换到 SVNKit 时,问题也消失了。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.