aboutsummaryrefslogtreecommitdiff
path: root/src/lombok/eclipse
diff options
context:
space:
mode:
Diffstat (limited to 'src/lombok/eclipse')
-rw-r--r--src/lombok/eclipse/handlers/HandleData.java4
-rw-r--r--src/lombok/eclipse/handlers/HandleEqualsAndHashCode.java15
-rw-r--r--src/lombok/eclipse/handlers/HandleSetter.java5
3 files changed, 14 insertions, 10 deletions
diff --git a/src/lombok/eclipse/handlers/HandleData.java b/src/lombok/eclipse/handlers/HandleData.java
index 38e3135d..f072ea64 100644
--- a/src/lombok/eclipse/handlers/HandleData.java
+++ b/src/lombok/eclipse/handlers/HandleData.java
@@ -150,7 +150,7 @@ public class HandleData implements EclipseAnnotationHandler<Data> {
assigns.add(new Assignment(thisX, new SingleNameReference(field.name, p), (int)p));
long fieldPos = (((long)field.sourceStart) << 32) | field.sourceEnd;
- Argument argument = new Argument(field.name, fieldPos, copyType(field.type), 0);
+ Argument argument = new Argument(field.name, fieldPos, copyType(field.type), Modifier.FINAL);
Annotation[] nonNulls = findAnnotations(field, NON_NULL_PATTERN);
Annotation[] nullables = findAnnotations(field, NULLABLE_PATTERN);
if (nonNulls.length != 0) nullChecks.add(generateNullCheck(field));
@@ -203,7 +203,7 @@ public class HandleData implements EclipseAnnotationHandler<Data> {
Annotation[] copiedAnnotations = copyAnnotations(
findAnnotations(field, NON_NULL_PATTERN), findAnnotations(field, NULLABLE_PATTERN));
if (copiedAnnotations.length != 0) argument.annotations = copiedAnnotations;
- args.add(new Argument(field.name, fieldPos, copyType(field.type), 0));
+ args.add(new Argument(field.name, fieldPos, copyType(field.type), Modifier.FINAL));
}
statement.arguments = assigns.isEmpty() ? null : assigns.toArray(new Expression[assigns.size()]);
diff --git a/src/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
index f837d4a6..1adbe781 100644
--- a/src/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
+++ b/src/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
@@ -126,7 +126,7 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler<EqualsA
try {
callSuper = ((Boolean)EqualsAndHashCode.class.getMethod("callSuper").getDefaultValue()).booleanValue();
} catch ( Exception ignore ) {}
- generateMethods(typeNode, errorNode, Collections.<String>emptyList(), callSuper, false);
+ generateMethods(typeNode, errorNode, Collections.<String>emptyList(), callSuper, true, false);
}
@Override public boolean handle(AnnotationValues<EqualsAndHashCode> annotation, Annotation ast, Node annotationNode) {
@@ -136,11 +136,12 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler<EqualsA
checkForBogusExcludes(typeNode, annotation);
- return generateMethods(typeNode, annotationNode, excludes, ann.callSuper(), true);
+ return generateMethods(typeNode, annotationNode, excludes,
+ ann.callSuper(), annotation.getRawExpression("callSuper") == null, true);
}
public boolean generateMethods(Node typeNode, Node errorNode, List<String> excludes,
- boolean callSuper, boolean whineIfExists) {
+ boolean callSuper, boolean implicit, boolean whineIfExists) {
TypeDeclaration typeDecl = null;
if ( typeNode.get() instanceof TypeDeclaration ) typeDecl = (TypeDeclaration) typeNode.get();
@@ -165,8 +166,8 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler<EqualsA
return true;
}
- if ( !isDirectDescendantOfObject && !callSuper ) {
- errorNode.addWarning("Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object.");
+ if ( !isDirectDescendantOfObject && !callSuper && implicit ) {
+ errorNode.addWarning("Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object. If this is intentional, add '@EqualsAndHashCode(callSuper=false)' to your type.");
}
List<Node> nodesForEquality = new ArrayList<Node>();
@@ -243,7 +244,7 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler<EqualsA
/* Without fields, PRIME isn't used, and that would trigger a 'local variable not used' warning. */
if ( !isEmpty || callSuper ) {
LocalDeclaration primeDecl = new LocalDeclaration(PRIME, 0 ,0);
- primeDecl.modifiers = Modifier.FINAL;
+ primeDecl.modifiers |= Modifier.FINAL;
primeDecl.type = TypeReference.baseTypeReference(TypeIds.T_int, 0);
primeDecl.initialization = new IntLiteral("31".toCharArray(), 0, 0);
statements.add(primeDecl);
@@ -363,7 +364,7 @@ public class HandleEqualsAndHashCode implements EclipseAnnotationHandler<EqualsA
method.bodyEnd = method.declarationSourceEnd = method.sourceEnd = pos.sourceEnd;
method.arguments = new Argument[] {
new Argument(new char[] { 'o' }, 0,
- new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, new long[] { 0, 0, 0 }), 0)
+ new QualifiedTypeReference(TypeConstants.JAVA_LANG_OBJECT, new long[] { 0, 0, 0 }), Modifier.FINAL)
};
List<Statement> statements = new ArrayList<Statement>();
diff --git a/src/lombok/eclipse/handlers/HandleSetter.java b/src/lombok/eclipse/handlers/HandleSetter.java
index 6214c86d..5ad9b193 100644
--- a/src/lombok/eclipse/handlers/HandleSetter.java
+++ b/src/lombok/eclipse/handlers/HandleSetter.java
@@ -23,6 +23,9 @@ package lombok.eclipse.handlers;
import static lombok.eclipse.Eclipse.*;
import static lombok.eclipse.handlers.PKG.*;
+
+import java.lang.reflect.Modifier;
+
import lombok.AccessLevel;
import lombok.Setter;
import lombok.core.AnnotationValues;
@@ -125,7 +128,7 @@ public class HandleSetter implements EclipseAnnotationHandler<Setter> {
method.modifiers = modifier;
method.returnType = TypeReference.baseTypeReference(TypeIds.T_void, 0);
method.annotations = null;
- Argument param = new Argument(field.name, pos, copyType(field.type), 0);
+ Argument param = new Argument(field.name, pos, copyType(field.type), Modifier.FINAL);
method.arguments = new Argument[] { param };
method.selector = name.toCharArray();
method.binding = null;