Skip to content

Commit 47bf7e8

Browse files
committed
Ensure nodes inserted into new trees are trimmed (don't need to trim rewritten nodes in original locations)
1 parent 42755e3 commit 47bf7e8

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

Sources/TestingMacros/Support/ConditionArgumentParsing.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ private final class _ContextInserter<C, M>: SyntaxRewriter where C: MacroExpansi
318318
override func visit(_ node: InfixOperatorExprSyntax) -> ExprSyntax {
319319
_rewrite(
320320
node
321-
.with(\.leftOperand, visit(node.leftOperand))
322-
.with(\.rightOperand, visit(node.rightOperand)),
321+
.with(\.leftOperand, visit(node.leftOperand).trimmed)
322+
.with(\.rightOperand, visit(node.rightOperand).trimmed),
323323
originalWas: node
324324
)
325325
}
@@ -347,7 +347,7 @@ private final class _ContextInserter<C, M>: SyntaxRewriter where C: MacroExpansi
347347
name: .identifier("__\(isAsKeyword)")
348348
)
349349
) {
350-
LabeledExprSyntax(expression: visit(valueExpr))
350+
LabeledExprSyntax(expression: visit(valueExpr).trimmed)
351351
LabeledExprSyntax(
352352
expression: _rewrite(
353353
MemberAccessExprSyntax(
@@ -356,7 +356,7 @@ private final class _ContextInserter<C, M>: SyntaxRewriter where C: MacroExpansi
356356
},
357357
declName: DeclReferenceExprSyntax(baseName: .keyword(.self))
358358
),
359-
originalWas: Syntax(type)
359+
originalWas: type
360360
)
361361
)
362362
LabeledExprSyntax(expression: type.expressionID(rootedAt: effectiveRootNode))
@@ -431,7 +431,7 @@ private final class _ContextInserter<C, M>: SyntaxRewriter where C: MacroExpansi
431431
node.with(
432432
\.elements, ArrayElementListSyntax {
433433
for element in node.elements {
434-
ArrayElementSyntax(expression: visit(element.expression))
434+
ArrayElementSyntax(expression: visit(element.expression).trimmed)
435435
}
436436
}
437437
),
@@ -448,7 +448,7 @@ private final class _ContextInserter<C, M>: SyntaxRewriter where C: MacroExpansi
448448
\.content, .elements(
449449
DictionaryElementListSyntax {
450450
for element in elements {
451-
DictionaryElementSyntax(key: visit(element.key), value: visit(element.value))
451+
DictionaryElementSyntax(key: visit(element.key).trimmed, value: visit(element.value).trimmed)
452452
}
453453
}
454454
)

0 commit comments

Comments
 (0)