Skip to content

Add default initialization for EOF token to auto-generate SourceFile convenience initializer #464

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -5561,7 +5561,7 @@ public struct SourceFile: SyntaxBuildable, ExpressibleAsSourceFile {
/// - eofToken:
public init(
statements: ExpressibleAsCodeBlockItemList,
eofToken: TokenSyntax
eofToken: TokenSyntax = TokenSyntax.eof
) {
self.statements = statements.createCodeBlockItemList()
self.eofToken = eofToken
Expand All @@ -5571,7 +5571,7 @@ public struct SourceFile: SyntaxBuildable, ExpressibleAsSourceFile {
/// - Initializing syntax collections using result builders
/// - Initializing tokens without default text using strings
public init(
eofToken: TokenSyntax,
eofToken: TokenSyntax = TokenSyntax.eof,
@CodeBlockItemListBuilder statementsBuilder: () -> ExpressibleAsCodeBlockItemList = { CodeBlockItemList([]) }
) {
self.init(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ def default_initialization(self):
token = self.token()
if token and token.text:
return ' = TokenSyntax.`%s`' % lowercase_first_word(token.name)
elif self.token_kind == 'EOFToken':
return ' = TokenSyntax.eof'
else:
return ''
else:
Expand Down