Skip to content

Commit 1c86040

Browse files
committed
[Macros] Rename ExpressionMacro.apply to "expand".
"Expand" better describes what the macro implementation is doing.
1 parent 5bc8a3c commit 1c86040

File tree

5 files changed

+11
-11
lines changed

5 files changed

+11
-11
lines changed

Sources/_SwiftSyntaxMacros/ExpressionMacro.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ import _CompilerPluginSupport
1919

2020
/// Describes a macro that is explicitly expanded as an expression.
2121
public protocol ExpressionMacro: Macro {
22-
/// Expansion a macro described by the given macro expansion expression
22+
/// Expand a macro described by the given macro expansion expression
2323
/// within the given context to produce a replacement expression.
24-
static func apply(
25-
_ expansion: MacroExpansionExprSyntax,
24+
static func expand(
25+
_ node: MacroExpansionExprSyntax,
2626
in context: inout MacroExpansionContext
2727
) -> ExprSyntax
2828
}
@@ -78,7 +78,7 @@ extension ExpressionMacro {
7878
}
7979

8080
// Evaluate the macro.
81-
let evalResult = apply(mee, in: context)
81+
let evalResult = expand(mee, in: context)
8282

8383
let rawDiags = UnsafeMutablePointer<_Diagnostic>.allocate(
8484
capacity: evalResult.diagnostics.count)

Sources/_SwiftSyntaxMacros/MacroSystem+Builtin.swift

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

2929
public struct ColorLiteralMacro: ExpressionMacro {
30-
public static func apply(
30+
public static func expand(
3131
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
3232
) -> ExprSyntax {
3333
let argList = replaceFirstLabel(
@@ -42,7 +42,7 @@ public struct ColorLiteralMacro: ExpressionMacro {
4242
}
4343

4444
public struct FileLiteralMacro: ExpressionMacro {
45-
public static func apply(
45+
public static func expand(
4646
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
4747
) -> ExprSyntax {
4848
let argList = replaceFirstLabel(
@@ -57,7 +57,7 @@ public struct FileLiteralMacro: ExpressionMacro {
5757
}
5858

5959
public struct ImageLiteralMacro: ExpressionMacro {
60-
public static func apply(
60+
public static func expand(
6161
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
6262
) -> ExprSyntax {
6363
let argList = replaceFirstLabel(
@@ -72,7 +72,7 @@ public struct ImageLiteralMacro: ExpressionMacro {
7272
}
7373

7474
public struct FileIDMacro: ExpressionMacro {
75-
public static func apply(
75+
public static func expand(
7676
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
7777
) -> ExprSyntax {
7878
// FIXME: Compiler has more sophisticated file ID computation

Sources/_SwiftSyntaxMacros/MacroSystem+Examples.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import SwiftSyntaxBuilder
1515

1616
// Macros used for testing purposes
1717
public struct StringifyMacro: ExpressionMacro {
18-
public static func apply(
18+
public static func expand(
1919
_ macro: MacroExpansionExprSyntax, in context: inout MacroExpansionContext
2020
) -> ExprSyntax {
2121
guard let argument = macro.argumentList.first?.expression else {

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.apply(disconnectedCopy(), in: &context)
44+
return exprMacro.expand(disconnectedCopy(), in: &context)
4545
}
4646
}
4747

Tests/SwiftSyntaxMacrosTest/MacroSystemTests.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ 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 apply(
22+
static func expand(
2323
_ macro: MacroExpansionExprSyntax,
2424
in context: inout MacroExpansionContext) -> ExprSyntax {
2525

0 commit comments

Comments
 (0)