diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2015-10-31 16:05:08 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2015-11-16 22:18:29 +0100 |
commit | 3f0a13501f19b966d3cbc0476a833783e6c6117a (patch) | |
tree | 0bbbd9de050212df7ce20f856f3588fb5bd40900 | |
parent | cb43dab23574d9c5dae2d3edec65fbdfa21b745f (diff) | |
download | lombok-3f0a13501f19b966d3cbc0476a833783e6c6117a.tar.gz lombok-3f0a13501f19b966d3cbc0476a833783e6c6117a.tar.bz2 lombok-3f0a13501f19b966d3cbc0476a833783e6c6117a.zip |
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).
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 17 |
1 files 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<JCTree> insertAfter = null; List<JCTree> 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; } |