void (PsiSwitchBlock block) { PsiCodeBlock body = block.getBody(); if (body == null) return; PsiExpression selector = block.getExpression(); if (selector == null || !TypeUtils.isJavaLangString(selector.getType())) return; // Matching of constant selector against constant labels is processed by Constant Conditions & Exceptions if (PsiUtil.isConstantExpression(selector)) return; StringCase selectorCase = fromExpression(selector, ANALYSIS_COMPLEXITY); if (selectorCase.myHasUpper != ThreeState.NO && selectorCase.myHasLower != ThreeState.NO) return; for (PsiStatement statement : body.getStatements()) { if (statement instanceof PsiSwitchLabelStatementBase) { PsiCaseLabelElementList labels = ((PsiSwitchLabelStatementBase)statement).getCaseLabelElementList(); if (labels != null) { for (PsiCaseLabelElement label : labels.getElements()) { if (label instanceof PsiExpression) { StringCase labelCase = fromExpression((PsiExpression)label, ANALYSIS_COMPLEXITY); String errorMessage; if (selectorCase.myHasLower == ThreeState.NO && labelCase.myHasLower == ThreeState.YES) { errorMessage = InspectionGadgetsBundle.message("inspection.case.mismatch.message.label.is.lower"); } else if (selectorCase.myHasUpper == ThreeState.NO && labelCase.myHasUpper == ThreeState.YES) { errorMessage = InspectionGadgetsBundle.message("inspection.case.mismatch.message.label.is.upper"); } else { continue; } holder.registerProblem(label, errorMessage); } } } } } }