aboutsummaryrefslogtreecommitdiff
path: root/src/core/lombok/eclipse
diff options
context:
space:
mode:
authorReinier Zwitserloot <reinier@zwitserloot.com>2021-02-04 22:02:30 +0100
committerGitHub <noreply@github.com>2021-02-04 22:02:30 +0100
commitccae25ac8c9b3a134a817eb2164d80a5b50322e8 (patch)
treea44d22233dda4612bd1ae083b4310cfbf7e061ee /src/core/lombok/eclipse
parent011e9915f2fbfa2d0ca9fea816003f90ce59ba5f (diff)
parent191a8011ef5e8ae2a4446b9b357e121272526364 (diff)
downloadlombok-ccae25ac8c9b3a134a817eb2164d80a5b50322e8.tar.gz
lombok-ccae25ac8c9b3a134a817eb2164d80a5b50322e8.tar.bz2
lombok-ccae25ac8c9b3a134a817eb2164d80a5b50322e8.zip
Merge pull request #2734 from Rawi01/data-equals-warning
Only show super()-warning if lombok generates a method
Diffstat (limited to 'src/core/lombok/eclipse')
-rwxr-xr-xsrc/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java48
1 files changed, 24 insertions, 24 deletions
diff --git a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
index deb19c00..8115a91f 100755
--- a/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
+++ b/src/core/lombok/eclipse/handlers/HandleEqualsAndHashCode.java
@@ -168,30 +168,6 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
boolean isDirectDescendantOfObject = isDirectDescendantOfObject(typeNode);
- if (isDirectDescendantOfObject && callSuper) {
- errorNode.addError("Generating equals/hashCode with a supercall to java.lang.Object is pointless.");
- return;
- }
-
- if (implicitCallSuper && !isDirectDescendantOfObject) {
- CallSuperType cst = typeNode.getAst().readConfiguration(ConfigurationKeys.EQUALS_AND_HASH_CODE_CALL_SUPER);
- if (cst == null) cst = CallSuperType.WARN;
-
- switch (cst) {
- default:
- case WARN:
- 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.");
- callSuper = false;
- break;
- case SKIP:
- callSuper = false;
- break;
- case CALL:
- callSuper = true;
- break;
- }
- }
-
boolean isFinal = (typeDecl.modifiers & ClassFileConstants.AccFinal) != 0;
boolean needsCanEqual = !isFinal || !isDirectDescendantOfObject;
MemberExistsResult equalsExists = methodExists("equals", typeNode, 1);
@@ -220,6 +196,30 @@ public class HandleEqualsAndHashCode extends EclipseAnnotationHandler<EqualsAndH
//fallthrough
}
+ if (isDirectDescendantOfObject && callSuper) {
+ errorNode.addError("Generating equals/hashCode with a supercall to java.lang.Object is pointless.");
+ return;
+ }
+
+ if (implicitCallSuper && !isDirectDescendantOfObject) {
+ CallSuperType cst = typeNode.getAst().readConfiguration(ConfigurationKeys.EQUALS_AND_HASH_CODE_CALL_SUPER);
+ if (cst == null) cst = CallSuperType.WARN;
+
+ switch (cst) {
+ default:
+ case WARN:
+ 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.");
+ callSuper = false;
+ break;
+ case SKIP:
+ callSuper = false;
+ break;
+ case CALL:
+ callSuper = true;
+ break;
+ }
+ }
+
MethodDeclaration equalsMethod = createEquals(typeNode, members, callSuper, errorNode.get(), fieldAccess, needsCanEqual, onParam);
equalsMethod.traverse(new SetGeneratedByVisitor(errorNode.get()), ((TypeDeclaration)typeNode.get()).scope);
injectMethod(typeNode, equalsMethod);