boolean (@Nullable PsiElement element, @NotNull PsiClassType exceptionType, PsiElement topElement) { PsiElement parent = PsiTreeUtil.getParentOfType(element, PsiLambdaExpression.class, PsiTryStatement.class, PsiMethod.class); if (parent instanceof PsiLambdaExpression) { // lambda it's another scope, @SneakyThrows annotation can't neglect exceptions in lambda only on method, constructor return false; } else if (parent instanceof PsiTryStatement && isHandledByTryCatch(exceptionType, (PsiTryStatement) parent)) { // that exception MAY be already handled by regular try-catch statement return false; } if (topElement instanceof PsiTryStatement && isHandledByTryCatch(exceptionType, (PsiTryStatement) topElement)) { // that exception MAY be already handled by regular try-catch statement (don't forget about nested try-catch) return false; } else if (!(topElement instanceof PsiCodeBlock)) { final PsiMethod psiMethod = PsiTreeUtil.getParentOfType(element, PsiMethod.class); return psiMethod != null && isExceptionHandled(psiMethod, exceptionType); } return false; }