Enum Class ClosurePrimitive

java.lang.Object
java.lang.Enum<ClosurePrimitive>
com.google.javascript.rhino.ClosurePrimitive
All Implemented Interfaces:
Serializable, Comparable<ClosurePrimitive>, Constable

public enum ClosurePrimitive extends Enum<ClosurePrimitive>
Enum of primitive functions that the compiler recognizes

These correspond to the @closurePrimitive tag in code; in order to parse new primitives, add any entry to the list in parsing/ParserConfig.properties, then map it to an enum member in the idToEnum map.

After typechecking is done, all calls to one of these primitive types should have their FunctionType annotated with the corresponding enum member. This is intended to make identifying these calls more accurate than previous methods of finding primitives by qualified name.

  • Enum Constant Details

  • Method Details

    • values

      public static ClosurePrimitive[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static ClosurePrimitive valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • fromStringId

      public static @Nullable ClosurePrimitive fromStringId(@Nullable String id)
      Returns the ClosurePrimitive corresponding to the given string id.

      This is to make reading @closurePrimitive easier in code. Using Enum.valueOf to parse closure primitive identifiers from JSDoc directly would require code like closurePrimitive {ASSERTS_FAIL}; instead we separate the string ids from the enum names.

      Parameters:
      id - a string id that normalized to an enum member, or null
      Returns:
      null if the argument is null, otherwise the corresponding enum member
      Throws:
      IllegalArgumentException - if the id is non-null but does not match an enum member