Skip to content

Commit 0d2a3fd

Browse files
committed
Fix formatting.
1 parent fd8ee2b commit 0d2a3fd

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

Sources/_SwiftSyntaxMacros/MacroSystem.swift

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,7 @@ class MacroApplication: SyntaxRewriter {
106106
return true
107107
}
108108

109-
return !(macro is PeerDeclarationMacro.Type ||
110-
macro is MemberDeclarationMacro.Type)
109+
return !(macro is PeerDeclarationMacro.Type || macro is MemberDeclarationMacro.Type)
111110
}
112111

113112
if newAttributes.isEmpty {
@@ -259,18 +258,20 @@ class MacroApplication: SyntaxRewriter {
259258

260259
extension MacroApplication {
261260
private func getMacroAttributes<MacroType>(
262-
attachedTo decl: DeclSyntax, ofType: MacroType.Type
261+
attachedTo decl: DeclSyntax,
262+
ofType: MacroType.Type
263263
) -> [(CustomAttributeSyntax, MacroType)] {
264264
guard let attributedNode = decl.asProtocol(AttributedSyntax.self),
265-
let attributes = attributedNode.attributes else {
265+
let attributes = attributedNode.attributes
266+
else {
266267
return []
267268
}
268269

269270
return attributes.compactMap {
270271
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
274275
else {
275276
return nil
276277
}
@@ -312,9 +313,13 @@ extension MacroApplication {
312313
let macroAttributes = getMacroAttributes(attachedTo: DeclSyntax(decl), ofType: MemberDeclarationMacro.Type.self)
313314
for (attribute, memberMacro) in macroAttributes {
314315
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+
)
318323
} catch {
319324
// Record the error
320325
context.diagnose(
@@ -327,9 +332,11 @@ extension MacroApplication {
327332
}
328333

329334
// 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+
)
333340
}
334341
}
335342

Tests/SwiftSyntaxMacrosTest/MacroSystemTests.swift

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -323,9 +323,10 @@ public struct AddBackingStorage: MemberDeclarationMacro {
323323
public static func expansion(
324324
of node: CustomAttributeSyntax,
325325
attachedTo decl: DeclSyntax,
326-
in context: inout
327-
MacroExpansionContext)
328-
throws -> [DeclSyntax] {
326+
in context: inout MacroExpansionContext
327+
)
328+
throws -> [DeclSyntax]
329+
{
329330
let storage: DeclSyntax = "var _storage: Storage<Self>"
330331
return [
331332
storage.withLeadingTrivia([.newlines(1), .spaces(2)])

0 commit comments

Comments
 (0)