private static boolean methodCallInDeclarationOfThrowingRunnable()

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


  private static boolean methodCallInDeclarationOfThrowingRunnable(VisitorState state) {
    // Find the nearest definitional context for this method invocation
    // (i.e.: the nearest surrounding class or lambda)
    Tree tree = null;
    out:
    for (Tree t : state.getPath()) {
      switch (t.getKind()) {
        case LAMBDA_EXPRESSION:
        case CLASS:
          tree = t;
          break out;
        default: // fall out, to loop again
      }
    }

    if (tree == null) {
      // Huh. Shouldn't happen.
      return false;
    }
    return isThrowingFunctionalInterface(state, getType(tree));
  }