Skip to content

Commit afce931

Browse files
committed
Reformat
1 parent 8e7c7af commit afce931

File tree

2 files changed

+34
-24
lines changed

2 files changed

+34
-24
lines changed

Sources/_SwiftSyntaxMacros/MacroSystem.swift

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

109-
return !(macro is PeerDeclarationMacro.Type ||
110-
macro is MemberDeclarationMacro.Type ||
111-
macro is AccessorDeclarationMacro.Type)
109+
return !(macro is PeerDeclarationMacro.Type || macro is MemberDeclarationMacro.Type || macro is AccessorDeclarationMacro.Type)
112110
}
113111

114112
if newAttributes.isEmpty {
@@ -265,7 +263,8 @@ class MacroApplication: SyntaxRewriter {
265263
}
266264

267265
guard let binding = visitedVarDecl.bindings.first,
268-
visitedVarDecl.bindings.count == 1 else {
266+
visitedVarDecl.bindings.count == 1
267+
else {
269268
return DeclSyntax(node)
270269
}
271270

@@ -292,12 +291,19 @@ class MacroApplication: SyntaxRewriter {
292291

293292
return DeclSyntax(
294293
visitedVarDecl.withBindings(
295-
visitedVarDecl.bindings.replacing(childAt: 0, with: binding.withAccessor(.accessors(
296-
.init(
297-
leftBrace: .leftBraceToken(leadingTrivia: .space),
298-
accessors: .init(accessors),
299-
rightBrace: .rightBraceToken(leadingTrivia: .newline))
300-
))))
294+
visitedVarDecl.bindings.replacing(
295+
childAt: 0,
296+
with: binding.withAccessor(
297+
.accessors(
298+
.init(
299+
leftBrace: .leftBraceToken(leadingTrivia: .space),
300+
accessors: .init(accessors),
301+
rightBrace: .rightBraceToken(leadingTrivia: .newline)
302+
)
303+
)
304+
)
305+
)
306+
)
301307
)
302308
}
303309

Tests/SwiftSyntaxMacrosTest/MacroSystemTests.swift

Lines changed: 18 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ struct DefineBitwidthNumberedStructsMacro: FreestandingDeclarationMacro {
208208
}
209209
}
210210

211-
public struct PropertyWrapper { }
211+
public struct PropertyWrapper {}
212212

213213
extension PropertyWrapper: AccessorDeclarationMacro {
214214
public static func expansion(
@@ -217,9 +217,10 @@ extension PropertyWrapper: AccessorDeclarationMacro {
217217
in context: inout MacroExpansionContext
218218
) throws -> [AccessorDeclSyntax] {
219219
guard let varDecl = declaration.as(VariableDeclSyntax.self),
220-
let binding = varDecl.bindings.first,
221-
let identifier = binding.pattern.as(IdentifierPatternSyntax.self)?.identifier,
222-
binding.accessor == nil else {
220+
let binding = varDecl.bindings.first,
221+
let identifier = binding.pattern.as(IdentifierPatternSyntax.self)?.identifier,
222+
binding.accessor == nil
223+
else {
223224
return []
224225
}
225226

@@ -235,7 +236,7 @@ extension PropertyWrapper: AccessorDeclarationMacro {
235236
set {
236237
_\(identifier).wrappedValue = newValue
237238
}
238-
"""
239+
""",
239240
]
240241
}
241242
}
@@ -247,17 +248,19 @@ extension PropertyWrapper: PeerDeclarationMacro {
247248
in context: inout MacroExpansionContext
248249
) throws -> [SwiftSyntax.DeclSyntax] {
249250
guard let varDecl = declaration.as(VariableDeclSyntax.self),
250-
let binding = varDecl.bindings.first,
251-
let identifier = binding.pattern.as(IdentifierPatternSyntax.self)?.identifier,
252-
let type = binding.typeAnnotation?.type,
253-
binding.accessor == nil else {
251+
let binding = varDecl.bindings.first,
252+
let identifier = binding.pattern.as(IdentifierPatternSyntax.self)?.identifier,
253+
let type = binding.typeAnnotation?.type,
254+
binding.accessor == nil
255+
else {
254256
return []
255257
}
256258

257259
guard let wrapperTypeNameExpr = node.argumentList?.first?.expression,
258-
let stringLiteral = wrapperTypeNameExpr.as(StringLiteralExprSyntax.self),
259-
stringLiteral.segments.count == 1,
260-
case let .stringSegment(wrapperTypeNameSegment)? = stringLiteral.segments.first else {
260+
let stringLiteral = wrapperTypeNameExpr.as(StringLiteralExprSyntax.self),
261+
stringLiteral.segments.count == 1,
262+
case let .stringSegment(wrapperTypeNameSegment)? = stringLiteral.segments.first
263+
else {
261264
return []
262265
}
263266

@@ -461,7 +464,7 @@ public let testMacros: [String: Macro.Type] = [
461464
"stringify": StringifyMacro.self,
462465
"myError": ErrorMacro.self,
463466
"bitwidthNumberedStructs": DefineBitwidthNumberedStructsMacro.self,
464-
"wrapProperty" : PropertyWrapper.self,
467+
"wrapProperty": PropertyWrapper.self,
465468
"addCompletionHandler": AddCompletionHandler.self,
466469
"addBackingStorage": AddBackingStorage.self,
467470
]
@@ -600,7 +603,8 @@ final class MacroSystemTests: XCTestCase {
600603
}
601604
}
602605
private var _x: MyWrapperType<Int>
603-
""")
606+
"""
607+
)
604608
}
605609

606610
func testAddCompletionHandler() {

0 commit comments

Comments
 (0)