一个自动格式化工具可以自动在单行子句周围插入大括号?
因此,假设在我们的工作环境中,我们决定“一个真正的信仰”禁止这样做:
if (something)
doSomething();
相反,我们想要:
if (something) {
doSomething();
}
是否有一种工具可以自动执行此操作? 最棒的是让 eclipse 来做这件事,但由于我们实际上刚刚从一位前雇员那里恢复过来,他认为他太漂亮了,不适合编码约定,所以一个不太友好的工具只需一次就可以做到这一点就足够了。
So assuming that in our work environment we've decided that the One True Faith forbids this:
if (something)
doSomething();
And instead we want:
if (something) {
doSomething();
}
Is there a tool that will do that automagically? Awesomest would be to have eclipse just do it, but since we're really just recovering from one ex-employee that thought he was too pretty for coding conventions, a less-friendly tool that would do it right just once would suffice.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为你可以在 Eclipse 的格式化规则中设置它并运行内置格式化程序..例如“使用块”选项:
(来源:ibm.com)
当然,您需要按照您想要的方式设置其余的格式选项,因为我认为您不能有选择地仅应用单个规则/选项。
I think you can set this in Eclipse's formatting rules and run the built-in formatter.. e.g. the "Use blocks" option:
(source: ibm.com)
Of course, you need the rest of the formatting options to be set how you want them, since I don't think you can selectively apply only a single rule/option..
啊,它实际上不是格式化程序,而是“清理”:
首选项-> Java-> 代码风格-> Clean Up
然后执行。 来源-> 清理
与来源相反 -> 格式
Ah, it's actually not a formatter, but a "Clean Up":
Preferences -> Java -> Code Style -> Clean Up
And then to execute. Source -> Clean Up
As opposed to Source -> Format
我相信 GreatCode 可以为您做到这一点(以及大量其他选项)
I believe that GreatCode can do this for you (along with a ton of other options)