@NotNull
  @Override
  public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
    return new JavaElementVisitor() {
      @Override
      public void visitMethodCallExpression(@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));
        }
      }

      private boolean processPrimitives(PsiElement nameElement, PsiExpression arg1, PsiExpression arg2) {
        PsiType type1 = arg1.getType();
        PsiType type2 = arg2.getType();
        if (type1 instanceof PsiPrimitiveType && type1.equals(type2) && !TypeConversionUtil.isFloatOrDoubleType(type1)) {
          holder.registerProblem(nameElement, JavaAnalysisBundle.message("inspection.can.be.replaced.with.message", "=="),
                                 new ReplaceWithEqualsFix(true));
          return true;
        }
        return false;
      }
    };
  }
@NotNull
  @Override
  public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly)