Class AbstractReturnValueIgnored

    • Constructor Detail

      • AbstractReturnValueIgnored

        protected AbstractReturnValueIgnored()
      • AbstractReturnValueIgnored

        protected AbstractReturnValueIgnored​(ErrorProneFlags flags)
    • Method Detail

      • isCovered

        public boolean isCovered​(com.sun.source.tree.ExpressionTree tree,
                                 VisitorState state)
        Returns whether this checker makes any determination about whether the given tree's return value should be used or not. Most checkers either determine that an expression is CRV or make no determination.
      • isCheckReturnValue

        public final boolean isCheckReturnValue​(com.sun.source.tree.ExpressionTree tree,
                                                VisitorState state)
        Returns whether the given tree's return value should be used according to this checker, regardless of whether or not the return value is actually used.
      • getMatchMetadata

        public com.google.common.collect.ImmutableMap<String,​?> getMatchMetadata​(com.sun.source.tree.ExpressionTree tree,
                                                                                       VisitorState state)
        Returns a map of optional metadata about why this check matched the given tree.
      • specializedMatcher

        protected abstract Matcher<? super com.sun.source.tree.ExpressionTree> specializedMatcher()
        Match whatever additional conditions concrete subclasses want to match (a list of known side-effect-free methods, has a @CheckReturnValue annotation, etc.).
      • lostType

        protected Optional<com.sun.tools.javac.code.Type> lostType​(VisitorState state)
        Check for occurrences of this type being lost, i.e. cast to Object.
      • lostTypeMessage

        protected String lostTypeMessage​(String returnedType,
                                         String declaredReturnType)
      • allowInExceptionThrowers

        protected boolean allowInExceptionThrowers()
        Override this to return false to forbid discarding return values in testers that are testing whether an exception is thrown.
      • describeReturnValueIgnored

        protected Description describeReturnValueIgnored​(com.sun.source.tree.MethodInvocationTree methodInvocationTree,
                                                         VisitorState state)
        Fixes the error by assigning the result of the call to the receiver reference, or deleting the method call. Subclasses may override if they prefer a different description.
      • describeReturnValueIgnored

        protected Description describeReturnValueIgnored​(com.sun.source.tree.MemberReferenceTree memberReferenceTree,
                                                         VisitorState state)
        Uses the default description for results ignored via a method reference. Subclasses may override if they prefer a different description.
      • describeReturnValueIgnored

        protected Description describeReturnValueIgnored​(com.sun.source.tree.NewClassTree newClassTree,
                                                         VisitorState state)
        Uses the default description for results ignored via a constructor call. Subclasses may override if they prefer a different description.
      • getMessage

        protected String getMessage​(Name name)
        Returns the diagnostic message. Can be overridden by subclasses to provide a customized diagnostic that includes the name of the invoked method.