From dee834a39780f61a0357c42f61592cd3c3598bd3 Mon Sep 17 00:00:00 2001 From: Roel Spilker Date: Mon, 8 Nov 2010 22:00:06 +0100 Subject: Added support for canEqual in ecj --- .../eclipse/handlers/HandleEqualsAndHashCode.java | 202 ++++++++++++++------- .../javac/handlers/HandleEqualsAndHashCode.java | 1 - .../transform/resource/after-ecj/DataExtended.java | 9 +- test/transform/resource/after-ecj/DataIgnore.java | 9 +- .../resource/after-ecj/DataOnLocalClass.java | 27 ++- test/transform/resource/after-ecj/DataPlain.java | 31 ++-- .../resource/after-ecj/DataWithGetter.java | 9 +- .../resource/after-ecj/DataWithGetterNone.java | 9 +- 8 files changed, 202 insertions(+), 95 deletions(-) diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java index e501c3f1..ed13fd1b 100644 --- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java @@ -47,6 +47,7 @@ import org.eclipse.jdt.internal.compiler.ast.Expression; import org.eclipse.jdt.internal.compiler.ast.FalseLiteral; import org.eclipse.jdt.internal.compiler.ast.FieldDeclaration; import org.eclipse.jdt.internal.compiler.ast.IfStatement; +import org.eclipse.jdt.internal.compiler.ast.InstanceOfExpression; import org.eclipse.jdt.internal.compiler.ast.IntLiteral; import org.eclipse.jdt.internal.compiler.ast.LocalDeclaration; import org.eclipse.jdt.internal.compiler.ast.MessageSend; @@ -202,9 +203,13 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler fields, boolean callSuper, ASTNode source, boolean useFieldsDirectly) { + private MethodDeclaration createEquals(EclipseNode type, Collection fields, boolean callSuper, ASTNode source, boolean useFieldsDirectly, boolean needsCanEqual) { int pS = source.sourceStart; int pE = source.sourceEnd; long p = (long)pS << 32 | pE; + TypeDeclaration typeDecl = (TypeDeclaration)type.get(); MethodDeclaration method = new MethodDeclaration( ((CompilationUnitDeclaration) type.top().get()).compilationResult); @@ -458,75 +477,36 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler other = (MyType) o; */ { if (!fields.isEmpty()) { - LocalDeclaration other = new LocalDeclaration(otherN, pS, pE); + LocalDeclaration other = new LocalDeclaration(otherName, pS, pE); other.modifiers |= ClassFileConstants.AccFinal; Eclipse.setGeneratedBy(other, source); char[] typeName = typeDecl.name; @@ -556,11 +536,63 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler