@NotNull
  @Override
  public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly) {
    LanguageLevel level = PsiUtil.getLanguageLevel(holder.getFile());
    if (level.isLessThan(LanguageLevel.JDK_11)) {
      return PsiElementVisitor.EMPTY_VISITOR;
    }
    return new JavaElementVisitor() {
      @Override
      public void visitMethodCallExpression(@NotNull PsiMethodCallExpression call) {
        if (FILES_WRITE.test(call)) {
          PsiMethodCallExpression bytesExpression = tryCast(ExpressionUtils.resolveExpression(call.getArgumentList().getExpressions()[1]), PsiMethodCallExpression.class);
          if (STRING_GET_BYTES.test(bytesExpression) && bytesExpression.getMethodExpression().getQualifierExpression() != null) {
            // Do not suggest for UTF-8 before Java 12 due to JDK-8209576
            ProblemHighlightType highlight;
            String message = JavaBundle.message("inspection.message.can.be.replaced.with.files.writestring");
            if (level.isAtLeast(LanguageLevel.JDK_12) || isNonUtf8Charset(bytesExpression.getArgumentList().getExpressions()[0])) {
              highlight = ProblemHighlightType.GENERIC_ERROR_OR_WARNING;
            } else {
              highlight = ProblemHighlightType.INFORMATION;
              if (!isOnTheFly) return;
            }
            PsiReferenceExpression methodExpression = call.getMethodExpression();
            PsiElement referenceNameElement = methodExpression.getReferenceNameElement();
            if (referenceNameElement != null) {
              holder.registerProblem(referenceNameElement, message, highlight,
                                     new ReplaceWithWriteStringFix(highlight == ProblemHighlightType.INFORMATION));
            }
          }
        } else if (FILES_READ_ALL_BYTES.test(call)) {
          PsiExpressionList expressionList = tryCast(PsiUtil.skipParenthesizedExprUp(call.getParent()), PsiExpressionList.class);
          if (expressionList != null) {
            PsiNewExpression newExpression = tryCast(expressionList.getParent(), PsiNewExpression.class);
            if (newExpression != null && newExpression.getAnonymousClass() == null &&
                ConstructionUtils.isReferenceTo(newExpression.getClassReference(), CommonClassNames.JAVA_LANG_STRING)) {
              PsiExpression[] args = expressionList.getExpressions();
              if (args.length == 2 && PsiTreeUtil.isAncestor(args[0], call, false) &&
                  TypeUtils.typeEquals("java.nio.charset.Charset", args[1].getType())) {
                final PsiJavaCodeReferenceElement classReference = newExpression.getClassOrAnonymousClassReference();
                if (classReference != null) {
                  holder.registerProblem(classReference, JavaBundle.message("inspection.message.can.be.replaced.with.files.readstring"),
                                         new ReplaceWithReadStringFix());
                }
              }
            }
          }
        }
      }
    };
  }
@NotNull
  @Override
  public PsiElementVisitor buildVisitor(@NotNull ProblemsHolder holder, boolean isOnTheFly)