Skip to content

Replace string-based keyword references with Keyword enum in CodeGeneration #2056

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

Conversation

Matejkob
Copy link
Contributor

Follow-up PR to #2006
Resolves #2008

@Matejkob Matejkob requested a review from ahoppen as a code owner August 12, 2023 11:01
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.

Wohooo. More type safety 🤩

Comment on lines 538 to 540
.keyword(.`private`),
.keyword(.`fileprivate`),
.keyword(.`internal`),
Copy link
Member

Choose a reason for hiding this comment

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

Do these even need to be backpacked here. IIRC the only case that needs to be backtracked on the call side is init.

Same in a couple more places

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great point thank you for it! ❤️ Just pushed the corrected version.

@Matejkob Matejkob force-pushed the remove-string-based-reference-of-keywords branch from 1f99046 to 57d105d Compare August 14, 2023 19:01
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.

Thanks for your continued work to clean up CodeGeneration @Matejkob.

@ahoppen
Copy link
Member

ahoppen commented Aug 14, 2023

@swift-ci Please test

@ahoppen ahoppen enabled auto-merge August 14, 2023 19:07
@Matejkob
Copy link
Contributor Author

Matejkob commented Aug 14, 2023

Thanks for this and other code reviews @ahoppen.

Sending much love! ❤️

@ahoppen
Copy link
Member

ahoppen commented Aug 14, 2023

@Matejkob Looks like there’s a merge conflict now. Could you rebase the PR?

…ration

The CodeGeneration module was previously referring to keywords using string-based references like switch, which is not idiomatic Swift. To make the code more concise and in line with Swift's best practices, this commit introduces a Keyword enum in the KeywordSpec.swift file.
Now, instead of string-based references, the new Keyword enum contains all the possible keyword kinds. It also includes a computed property that returns the corresponding KeywordSpec for a given keyword, allowing for more concise and idiomatic references.
The code has been refactored to replace all string-based keyword references with members of the newly introduced Keyword enum. Associated tests have also been updated to reflect these changes.
auto-merge was automatically disabled August 15, 2023 19:05

Head branch was pushed to by a user without write access

@Matejkob Matejkob force-pushed the remove-string-based-reference-of-keywords branch from 57d105d to 9c270a7 Compare August 15, 2023 19:05
@Matejkob
Copy link
Contributor Author

@ahoppen I've just resolved the merge conflict.

@ahoppen
Copy link
Member

ahoppen commented Aug 15, 2023

@swift-ci Please test

@ahoppen ahoppen enabled auto-merge August 15, 2023 21:55
@ahoppen
Copy link
Member

ahoppen commented Aug 15, 2023

@swift-ci Please test Windows

1 similar comment
@ahoppen
Copy link
Member

ahoppen commented Aug 15, 2023

@swift-ci Please test Windows

@ahoppen ahoppen merged commit f46c7e0 into swiftlang:main Aug 16, 2023
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.

Remove string-based reference of keyword tokens in CodeGeneration
2 participants