Skip to content

[java] Refactor switch grammar#2204

Merged
oowekyala merged 3 commits into
pmd:java-grammarfrom
oowekyala:grammar-switches
Jan 16, 2020
Merged

[java] Refactor switch grammar#2204
oowekyala merged 3 commits into
pmd:java-grammarfrom
oowekyala:grammar-switches

Conversation

@oowekyala

Copy link
Copy Markdown
Member
  • Introduce SwitchLike as a supertype of SwitchExpression and SwitchStatement (since they have the same grammar). Pull up all interesting methods

  • Reorganise structure of the block:

    • A SwitchLike is an Iterable<ASTSwitchBranch>
    • A SwitchBranch is either a SwitchFallthroughBranch or a SwitchArrowBranch (the latter replaced SwitchLabeledRule)
  • About SwitchArrowBranch:

    • Previously we distinguished several kinds of SwitchLabeledRule
    • That's annoying because they don't provide more specialized API: the only difference is on the right-hand-side of the arrow.
    • So SwitchArrowBranch merges those three alternatives, and the three nodes that may appear as RHS share a common interface now
  • About SwitchFallthroughBranch: it doesn't make much sense to make the statements children of the branches (they don't belong more to one branch than to the previous branches, which may fallthrough to them).... but at least it allows sharing a regular API with SwitchArrowBranch. In any case we're going to need some basic CFG to work with exit points in switches... TBD

@oowekyala oowekyala added the in:ast About the AST structure or API, the parsing step label Jan 7, 2020
@oowekyala oowekyala added this to the 7.0.0 milestone Jan 7, 2020
@oowekyala oowekyala requested a review from adangel January 7, 2020 22:43
@ghost

ghost commented Jan 8, 2020

Copy link
Copy Markdown
1 Message
📖 No java rules are changed!

Generated by 🚫 Danger

@oowekyala oowekyala merged commit a30fa67 into pmd:java-grammar Jan 16, 2020
@oowekyala oowekyala deleted the grammar-switches branch January 16, 2020 22:30
@adangel adangel mentioned this pull request Jan 23, 2023
55 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

in:ast About the AST structure or API, the parsing step

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant