Collection<LookupElement> (PsiReferenceExpression ref, List<ExpectedTypeInfo> expectedTypeInfos) { PsiExpression qualifier = ref.getQualifierExpression(); if (qualifier == null) return Collections.emptyList(); PsiType type = qualifier.getType(); if (!TypeUtils.isJavaLangString(type) || !PsiUtil.isLanguageLevel7OrHigher(ref)) return Collections.emptyList(); PsiClass stringClass = PsiUtil.resolveClassInClassTypeOnly(type); if (stringClass == null) return Collections.emptyList(); PsiMethod toLowerCase = findMethod(stringClass, "toLowerCase", "java.util.Locale"); PsiMethod toUpperCase = findMethod(stringClass, "toUpperCase", "java.util.Locale"); PsiMethod getBytes = findMethod(stringClass, "getBytes", "java.nio.charset.Charset"); if (toLowerCase == null || toUpperCase == null || getBytes == null) return Collections.emptyList(); StreamEx<MethodWithArgument> stream = StreamEx.of( new MethodWithArgument(toLowerCase, type, "java.util.Locale.ROOT", "Locale.ROOT"), new MethodWithArgument(toUpperCase, type, "java.util.Locale.ROOT", "Locale.ROOT"), new MethodWithArgument(getBytes, PsiTypes.byteType().createArrayType(), "java.nio.charset.StandardCharsets.UTF_8", "StandardCharsets.UTF_8")); if (!expectedTypeInfos.isEmpty()) { stream = stream.filter(element -> ContainerUtil.exists(expectedTypeInfos, info -> info.getType().isAssignableFrom(element.getType()))); } return stream.map(element -> PrioritizedLookupElement.withPriority(element, 1)).toList(); }