private static boolean expectedExceptionTest()

in static-analysis/autodispose-error-prone/src/main/java/autodispose2/errorprone/AbstractReturnValueIgnored.java [296:314]


  private static boolean expectedExceptionTest(Tree tree, VisitorState state) {
    if (mockitoInvocation(tree, state)) {
      return true;
    }

    // Allow unused return values in tests that check for thrown exceptions, e.g.:
    //
    // try {
    //   Foo.newFoo(-1);
    //   fail();
    // } catch (IllegalArgumentException expected) {
    // }
    //
    StatementTree statement = ASTHelpers.findEnclosingNode(state.getPath(), StatementTree.class);
    if (statement != null && EXPECTED_EXCEPTION_MATCHER.matches(statement, state)) {
      return true;
    }
    return false;
  }