Class CheckReturnValue

All Implemented Interfaces:
BugChecker.ClassTreeMatcher, BugChecker.MemberReferenceTreeMatcher, BugChecker.MethodInvocationTreeMatcher, BugChecker.MethodTreeMatcher, BugChecker.ReturnTreeMatcher, Suppressible, Serializable

public class CheckReturnValue
extends AbstractReturnValueIgnored
implements BugChecker.MethodTreeMatcher, BugChecker.ClassTreeMatcher
Author: (Eddie Aftandilian)
See Also:
Serialized Form
  • Constructor Details

    • CheckReturnValue

      public CheckReturnValue()
  • Method Details

    • specializedMatcher

      public Matcher<com.sun.source.tree.ExpressionTree> specializedMatcher()
      Return a matcher for method invocations in which the method being called has the @CheckReturnValue annotation.
      Specified by:
      specializedMatcher in class AbstractReturnValueIgnored
    • matchMethod

      public Description matchMethod​(com.sun.source.tree.MethodTree tree, VisitorState state)
      Validate @CheckReturnValue and CanIgnoreReturnValue usage on methods.

      The annotations should not both be applied to the same method.

      The annotations should not be applied to void-returning methods. Doing so makes no sense, because there is no return value to check.

      Specified by:
      matchMethod in interface BugChecker.MethodTreeMatcher
    • matchClass

      public Description matchClass​(com.sun.source.tree.ClassTree tree, VisitorState state)
      Validate that at most one of CheckReturnValue and CanIgnoreReturnValue are applied to a class (or interface or enum).
      Specified by:
      matchClass in interface BugChecker.ClassTreeMatcher
    • getMessage

      protected String getMessage​(Name name)
      Description copied from class: AbstractReturnValueIgnored
      Returns the diagnostic message. Can be overridden by subclasses to provide a customized diagnostic that includes the name of the invoked method.
      getMessage in class AbstractReturnValueIgnored