Skip to content

Commit 51dd7ce

Browse files
committed
Add utility property for adding backticks
1 parent 554057f commit 51dd7ce

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

Sources/SwiftSyntaxBuilderGeneration/String+Extensions.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,4 +14,5 @@ import Foundation
1414

1515
extension StringProtocol {
1616
var withFirstCharacterLowercased: String { prefix(1).lowercased() + dropFirst() }
17+
var backticked: String { "`\(string.replacingOccurrences(of: "`", with: ""))`" }
1718
}

Sources/SwiftSyntaxBuilderGeneration/Templates/TokensFile.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ let tokensFile = SourceFile {
3838
FunctionCallExpr(MemberAccessExpr(base: "SyntaxFactory", name: "make\(token.name)Keyword"))
3939
}
4040

41-
createTokenSyntaxPatternBinding("`\(token.name.withFirstCharacterLowercased)`", accessor: accessor)
41+
createTokenSyntaxPatternBinding(token.name.withFirstCharacterLowercased.backticked, accessor: accessor)
4242
}
4343
} else if let text = token.text {
4444
VariableDecl(
@@ -69,7 +69,7 @@ let tokensFile = SourceFile {
6969

7070
FunctionDecl(
7171
modifiers: [TokenSyntax.static],
72-
identifier: .identifier("`\(token.name.withFirstCharacterLowercased)`"),
72+
identifier: .identifier(token.name.withFirstCharacterLowercased.backticked),
7373
signature: signature
7474
) {
7575
FunctionCallExpr(MemberAccessExpr(base: "SyntaxFactory", name: "make\(token.name)")) {

0 commit comments

Comments
 (0)