boolean (PsiElement element) { if (!isInTestSourceContent(element)) return false; for(; element != null && !(element instanceof PsiFile); element = element.getParent()) { if (element instanceof PsiMethod) { return hasExpectedExceptionAnnotation((PsiMethod)element); } if (element instanceof PsiLambdaExpression) { PsiExpressionList expressionList = ObjectUtils.tryCast(PsiUtil.skipParenthesizedExprUp(element.getParent()), PsiExpressionList.class); if (expressionList != null) { PsiElement parent = expressionList.getParent(); if (parent instanceof PsiMethodCallExpression && ASSERT_THROWS.test((PsiMethodCallExpression)parent)) return true; } } if (element instanceof PsiTryStatement && ((PsiTryStatement)element).getCatchBlocks().length > 0) { return true; } } return false; }