@@ -647,8 +647,8 @@ class AnnotatingParser {
647
647
return true ;
648
648
649
649
// Limit this to being an access modifier that follows.
650
- if (AttrTok->isOneOf (tok::kw_public, tok::kw_private, tok::kw_protected,
651
- tok::comment, tok::kw_class, tok::kw_static,
650
+ if (AttrTok->isAccessSpecifierKeyword () ||
651
+ AttrTok-> isOneOf ( tok::comment, tok::kw_class, tok::kw_static,
652
652
tok::l_square, Keywords.kw_internal )) {
653
653
return true ;
654
654
}
@@ -1419,7 +1419,7 @@ class AnnotatingParser {
1419
1419
Tok->setType (TT_CtorInitializerColon);
1420
1420
} else {
1421
1421
Tok->setType (TT_InheritanceColon);
1422
- if (Prev->isOneOf (tok::kw_public, tok::kw_private, tok::kw_protected ))
1422
+ if (Prev->isAccessSpecifierKeyword ( ))
1423
1423
Line.Type = LT_AccessModifier;
1424
1424
}
1425
1425
} else if (canBeObjCSelectorComponent (*Tok->Previous ) && Tok->Next &&
@@ -2333,7 +2333,7 @@ class AnnotatingParser {
2333
2333
if (Current.Previous ) {
2334
2334
bool IsIdentifier =
2335
2335
Style.isJavaScript ()
2336
- ? Keywords.IsJavaScriptIdentifier (
2336
+ ? Keywords.isJavaScriptIdentifier (
2337
2337
*Current.Previous , /* AcceptIdentifierName= */ true )
2338
2338
: Current.Previous ->is (tok::identifier);
2339
2339
if (IsIdentifier ||
@@ -4949,11 +4949,11 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
4949
4949
4950
4950
// space between method modifier and opening parenthesis of a tuple return
4951
4951
// type
4952
- if (Left.isOneOf (tok::kw_public, tok::kw_private, tok::kw_protected,
4953
- tok::kw_virtual, tok::kw_extern, tok::kw_static,
4954
- Keywords.kw_internal , Keywords.kw_abstract ,
4955
- Keywords.kw_sealed , Keywords.kw_override ,
4956
- Keywords.kw_async , Keywords.kw_unsafe ) &&
4952
+ if (( Left.isAccessSpecifierKeyword () ||
4953
+ Left. isOneOf ( tok::kw_virtual, tok::kw_extern, tok::kw_static,
4954
+ Keywords.kw_internal , Keywords.kw_abstract ,
4955
+ Keywords.kw_sealed , Keywords.kw_override ,
4956
+ Keywords.kw_async , Keywords.kw_unsafe ) ) &&
4957
4957
Right.is (tok::l_paren)) {
4958
4958
return true ;
4959
4959
}
@@ -4979,7 +4979,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
4979
4979
}
4980
4980
// In tagged template literals ("html`bar baz`"), there is no space between
4981
4981
// the tag identifier and the template string.
4982
- if (Keywords.IsJavaScriptIdentifier (Left,
4982
+ if (Keywords.isJavaScriptIdentifier (Left,
4983
4983
/* AcceptIdentifierName= */ false ) &&
4984
4984
Right.is (TT_TemplateString)) {
4985
4985
return false ;
@@ -5074,9 +5074,8 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line,
5074
5074
return Style.SpaceBeforeParensOptions .AfterControlStatements ||
5075
5075
spaceRequiredBeforeParens (Right);
5076
5076
}
5077
- if ((Left.isOneOf (tok::kw_static, tok::kw_public, tok::kw_private,
5078
- tok::kw_protected) ||
5079
- Left.isOneOf (Keywords.kw_final , Keywords.kw_abstract ,
5077
+ if ((Left.isAccessSpecifierKeyword () ||
5078
+ Left.isOneOf (tok::kw_static, Keywords.kw_final , Keywords.kw_abstract ,
5080
5079
Keywords.kw_native )) &&
5081
5080
Right.is (TT_TemplateOpener)) {
5082
5081
return true ;
@@ -5699,9 +5698,8 @@ bool TokenAnnotator::mustBreakBefore(const AnnotatedLine &Line,
5699
5698
if (isAllmanBrace (Left) || isAllmanBrace (Right)) {
5700
5699
auto *FirstNonComment = Line.getFirstNonComment ();
5701
5700
bool AccessSpecifier =
5702
- FirstNonComment &&
5703
- FirstNonComment->isOneOf (Keywords.kw_internal , tok::kw_public,
5704
- tok::kw_private, tok::kw_protected);
5701
+ FirstNonComment && (FirstNonComment->is (Keywords.kw_internal ) ||
5702
+ FirstNonComment->isAccessSpecifierKeyword ());
5705
5703
5706
5704
if (Style.BraceWrapping .AfterEnum ) {
5707
5705
if (Line.startsWith (tok::kw_enum) ||
@@ -5887,13 +5885,13 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
5887
5885
} else if (Style.isJavaScript ()) {
5888
5886
const FormatToken *NonComment = Right.getPreviousNonComment ();
5889
5887
if (NonComment &&
5890
- NonComment->isOneOf (
5891
- tok::kw_return, Keywords. kw_yield , tok::kw_continue, tok::kw_break,
5892
- tok::kw_throw , Keywords.kw_interface , Keywords. kw_type ,
5893
- tok::kw_static, tok::kw_public, tok::kw_private, tok::kw_protected ,
5894
- Keywords. kw_readonly , Keywords.kw_override , Keywords.kw_abstract ,
5895
- Keywords.kw_get , Keywords.kw_set , Keywords.kw_async ,
5896
- Keywords.kw_await )) {
5888
+ ( NonComment->isAccessSpecifierKeyword () ||
5889
+ NonComment-> isOneOf (
5890
+ tok::kw_return , Keywords.kw_yield , tok::kw_continue, tok::kw_break ,
5891
+ tok::kw_throw, Keywords. kw_interface , Keywords. kw_type ,
5892
+ tok::kw_static , Keywords.kw_readonly , Keywords.kw_override ,
5893
+ Keywords.kw_abstract , Keywords.kw_get , Keywords.kw_set ,
5894
+ Keywords.kw_async , Keywords. kw_await ) )) {
5897
5895
return false ; // Otherwise automatic semicolon insertion would trigger.
5898
5896
}
5899
5897
if (Right.NestingLevel == 0 &&
0 commit comments