boolean (@NotNull PsiSwitchBlock statement) { if(statement instanceof PsiSwitchExpression) return true; PsiExpression selector = statement.getExpression(); if (selector == null) { return false; } PsiType selectorType = selector.getType(); if (selectorType == null) { return false; } PsiCodeBlock body = statement.getBody(); if (body == null) { return false; } List<PsiCaseLabelElement> cases = new ArrayList<>(); for (PsiStatement psiStatement : body.getStatements()) { if (psiStatement instanceof PsiSwitchLabelStatementBase) { PsiSwitchLabelStatementBase labelStatementBase = (PsiSwitchLabelStatementBase)psiStatement; PsiCaseLabelElementList elementList = labelStatementBase.getCaseLabelElementList(); if (elementList == null) { continue; } PsiCaseLabelElement[] elements = elementList.getElements(); for (PsiCaseLabelElement caseLabelElement : elements) { if (caseLabelElement != null) { cases.add(caseLabelElement); } } } } return isEnhancedSwitch(cases, isClassSelectorType(selectorType)); }