aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/javac
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/lombok/javac')
-rw-r--r--src/core/lombok/javac/handlers/JavacHandlerUtil.java26
1 files changed, 25 insertions, 1 deletions
diff --git a/src/core/lombok/javac/handlers/JavacHandlerUtil.java b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
index 00090be9..fc9435d8 100644
--- a/src/core/lombok/javac/handlers/JavacHandlerUtil.java
+++ b/src/core/lombok/javac/handlers/JavacHandlerUtil.java
@@ -532,11 +532,35 @@ public class JavacHandlerUtil {
JCClassDecl type = (JCClassDecl) typeNode.get();
if (addSuppressWarnings) addSuppressWarningsAll(field.mods, typeNode, field.pos, getGeneratedBy(field));
- type.defs = type.defs.append(field);
+
+ List<JCTree> insertAfter = null;
+ List<JCTree> insertBefore = type.defs;
+ while (insertBefore.tail != null) {
+ if (insertBefore.head instanceof JCVariableDecl) {
+ JCVariableDecl f = (JCVariableDecl) insertBefore.head;
+ if (isEnumConstant(f) || isGenerated(f)) {
+ insertAfter = insertBefore;
+ insertBefore = insertBefore.tail;
+ continue;
+ }
+ }
+ break;
+ }
+ List<JCTree> fieldEntry = List.<JCTree>of(field);
+ fieldEntry.tail = insertBefore;
+ if (insertAfter == null) {
+ type.defs = fieldEntry;
+ } else {
+ insertAfter.tail = fieldEntry;
+ }
typeNode.add(field, Kind.FIELD);
}
+ private static boolean isEnumConstant(final JCVariableDecl field) {
+ return (field.mods.flags & Flags.ENUM) != 0;
+ }
+
/**
* Adds the given new method declaration to the provided type AST Node.
* Can also inject constructors.