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); }