aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorRoel Spilker <r.spilker@gmail.com>2010-11-07 15:16:48 +0100
committerRoel Spilker <r.spilker@gmail.com>2010-11-07 15:16:48 +0100
commit2097dd87310026733a4f48c47bb31a59996f5d83 (patch)
tree07b67c81a738699a5f076725c2388e5e439cf6bc /src
parent378b939108ef2216da00724a8efd9521b7a10b8f (diff)
downloadlombok-2097dd87310026733a4f48c47bb31a59996f5d83.tar.gz
lombok-2097dd87310026733a4f48c47bb31a59996f5d83.tar.bz2
lombok-2097dd87310026733a4f48c47bb31a59996f5d83.zip
Solved issue 155: "Eclipse constructor generation not in class body" http://code.google.com/p/projectlombok/issues/detail?id=155
Now all lombok generated methods are located before any other method.
Diffstat (limited to 'src')
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java33
1 files changed, 25 insertions, 8 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index c37de8ea..019ae637 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -460,25 +460,42 @@ public class EclipseHandlerUtil {
parent.methods = new AbstractMethodDeclaration[1];
parent.methods[0] = method;
} else {
- boolean injectionComplete = false;
if (method instanceof ConstructorDeclaration) {
for (int i = 0 ; i < parent.methods.length ; i++) {
if (parent.methods[i] instanceof ConstructorDeclaration &&
(parent.methods[i].bits & ASTNode.IsDefaultConstructor) != 0) {
EclipseNode tossMe = type.getNodeFor(parent.methods[i]);
- parent.methods[i] = method;
+
+ AbstractMethodDeclaration[] withoutGeneratedConstructor = new AbstractMethodDeclaration[parent.methods.length - 1];
+
+ System.arraycopy(parent.methods, 0, withoutGeneratedConstructor, 0, i);
+ System.arraycopy(parent.methods, i + 1, withoutGeneratedConstructor, i, parent.methods.length - i - 1);
+
+ parent.methods = withoutGeneratedConstructor;
if (tossMe != null) tossMe.up().removeChild(tossMe);
- injectionComplete = true;
break;
}
}
}
- if (!injectionComplete) {
- AbstractMethodDeclaration[] newArray = new AbstractMethodDeclaration[parent.methods.length + 1];
- System.arraycopy(parent.methods, 0, newArray, 0, parent.methods.length);
- newArray[parent.methods.length] = method;
- parent.methods = newArray;
+ int insertionPoint;
+ for (insertionPoint = 0; insertionPoint < parent.methods.length; insertionPoint++) {
+ AbstractMethodDeclaration current = parent.methods[insertionPoint];
+ if (current instanceof Clinit) continue;
+ if (method instanceof ConstructorDeclaration) {
+ if (current instanceof ConstructorDeclaration) continue;
+ break;
+ }
+ if (Eclipse.isGenerated(current)) continue;
+ break;
+ }
+ AbstractMethodDeclaration[] newArray = new AbstractMethodDeclaration[parent.methods.length + 1];
+ System.arraycopy(parent.methods, 0, newArray, 0, insertionPoint);
+ if (insertionPoint <= parent.methods.length) {
+ System.arraycopy(parent.methods, insertionPoint, newArray, insertionPoint + 1, parent.methods.length - insertionPoint);
}
+
+ newArray[insertionPoint] = method;
+ parent.methods = newArray;
}
type.add(method, Kind.METHOD).recursiveSetHandled();