@@ -106,8 +106,7 @@ class MacroApplication: SyntaxRewriter {
106
106
return true
107
107
}
108
108
109
- return !( macro is PeerDeclarationMacro . Type ||
110
- macro is MemberDeclarationMacro . Type )
109
+ return !( macro is PeerDeclarationMacro . Type || macro is MemberDeclarationMacro . Type )
111
110
}
112
111
113
112
if newAttributes. isEmpty {
@@ -259,18 +258,20 @@ class MacroApplication: SyntaxRewriter {
259
258
260
259
extension MacroApplication {
261
260
private func getMacroAttributes< MacroType> (
262
- attachedTo decl: DeclSyntax , ofType: MacroType . Type
261
+ attachedTo decl: DeclSyntax ,
262
+ ofType: MacroType . Type
263
263
) -> [ ( CustomAttributeSyntax , MacroType ) ] {
264
264
guard let attributedNode = decl. asProtocol ( AttributedSyntax . self) ,
265
- let attributes = attributedNode. attributes else {
265
+ let attributes = attributedNode. attributes
266
+ else {
266
267
return [ ]
267
268
}
268
269
269
270
return attributes. compactMap {
270
271
guard case let . customAttribute( customAttr) = $0,
271
- let attributeName = customAttr. attributeName. as ( SimpleTypeIdentifierSyntax . self) ? . name. text,
272
- let macro = macroSystem. macros [ attributeName] ,
273
- let macroType = macro as? MacroType
272
+ let attributeName = customAttr. attributeName. as ( SimpleTypeIdentifierSyntax . self) ? . name. text,
273
+ let macro = macroSystem. macros [ attributeName] ,
274
+ let macroType = macro as? MacroType
274
275
else {
275
276
return nil
276
277
}
@@ -312,9 +313,13 @@ extension MacroApplication {
312
313
let macroAttributes = getMacroAttributes ( attachedTo: DeclSyntax ( decl) , ofType: MemberDeclarationMacro . Type. self)
313
314
for (attribute, memberMacro) in macroAttributes {
314
315
do {
315
- try newMembers. append ( contentsOf: memberMacro. expansion ( of: attribute,
316
- attachedTo: DeclSyntax ( decl) ,
317
- in: & context) )
316
+ try newMembers. append (
317
+ contentsOf: memberMacro. expansion (
318
+ of: attribute,
319
+ attachedTo: DeclSyntax ( decl) ,
320
+ in: & context
321
+ )
322
+ )
318
323
} catch {
319
324
// Record the error
320
325
context. diagnose (
@@ -327,9 +332,11 @@ extension MacroApplication {
327
332
}
328
333
329
334
// FIXME: Is there a better way to add N members to a decl?
330
- return decl. withMembers ( newMembers. reduce ( decl. members) { partialMembers, newMember in
331
- partialMembers. addMember ( . init( decl: newMember) )
332
- } )
335
+ return decl. withMembers (
336
+ newMembers. reduce ( decl. members) { partialMembers, newMember in
337
+ partialMembers. addMember ( . init( decl: newMember) )
338
+ }
339
+ )
333
340
}
334
341
}
335
342
0 commit comments