Class CompileTimeConstantExpressionMatcher

java.lang.Object
com.google.errorprone.matchers.CompileTimeConstantExpressionMatcher
All Implemented Interfaces:
Matcher<com.sun.source.tree.ExpressionTree>, Serializable

public class CompileTimeConstantExpressionMatcher
extends Object
implements Matcher<com.sun.source.tree.ExpressionTree>
A matcher for compile-time-constant expressions.

For the purposes of this matcher, a compile-time constant expression is one of the following:

  1. Any expression for which the Java compiler can determine a constant value at compile time.
  2. The expression consisting of the literal null.
  3. An expression consisting of a single identifier, where the identifier is a formal method parameter that is declared final and has the CompileTimeConstant annotation.
See Also:
Serialized Form
  • Constructor Details

    • CompileTimeConstantExpressionMatcher

      public CompileTimeConstantExpressionMatcher()
  • Method Details

    • matches

      public boolean matches​(com.sun.source.tree.ExpressionTree t, VisitorState state)
      Specified by:
      matches in interface Matcher<com.sun.source.tree.ExpressionTree>
    • hasCompileTimeConstantAnnotation

      public static boolean hasCompileTimeConstantAnnotation​(VisitorState state, com.sun.tools.javac.code.Symbol symbol)