private static boolean isEnumInSwitch(@NotNull PsiField field, PsiElement element) {
    if (!(field instanceof PsiEnumConstant) || !(element.getParent() instanceof PsiCaseLabelElementList)) return false;
    PsiClass enumClass = field.getContainingClass();
    PsiSwitchLabelStatementBase label = ObjectUtils.tryCast(element.getParent().getParent(), PsiSwitchLabelStatementBase.class);
    if (label == null || enumClass == null) return false;
    PsiSwitchBlock block = label.getEnclosingSwitchBlock();
    if (block == null) return false;
    PsiExpression expression = block.getExpression();
    if (expression == null) return false;
    PsiType type = expression.getType();
    return type instanceof PsiClassType && enumClass.getManager().areElementsEquivalent(enumClass, ((PsiClassType)type).resolve());
  }
private static boolean isEnumInSwitch(@NotNull PsiField field, PsiElement element)