void (@NotNull PsiSwitchBlock switchBlock) { final PsiElement defaultStatement = retrieveUnnecessaryDefault(switchBlock); if (defaultStatement == null) { return; } PsiSwitchLabeledRuleStatement ruleStatement = null; if (defaultStatement instanceof PsiSwitchLabeledRuleStatement) { ruleStatement = (PsiSwitchLabeledRuleStatement)defaultStatement; } else if (defaultStatement instanceof PsiDefaultCaseLabelElement) { PsiSwitchLabelStatementBase pDefaultStatement = PsiTreeUtil.getParentOfType(defaultStatement, PsiSwitchLabelStatementBase.class); if (pDefaultStatement instanceof PsiSwitchLabeledRuleStatement) { ruleStatement = (PsiSwitchLabeledRuleStatement)pDefaultStatement; } } final boolean ruleBasedSwitch = ruleStatement != null; final boolean statementSwitch = switchBlock instanceof PsiStatement; PsiStatement nextStatement = ruleBasedSwitch ? ruleStatement.getBody() : PsiTreeUtil.getNextSiblingOfType(defaultStatement, PsiStatement.class); if (statementSwitch && nextStatement instanceof PsiThrowStatement) { // consider a single throw statement a guard against future changes that update the code only partially return; } if (isDefaultNeededForInitializationOfVariable(switchBlock)) { return; } while (nextStatement != null) { if (statementSwitch && !ControlFlowUtils.statementMayCompleteNormally(nextStatement)) { final PsiMethod method = PsiTreeUtil.getParentOfType(switchBlock, PsiMethod.class, true, PsiClass.class, PsiLambdaExpression.class); if (method != null && !PsiTypes.voidType().equals(method.getReturnType()) && !ControlFlowUtils.statementContainsNakedBreak(nextStatement)) { final PsiCodeBlock body = method.getBody(); assert body != null; if (ControlFlowUtils.blockCompletesWithStatement(body, (PsiStatement)switchBlock)) { return; } } else { break; } } if (ruleBasedSwitch) { break; } nextStatement = PsiTreeUtil.getNextSiblingOfType(nextStatement, PsiStatement.class); } final ProblemHighlightType highlightType; if (onlyReportSwitchExpressions && statementSwitch) { if (!isOnTheFly()) { return; } highlightType = INFORMATION; } else { highlightType = GENERIC_ERROR_OR_WARNING; } registerError(defaultStatement.getFirstChild(), highlightType); }