Skip to content

Fix parsing of multiple patterns in switch case labels (issue #4996)#5009

Merged
jlerbsc merged 1 commit into
javaparser:masterfrom
jlerbsc:master
May 6, 2026
Merged

Fix parsing of multiple patterns in switch case labels (issue #4996)#5009
jlerbsc merged 1 commit into
javaparser:masterfrom
jlerbsc:master

Conversation

@jlerbsc

@jlerbsc jlerbsc commented May 6, 2026

Copy link
Copy Markdown
Collaborator

Fixes #4996 .

The JavaCC grammar only allowed a single PatternExpression per case label,
causing a parse error on valid Java 22+ syntax such as:
case String _, Integer _ -> ...
Extended the SwitchEntry grammar rule to accept one or more comma-separated
PatternExpression nodes using a targeted LOOKAHEAD to avoid ambiguity with
the existing multi-constant case branch (case A, B ->).

@codecov

codecov Bot commented May 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 58.694%. Comparing base (b3b12a3) to head (0366a71).
⚠️ Report is 10 commits behind head on master.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##              master     #5009   +/-   ##
===========================================
  Coverage     58.694%   58.694%           
  Complexity      2592      2592           
===========================================
  Files            700       700           
  Lines          40188     40188           
  Branches        7323      7323           
===========================================
  Hits           23588     23588           
  Misses         13630     13630           
  Partials        2970      2970           
Flag Coverage Δ
AlsoSlowTests 58.694% <ø> (ø)
javaparser-core 58.694% <ø> (ø)
javaparser-symbol-solver 58.694% <ø> (ø)
jdk-10 58.266% <ø> (ø)
jdk-11 58.265% <ø> (ø)
jdk-12 58.263% <ø> (-0.003%) ⬇️
jdk-13 58.265% <ø> (ø)
jdk-14 58.496% <ø> (+0.002%) ⬆️
jdk-15 58.496% <ø> (ø)
jdk-16 58.472% <ø> (ø)
jdk-17 58.621% <ø> (ø)
jdk-18 58.618% <ø> (-0.003%) ⬇️
jdk-8 58.102% <ø> (ø)
jdk-9 58.264% <ø> (ø)
macos-latest 58.669% <ø> (ø)
ubuntu-latest 58.664% <ø> (ø)
windows-latest 58.676% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 67f2951...0366a71. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jlerbsc jlerbsc merged commit f7dd5d4 into javaparser:master May 6, 2026
34 of 35 checks passed
@jlerbsc jlerbsc added this to the next release milestone May 6, 2026
@jlerbsc jlerbsc added the PR: Fixed A PR that offers a fix or correction label May 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Fixed A PR that offers a fix or correction

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Java 25 multi-label unnamed patterns (case A _, B _ ->) is not supported by the XJC plugin's JavaParser

1 participant