From 4cabd0d0ce6122945502a45f41dc22be6b2f22d9 Mon Sep 17 00:00:00 2001 From: Christian Sterzl Date: Thu, 3 Apr 2014 11:26:46 +0200 Subject: Adding eclipse support. --- src/core/lombok/EqualsAndHashCode.java | 2 +- .../eclipse/handlers/HandleEqualsAndHashCode.java | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/core/lombok/EqualsAndHashCode.java b/src/core/lombok/EqualsAndHashCode.java index de9c43ba..0ce9ded7 100644 --- a/src/core/lombok/EqualsAndHashCode.java +++ b/src/core/lombok/EqualsAndHashCode.java @@ -66,7 +66,7 @@ public @interface EqualsAndHashCode { * Any annotations listed here are put on the generated parameter of {@code equals} and {@code canEqual}. The syntax for this feature is: {@code @EqualsAndHashCode(onParam=@__({@AnnotationsGoHere}))} * This is useful to add for example a {@code Nullable} annotation. */ - AnyAnnotation[] onParam() default @AnyAnnotation; + AnyAnnotation[] onParam() default {}; /** * Placeholder annotation to enable the placement of annotations on the generated code. diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java index 8b4d14ed..a540299e 100644 --- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java +++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java @@ -116,7 +116,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler annotation, Annotation ast, EclipseNode annotationNode) { @@ -127,6 +127,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler includes = Arrays.asList(ann.of()); EclipseNode typeNode = annotationNode.up(); + List onParam = unboxAndRemoveAnnotationParameter(ast, "onParam", "@EqualsAndHashCode(onParam=", annotationNode); checkForBogusFieldNames(typeNode, annotation); Boolean callSuper = ann.callSuper(); @@ -141,11 +142,11 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler excludes, List includes, - Boolean callSuper, boolean whineIfExists, FieldAccess fieldAccess) { + Boolean callSuper, boolean whineIfExists, FieldAccess fieldAccess, List onParam) { assert excludes == null || includes == null; TypeDeclaration typeDecl = null; @@ -235,12 +236,12 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler fields, boolean callSuper, ASTNode source, FieldAccess fieldAccess, boolean needsCanEqual) { + public MethodDeclaration createEquals(EclipseNode type, Collection fields, boolean callSuper, ASTNode source, FieldAccess fieldAccess, boolean needsCanEqual, List onParam) { int pS = source.sourceStart; int pE = source.sourceEnd; long p = (long)pS << 32 | pE; TypeDeclaration typeDecl = (TypeDeclaration)type.get(); @@ -483,6 +484,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler statements = new ArrayList(); @@ -720,7 +722,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler onParam) { /* public boolean canEqual(final java.lang.Object other) { * return other instanceof Outer.Inner.MyType; * } @@ -747,6 +749,7 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler