@Override
  public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
    return new JavaElementVisitor() {
      @Override
      public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
        PsiElement nameElement = call.getMethodExpression().getReferenceNameElement();
        if (nameElement == null) return;
        boolean isInstance = IS_INSTANCE.test(call);
        boolean cast = CAST.test(call);
        if (isInstance || cast) {
          PsiExpression qualifier = PsiUtil.skipParenthesizedExprDown(call.getMethodExpression().getQualifierExpression());
          if (qualifier instanceof PsiClassObjectAccessExpression) {
            PsiTypeElement typeElement = ((PsiClassObjectAccessExpression)qualifier).getOperand();
            PsiType classType = typeElement.getType();
            PsiExpression argument = call.getArgumentList().getExpressions()[0];
            PsiType argumentType = argument.getType();
            if (argumentType == null ||
                (isInstance && TypeConversionUtil.isPrimitiveAndNotNull(argumentType)) ||
                !argumentType.isConvertibleFrom(classType)) {
              // will be a compilation error after replacement; skip this
              return;
            }
            LocalQuickFix fix = isInstance ? new ReplaceWithInstanceOfFix(typeElement) : new ReplaceWithCastFix(typeElement);
            holder.registerProblem(nameElement, InspectionGadgetsBundle.message("redundant.call.problem.descriptor"), fix);
          }
        }
      }
    };
  }
@Override
  public @NotNull PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly)