@@ -24,7 +24,7 @@ public struct TracedMacro: BodyMacro {
2424 in context: some MacroExpansionContext
2525 ) throws -> [ CodeBlockItemSyntax ] {
2626 guard let function = declaration. as ( FunctionDeclSyntax . self) ,
27- let body = function. body
27+ let body = function. body
2828 else {
2929 throw MacroExpansionErrorMessage ( " expected a function with a body " )
3030 }
@@ -33,10 +33,14 @@ public struct TracedMacro: BodyMacro {
3333 let ( operationName, context, kind, spanName) = try extractArguments ( from: node)
3434
3535 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+ )
3841 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( )
4044 }
4145 if let context {
4246 appendComma ( )
@@ -66,8 +70,8 @@ public struct TracedMacro: BodyMacro {
6670 throwsClause? . throwsSpecifier = . keyword( . throws)
6771 }
6872 var withSpanExpr : ExprSyntax = """
69- \( withSpanCall) { \( spanIdentifier) \( asyncClause) \( throwsClause) \( returnClause) in \( body. statements) }
70- """
73+ \( withSpanCall) { \( spanIdentifier) \( asyncClause) \( throwsClause) \( returnClause) in \( body. statements) }
74+ """
7175
7276 // Apply a try / await as necessary to adapt the withSpan expression
7377
@@ -111,9 +115,9 @@ public struct TracedMacro: BodyMacro {
111115 let spanNameExpr = getArgument ( label: " span " )
112116 if let spanNameExpr {
113117 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)
117121 else {
118122 throw MacroExpansionErrorMessage ( " span name must be a simple string literal " )
119123 }
@@ -138,11 +142,11 @@ public struct TracedMacro: BodyMacro {
138142
139143@main
140144struct TracingMacroPlugin : CompilerPlugin {
141- #if compiler(>=6.0)
145+ #if compiler(>=6.0)
142146 let providingMacros : [ Macro . Type ] = [
143- TracedMacro . self,
147+ TracedMacro . self
144148 ]
145- #else
149+ #else
146150 let providingMacros : [ Macro . Type ] = [ ]
147- #endif
151+ #endif
148152}
0 commit comments