aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/eclipse/handlers
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@tipit.to>2009-07-26 09:34:10 +0200
committerReinier Zwitserloot <reinier@tipit.to>2009-07-26 09:34:10 +0200
commitf74109fdc8d35a1577167736598d95dcad321f0f (patch)
treedcf2dc1f48621ec14dc2cb41f0757e51e37e2887 /src/lombok/eclipse/handlers
parentdfbc6a79e79c1e070ad9d661a468199cffffddc1 (diff)
downloadlombok-f74109fdc8d35a1577167736598d95dcad321f0f.tar.gz
lombok-f74109fdc8d35a1577167736598d95dcad321f0f.tar.bz2
lombok-f74109fdc8d35a1577167736598d95dcad321f0f.zip
Addresses issue #5:
hitting 'find callers' on a @Data annotation should find callers of the (static) constructor. Right now it'll find callers to the *static* constructor ONLY. Letting it find callers of the public constructor if there is no static constructor just doesn't work.
Diffstat (limited to 'src/lombok/eclipse/handlers')
-rw-r--r--src/lombok/eclipse/handlers/HandleData.java26
1 files changed, 16 insertions, 10 deletions
diff --git a/src/lombok/eclipse/handlers/HandleData.java b/src/lombok/eclipse/handlers/HandleData.java
index 5542dd58..f6072137 100644
--- a/src/lombok/eclipse/handlers/HandleData.java
+++ b/src/lombok/eclipse/handlers/HandleData.java
@@ -129,6 +129,22 @@ public class HandleData implements EclipseAnnotationHandler<Data> {
injectMethod(typeNode, toString);
}
+ if ( methodExists("equals", typeNode) == MemberExistsResult.NOT_EXISTS ) {
+ MethodDeclaration equals = createEquals(typeNode, nodesForEquality, ast);
+ injectMethod(typeNode, equals);
+ }
+
+ if ( methodExists("hashCode", typeNode) == MemberExistsResult.NOT_EXISTS ) {
+ MethodDeclaration hashCode = createHashCode(typeNode, nodesForEquality, ast);
+ injectMethod(typeNode, hashCode);
+ }
+
+ //Careful: Generate the public static constructor (if there is one) LAST, so that any attempt to
+ //'find callers' on the annotation node will find callers of the constructor, which is by far the
+ //most useful of the many methods built by @Data. This trick won't work for the non-static constructor,
+ //for whatever reason, though you can find callers of that one by focussing on the class name itself
+ //and hitting 'find callers'.
+
if ( constructorExists(typeNode) == MemberExistsResult.NOT_EXISTS ) {
ConstructorDeclaration constructor = createConstructor(
ann.staticConstructor().length() == 0, typeNode, nodesForConstructor, ast);
@@ -143,16 +159,6 @@ public class HandleData implements EclipseAnnotationHandler<Data> {
}
}
- if ( methodExists("equals", typeNode) == MemberExistsResult.NOT_EXISTS ) {
- MethodDeclaration equals = createEquals(typeNode, nodesForEquality, ast);
- injectMethod(typeNode, equals);
- }
-
- if ( methodExists("hashCode", typeNode) == MemberExistsResult.NOT_EXISTS ) {
- MethodDeclaration hashCode = createHashCode(typeNode, nodesForEquality, ast);
- injectMethod(typeNode, hashCode);
- }
-
return false;
}