DfaPsiUtil#isEnumPredefinedMethod: use CallMatchers

GitOrigin-RevId: 2b28d1b229f2127a0f19901eb595423373ec0228
This commit is contained in:
Tagir Valeev
2020-02-03 10:01:03 +07:00
committed by intellij-monorepo-bot
parent 6b3a483775
commit 251f34e91f

View File

@@ -283,16 +283,7 @@ public class DfaPsiUtil {
}
private static boolean isEnumPredefinedMethod(PsiMethod method) {
String methodName = method.getName();
if (("valueOf".equals(methodName) || "values".equals(methodName)) && method.hasModifierProperty(PsiModifier.STATIC)) {
PsiClass containingClass = method.getContainingClass();
if (containingClass != null && containingClass.isEnum()) {
PsiParameter[] parameters = method.getParameterList().getParameters();
if ("values".equals(methodName)) return parameters.length == 0;
return parameters.length == 1 && parameters[0].getType().equalsToText(JAVA_LANG_STRING);
}
}
return false;
return CallMatcher.enumValueOf().methodMatches(method) || CallMatcher.enumValues().methodMatches(method);
}
public static boolean isInitializedNotNull(PsiField field) {