@@ -227,8 +227,7 @@ class AnnotatingParser {
227
227
}
228
228
if (CurrentToken->isOneOf (tok::r_paren, tok::r_square, tok::r_brace) ||
229
229
(CurrentToken->isOneOf (tok::colon, tok::question) && InExprContext &&
230
- !Style.isCSharp () && Style.Language != FormatStyle::LK_Proto &&
231
- Style.Language != FormatStyle::LK_TextProto)) {
230
+ !Style.isCSharp () && !Style.isProto ())) {
232
231
return false ;
233
232
}
234
233
// If a && or || is found and interpreted as a binary operator, this set
@@ -678,8 +677,7 @@ class AnnotatingParser {
678
677
} else if (CurrentToken->is (tok::r_square) && Parent &&
679
678
Parent->is (TT_TemplateCloser)) {
680
679
Left->setType (TT_ArraySubscriptLSquare);
681
- } else if (Style.Language == FormatStyle::LK_Proto ||
682
- Style.Language == FormatStyle::LK_TextProto) {
680
+ } else if (Style.isProto ()) {
683
681
// Square braces in LK_Proto can either be message field attributes:
684
682
//
685
683
// optional Aaa aaa = 1 [
@@ -906,8 +904,7 @@ class AnnotatingParser {
906
904
Previous = Previous->getPreviousNonComment ();
907
905
if ((CurrentToken->is (tok::colon) &&
908
906
(!Contexts.back ().ColonIsDictLiteral || !Style.isCpp ())) ||
909
- Style.Language == FormatStyle::LK_Proto ||
910
- Style.Language == FormatStyle::LK_TextProto) {
907
+ Style.isProto ()) {
911
908
OpeningBrace.setType (TT_DictLiteral);
912
909
if (Previous->Tok .getIdentifierInfo () ||
913
910
Previous->is (tok::string_literal)) {
@@ -1049,9 +1046,7 @@ class AnnotatingParser {
1049
1046
Line.First ->startsSequence (tok::kw_export, Keywords.kw_module ) ||
1050
1047
Line.First ->startsSequence (tok::kw_export, Keywords.kw_import )) {
1051
1048
Tok->setType (TT_ModulePartitionColon);
1052
- } else if (Contexts.back ().ColonIsDictLiteral ||
1053
- Style.Language == FormatStyle::LK_Proto ||
1054
- Style.Language == FormatStyle::LK_TextProto) {
1049
+ } else if (Contexts.back ().ColonIsDictLiteral || Style.isProto ()) {
1055
1050
Tok->setType (TT_DictLiteral);
1056
1051
if (Style.Language == FormatStyle::LK_TextProto) {
1057
1052
if (FormatToken *Previous = Tok->getPreviousNonComment ())
@@ -1290,10 +1285,8 @@ class AnnotatingParser {
1290
1285
Tok->SpacesRequiredBefore = 1 ;
1291
1286
break ;
1292
1287
case tok::kw_operator:
1293
- if (Style.Language == FormatStyle::LK_TextProto ||
1294
- Style.Language == FormatStyle::LK_Proto) {
1288
+ if (Style.isProto ())
1295
1289
break ;
1296
- }
1297
1290
while (CurrentToken &&
1298
1291
!CurrentToken->isOneOf (tok::l_paren, tok::semi, tok::r_paren)) {
1299
1292
if (CurrentToken->isOneOf (tok::star, tok::amp))
@@ -2877,9 +2870,7 @@ class ExpressionParser {
2877
2870
return prec::Conditional;
2878
2871
if (NextNonComment && Current->is (TT_SelectorName) &&
2879
2872
(NextNonComment->isOneOf (TT_DictLiteral, TT_JsTypeColon) ||
2880
- ((Style.Language == FormatStyle::LK_Proto ||
2881
- Style.Language == FormatStyle::LK_TextProto) &&
2882
- NextNonComment->is (tok::less)))) {
2873
+ (Style.isProto () && NextNonComment->is (tok::less)))) {
2883
2874
return prec::Assignment;
2884
2875
}
2885
2876
if (Current->is (TT_JsComputedPropertyName))
@@ -3740,7 +3731,7 @@ unsigned TokenAnnotator::splitPenalty(const AnnotatedLine &Line,
3740
3731
// Prefer breaking call chains (".foo") over empty "{}", "[]" or "()".
3741
3732
if (Left.opensScope () && Right.closesScope ())
3742
3733
return 200 ;
3743
- } else if (Style.isProto () ) {
3734
+ } else if (Style.Language == FormatStyle::LK_Proto ) {
3744
3735
if (Right.is (tok::l_square))
3745
3736
return 1 ;
3746
3737
if (Right.is (tok::period))
@@ -4194,9 +4185,7 @@ bool TokenAnnotator::spaceRequiredBetween(const AnnotatedLine &Line,
4194
4185
const auto SpaceRequiredForArrayInitializerLSquare =
4195
4186
[](const FormatToken &LSquareTok, const FormatStyle &Style) {
4196
4187
return Style.SpacesInContainerLiterals ||
4197
- ((Style.Language == FormatStyle::LK_Proto ||
4198
- Style.Language == FormatStyle::LK_TextProto) &&
4199
- !Style.Cpp11BracedListStyle &&
4188
+ (Style.isProto () && !Style.Cpp11BracedListStyle &&
4200
4189
LSquareTok.endsSequence (tok::l_square, tok::colon,
4201
4190
TT_SelectorName));
4202
4191
};
@@ -4462,8 +4451,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
4462
4451
Right.is (TT_TemplateOpener)) {
4463
4452
return true ;
4464
4453
}
4465
- } else if (Style.Language == FormatStyle::LK_Proto ||
4466
- Style.Language == FormatStyle::LK_TextProto) {
4454
+ } else if (Style.isProto ()) {
4467
4455
if (Right.is (tok::period) &&
4468
4456
Left.isOneOf (Keywords.kw_optional , Keywords.kw_required ,
4469
4457
Keywords.kw_repeated , Keywords.kw_extend )) {
@@ -5085,8 +5073,7 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
5085
5073
return true ;
5086
5074
} else if (Style.BreakAdjacentStringLiterals &&
5087
5075
(Style.isCpp () || Style.isProto () ||
5088
- Style.Language == FormatStyle::LK_TableGen ||
5089
- Style.Language == FormatStyle::LK_TextProto)) {
5076
+ Style.Language == FormatStyle::LK_TableGen)) {
5090
5077
if (Left.isStringLiteral () && Right.isStringLiteral ())
5091
5078
return true ;
5092
5079
}
@@ -5338,9 +5325,8 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
5338
5325
// together.
5339
5326
//
5340
5327
// We ensure elsewhere that extensions are always on their own line.
5341
- if ((Style.Language == FormatStyle::LK_Proto ||
5342
- Style.Language == FormatStyle::LK_TextProto) &&
5343
- Right.is (TT_SelectorName) && Right.isNot (tok::r_square) && Right.Next ) {
5328
+ if (Style.isProto () && Right.is (TT_SelectorName) &&
5329
+ Right.isNot (tok::r_square) && Right.Next ) {
5344
5330
// Keep `@submessage` together in:
5345
5331
// @submessage { key: value }
5346
5332
if (Left.is (tok::at))
@@ -5554,8 +5540,7 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
5554
5540
return false ;
5555
5541
}
5556
5542
if (Left.is (tok::colon) && Left.isOneOf (TT_DictLiteral, TT_ObjCMethodExpr)) {
5557
- if (Style.Language == FormatStyle::LK_Proto ||
5558
- Style.Language == FormatStyle::LK_TextProto) {
5543
+ if (Style.isProto ()) {
5559
5544
if (!Style.AlwaysBreakBeforeMultilineStrings && Right.isStringLiteral ())
5560
5545
return false ;
5561
5546
// Prevent cases like:
0 commit comments