mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java inspection: Don't offer to replace this.quals() and super.equals() with Objects.equals() (IDEA-161707)
This commit is contained in:
+4
-1
@@ -123,6 +123,10 @@ public class EqualsReplaceableByObjectsCallInspection extends BaseInspection {
|
||||
if (!HardcodedMethodConstants.EQUALS.equals(methodName)) {
|
||||
return;
|
||||
}
|
||||
final PsiExpression qualifierExpression = getQualifierExpression(expression);
|
||||
if (qualifierExpression instanceof PsiThisExpression || qualifierExpression instanceof PsiSuperExpression) {
|
||||
return;
|
||||
}
|
||||
final PsiElement maybeBinary = PsiTreeUtil.skipParentsOfType(expression, PsiParenthesizedExpression.class, PsiPrefixExpression.class);
|
||||
if (maybeBinary instanceof PsiBinaryExpression) {
|
||||
if (processNotNullCheck((PsiBinaryExpression)maybeBinary)) {
|
||||
@@ -130,7 +134,6 @@ public class EqualsReplaceableByObjectsCallInspection extends BaseInspection {
|
||||
}
|
||||
}
|
||||
if (!checkNotNull) {
|
||||
final PsiExpression qualifierExpression = getQualifierExpression(expression);
|
||||
if (qualifierExpression == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
+14
@@ -35,4 +35,18 @@ class EqualsReplaceableByObjectsCall {
|
||||
String s;
|
||||
T copy() { T t = new T(); t.s = s; return t; }
|
||||
}
|
||||
|
||||
static class X extends T {
|
||||
public boolean equals(Object o) {
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
boolean same(T t) {
|
||||
return this == t || this != null && this.equals(t);
|
||||
}
|
||||
|
||||
boolean different(T t) {
|
||||
return <warning descr="'t != this && (t == null || !t.equals(this))' replaceable by 'Objects.equals()' expression">t != this && (t == null || !t.equals(this))</warning>;
|
||||
}
|
||||
}
|
||||
}
|
||||
+14
@@ -35,4 +35,18 @@ class EqualsReplaceableByObjectsCall {
|
||||
String s;
|
||||
T copy() { T t = new T(); t.s = s; return t; }
|
||||
}
|
||||
|
||||
static class X extends T {
|
||||
public boolean equals(Object o) {
|
||||
return super.equals(o);
|
||||
}
|
||||
|
||||
boolean same(T t) {
|
||||
return this == t || this != null && this.equals(t);
|
||||
}
|
||||
|
||||
boolean different(T t) {
|
||||
return <warning descr="'t != this && (t == null || !t.equals(this))' replaceable by 'Objects.equals()' expression">t != this && (t == null || !t.equals(this))</warning>;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user