diff options
author | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-11-01 16:38:25 +0100 |
---|---|---|
committer | Reinier Zwitserloot <reinier@zwitserloot.com> | 2018-11-01 16:38:25 +0100 |
commit | 2fd46a50b6125fd9f0e8177ffad5db8ee934fe34 (patch) | |
tree | 6662a3cb71b99b8c2b9fc058db8b735dc36145d0 /src/core/lombok/javac/handlers/JavacHandlerUtil.java | |
parent | 21878e253e331f6ea340ae44bf824890185e1938 (diff) | |
download | lombok-2fd46a50b6125fd9f0e8177ffad5db8ee934fe34.tar.gz lombok-2fd46a50b6125fd9f0e8177ffad5db8ee934fe34.tar.bz2 lombok-2fd46a50b6125fd9f0e8177ffad5db8ee934fe34.zip |
[feature] FieldNameConstants now works like Builder: Make whatever bits it does by hand and lombok fills in whatever is missing.
Diffstat (limited to 'src/core/lombok/javac/handlers/JavacHandlerUtil.java')
-rw-r--r-- | src/core/lombok/javac/handlers/JavacHandlerUtil.java | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java index c97c7ede..d7fae8e6 100644 --- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java +++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java @@ -224,6 +224,15 @@ public class JavacHandlerUtil { } } + public static JavacNode findInnerClass(JavacNode parent, String name) { + for (JavacNode child : parent.down()) { + if (child.getKind() != Kind.TYPE) continue; + JCClassDecl td = (JCClassDecl) child.get(); + if (td.name.contentEquals(name)) return child; + } + return null; + } + public static JavacNode findAnnotation(Class<? extends Annotation> type, JavacNode node) { return findAnnotation(type, node, false); } @@ -1001,7 +1010,11 @@ public class JavacHandlerUtil { return injectField(typeNode, field, false); } - private static JavacNode injectField(JavacNode typeNode, JCVariableDecl field, boolean addGenerated) { + public static JavacNode injectField(JavacNode typeNode, JCVariableDecl field, boolean addGenerated) { + return injectField(typeNode, field, addGenerated, false); + } + + public static JavacNode injectField(JavacNode typeNode, JCVariableDecl field, boolean addGenerated, boolean specialEnumHandling) { JCClassDecl type = (JCClassDecl) typeNode.get(); if (addGenerated) { @@ -1015,7 +1028,7 @@ public class JavacHandlerUtil { boolean skip = false; if (insertBefore.head instanceof JCVariableDecl) { JCVariableDecl f = (JCVariableDecl) insertBefore.head; - if (isEnumConstant(f) || isGenerated(f)) skip = true; + if ((!specialEnumHandling && isEnumConstant(f)) || isGenerated(f)) skip = true; } else if (insertBefore.head instanceof JCMethodDecl) { if ((((JCMethodDecl) insertBefore.head).mods.flags & GENERATEDCONSTR) != 0) skip = true; } |