private static @NotNull CharsetOverload getCharsetOverload(PsiMethod method) {
    if (method == null) return CharsetOverload.NONE;

    CharsetOverload charsetOverload = method.getUserData(HAS_CHARSET_OVERLOAD);
    if (charsetOverload == null) {
      PsiMethod methodWithCharsetArgument = null;
      PsiClass aClass = method.getContainingClass();
      List<String> args = UTF_8_ARG;
      if (aClass != null) {
        MethodSignature signature = method.getSignature(PsiSubstitutor.EMPTY);
        PsiType charsetType =
          JavaPsiFacade.getElementFactory(method.getProject()).createTypeByFQClassName("java.nio.charset.Charset", method.getResolveScope());
        PsiType[] parameterTypes = signature.getParameterTypes();
        if (method.isConstructor() && "java.io.PrintWriter".equals(aClass.getQualifiedName()) && parameterTypes.length == 1 &&
            parameterTypes[0].equalsToText("java.io.OutputStream")) {
          parameterTypes = ArrayUtil.append(parameterTypes, PsiTypes.booleanType());
          args = FALSE_AND_UTF_8_ARG;
        }
        MethodSignature newSignature = MethodSignatureUtil
          .createMethodSignature(signature.getName(), ArrayUtil.append(parameterTypes, charsetType),
                                 signature.getTypeParameters(), signature.getSubstitutor(), signature.isConstructor()
          );
        methodWithCharsetArgument = MethodSignatureUtil.findMethodBySignature(aClass, newSignature, false);
      }
      charsetOverload = methodWithCharsetArgument != null ? new CharsetOverload(methodWithCharsetArgument, args) : CharsetOverload.NONE;
      method.putUserData(HAS_CHARSET_OVERLOAD, charsetOverload);
    }
    return charsetOverload;
  }
private static @NotNull CharsetOverload getCharsetOverload(PsiMethod method)