@@ -35,10 +35,10 @@ let tokensFile = SourceFile {
35
35
// We need to use `CodeBlock` here to ensure there is braces around.
36
36
37
37
let accessor = CodeBlock {
38
- FunctionCallExpr ( MemberAccessExpr ( base: " TokenSyntax " , name: " \( token. swiftKind) " ) )
38
+ FunctionCallExpr ( MemberAccessExpr ( base: " TokenSyntax " , name: token. swiftKind) )
39
39
}
40
40
41
- createTokenSyntaxPatternBinding ( " ` \( token. name. withFirstCharacterLowercased) ` " , accessor: accessor)
41
+ createTokenSyntaxPatternBinding ( token. name. withFirstCharacterLowercased. backticked , accessor: accessor)
42
42
}
43
43
} else if let text = token. text {
44
44
VariableDecl (
@@ -51,7 +51,30 @@ let tokensFile = SourceFile {
51
51
FunctionCallExpr ( MemberAccessExpr ( base: " TokenSyntax " , name: " \( token. swiftKind) Token " ) )
52
52
}
53
53
54
- createTokenSyntaxPatternBinding ( " ` \( token. name. withFirstCharacterLowercased) ` " , accessor: accessor)
54
+ createTokenSyntaxPatternBinding ( token. name. withFirstCharacterLowercased. backticked, accessor: accessor)
55
+ }
56
+ } else {
57
+ let signature = FunctionSignature (
58
+ input: ParameterClause {
59
+ FunctionParameter (
60
+ attributes: nil ,
61
+ firstName: . wildcard,
62
+ secondName: . identifier( " text " ) ,
63
+ colon: . colon,
64
+ type: " String "
65
+ )
66
+ } ,
67
+ output: " TokenSyntax "
68
+ )
69
+
70
+ FunctionDecl (
71
+ modifiers: [ TokenSyntax . static] ,
72
+ identifier: . identifier( token. name. withFirstCharacterLowercased. backticked) ,
73
+ signature: signature
74
+ ) {
75
+ FunctionCallExpr ( MemberAccessExpr ( base: " SyntaxFactory " , name: " make \( token. name) " ) ) {
76
+ TupleExprElement ( expression: IdentifierExpr ( " text " ) )
77
+ }
55
78
}
56
79
}
57
80
// TokenSyntax with custom text already has a static constructor function defined in SwiftSyntax.
0 commit comments