aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgrootjans <grootjans@gmail.com>2012-07-02 23:08:33 +0200
committergrootjans <grootjans@gmail.com>2012-07-02 23:08:33 +0200
commit3c0ed22062a83bd6611677ed6625698a769dd4fb (patch)
tree22d0448fb678020f4ca8ec16c4f1f12f49da350d
parent1c3ba98204345edf81c02b72e123df13e0ab0911 (diff)
downloadlombok-3c0ed22062a83bd6611677ed6625698a769dd4fb.tar.gz
lombok-3c0ed22062a83bd6611677ed6625698a769dd4fb.tar.bz2
lombok-3c0ed22062a83bd6611677ed6625698a769dd4fb.zip
Simplified method injection into Eclipse. Pre-3.6 version of Eclipse seemed
to need some special treatment to avoid a bug when generating constructors, see: http://code.google.com/p/projectlombok/issues/detail?id=155 Since Eclipse 3.6 we are no longer able to reproduce this issue. The fix, however, introduced bug 377 i.e. it was no longer possible to set break-points on lines above generated methods/constructors. tl;dr: Fixes #377, but does not reintroduce #155
-rw-r--r--src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java28
1 files changed, 7 insertions, 21 deletions
diff --git a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
index 4ea9421c..74512cc8 100644
--- a/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
+++ b/src/core/lombok/eclipse/handlers/EclipseHandlerUtil.java
@@ -40,14 +40,14 @@ import lombok.AccessLevel;
import lombok.Data;
import lombok.Getter;
import lombok.Lombok;
-import lombok.core.AnnotationValues;
-import lombok.core.TransformationsUtil;
import lombok.core.AST.Kind;
+import lombok.core.AnnotationValues;
import lombok.core.AnnotationValues.AnnotationValue;
+import lombok.core.TransformationsUtil;
+import lombok.core.TypeResolver;
import lombok.eclipse.EclipseAST;
import lombok.eclipse.EclipseNode;
import lombok.experimental.Accessors;
-import lombok.core.TypeResolver;
import org.eclipse.core.runtime.ILog;
import org.eclipse.core.runtime.IStatus;
@@ -62,7 +62,6 @@ import org.eclipse.jdt.internal.compiler.ast.ArrayInitializer;
import org.eclipse.jdt.internal.compiler.ast.ArrayQualifiedTypeReference;
import org.eclipse.jdt.internal.compiler.ast.ArrayTypeReference;
import org.eclipse.jdt.internal.compiler.ast.CastExpression;
-import org.eclipse.jdt.internal.compiler.ast.Clinit;
import org.eclipse.jdt.internal.compiler.ast.CompilationUnitDeclaration;
import org.eclipse.jdt.internal.compiler.ast.ConstructorDeclaration;
import org.eclipse.jdt.internal.compiler.ast.EqualExpression;
@@ -1215,24 +1214,11 @@ public class EclipseHandlerUtil {
}
}
}
- 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 (isGenerated(current)) continue;
- break;
- }
+ //We insert the method in the last position of the methods registered to the type
+ //When changing this behavior, this may trigger issue #155 and #377
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;
+ System.arraycopy(parent.methods, 0, newArray, 0, parent.methods.length);
+ newArray[parent.methods.length] = method;
parent.methods = newArray;
}