mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-15 10:15:19 +00:00
The warning for not enabling callSuper cannot be avoided, but there are legal reasons for using it, so, changed it: explicitly setting 'callSuper=false' removes the warning. You only get the warning
if callSuper is false because that's the default. Fixes issue #13
This commit is contained in:
1 parent
2bdc1210d7
commit
8428be5c68
3 files changed
+16
-10
No files matched your search
@@ -1,6 +1,10 @@
|
||||
Lombok Changelog
|
||||
----------------
|
||||
|
||||
### v0.8.3
|
||||
|
||||
* @EqualsAndHashCode (and, indirectly, @Data) generate a warning when overriding a class other than java.lang.Object but not setting EqualsAndHashCode's callSuper to true. There are, however, legitimate reasons to do this, so this warning is now no longer generated if you explicitly set callSuper to false. The warning text now also refers to this action if not calling super is intentional.
|
||||
|
||||
### v0.8.2
|
||||
|
||||
* @EqualsAndHashCode and @ToString created; these are subsets of what @Data does (namely: generate toString(), and generate equals() and hashCode() implementations). @Data will still generate these methods, but you can now generate them separately if you wish. As part of this split off, you can now specify for toString generation to include the field names in the produced toString method, and for all 3 methods: You can choose to involve the implementation of the superclass, and you can choose to exclude certain fields. [Issue #8](http://code.google.com/p/projectlombok/issues/detail?id=8)
|
||||
|
||||
@@ -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 ( !isDirectDescendentOfObject && !callSuper ) {
|
||||
errorNode.addWarning("Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object.");
|
||||
if ( !isDirectDescendentOfObject && !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>();
|
||||
|
||||
@@ -86,7 +86,8 @@ public class HandleEqualsAndHashCode implements JavacAnnotationHandler<EqualsAnd
|
||||
|
||||
checkForBogusExcludes(typeNode, annotation);
|
||||
|
||||
return generateMethods(typeNode, annotationNode, excludes, ann.callSuper(), true);
|
||||
return generateMethods(typeNode, annotationNode, excludes,
|
||||
ann.callSuper(), annotation.getRawExpression("callSuper") == null, true);
|
||||
}
|
||||
|
||||
public void generateEqualsAndHashCodeForType(Node typeNode, Node errorNode) {
|
||||
@@ -103,11 +104,11 @@ public class HandleEqualsAndHashCode implements JavacAnnotationHandler<EqualsAnd
|
||||
try {
|
||||
callSuper = ((Boolean)EqualsAndHashCode.class.getMethod("callSuper").getDefaultValue()).booleanValue();
|
||||
} catch ( Exception ignore ) {}
|
||||
generateMethods(typeNode, errorNode, List.<String>nil(), callSuper, false);
|
||||
generateMethods(typeNode, errorNode, List.<String>nil(), callSuper, true, false);
|
||||
}
|
||||
|
||||
private boolean generateMethods(Node typeNode, Node errorNode, List<String> excludes,
|
||||
boolean callSuper, boolean whineIfExists) {
|
||||
boolean callSuper, boolean implicit, boolean whineIfExists) {
|
||||
boolean notAClass = true;
|
||||
if ( typeNode.get() instanceof JCClassDecl ) {
|
||||
long flags = ((JCClassDecl)typeNode.get()).mods.flags;
|
||||
@@ -132,8 +133,8 @@ public class HandleEqualsAndHashCode implements JavacAnnotationHandler<EqualsAnd
|
||||
return true;
|
||||
}
|
||||
|
||||
if ( !isDirectDescendentOfObject && !callSuper ) {
|
||||
errorNode.addWarning("Generating equals/hashCode implementation but without a call to superclass, even though this class does not extend java.lang.Object.");
|
||||
if ( !isDirectDescendentOfObject && !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 = List.nil();
|
||||
|
||||
Reference in new issue
Block a user