lang语格式不总是尊重BinPackParameters:false

时间:2018-12-07 17:57:48

标签: c++ clang-format

我试图在Visual Studio 2017中使用.clang格式的文件,但它似乎并不总是遵守我设置为false的BinPackParameters参数。

设置以下参数:

AlignAfterOpenBracket: AlwaysBreak
AllowAllParametersOfDeclarationOnNextLine: false
BinPackArguments: false
BinPackParameters: false
ColumnLimit: 110

我希望我的方法调用太长(即大于ColumnWidth参数),以至于总是将每个参数换行到一个方法,以便它们分别位于不同的行上,如下所示:

LongMethodNameCall(
    someLongParameter1,
    someLongParameter2,
    someLongParameter3,
    someLongParameter4 );

有时候是这种情况,但其他时候我会得到:

LongMethodNameCall(
    someLongParameter1, someLongParameter2, someLongParameter3, someLongParameter4 );

为清楚起见,我希望它始终在开括号后换行,如果整个语句超出ColumnWidth参数,则将每个参数放在一行上

这是我的.clang格式文件:

Language: Cpp
#DisableFormat: true

AccessModifierOffset: -4
AlignAfterOpenBracket: AlwaysBreak
AlignConsecutiveAssignments: false
AlignConsecutiveDeclarations: false
AlignEscapedNewlines: Left
AlignOperands: true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Inline
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: false
BinPackParameters: false
BraceWrapping:
    AfterClass:      true   
    AfterControlStatement: true
    AfterEnum:       true
    AfterFunction:   true          
    AfterNamespace:  false                
    AfterStruct:     true
    AfterUnion:      true
    BeforeCatch:     true
    BeforeElse:      true   
    IndentBraces:    false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BreakBeforeInheritanceComma: false
BreakBeforeTernaryOperators: false
BreakConstructorInitializers: AfterColon
BreakStringLiterals: true
ColumnLimit: 110
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
IncludeCategories:
    - Regex:           '\/stdafx.h'
      Priority:        -1
IndentCaseLabels: true
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyBreakAssignment: 100
PenaltyBreakBeforeFirstCallParameter: 0
PenaltyBreakComment: 0
PenaltyBreakFirstLessLess: 100
PenaltyBreakString: 50
PenaltyExcessCharacter: 20
PenaltyReturnTypeOnItsOwnLine: 1000
PointerAlignment: Left
ReflowComments: true
SortIncludes: true
SortUsingDeclarations: true
SpaceAfterCStyleCast: false
SpaceAfterTemplateKeyword: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesInAngles: true
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: true
SpacesInParentheses: true
SpacesInSquareBrackets: true
TabWidth: 4
UseTab: Never

1 个答案:

答案 0 :(得分:0)

仅当 AllowAllParametersOfDeclarationOnNextLine 设置为 true 时,才不接受BinPackParameters:false的情况,

我尝试使用提供的配置,但无法重现该问题。

与此同时,该工具可能已被修改。