DfType (@Nullable DfaVariableValue qualifier) { if (qualifier != null) { TypeConstraint constraint = TypeConstraint.fromDfType(qualifier.getDfType()); if (constraint.isExact()) { PsiClass cls = PsiUtil.resolveClassInClassTypeOnly(constraint.getPsiType(qualifier.getFactory().getProject())); if (cls != null) { long count = Arrays.stream(cls.getFields()).filter(field -> field instanceof PsiEnumConstant).count(); // Keep +1 ordinal for possible enum changes return DfTypes.intRange(LongRangeSet.range(0, count)); } } } return super.getDfType(qualifier); }