Comments (5)
Will do! I have a few other tasks keeping be busy, but I'll hopefully get to this at the end of this week or early next
from javaparser.
I introduced this bug in my first java 21 related PR, specifically here where I changed the Expression
expected in the switch body to StatementExpression
. I did that to fix semi-colon issues with the lexical preserving printer, but didn't consider the fact that not every expression is a statement expression. The tests I wrote all had either empty switch bodies, or print statements in the body, so I didn't cover the expression case. I'm working on a fix now!
from javaparser.
Apparently it is not only unary operators in a SwitchEntry, but also binary operators that cause parser errors.
An additional test follows:
@Test
void testSwitchExprWithBinaryExpr() {
parseStatement("int i = switch (1) {\n" +
" case 1 -> 1;\n" +
" case 2, 3 -> 1 + 2;\n" +
" default -> 1;\n" +
"};");
}
Output:
[ERROR] SwitchExprTest.testSwitchExprWithBinaryExpr:309 [(line 3,col 18) Parse error. Found "+", expected one of "%=" "&=" "*=" "++" "+=" "--" "-=" "/=" ";" "<<=" "=" ">>=" ">>>=" "^=" "|="
Problem stacktrace :
com.github.javaparser.GeneratedJavaParser.generateParseException(GeneratedJavaParser.java:14249)
com.github.javaparser.GeneratedJavaParser.jj_consume_token(GeneratedJavaParser.java:14094)
com.github.javaparser.GeneratedJavaParser.StatementExpression(GeneratedJavaParser.java:6228)
com.github.javaparser.GeneratedJavaParser.SwitchEntry(GeneratedJavaParser.java:6540)
[...]
Best regards
from javaparser.
@johannescoetzee Can you take a look at this?
from javaparser.
I've opened a PR that fixes this issue.
@Kimmmey thank you very much for the report and the small code examples! This was very useful for diagnosing the issue quickly :)
from javaparser.
Related Issues (20)
- Record can't be resolved in lambda expressions HOT 4
- UnsolvedSymbolException{context='null', name='We are unable to find the method declaration corresponding to this::getAmount', cause='null'} HOT 2
- ParseProblemException when parsing record pattern with primitive types HOT 7
- `com.github.javaparser.ast.Node#setParentNode` maybe lost parentNode,There may be forced modifications to the original AST Node HOT 5
- FindAll does not retrieve all the MethodCallExpr within a Statement HOT 2
- javaparser-core.jar is not reproducible due to JavaParserBuild
- Out of Memory Error with `sourceZip` API while trying to parse java's Core Library by javaparser HOT 2
- JavaParser cannot resolve objectCreationExpression when type argument is a record type HOT 2
- Question: Getting the index of token in parsed text HOT 1
- ResolvedMethodDeclaration.toDescription fails in the presence of type variables HOT 1
- VariableDeclarator character range does not match range of children HOT 1
- How to find implementation by MethodCallExpr HOT 2
- Pattern variables not always introduced into the correct scope HOT 7
- Node.PostOrderIterator broken for root without children
- Parsing issue in switch with yield HOT 2
- parseVariableDeclarationExpr with `var` HOT 1
- LexicalPreservingPrinter performance HOT 7
- ParseProblemException Switch expressions with constants throw error HOT 4
- After toAst(),error: Symbol resolution not configured: to configure consider setting a SymbolResolver in the ParserConfiguration HOT 6
- Import added through CompilationUnit.addImport should not have a range HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from javaparser.