private static boolean isEnumAcceptable(PsiElement element, PsiClass targetClass) {
    if (element instanceof PsiExpression) {
      ExpectedTypeInfo[] types = ExpectedTypesProvider.getExpectedTypes((PsiExpression)element, false);
      if (types.length == 1) {
        PsiType type = types[0].getType();
        return type.isAssignableFrom(JavaPsiFacade.getElementFactory(element.getProject()).createType(targetClass));
      }
    }
    return false;
  }
private static boolean isEnumAcceptable(PsiElement element, PsiClass targetClass)