开发者

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.

I'd like to change that so that it's created with protected scope by开发者_运维知识库 default. How can I do so?


Already in 2002

I've just discovered the Quick Fix feature in the F2 build. 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. In fact, other quick fixes produce incorrect private methods (in another context though, like 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)


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. Plus, if this would work, then the template would not represent the true meaning of having private methods... for all cases.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜