File tree Expand file tree Collapse file tree 3 files changed +18
-33
lines changed
lib/ASTGen/Sources/ASTGen Expand file tree Collapse file tree 3 files changed +18
-33
lines changed Original file line number Diff line number Diff line change @@ -54,17 +54,7 @@ extension ASTGenVisitor {
54
54
}
55
55
56
56
// '@' attributes.
57
- // FIXME: Factor out this and share it with 'generate(accessorDecl:)'.
58
- visitIfConfigElements ( node. attributes, of: AttributeSyntax . self) { element in
59
- switch element {
60
- case . ifConfigDecl( let ifConfigDecl) :
61
- return . ifConfigDecl( ifConfigDecl)
62
- case . attribute( let attribute) :
63
- return . underlying( attribute)
64
- }
65
- } body: { attribute in
66
- self . generateDeclAttribute ( attribute: attribute, handler: addAttribute ( _: ) )
67
- }
57
+ self . generateDeclAttributes ( attributeList: node. attributes, handler: addAttribute ( _: ) )
68
58
69
59
func genStatic( node: DeclModifierSyntax , spelling: BridgedStaticSpelling ) {
70
60
// TODO: Diagnose duplicated attrs.
@@ -93,6 +83,19 @@ extension ASTGenVisitor {
93
83
staticLoc: staticLoc
94
84
)
95
85
}
86
+
87
+ func generateDeclAttributes( attributeList node: AttributeListSyntax , handler: ( BridgedDeclAttribute ) -> Void ) {
88
+ visitIfConfigElements ( node, of: AttributeSyntax . self) { element in
89
+ switch element {
90
+ case . ifConfigDecl( let ifConfigDecl) :
91
+ return . ifConfigDecl( ifConfigDecl)
92
+ case . attribute( let attribute) :
93
+ return . underlying( attribute)
94
+ }
95
+ } body: { attribute in
96
+ self . generateDeclAttribute ( attribute: attribute, handler: handler)
97
+ }
98
+ }
96
99
}
97
100
98
101
// MARK: - Decl attributes
Original file line number Diff line number Diff line change @@ -381,17 +381,8 @@ extension ASTGenVisitor {
381
381
var attrs = BridgedDeclAttributes ( )
382
382
383
383
// '@' attributes.
384
- visitIfConfigElements ( node. attributes, of: AttributeSyntax . self) { element in
385
- switch element {
386
- case . ifConfigDecl( let ifConfigDecl) :
387
- return . ifConfigDecl( ifConfigDecl)
388
- case . attribute( let attribute) :
389
- return . underlying( attribute)
390
- }
391
- } body: { node in
392
- self . generateDeclAttribute ( attribute: node) { attr in
393
- attrs. add ( attr)
394
- }
384
+ self . generateDeclAttributes ( attributeList: node. attributes) { attr in
385
+ attrs. add ( attr)
395
386
}
396
387
397
388
// The modifier
Original file line number Diff line number Diff line change @@ -224,17 +224,8 @@ extension ASTGenVisitor {
224
224
var result = GeneratedClosureSignature ( )
225
225
226
226
// Attributes.
227
- visitIfConfigElements ( node. attributes, of: AttributeSyntax . self) { element in
228
- switch element {
229
- case . ifConfigDecl( let ifConfigDecl) :
230
- return . ifConfigDecl( ifConfigDecl)
231
- case . attribute( let attribute) :
232
- return . underlying( attribute)
233
- }
234
- } body: { node in
235
- self . generateDeclAttribute ( attribute: node) { attr in
236
- result. attributes. add ( attr)
237
- }
227
+ self . generateDeclAttributes ( attributeList: node. attributes) { attr in
228
+ result. attributes. add ( attr)
238
229
}
239
230
240
231
if let node = node. capture {
You can’t perform that action at this time.
0 commit comments