CharsetMatch (LanguageLevel languageLevel, PsiMethod method, PsiExpressionList arguments) { PsiExpression argument = arguments.getExpressions()[myCharsetParameterIndex]; PsiClass aClass = method.getContainingClass(); if (aClass == null) return null; PsiMethod[] candidates = method.isConstructor() ? aClass.getConstructors() : aClass.findMethodsByName(method.getName(), false); PsiMethod charsetMethod = Arrays.stream(candidates) .filter(psiMethod -> checkMethod(psiMethod, "java.nio.charset.Charset")) .filter(psiMethod -> LanguageLevelUtil.getLastIncompatibleLanguageLevel(psiMethod, languageLevel) == null) .findFirst().orElse(null); if (charsetMethod == null) return null; return new CharsetMatch(argument, method, charsetMethod); }