diff --git a/pom.xml b/pom.xml index 1f4e235db6f..cc3e82f787f 100644 --- a/pom.xml +++ b/pom.xml @@ -34,7 +34,7 @@ org.eclipse.jdt org.eclipse.jdt.core - 3.39.0 + 3.40.0 org.eclipse.platform diff --git a/src/main/java/spoon/support/compiler/jdt/JDTTreeBuilder.java b/src/main/java/spoon/support/compiler/jdt/JDTTreeBuilder.java index a042f1046ba..fb8ea9df4af 100644 --- a/src/main/java/spoon/support/compiler/jdt/JDTTreeBuilder.java +++ b/src/main/java/spoon/support/compiler/jdt/JDTTreeBuilder.java @@ -1780,6 +1780,10 @@ public void endVisit(TypePattern anyPattern, BlockScope scope) { @Override public boolean visit(SwitchStatement switchStatement, BlockScope scope) { + // JDT 3.40.0 removes SwitchExpression#traverse method, so let's emulate it + if (switchStatement instanceof SwitchExpression switchExpression) { + return visit(switchExpression, scope); + } context.enter(factory.Core().createSwitch(), switchStatement); return true; } diff --git a/src/main/java/spoon/support/compiler/jdt/ParentExiter.java b/src/main/java/spoon/support/compiler/jdt/ParentExiter.java index 4bea9488b3c..4da526e6188 100644 --- a/src/main/java/spoon/support/compiler/jdt/ParentExiter.java +++ b/src/main/java/spoon/support/compiler/jdt/ParentExiter.java @@ -503,8 +503,8 @@ public void visitCtBreak(CtBreak b) { @Override public void visitCtCase(CtCase caseStatement) { final ASTNode node = jdtTreeBuilder.getContextBuilder().getCurrentNode(); - if (node instanceof CaseStatement) { - caseStatement.setCaseKind(((CaseStatement) node).isExpr ? CaseKind.ARROW : CaseKind.COLON); + if (node instanceof CaseStatement cs) { + caseStatement.setCaseKind(cs.isSwitchRule ? CaseKind.ARROW : CaseKind.COLON); } if (shouldAddAsCaseExpression(caseStatement, node)) { if (child instanceof CtPattern pattern) { diff --git a/src/test/java/spoon/test/reference/ElasticsearchStackoverflowTest.java b/src/test/java/spoon/test/reference/ElasticsearchStackoverflowTest.java index ad07a7120ab..107e2873d3b 100644 --- a/src/test/java/spoon/test/reference/ElasticsearchStackoverflowTest.java +++ b/src/test/java/spoon/test/reference/ElasticsearchStackoverflowTest.java @@ -46,7 +46,6 @@ public void visitCtExecutableReference( } } - @GitHubIssue(issueNumber = 5977, fixed = false) @Test public void testStackOverflow() { Launcher launcher = new Launcher();