Skip to content

Commit df00782

Browse files
authored
Merge pull request #464 from fwcd/eof-token-default-init
Add default initialization for EOF token to auto-generate SourceFile convenience initializer
2 parents 54ff9a2 + 42ba177 commit df00782

File tree

3 files changed

+4
-25
lines changed

3 files changed

+4
-25
lines changed

Sources/SwiftSyntaxBuilder/SourceFileConvenienceInitializers.swift

Lines changed: 0 additions & 23 deletions
This file was deleted.

Sources/SwiftSyntaxBuilder/gyb_generated/BuildableNodes.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5561,7 +5561,7 @@ public struct SourceFile: SyntaxBuildable, ExpressibleAsSourceFile {
55615561
/// - eofToken:
55625562
public init(
55635563
statements: ExpressibleAsCodeBlockItemList,
5564-
eofToken: TokenSyntax
5564+
eofToken: TokenSyntax = TokenSyntax.eof
55655565
) {
55665566
self.statements = statements.createCodeBlockItemList()
55675567
self.eofToken = eofToken
@@ -5571,7 +5571,7 @@ public struct SourceFile: SyntaxBuildable, ExpressibleAsSourceFile {
55715571
/// - Initializing syntax collections using result builders
55725572
/// - Initializing tokens without default text using strings
55735573
public init(
5574-
eofToken: TokenSyntax,
5574+
eofToken: TokenSyntax = TokenSyntax.eof,
55755575
@CodeBlockItemListBuilder statementsBuilder: () -> ExpressibleAsCodeBlockItemList = { CodeBlockItemList([]) }
55765576
) {
55775577
self.init(

Sources/SwiftSyntaxBuilder/gyb_helpers/SyntaxBuildableWrappers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,8 @@ def default_initialization(self):
191191
token = self.token()
192192
if token and token.text:
193193
return ' = TokenSyntax.`%s`' % lowercase_first_word(token.name)
194+
elif self.token_kind == 'EOFToken':
195+
return ' = TokenSyntax.eof'
194196
else:
195197
return ''
196198
else:

0 commit comments

Comments
 (0)