void (@NotNull PsiMethodCallExpression call) { if (!OBJECTS_EQUALS.test(call)) return; PsiExpression[] args = call.getArgumentList().getExpressions(); PsiExpression arg1 = args[0]; PsiExpression arg2 = args[1]; PsiElement nameElement = Objects.requireNonNull(call.getMethodExpression().getReferenceNameElement()); if (processPrimitives(nameElement, arg1, arg2)) return; PsiClass argClass = PsiUtil.resolveClassInClassTypeOnly(arg1.getType()); if (argClass == null) return; if (NullabilityUtil.getExpressionNullability(arg1, true) == Nullability.NOT_NULL) { PsiMethod[] equalsMethods = argClass.findMethodsByName("equals", true); for (PsiMethod method : equalsMethods) { if (!method.hasModifierProperty(PsiModifier.STATIC) && method.getParameterList().getParametersCount() == 1 && !TypeUtils.isJavaLangObject(Objects.requireNonNull(method.getParameterList().getParameter(0)).getType())) { // After replacement may be linked to overloaded equals method // even if not, the code becomes more fragile, so let's not suggest the replacement if equals(SomeType) is defined. return; } } @NlsSafe final String message = JavaAnalysisBundle.message("inspection.can.be.replaced.with.message", "equals()"); holder.registerProblem(nameElement, message, new ReplaceWithEqualsFix(false)); } }