Skip to content

Commit fd36f96

Browse files
committed
fixed wrong code generation
1 parent 86be013 commit fd36f96

File tree

1 file changed

+25
-26
lines changed

1 file changed

+25
-26
lines changed

CodeGeneration/Sources/generate-swift-syntax/templates/swiftsyntax/SyntaxBaseNodesFile.swift

Lines changed: 25 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -292,38 +292,37 @@ let syntaxBaseNodesFiles: [SourceFileSyntax] = {
292292

293293
leafProtocolDecl(type: node.kind.leafProtocolType, inheritedType: node.kind.protocolType)
294294
leafProtocolExtension(type: node.kind.leafProtocolType, inheritedType: node.kind.protocolType)
295-
296-
297-
try! ExtensionDeclSyntax(
298-
"""
299-
// MARK: - Syntax
300-
301-
extension Syntax
302-
"""
303-
) {
304-
try VariableDeclSyntax("public static var structure: SyntaxNodeStructure") {
305-
let choices = ArrayExprSyntax {
295+
})
296+
}
297+
retVal.append(SourceFileSyntax(leadingTrivia: copyrightHeader) {
298+
try! ExtensionDeclSyntax(
299+
"""
300+
// MARK: - Syntax
301+
302+
extension Syntax
303+
"""
304+
) {
305+
try VariableDeclSyntax("public static var structure: SyntaxNodeStructure") {
306+
let choices = ArrayExprSyntax {
307+
ArrayElementSyntax(
308+
leadingTrivia: .newline,
309+
expression: ExprSyntax(".node(TokenSyntax.self)")
310+
)
311+
312+
for node in NON_BASE_SYNTAX_NODES {
306313
ArrayElementSyntax(
307314
leadingTrivia: .newline,
308-
expression: ExprSyntax(".node(TokenSyntax.self)")
315+
expression: ExprSyntax(".node(\(node.kind.syntaxType).self)")
309316
)
310-
311-
for node in NON_BASE_SYNTAX_NODES {
312-
ArrayElementSyntax(
313-
leadingTrivia: .newline,
314-
expression: ExprSyntax(".node(\(node.kind.syntaxType).self)")
315-
)
316-
}
317317
}
318-
319-
StmtSyntax("return .choices(\(choices))")
320318
}
321-
}
322319

323-
leafProtocolDecl(type: "_LeafSyntaxNodeProtocol", inheritedType: "SyntaxProtocol")
324-
leafProtocolExtension(type: "_LeafSyntaxNodeProtocol", inheritedType: "SyntaxProtocol")
325-
})
326-
}
320+
StmtSyntax("return .choices(\(choices))")
321+
}
322+
}
323+
leafProtocolDecl(type: "_LeafSyntaxNodeProtocol", inheritedType: "SyntaxProtocol")
324+
leafProtocolExtension(type: "_LeafSyntaxNodeProtocol", inheritedType: "SyntaxProtocol")
325+
})
327326
return retVal
328327
}()
329328

0 commit comments

Comments
 (0)