Skip to content

Commit e2842c7

Browse files
authored
Merge pull request #62961 from ahoppen/ahoppen/merge-binary-operators
[Macros] Adjustments for merging `spacedBinaryOperator` and `unspacedBinaryOperator` in SwiftSyntax
2 parents 9aeddd0 + ee9033b commit e2842c7

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/Macros/Inputs/syntax_macro_definitions.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public struct FileIDMacro: ExpressionMacro {
3636
public static func expansion(
3737
of macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
3838
) -> ExprSyntax {
39-
let fileLiteral: ExprSyntax = #""\#(context.moduleName)/\#(context.fileName)""#
39+
let fileLiteral: ExprSyntax = #""\#(raw: context.moduleName)/\#(raw: context.fileName)""#
4040
if let leadingTrivia = macro.leadingTrivia {
4141
return fileLiteral.withLeadingTrivia(leadingTrivia)
4242
}
@@ -82,9 +82,9 @@ public enum AddBlocker: ExpressionMacro {
8282
}
8383

8484
// Link the folded argument back into the tree.
85-
var node = node.withArgumentList(node.argumentList.replacing(childAt: 0, with: node.argumentList.first!.withExpression(foldedArgument.as(ExprSyntax.self)!)))
85+
let node = node.withArgumentList(node.argumentList.replacing(childAt: 0, with: node.argumentList.first!.withExpression(foldedArgument.as(ExprSyntax.self)!)))
8686

87-
class AddVisitor: SyntaxRewriter {
87+
class AddVisitor: SyntaxRewriter {
8888
var diagnostics: [Diagnostic] = []
8989

9090
override func visit(
@@ -117,7 +117,7 @@ public enum AddBlocker: ExpressionMacro {
117117
oldNode: Syntax(binOp.operatorToken.withoutTrivia()),
118118
newNode: Syntax(
119119
TokenSyntax(
120-
.spacedBinaryOperator("-"),
120+
.binaryOperator("-"),
121121
presence: .present
122122
)
123123
)
@@ -132,7 +132,7 @@ public enum AddBlocker: ExpressionMacro {
132132
node.withOperatorOperand(
133133
ExprSyntax(
134134
binOp.withOperatorToken(
135-
binOp.operatorToken.withKind(.spacedBinaryOperator("-"))
135+
binOp.operatorToken.withKind(.binaryOperator("-"))
136136
)
137137
)
138138
)

0 commit comments

Comments
 (0)