boolean (PsiExpression expression) { expression = PsiUtil.skipParenthesizedExprDown(expression); if (expression instanceof PsiReferenceExpression ref) { if (!"UTF_8".equals(ref.getReferenceName())) { return false; } PsiField target = tryCast(ref.resolve(), PsiField.class); return target != null && target.getContainingClass() != null && "java.nio.charset.StandardCharsets".equals(target.getContainingClass().getQualifiedName()); } if (expression instanceof PsiMethodCallExpression && CHARSET_FOR_NAME.test((PsiMethodCallExpression)expression)) { PsiExpression arg = ((PsiMethodCallExpression)expression).getArgumentList().getExpressions()[0]; Object value = ExpressionUtils.computeConstantExpression(arg); return value instanceof String && ((String)value).equalsIgnoreCase("utf-8"); } return false; }