-
Notifications
You must be signed in to change notification settings - Fork 10.6k
[Source Tooling] Refactoring action to convert if statement to switch #29596
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
Conversation
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.
This looks great! Thanks for all the improvements. Just left one suggestion to improve the tests, but I'm happy to merge this without it too.
|
|
||
| // RUN: rm -rf %t.result && mkdir -p %t.result | ||
|
|
||
| // RUN: %refactor -convert-to-switch-stmt -source-filename %s -pos=9:3 -end-pos=16:4 > %t.result/L9-3.swift |
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.
It'd be good to type check the output file for each of these to make sure the code we're generating is valid and continues to type check as the compiler changes. You can do that be adding an extra RUN line like the below:
// RUN: %target-swift-frontend-typecheck %t.result/L9-3.swift
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.
Added for each test case.
|
@swift-ci please test |
|
@swift-ci Please Sourcekit Stress test |
|
Build failed |
|
Looks like a few of the existing tests need updating to allow for the new refactoring kind being in the list: |
|
Tests are failed at cases like this: I think there are no sense to convert |
|
@swift-ci please test |
|
Build failed |
|
Build failed |
Implement action to convert if statements from:
to
Resolves SR-5740.
P.S. I can't reopen previous PR](#26719) because of force push to branch after rebase. I remade refactoring action to resolve comments from previous PR.
@nathawes please take a look to new implementation.