Skip to content

[Macros] Adjustments for merging spacedBinaryOperator and unspacedBinaryOperator in SwiftSyntax #62961

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 11, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions test/Macros/Inputs/syntax_macro_definitions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public struct FileIDMacro: ExpressionMacro {
public static func expansion(
of macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
) -> ExprSyntax {
let fileLiteral: ExprSyntax = #""\#(context.moduleName)/\#(context.fileName)""#
let fileLiteral: ExprSyntax = #""\#(raw: context.moduleName)/\#(raw: context.fileName)""#
if let leadingTrivia = macro.leadingTrivia {
return fileLiteral.withLeadingTrivia(leadingTrivia)
}
Expand Down Expand Up @@ -82,9 +82,9 @@ public enum AddBlocker: ExpressionMacro {
}

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

class AddVisitor: SyntaxRewriter {
class AddVisitor: SyntaxRewriter {
var diagnostics: [Diagnostic] = []

override func visit(
Expand Down Expand Up @@ -117,7 +117,7 @@ public enum AddBlocker: ExpressionMacro {
oldNode: Syntax(binOp.operatorToken.withoutTrivia()),
newNode: Syntax(
TokenSyntax(
.spacedBinaryOperator("-"),
.binaryOperator("-"),
presence: .present
)
)
Expand All @@ -132,7 +132,7 @@ public enum AddBlocker: ExpressionMacro {
node.withOperatorOperand(
ExprSyntax(
binOp.withOperatorToken(
binOp.operatorToken.withKind(.spacedBinaryOperator("-"))
binOp.operatorToken.withKind(.binaryOperator("-"))
)
)
)
Expand Down