From d792f7414008ade38eaadbec59ce4a1bfa6da7c5 Mon Sep 17 00:00:00 2001 From: Rob Stryker Date: Fri, 3 May 2024 02:07:38 -0400 Subject: [PATCH] Partial fix for ASTConverter15JLS8Test.test0059 - body declarations for enum type mishandled Signed-off-by: Rob Stryker --- .../eclipse/jdt/core/dom/JavacConverter.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java index a7831ce9107..1f475c90874 100644 --- a/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java +++ b/org.eclipse.jdt.core.javac/src/org/eclipse/jdt/core/dom/JavacConverter.java @@ -478,19 +478,16 @@ private AbstractTypeDeclaration convertClassDecl(JCClassDecl javacClassDecl, AST List enumStatements= enumDecl.enumConstants(); if (javacClassDecl.getMembers() != null) { for( Iterator i = javacClassDecl.getMembers().iterator(); i.hasNext(); ) { - EnumConstantDeclaration dec1 = convertEnumConstantDeclaration(i.next(), parent, enumDecl); + JCTree iNext = i.next(); + EnumConstantDeclaration dec1 = convertEnumConstantDeclaration(iNext, parent, enumDecl); if( dec1 != null ) { enumStatements.add(dec1); - } - } - } - - List bodyDecl = enumDecl.bodyDeclarations(); - if (javacClassDecl.getMembers() != null) { - for( Iterator i = javacClassDecl.getMembers().iterator(); i.hasNext(); ) { - BodyDeclaration bd = convertEnumFieldOrMethodDeclaration(i.next(), res, enumDecl); - if( bd != null ) { - bodyDecl.add(bd); + } else { + // body declaration + ASTNode bodyDecl = convertBodyDeclaration(iNext, res); + if( bodyDecl != null ) { + res.bodyDeclarations().add(bodyDecl); + } } } }