停止蚀在字符串内部重命名 [英] Stop eclipse renaming inside strings

查看:61
本文介绍了停止蚀在字符串内部重命名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我遇到这个问题已有一段时间了,因为Eclipse有一个糟糕的帮助系统,而且我似乎也找不到合适的Google关键字来找到我所需要的东西.

I've been having this problem for some time and have never bothered to fix it since Eclipse has a horrible help system and I can't seem to find the right Google keywords to find what I need.

我的问题是,当我重构类名称时,eclipse会查找该名称的所有可能位置并替换它们.

My problem is that when I refactor a class name, eclipse looks for all potential locations of that name and replaces them.

例如,当我将List.java类重构为类似UserListCommand的内容时,如果我在"list命令"的测试用例中有一个字符串,内容为"List-列出团队中的所有用户",.java,字符串中的表达式也更改为"UserListCommand-列出团队中的所有用户"

For instance, if I have a string inside a test case for the "list command" that says something like, "List - list all the users on a team", when I refactor the List.java class to something like UserListCommand.java, the expression inside the string also changes to "UserListCommand - list all the users on a team"

这太讨厌了!就像我说的那样,当您甚至没有想到要使用正确的关键字时,Google都是无用的.

This is SOOO annoying! And like I said, Google is useless when you cannot even think of the right keywords to use.

还有其他人遇到过这个问题并解决了吗?

Has anyone else had this problem and solved it?

谢谢.

推荐答案

Eclipse在注释和字符串中调用此更新的文本出现.有时,我会打开它,因此如果我没有正确链接它,javadoc会正确更新.但这可能会很痛苦,因为它有时会替换匹配的子字符串.

Eclipse calls this updating textual occurrences in comments and strings. I sometimes turn this on so javadoc gets updated correctly if I didn't properly link it. But it can be a pain because it sometimes replaces substrings that match.

我只在重命名类或接口时才看到这种情况(方法似乎没有这样做,至少对我来说不是),

I've only seen this when renaming classes or interfaces (methods don't seem to do this, at least not for me),

您需要打开重命名对话框"以阻止Eclipse更新注释和字符串中的文本出现:

You need to open the Rename Dialog to stop eclipse from updating textual occurrences in comments and strings:

突出显示要重命名的类型,然后选择:

Highlight the type you want to rename, then either:

  1. 按Shift + Alt + R
  2. 右键单击,然后转到重构"->重命名..",而不是键入新名称,现在应该在要更改的类名称下出现一个黄色的上下文弹出菜单,其中显示输入新名称,按输入进行重构",请注意有一个向下箭头以展开菜单.如果您按此按钮而不是输入新名称,则会出现一个新的下拉菜单,请选择打开重命名对话框".
  1. press Shift+Alt+R
  2. Right click, then go to refactor->rename.. then instead of typing the new name, there should now be a yellow context popup menu under the class name to be changed which says "Enter new name, press Enter to refactor", notice that there is a down arrow to expand the menu. If you press that instead of enter a new name a new drop down menu appears, select Open Rename Dialog...

打开重命名对话框后:

取消选中更新注释和字符串中的文本出现(强制预览)"和更新非Java文本文件中的完全限定名称(强制预览)"

uncheck "update textual occurences in comments and strings (forces preview)" and "Update fully qualified names in non-Java text files (forces preview)"

希望有帮助

这篇关于停止蚀在字符串内部重命名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆