[英]How do I configure Eclipse to create protected java methods by default instead of private?
When I use Eclipse 3.5 to auto-create methods for me (for example, by calling a method that does not yet exist, then using Quickfix to create the method), Eclipse creates the method with private scope. 当我使用Eclipse 3.5为我自动创建方法时(例如,通过调用尚不存在的方法,然后使用Quickfix创建方法),Eclipse将创建具有私有作用域的方法。
I'd like to change that so that it's created with protected scope by default. 我想更改它,以便默认情况下使用受保护的范围创建它。 How can I do so? 我该怎么办?
I've just discovered the Quick Fix feature in the F2 build. 我刚刚在F2版本中发现了快速修复功能。 It's really cool. 这真的很酷。
One question: Is there a way to change the way it creates methods for you? 一个问题:有没有办法改变它为您创建方法的方式? I would like the new methods to be protected instead of private. 我希望保护新方法,而不是私有方法。there's no way to do this now. 现在无法执行此操作。
Please enter a feature request a. 请输入功能请求
Ouch. 哎哟。 And 7 years later, for the 3.5 edition, it does not seem to have changed one bit. 七年后的今天,对于3.5版,它似乎一点也没有改变。 In fact, other quick fixes produce incorrect private methods (in another context though, like bug 271551 ) 实际上,其他快速修复会产生不正确的私有方法(尽管在另一个上下文中,例如bug 271551 )
Arguably, in this instance, the generation of private method could be view as a "good practice", forcing the developer to explicitly raise the visibility level of said method (with the adequate javadoc saying why this method could be sub-classed or is even a public one) 可以说,在这种情况下,私有方法的生成可以被视为“良好实践”,从而迫使开发人员显式提高该方法的可见性级别(适当的javadoc指出了为什么可以将该方法子类化甚至是什至是)。一个公共的)
You might have a look at: Eclipse templates , but what you want to do, can only be done by changing the "private_method" template, if and only if that template is used by the fix suggestion logic, and I'm not sure that you can change that logic. 您可能会看一下: Eclipse模板 ,但是您想做的事情只能通过更改“ private_method”模板来完成,前提是并且仅当修订建议逻辑使用了该模板,并且我不确定您可以更改该逻辑。 Plus, if this would work, then the template would not represent the true meaning of having private methods... for all cases. 另外,如果这行得通,那么该模板将无法代表拥有私有方法的真正含义……在所有情况下。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.