PsiMethod (@NotNull PsiType type, @NotNull PsiClassType expectedType, boolean primitiveExpected, @NotNull PsiElement context) { PsiClass aClass = expectedType.resolve(); if (aClass != null) { PsiType expectedReturnType = expectedType; if (primitiveExpected) { expectedReturnType = PsiPrimitiveType.getUnboxedType(expectedType); } boolean isString = CommonClassNames.JAVA_LANG_STRING.equals(aClass.getQualifiedName()); if (type instanceof PsiArrayType && isString) { aClass = PsiResolveHelper.getInstance(aClass.getProject()).resolveReferencedClass(CommonClassNames.JAVA_UTIL_ARRAYS, aClass); if (aClass == null) return null; } if (expectedReturnType == null) return null; PsiMethod[] methods = aClass.getMethods(); final Set<PsiMethod> wrapperMethods = new LinkedHashSet<>(); for (PsiMethod method : methods) { if (method.hasModifierProperty(PsiModifier.STATIC) && method.getParameterList().getParametersCount() == 1 && Objects.requireNonNull(method.getParameterList().getParameter(0)).getType().isAssignableFrom(type) && method.getReturnType() != null && expectedReturnType.equals(method.getReturnType())) { final String methodName = method.getName(); if (methodName.startsWith("parse") || methodName.equals("valueOf") || (isString && methodName.equals("toString"))) { return method; } wrapperMethods.add(method); } } if (!wrapperMethods.isEmpty()) return wrapperMethods.iterator().next(); } return null; }