check_api/src/main/java/com/google/errorprone/matchers/UnusedReturnValueMatcher.java
public static boolean isReturnValueUnused(ExpressionTree tree, VisitorState state) {
    Symbol sym = getSymbol(tree);
    if (!(sym instanceof MethodSymbol) || isVoidMethod((MethodSymbol) sym)) {
      return false;
    }
    if (tree instanceof MemberReferenceTree) {
      // Runnable r = foo::getBar;
      return implementsVoidMethod(tree, state);
    }
    Tree parent = state.getPath().getParentPath().getLeaf();
    return parent instanceof LambdaExpressionTree
        // Runnable r = () -> foo.getBar();
        ? implementsVoidMethod((LambdaExpressionTree) parent, state)
        // foo.getBar();
        : parent.getKind() == Kind.EXPRESSION_STATEMENT;
  }
/**
   * Returns {@code true} if and only if the given {@code tree} is an invocation of or reference to
   * a constructor or non-{@code void} method for which the return value is considered unused.
   */
Returns  true if and only if the given  tree is an invocation of or reference to
a constructor or non- void method for which the return value is considered unused.
Returns true if and only if the given tree is an invocation of or reference to a constructor or non - void method for which the return value is considered unused .
public static boolean isReturnValueUnused(ExpressionTree tree, VisitorState state) {
    Symbol sym = getSymbol(tree);
    if (!(sym instanceof MethodSymbol) || isVoidMethod((MethodSymbol) sym)) {
      return false;
    }
    if (tree instanceof MemberReferenceTree) {
      return implementsVoidMethod(tree, state);
    }
    Tree parent = state.getPath().getParentPath().getLeaf();
    return parent instanceof LambdaExpressionTree
        ? implementsVoidMethod((LambdaExpressionTree) parent, state)
        : parent.getKind() == Kind.EXPRESSION_STATEMENT;
  }
public static boolean isReturnValueUnused ( ExpressionTree tree , VisitorState state ) { Symbol sym = getSymbol ( tree ) ; if ( ! ( sym instanceof MethodSymbol ) || isVoidMethod ( ( MethodSymbol ) sym ) ) { return false ; } if ( tree instanceof MemberReferenceTree ) { return implementsVoidMethod ( tree , state ) ; } Tree parent = state . getPath ( ) . getParentPath ( ) . getLeaf ( ) ; return parent instanceof LambdaExpressionTree ? implementsVoidMethod ( ( LambdaExpressionTree ) parent , state ) : parent . getKind ( ) == Kind . EXPRESSION_STATEMENT ; }
Returns {@code true} if and only if the given {@code tree} is an invocation of or reference to
 a constructor or non-{@code void} method for which the return value is considered unused.
Returns { @code true } if and only if the given { @code tree } is an invocation of or reference to a constructor or non - { @code void } method for which the return value is considered unused .
// Runnable r = foo::getBar; // Runnable r = () -> foo.getBar(); // foo.getBar();