Skip to content

Commit aeb2ff5

Browse files
authored
Merge pull request #1112 from DougGregor/macro-expansion-of-in
Rename expression macro expansion to `expansion(of:in:).`
2 parents 0b170fa + 1b66bbc commit aeb2ff5

File tree

5 files changed

+15
-15
lines changed

5 files changed

+15
-15
lines changed

Sources/_SwiftSyntaxMacros/ExpressionMacro.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ import SwiftDiagnostics
1818
public protocol ExpressionMacro: Macro {
1919
/// Expand a macro described by the given macro expansion expression
2020
/// within the given context to produce a replacement expression.
21-
static func expand(
22-
_ node: MacroExpansionExprSyntax,
21+
static func expansion(
22+
of node: MacroExpansionExprSyntax,
2323
in context: inout MacroExpansionContext
2424
) -> ExprSyntax
2525
}

Sources/_SwiftSyntaxMacros/MacroSystem+Builtin.swift

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ private func replaceFirstLabel(
2727
}
2828

2929
public struct ColorLiteralMacro: ExpressionMacro {
30-
public static func expand(
31-
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
30+
public static func expansion(
31+
of macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
3232
) -> ExprSyntax {
3333
let argList = replaceFirstLabel(
3434
of: macro.argumentList, with: "_colorLiteralRed"
@@ -42,8 +42,8 @@ public struct ColorLiteralMacro: ExpressionMacro {
4242
}
4343

4444
public struct FileLiteralMacro: ExpressionMacro {
45-
public static func expand(
46-
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
45+
public static func expansion(
46+
of macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
4747
) -> ExprSyntax {
4848
let argList = replaceFirstLabel(
4949
of: macro.argumentList, with: "fileReferenceLiteralResourceName"
@@ -57,8 +57,8 @@ public struct FileLiteralMacro: ExpressionMacro {
5757
}
5858

5959
public struct ImageLiteralMacro: ExpressionMacro {
60-
public static func expand(
61-
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
60+
public static func expansion(
61+
of macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
6262
) -> ExprSyntax {
6363
let argList = replaceFirstLabel(
6464
of: macro.argumentList, with: "imageLiteralResourceName"
@@ -72,8 +72,8 @@ public struct ImageLiteralMacro: ExpressionMacro {
7272
}
7373

7474
public struct FileIDMacro: ExpressionMacro {
75-
public static func expand(
76-
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
75+
public static func expansion(
76+
of macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
7777
) -> ExprSyntax {
7878
// FIXME: Compiler has more sophisticated file ID computation
7979
let fileID = "\(context.moduleName)/\(context.fileName)"

Sources/_SwiftSyntaxMacros/MacroSystem+Examples.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import SwiftSyntaxBuilder
1515

1616
// Macros used for testing purposes
1717
public struct StringifyMacro: ExpressionMacro {
18-
public static func expand(
19-
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
18+
public static func expansion(
19+
of macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
2020
) -> ExprSyntax {
2121
guard let argument = macro.argumentList.first?.expression else {
2222
// FIXME: Create a diagnostic for the missing argument?

Sources/_SwiftSyntaxMacros/Syntax+MacroEvaluation.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ extension MacroExpansionExprSyntax {
4141
}
4242

4343
// Handle the rewrite.
44-
return exprMacro.expand(disconnectedCopy(), in: &context)
44+
return exprMacro.expansion(of: disconnectedCopy(), in: &context)
4545
}
4646
}
4747

Tests/SwiftSyntaxMacrosTest/MacroSystemTests.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ import _SwiftSyntaxTestSupport
1919
/// Macro whose only purpose is to ensure that we cannot see "out" of the
2020
/// macro expansion syntax node we were given.
2121
struct CheckContextIndependenceMacro: ExpressionMacro {
22-
static func expand(
23-
_ macro: MacroExpansionExprSyntax,
22+
static func expansion(
23+
of macro: MacroExpansionExprSyntax,
2424
in context: inout MacroExpansionContext) -> ExprSyntax {
2525

2626
// Should not have a parent.

0 commit comments

Comments
 (0)