WIP(general feedback appreciated): fix/refactor(control-flow): Switch rework and multi-node statement changes #5742
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
In the process of handling switch expressions and enhanced switch statements I ended up rewriting the whole switch code.
Notable Changes to the results:
default
cases don't have a dummy statement any more.The construct starts with a node that is assigned the entire statement, then the subnodes follow and the construct is finished with a
STATEMENT_END
node that is tagged with the start node (See details below).I intend to adapt this to other multi-node constructs as well and some support for this is already implemented, but the rest is probably better placed in another PR. I think this change enables a more complete representation of multi-node constructs, especially of multi-node expressions like conditionals (currently conditionals in returns are not handled at all, for example) or maybe even nested method calls. The design of this was based on the way conditionals are handled when assigned to local variables. I added the end marker mainly as a jump point for skipping the entire statement and for easier support with return statements.
I'd appreciate some feedback for these changes, especially on the last point as it has a pretty big impact
for