简体   繁体   English

在Eclipse的“重构”->“重命名本地变量”上禁用信息列表

[英]Disable information list in Eclipse on “Refactor” -> “Rename local Variable”

Due to some reason, my variables in Eclipse do not match convention (first letter upper case). 由于某种原因,我在Eclipse中的变量不符合约定(首字母大写)。 It's not possible to change that. 无法更改。

So when I perform a "Refactor" -> "Rename" on a local Variable, a popup-windows appears: 因此,当我在本地变量上执行“重构”->“重命名”时,会出现一个弹出窗口:

"Rename local Variable" - "This name is discouraged. According to convention, names of local variables should start with a lowercase letter." “”重命名本地变量“-”不建议使用此名称。根据约定,本地变量的名称应以小写字母开头。“

I click "Continue" and the action is done. 我单击“继续”,操作完成。 But is there a way to disable this check, because it's very exhausting to always confirm with "Continue". 但是有一种方法可以禁用此检查,因为总是要用“ Continue”进行确认非常麻烦。

Example: 例:

public class Foo{
    private String bar;
}
  1. Mark the String bar 标记字符串栏
  2. "Refactor" -> "Rename" and type "Bar" “重构”->“重命名”,然后键入“ Bar”

I >>hope<< there isn't a way to disable it!! 我>>希望<<无法禁用它!

It is very bad style in Java to declare variables with an uppercase letter as the first letter. 在Java中,用大写字母声明第一个字母的变量是非常糟糕的样式。 Indeed, it worse than just bad style, because the Java language is designed on the assumption that you will obey that convention, and certain things will break if you ignore it. 的确,它比不好的样式还要糟糕,因为Java语言是在您将遵守该约定的前提下设计的,如果忽略它,某些事情将会中断。 (For instance, you are liable to get bitten by the identifier disambiguation rules if you have a class and variable name that are the same.) (例如,如果类和变量名相同,则容易被标识符歧义消除规则咬住。)


It's not possible to change that. 无法更改。

Rubbish! 垃圾! Of course it is possible! 当然可以!

... and would be a huge mess to fix ...并且将造成巨大的混乱

It would be straightforward to fix. 修复起来很简单。 Just use Eclipse's variable rename, one variable at a time. 只需使用Eclipse的变量重命名,一次即可更改一个变量。 OK, it could take a long time, and it would be tedious. 好的,可能要花很长时间,而且很乏味。 But it would also be a safe transformation. 但这也将是一个安全的转变。 And then you can run a style checker over your code to make sure you've got all of the instances that need fixing. 然后,您可以对代码运行样式检查器,以确保您拥有所有需要修复的实例。

But as earlier said, Don't go against naming conventions. 但是正如前面所说,不要违背命名约定。

If still you want , 如果你仍然想要,

Go to preferences ---> type "refa" ---> click java ---> Uncheck the "Rename with out dialog" checkbox. 转到preferences ---> type "refa" ---> click Java --->取消选中"Rename with out dialog"复选框。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM