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

Conversation

fwcd
Copy link
Member

@fwcd fwcd commented Jun 16, 2022

The EOF token currently does not yield a .default_initialization() since it is not part of the SYNTAX_TOKEN_MAP (.token() therefore evaluates to None). This makes it slightly inconvenient to initialize SourceFile, since the eof argument has to be passed explicitly:

public init(
  eofToken: TokenSyntax,
  @CodeBlockItemListBuilder statementsBuilder: () -> ExpressibleAsCodeBlockItemList = { CodeBlockItemList([]) }
)

While the convenience initializer from SourceFileConvenienceInitializers.swift currently works around this, this PR makes the explicit convenience initializer superfluous, since the generated initializer is now essentially equivalent:

public init(
  eofToken: TokenSyntax = TokenSyntax.eof,
  @CodeBlockItemListBuilder statementsBuilder: () -> ExpressibleAsCodeBlockItemList = { CodeBlockItemList([]) }
)

cc @ahoppen

fwcd added 2 commits June 16, 2022 03:34
This is no longer needed since an equivalent initializer is now
generated by gyb.
@kimdv
Copy link
Contributor

kimdv commented Jun 16, 2022

@swift-ci please test

Copy link
Member

@ahoppen ahoppen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@ahoppen ahoppen merged commit df00782 into swiftlang:main Jun 16, 2022
@fwcd fwcd deleted the eof-token-default-init branch June 16, 2022 11:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants