From 3f0a13501f19b966d3cbc0476a833783e6c6117a Mon Sep 17 00:00:00 2001 From: Reinier Zwitserloot Date: Sat, 31 Oct 2015 16:05:08 +0100 Subject: generating fields now occurs in the right place even for enums (no impact; the pretty printer fixes this for delombok and javac doesn’t care, but, still, let’s generate the same structure as what is parsed). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/lombok/javac/handlers/JavacHandlerUtil.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index c3607d37..4e9be00b 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -21,6 +21,7 @@ */ package lombok.javac.handlers; +import static com.sun.tools.javac.code.Flags.GENERATEDCONSTR; import static lombok.core.handlers.HandlerUtil.*; import static lombok.javac.Javac.*; import static lombok.javac.JavacAugments.JCTree_generatedNode; @@ -840,14 +841,18 @@ public class JavacHandlerUtil { List insertAfter = null; List insertBefore = type.defs; - while (insertBefore.tail != null) { + while (true) { + boolean skip = false; if (insertBefore.head instanceof JCVariableDecl) { JCVariableDecl f = (JCVariableDecl) insertBefore.head; - if (isEnumConstant(f) || isGenerated(f)) { - insertAfter = insertBefore; - insertBefore = insertBefore.tail; - continue; - } + if (isEnumConstant(f) || isGenerated(f)) skip = true; + } else if (insertBefore.head instanceof JCMethodDecl) { + if ((((JCMethodDecl) insertBefore.head).mods.flags & GENERATEDCONSTR) != 0) skip = true; + } + if (skip) { + insertAfter = insertBefore; + insertBefore = insertBefore.tail; + continue; } break; } -- cgit