void (@NotNull PsiThrowStatement statement) { super.visitThrowStatement(statement); final PsiExpression exception = statement.getException(); if (exception == null) { return; } final PsiType exceptionType = exception.getType(); if (exceptionType == null) { return; } PsiTryStatement containingTryStatement = PsiTreeUtil.getParentOfType(statement, PsiTryStatement.class, true, PsiLambdaExpression.class, PsiClass.class); while (containingTryStatement != null) { final PsiCodeBlock tryBlock = containingTryStatement.getTryBlock(); if (tryBlock == null) { return; } if (PsiTreeUtil.isAncestor(tryBlock, statement, true)) { final PsiParameter[] catchBlockParameters = containingTryStatement.getCatchBlockParameters(); for (PsiParameter parameter : catchBlockParameters) { final PsiType parameterType = parameter.getType(); if (!parameterType.isAssignableFrom(exceptionType)) { continue; } if (ignoreRethrownExceptions) { final PsiCatchSection section = (PsiCatchSection)parameter.getParent(); final PsiCodeBlock catchBlock = section.getCatchBlock(); if (ExceptionUtils.isThrowableRethrown(parameter, catchBlock)) { return; } } registerStatementError(statement); } } containingTryStatement = PsiTreeUtil.getParentOfType(containingTryStatement, PsiTryStatement.class, true, PsiLambdaExpression.class, PsiClass.class); } }