@@ -15,13 +15,7 @@ public extension FormatRule {
15
15
options: [ " modifier-order " ]
16
16
) { formatter in
17
17
formatter. forEach ( . keyword) { i, token in
18
- switch token. string {
19
- case " let " , " func " , " var " , " class " , " actor " , " extension " , " init " , " enum " ,
20
- " struct " , " typealias " , " subscript " , " associatedtype " , " protocol " :
21
- break
22
- default :
23
- return
24
- }
18
+ guard token. isDeclarationTypeKeyword else { return }
25
19
var modifiers = [ String: [ Token] ] ( )
26
20
var lastModifier : ( name: String , tokens: [ Token ] ) ?
27
21
func pushModifier( ) {
@@ -36,7 +30,7 @@ public extension FormatRule {
36
30
lastModifier = nil
37
31
lastIndex = previousIndex
38
32
break loop
39
- case let token where token . isModifierKeyword :
33
+ case let token where formatter . isModifier ( at : index ) :
40
34
pushModifier ( )
41
35
lastModifier = ( token. string, [ Token] ( formatter. tokens [ index ..< lastIndex] ) )
42
36
previousIndex = lastIndex
@@ -45,7 +39,7 @@ public extension FormatRule {
45
39
if case let . identifier( param) ? = formatter. last ( . nonSpaceOrCommentOrLinebreak, before: index) ,
46
40
let openParenIndex = formatter. index ( of: . startOfScope( " ( " ) , before: index) ,
47
41
let index = formatter. index ( of: . nonSpaceOrCommentOrLinebreak, before: openParenIndex) ,
48
- let token = formatter. token ( at: index) , token . isModifierKeyword
42
+ let token = formatter. token ( at: index) , formatter . isModifier ( at : index )
49
43
{
50
44
pushModifier ( )
51
45
let modifier = token. string + ( param == " set " ? " (set) " : " " )
0 commit comments