From b706657c4ed8975d325c40d9840809525abc12b8 Mon Sep 17 00:00:00 2001 From: Rob Stryker Date: Thu, 11 Apr 2024 16:47:21 -0400 Subject: [PATCH] int x,y format fields inside anonymous class was incorrect Signed-off-by: Rob Stryker --- .../src/org/eclipse/jdt/core/dom/JavacConverter.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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 e74a4d10380..8c7fd5bedc8 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 @@ -684,6 +684,11 @@ private FieldDeclaration convertFieldDeclaration(JCVariableDecl javac, ASTNode p .filter(x -> ((FieldDeclaration)x).getType().getStartPosition() == javac.vartype.getStartPosition()) .forEach(x -> sameStartPosition.add((ASTNode)x)); } + if( parent instanceof AnonymousClassDeclaration decl) { + decl.bodyDeclarations().stream().filter(x -> x instanceof FieldDeclaration) + .filter(x -> ((FieldDeclaration)x).getType().getStartPosition() == javac.vartype.getStartPosition()) + .forEach(x -> sameStartPosition.add((ASTNode)x)); + } if( sameStartPosition.size() >= 1 ) { FieldDeclaration fd = (FieldDeclaration)sameStartPosition.get(0); if( fd != null ) { @@ -1132,7 +1137,7 @@ private AnonymousClassDeclaration createAnonymousClassDeclaration(JCClassDecl ja if (javacAnon.getMembers() != null) { List members = javacAnon.getMembers(); for( int i = 0; i < members.size(); i++ ) { - ASTNode decl = convertBodyDeclaration(members.get(i), parent); + ASTNode decl = convertBodyDeclaration(members.get(i), anon); if( decl != null ) { anon.bodyDeclarations().add(decl); }