@@ -6105,6 +6105,33 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
6105
6105
return false ;
6106
6106
}
6107
6107
6108
+ // We only break before r_brace if there was a corresponding break before
6109
+ // the l_brace, which is tracked by BreakBeforeClosingBrace.
6110
+ if (Right.is (tok::r_brace)) {
6111
+ return Right.MatchingParen && (Right.MatchingParen ->is (BK_Block) ||
6112
+ (Right.isBlockIndentedInitRBrace (Style)));
6113
+ }
6114
+
6115
+ // We only break before r_paren if we're in a block indented context.
6116
+ if (Right.is (tok::r_paren)) {
6117
+ if (Style.AlignAfterOpenBracket != FormatStyle::BAS_BlockIndent ||
6118
+ !Right.MatchingParen ) {
6119
+ return false ;
6120
+ }
6121
+ auto Next = Right.Next ;
6122
+ if (Next && Next->is (tok::r_paren))
6123
+ Next = Next->Next ;
6124
+ if (Next && Next->is (tok::l_paren))
6125
+ return false ;
6126
+ const FormatToken *Previous = Right.MatchingParen ->Previous ;
6127
+ return !(Previous && (Previous->is (tok::kw_for) || Previous->isIf ()));
6128
+ }
6129
+
6130
+ if (Left.isOneOf (tok::r_paren, TT_TrailingAnnotation) &&
6131
+ Right.is (TT_TrailingAnnotation) &&
6132
+ Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
6133
+ return false ;
6134
+ }
6108
6135
if (Left.is (tok::at))
6109
6136
return false ;
6110
6137
if (Left.Tok .getObjCKeywordID () == tok::objc_interface)
@@ -6260,34 +6287,6 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
6260
6287
return false ;
6261
6288
}
6262
6289
6263
- // We only break before r_brace if there was a corresponding break before
6264
- // the l_brace, which is tracked by BreakBeforeClosingBrace.
6265
- if (Right.is (tok::r_brace)) {
6266
- return Right.MatchingParen && (Right.MatchingParen ->is (BK_Block) ||
6267
- (Right.isBlockIndentedInitRBrace (Style)));
6268
- }
6269
-
6270
- // We only break before r_paren if we're in a block indented context.
6271
- if (Right.is (tok::r_paren)) {
6272
- if (Style.AlignAfterOpenBracket != FormatStyle::BAS_BlockIndent ||
6273
- !Right.MatchingParen ) {
6274
- return false ;
6275
- }
6276
- auto Next = Right.Next ;
6277
- if (Next && Next->is (tok::r_paren))
6278
- Next = Next->Next ;
6279
- if (Next && Next->is (tok::l_paren))
6280
- return false ;
6281
- const FormatToken *Previous = Right.MatchingParen ->Previous ;
6282
- return !(Previous && (Previous->is (tok::kw_for) || Previous->isIf ()));
6283
- }
6284
-
6285
- if (Left.isOneOf (tok::r_paren, TT_TrailingAnnotation) &&
6286
- Right.is (TT_TrailingAnnotation) &&
6287
- Style.AlignAfterOpenBracket == FormatStyle::BAS_BlockIndent) {
6288
- return false ;
6289
- }
6290
-
6291
6290
// Allow breaking after a trailing annotation, e.g. after a method
6292
6291
// declaration.
6293
6292
if (Left.is (TT_TrailingAnnotation)) {
0 commit comments