Skip to content

Rename expression macro expansion to expansion(of:in:). #1112

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
Dec 5, 2022
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions Sources/_SwiftSyntaxMacros/ExpressionMacro.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ import SwiftDiagnostics
public protocol ExpressionMacro: Macro {
/// Expand a macro described by the given macro expansion expression
/// within the given context to produce a replacement expression.
static func expand(
_ node: MacroExpansionExprSyntax,
static func expansion(
of node: MacroExpansionExprSyntax,
in context: inout MacroExpansionContext
) -> ExprSyntax
}
16 changes: 8 additions & 8 deletions Sources/_SwiftSyntaxMacros/MacroSystem+Builtin.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ private func replaceFirstLabel(
}

public struct ColorLiteralMacro: ExpressionMacro {
public static func expand(
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
public static func expansion(
of macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
) -> ExprSyntax {
let argList = replaceFirstLabel(
of: macro.argumentList, with: "_colorLiteralRed"
Expand All @@ -42,8 +42,8 @@ public struct ColorLiteralMacro: ExpressionMacro {
}

public struct FileLiteralMacro: ExpressionMacro {
public static func expand(
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
public static func expansion(
of macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
) -> ExprSyntax {
let argList = replaceFirstLabel(
of: macro.argumentList, with: "fileReferenceLiteralResourceName"
Expand All @@ -57,8 +57,8 @@ public struct FileLiteralMacro: ExpressionMacro {
}

public struct ImageLiteralMacro: ExpressionMacro {
public static func expand(
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
public static func expansion(
of macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
) -> ExprSyntax {
let argList = replaceFirstLabel(
of: macro.argumentList, with: "imageLiteralResourceName"
Expand All @@ -72,8 +72,8 @@ public struct ImageLiteralMacro: ExpressionMacro {
}

public struct FileIDMacro: ExpressionMacro {
public static func expand(
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
public static func expansion(
of macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
) -> ExprSyntax {
// FIXME: Compiler has more sophisticated file ID computation
let fileID = "\(context.moduleName)/\(context.fileName)"
Expand Down
4 changes: 2 additions & 2 deletions Sources/_SwiftSyntaxMacros/MacroSystem+Examples.swift
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ import SwiftSyntaxBuilder

// Macros used for testing purposes
public struct StringifyMacro: ExpressionMacro {
public static func expand(
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
public static func expansion(
of macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
) -> ExprSyntax {
guard let argument = macro.argumentList.first?.expression else {
// FIXME: Create a diagnostic for the missing argument?
Expand Down
2 changes: 1 addition & 1 deletion Sources/_SwiftSyntaxMacros/Syntax+MacroEvaluation.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ extension MacroExpansionExprSyntax {
}

// Handle the rewrite.
return exprMacro.expand(disconnectedCopy(), in: &context)
return exprMacro.expansion(of: disconnectedCopy(), in: &context)
}
}

Expand Down
4 changes: 2 additions & 2 deletions Tests/SwiftSyntaxMacrosTest/MacroSystemTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ import _SwiftSyntaxTestSupport
/// Macro whose only purpose is to ensure that we cannot see "out" of the
/// macro expansion syntax node we were given.
struct CheckContextIndependenceMacro: ExpressionMacro {
static func expand(
_ macro: MacroExpansionExprSyntax,
static func expansion(
of macro: MacroExpansionExprSyntax,
in context: inout MacroExpansionContext) -> ExprSyntax {

// Should not have a parent.
Expand Down