Changeset View
Changeset View
Standalone View
Standalone View
clang/lib/Format/ContinuationIndenter.cpp
Show First 20 Lines • Show All 1,532 Lines • ▼ Show 20 Lines | if (!Current.isTrailingComment() && | ||||
(!Previous || Previous->isNot(tok::kw_return) || | (!Previous || Previous->isNot(tok::kw_return) || | ||||
(Style.Language != FormatStyle::LK_Java && PrecedenceLevel > 0)) && | (Style.Language != FormatStyle::LK_Java && PrecedenceLevel > 0)) && | ||||
(Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign || | (Style.AlignAfterOpenBracket != FormatStyle::BAS_DontAlign || | ||||
PrecedenceLevel != prec::Comma || Current.NestingLevel == 0)) { | PrecedenceLevel != prec::Comma || Current.NestingLevel == 0)) { | ||||
NewParenState.Indent = std::max( | NewParenState.Indent = std::max( | ||||
std::max(State.Column, NewParenState.Indent), CurrentState.LastSpace); | std::max(State.Column, NewParenState.Indent), CurrentState.LastSpace); | ||||
} | } | ||||
// Special case for generic selection expressions, its comma-separated | |||||
// expressions are not aligned to the opening paren like regular calls, but | |||||
// rather continuation-indented relative to the _Generic keyword. | |||||
if (Previous && Previous->endsSequence(tok::l_paren, tok::kw__Generic)) | |||||
NewParenState.Indent = CurrentState.LastSpace; | |||||
if (Previous && | if (Previous && | ||||
(Previous->getPrecedence() == prec::Assignment || | (Previous->getPrecedence() == prec::Assignment || | ||||
Previous->isOneOf(tok::kw_return, TT_RequiresClause) || | Previous->isOneOf(tok::kw_return, TT_RequiresClause) || | ||||
(PrecedenceLevel == prec::Conditional && Previous->is(tok::question) && | (PrecedenceLevel == prec::Conditional && Previous->is(tok::question) && | ||||
Previous->is(TT_ConditionalExpr))) && | Previous->is(TT_ConditionalExpr))) && | ||||
!Newline) { | !Newline) { | ||||
// If BreakBeforeBinaryOperators is set, un-indent a bit to account for | // If BreakBeforeBinaryOperators is set, un-indent a bit to account for | ||||
// the operator and keep the operands aligned. | // the operator and keep the operands aligned. | ||||
▲ Show 20 Lines • Show All 130 Lines • ▼ Show 20 Lines | bool ObjCBinPackProtocolList = | ||||
(Style.ObjCBinPackProtocolList == FormatStyle::BPS_Auto && | (Style.ObjCBinPackProtocolList == FormatStyle::BPS_Auto && | ||||
Style.BinPackParameters) || | Style.BinPackParameters) || | ||||
Style.ObjCBinPackProtocolList == FormatStyle::BPS_Always; | Style.ObjCBinPackProtocolList == FormatStyle::BPS_Always; | ||||
bool BinPackDeclaration = | bool BinPackDeclaration = | ||||
(State.Line->Type != LT_ObjCDecl && Style.BinPackParameters) || | (State.Line->Type != LT_ObjCDecl && Style.BinPackParameters) || | ||||
(State.Line->Type == LT_ObjCDecl && ObjCBinPackProtocolList); | (State.Line->Type == LT_ObjCDecl && ObjCBinPackProtocolList); | ||||
bool GenericSelection = | |||||
Current.getPreviousNonComment() && | |||||
Current.getPreviousNonComment()->is(tok::kw__Generic); | |||||
AvoidBinPacking = | AvoidBinPacking = | ||||
(CurrentState.IsCSharpGenericTypeConstraint) || | (CurrentState.IsCSharpGenericTypeConstraint) || GenericSelection || | ||||
(Style.isJavaScript() && EndsInComma) || | (Style.isJavaScript() && EndsInComma) || | ||||
MyDeveloperDay: I wonder if this says isJavaScript() here because of the
```foo(name: type,name2: type2)… | |||||
(State.Line->MustBeDeclaration && !BinPackDeclaration) || | (State.Line->MustBeDeclaration && !BinPackDeclaration) || | ||||
(!State.Line->MustBeDeclaration && !Style.BinPackArguments) || | (!State.Line->MustBeDeclaration && !Style.BinPackArguments) || | ||||
(Style.ExperimentalAutoDetectBinPacking && | (Style.ExperimentalAutoDetectBinPacking && | ||||
(Current.is(PPK_OnePerLine) || | (Current.is(PPK_OnePerLine) || | ||||
(!BinPackInconclusiveFunctions && Current.is(PPK_Inconclusive)))); | (!BinPackInconclusiveFunctions && Current.is(PPK_Inconclusive)))); | ||||
if (Current.is(TT_ObjCMethodExpr) && Current.MatchingParen && | if (Current.is(TT_ObjCMethodExpr) && Current.MatchingParen && | ||||
Style.ObjCBreakBeforeNestedBlockParam) { | Style.ObjCBreakBeforeNestedBlockParam) { | ||||
▲ Show 20 Lines • Show All 891 Lines • Show Last 20 Lines |
I wonder if this says isJavaScript() here because of the
if that might be the case then given the format you present in your test then maybe it IS correct to have GenericSelection here.