Formatter (@NotNull PsiExpression expression) { if (!(expression.getParent() instanceof PsiExpressionList parent)) return Formatter.NONE; final PsiType type = expression.getType(); if (!TypeUtils.isJavaLangString(type)) return Formatter.NONE; final PsiElement grandParent = parent.getParent(); if (grandParent instanceof PsiMethodCallExpression call) { if (SIMPLE_DATE_FORMAT_METHODS.test(call)) { return Formatter.SIMPLE_DATE_FORMAT; } if (DATE_TIME_FORMATTER_METHODS.test(call)) { return Formatter.DATE_TIME_FORMATTER; } return Formatter.NONE; } if (grandParent instanceof PsiNewExpression newExpression) { final PsiJavaCodeReferenceElement classReference = newExpression.getClassReference(); if (classReference == null || !"SimpleDateFormat".equals(classReference.getReferenceName())) { return Formatter.NONE; } final PsiElement target = classReference.resolve(); if (!(target instanceof PsiClass aClass)) { return Formatter.NONE; } if (!InheritanceUtil.isInheritor(aClass, "java.text.SimpleDateFormat")) { return Formatter.NONE; } return Formatter.SIMPLE_DATE_FORMAT; } return Formatter.NONE; }