-
Notifications
You must be signed in to change notification settings - Fork 439
Replace string-based token references with Token
enum in CodeGeneration
#2006
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
Replace string-based token references with Token
enum in CodeGeneration
#2006
Conversation
7971c34
to
98be350
Compare
98be350
to
7324a4c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wohooo. Looks very good, I love it. I’ve got a couple of minor comments but otherwise this looks ready to ship.
CodeGeneration/Sources/generate-swiftsyntax/templates/swiftparser/ParserTokenSpecSetFile.swift
Outdated
Show resolved
Hide resolved
CodeGeneration/Tests/ValidateSyntaxNodes/ValidateSyntaxNodes.swift
Outdated
Show resolved
Hide resolved
7324a4c
to
71fd968
Compare
The CodeGeneration module was previously referring to tokens using string-based references like IdentifierToken, which is not idiomatic Swift. To make the code more concise and in line with Swift's best practices, this commit introduces a Token enum in the TokenSpec.swift file. Now, instead of string-based references, the new Token enum contains all the possible token kinds. It also includes a computed property that returns the corresponding TokenSpec for a given token, allowing for more concise and idiomatic references. The code has been refactored to replace all string-based token references with members of the newly introduced Token enum. Associated tests have also been updated to reflect these changes.
71fd968
to
8ebbac7
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thank you
@swift-ci Please test |
@swift-ci Please test |
The CodeGeneration module was previously referring to tokens using string-based references like
IdentifierToken
, which is not idiomatic Swift. To make the code more concise and in line with Swift's best practices, this commit introduces aToken
enum in theTokenSpec.swift
file.Now, instead of string-based references, the new
Token
enum contains all the possible token kinds. It also includes a computed property that returns the correspondingTokenSpec
for a given token, allowing for more concise and idiomatic references.The code has been refactored to replace all string-based token references with members of the newly introduced
Token
enum. Associated tests have also been updated to reflect these changes.Resolves #1978