@@ -24,7 +24,7 @@ public struct TracedMacro: BodyMacro {
24
24
in context: some MacroExpansionContext
25
25
) throws -> [ CodeBlockItemSyntax ] {
26
26
guard let function = declaration. as ( FunctionDeclSyntax . self) ,
27
- let body = function. body
27
+ let body = function. body
28
28
else {
29
29
throw MacroExpansionErrorMessage ( " expected a function with a body " )
30
30
}
@@ -33,10 +33,14 @@ public struct TracedMacro: BodyMacro {
33
33
let ( operationName, context, kind, spanName) = try extractArguments ( from: node)
34
34
35
35
var withSpanCall = FunctionCallExprSyntax ( " withSpan() " as ExprSyntax ) !
36
- withSpanCall. arguments. append ( LabeledExprSyntax (
37
- expression: operationName ?? ExprSyntax ( StringLiteralExprSyntax ( content: function. name. text) ) ) )
36
+ withSpanCall. arguments. append (
37
+ LabeledExprSyntax (
38
+ expression: operationName ?? ExprSyntax ( StringLiteralExprSyntax ( content: function. name. text) )
39
+ )
40
+ )
38
41
func appendComma( ) {
39
- withSpanCall. arguments [ withSpanCall. arguments. index ( before: withSpanCall. arguments. endIndex) ] . trailingComma = . commaToken( )
42
+ withSpanCall. arguments [ withSpanCall. arguments. index ( before: withSpanCall. arguments. endIndex) ]
43
+ . trailingComma = . commaToken( )
40
44
}
41
45
if let context {
42
46
appendComma ( )
@@ -66,8 +70,8 @@ public struct TracedMacro: BodyMacro {
66
70
throwsClause? . throwsSpecifier = . keyword( . throws)
67
71
}
68
72
var withSpanExpr : ExprSyntax = """
69
- \( withSpanCall) { \( spanIdentifier) \( asyncClause) \( throwsClause) \( returnClause) in \( body. statements) }
70
- """
73
+ \( withSpanCall) { \( spanIdentifier) \( asyncClause) \( throwsClause) \( returnClause) in \( body. statements) }
74
+ """
71
75
72
76
// Apply a try / await as necessary to adapt the withSpan expression
73
77
@@ -111,9 +115,9 @@ public struct TracedMacro: BodyMacro {
111
115
let spanNameExpr = getArgument ( label: " span " )
112
116
if let spanNameExpr {
113
117
guard let stringLiteral = spanNameExpr. as ( StringLiteralExprSyntax . self) ,
114
- stringLiteral. segments. count == 1 ,
115
- let segment = stringLiteral. segments. first,
116
- let segmentText = segment. as ( StringSegmentSyntax . self)
118
+ stringLiteral. segments. count == 1 ,
119
+ let segment = stringLiteral. segments. first,
120
+ let segmentText = segment. as ( StringSegmentSyntax . self)
117
121
else {
118
122
throw MacroExpansionErrorMessage ( " span name must be a simple string literal " )
119
123
}
@@ -138,11 +142,11 @@ public struct TracedMacro: BodyMacro {
138
142
139
143
@main
140
144
struct TracingMacroPlugin : CompilerPlugin {
141
- #if compiler(>=6.0)
145
+ #if compiler(>=6.0)
142
146
let providingMacros : [ Macro . Type ] = [
143
- TracedMacro . self,
147
+ TracedMacro . self
144
148
]
145
- #else
149
+ #else
146
150
let providingMacros : [ Macro . Type ] = [ ]
147
- #endif
151
+ #endif
148
152
}
0 commit comments