Java 中复杂 if 语句的带有 8 空格规则的 Clang 格式
我正在尝试设置 clang-format ,以便它符合 Oracle 的 Java代码约定。该文档提供了大量示例,其中最重要的是:
function(longExpression1, longExpression2, longExpression3,
longExpression4, longExpression5);
var = function1(longExpression1,
function2(longExpression2,
longExpression3));
longName1 = longName2 * (longName3 + longName4 - longName5)
+ 4 * longname6;
if ((condition1 && condition2)
|| (condition3 && condition4)
||!(condition5 && condition6)) {
doSomethingAboutIt();
}
以下选项涵盖了前三种情况:
AlignAfterOpenBracket: Align
AlignAfterOpenBracket: Align
BreakBeforeBinaryOperators: true
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
ColumnLimit: 80
IndentWidth: 4
TabWidth: 8
关于第四种情况,该文档说:“if
语句的换行通常应使用 8-空格规则,因为传统的(4 个空格)缩进使得看到正文变得困难。”我尝试了所有选项,但我认为我没有遇到任何问题。
诚然,这是一个相当挑剔的问题,但我想也许我忽略了一些事情。任何想法将不胜感激。提前致谢!
I'm trying to set-up clang-format so that it confirms to Oracle's Java Code Conventions. The document provides numerous examples, of which the most important are:
function(longExpression1, longExpression2, longExpression3,
longExpression4, longExpression5);
var = function1(longExpression1,
function2(longExpression2,
longExpression3));
longName1 = longName2 * (longName3 + longName4 - longName5)
+ 4 * longname6;
if ((condition1 && condition2)
|| (condition3 && condition4)
||!(condition5 && condition6)) {
doSomethingAboutIt();
}
The following options cover the first three cases:
AlignAfterOpenBracket: Align
AlignAfterOpenBracket: Align
BreakBeforeBinaryOperators: true
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
ColumnLimit: 80
IndentWidth: 4
TabWidth: 8
About the fourth case, the document says: "Line wrapping for if
statements should generally use the 8-space rule, since conventional (4 space) indentation makes seeing the body difficult." I went through all options, but I don't think I came across something.
Its admittedly a rather fastidious issue, but I thought maybe there is something I overlooked. Any ideas would be greatly appreciated. Thanks in advance!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论