Class TokenSet

java.lang.Object
com.intellij.psi.tree.TokenSet

public final class TokenSet extends Object
A set of element types.
  • Field Details

    • EMPTY

      public static final TokenSet EMPTY
    • ANY

      public static final TokenSet ANY
    • WHITE_SPACE

      public static final TokenSet WHITE_SPACE
  • Method Details

    • contains

      @Contract("null -> false") public boolean contains(@Nullable @Nullable IElementType t)
      Checks if the specified element type is contained in the set.
      Parameters:
      t - the element type to search for.
      Returns:
      true if the element type is found in the set, false otherwise.
    • getTypes

      public IElementType @NotNull [] getTypes()
      Returns the array of element types contained in the set.
      Returns:
      the contents of the set.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • create

      @NotNull public static @NotNull TokenSet create(IElementType @NotNull ... types)
      Returns a new token set containing the specified element types.
      Parameters:
      types - the element types contained in the set.
      Returns:
      the new token set.
    • forAllMatching

      public static TokenSet forAllMatching(@NotNull IElementType.Predicate condition)
      Returns:
      a token set containing all element types satisfying the given condition, including ones registered after this set creation
    • orSet

      @NotNull public static @NotNull TokenSet orSet(TokenSet @NotNull ... sets)
      Returns a token set containing the union of the specified token sets.
      Parameters:
      sets - the token sets to unite.
      Returns:
      the new token set.
    • andSet

      @NotNull public static @NotNull TokenSet andSet(@NotNull @NotNull TokenSet a, @NotNull @NotNull TokenSet b)
      Returns a token set containing the intersection of the specified token sets.
      Parameters:
      a - the first token set to intersect.
      b - the second token set to intersect.
      Returns:
      the new token set.
    • andNot

      @NotNull public static @NotNull TokenSet andNot(@NotNull @NotNull TokenSet a, @NotNull @NotNull TokenSet b)
      Returns a token set containing a result of "set subtraction" of set B from set A.
      Parameters:
      a - the basic token set.
      b - the token set to subtract.
      Returns:
      the new token set.