Skip to content

Commit 77c886c

Browse files
committed
[Macros] Rename createUniqueName to makeUniqueName
As per Evolution comment: https://forums.swift.org/t/se-0382-second-review-expression-macros/63064/20 To be merged with swiftlang/swift-syntax#1367
1 parent 46bf41c commit 77c886c

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

lib/ASTGen/Sources/ASTGen/SourceManager+MacroExpansionContext.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ extension String {
5353

5454
extension SourceManager.MacroExpansionContext: MacroExpansionContext {
5555
/// Generate a unique name for use in the macro.
56-
public func createUniqueName(_ providedName: String) -> TokenSyntax {
56+
public func makeUniqueName(_ providedName: String) -> TokenSyntax {
5757
// If provided with an empty name, substitute in something.
5858
let name = providedName.isEmpty ? "__local" : providedName
5959

test/Macros/Inputs/syntax_macro_definitions.swift

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -214,8 +214,8 @@ public struct DefineBitwidthNumberedStructsMacro: DeclarationMacro {
214214
"""
215215
216216
struct \(raw: prefix) {
217-
func \(context.createUniqueName("method"))() { return 0 }
218-
func \(context.createUniqueName("method"))() { return 1 }
217+
func \(context.makeUniqueName("method"))() { return 0 }
218+
func \(context.makeUniqueName("method"))() { return 1 }
219219
}
220220
"""
221221
]
@@ -225,8 +225,8 @@ public struct DefineBitwidthNumberedStructsMacro: DeclarationMacro {
225225
"""
226226
227227
struct \(raw: prefix)\(raw: String(bitwidth)) {
228-
func \(context.createUniqueName("method"))() { }
229-
func \(context.createUniqueName("method"))() { }
228+
func \(context.makeUniqueName("method"))() { }
229+
func \(context.makeUniqueName("method"))() { }
230230
}
231231
"""
232232
}
@@ -242,15 +242,15 @@ public struct DefineDeclsWithKnownNamesMacro: DeclarationMacro {
242242
"""
243243
244244
struct A {
245-
func \(context.createUniqueName("method"))() { }
246-
func \(context.createUniqueName("method"))() { }
245+
func \(context.makeUniqueName("method"))() { }
246+
func \(context.makeUniqueName("method"))() { }
247247
}
248248
""",
249249
"""
250250
251251
struct B {
252-
func \(context.createUniqueName("method"))() { }
253-
func \(context.createUniqueName("method"))() { }
252+
func \(context.makeUniqueName("method"))() { }
253+
func \(context.makeUniqueName("method"))() { }
254254
}
255255
""",
256256
"""
@@ -780,7 +780,7 @@ public struct WrapInType: PeerMacro {
780780
funcDecl
781781
.with(
782782
\.identifier,
783-
"\(context.createUniqueName(funcDecl.identifier.text))"
783+
"\(context.makeUniqueName(funcDecl.identifier.text))"
784784
)
785785
.with(
786786
\.signature,
@@ -801,7 +801,7 @@ public struct WrapInType: PeerMacro {
801801

802802
let structType: DeclSyntax =
803803
"""
804-
struct \(context.createUniqueName(funcDecl.identifier.text)) {
804+
struct \(context.makeUniqueName(funcDecl.identifier.text)) {
805805
\(method)
806806
}
807807
"""

0 commit comments

Comments
 (0)