Class CachingIntervalSet

java.lang.Object
org.antlr.v4.runtime.misc.IntervalSet
io.github.douira.glsl_transformer.print.CachingIntervalSet
All Implemented Interfaces:
IntSet

public class CachingIntervalSet extends IntervalSet
The caching interval set is a regular interval set IntervalSet but the @link org.antlr.v4.runtime.misc.IntervalSet#contains(int)} method does caching of queries. Repeatedly requesting the same query is a common operation and therefore caching it like this can be helpful.
  • Constructor Details

    • CachingIntervalSet

      public CachingIntervalSet()
  • Method Details

    • contains

      public boolean contains(int el)
      Copied from ANTLR's IntervalSet.contains(int) but with an addition of caching. The cache size is 1. This method will test the cached interval if it hasn't been invalidated since.
      Specified by:
      contains in interface IntSet
      Overrides:
      contains in class IntervalSet
    • clear

      public void clear()
      Add cache invalidation.
      Overrides:
      clear in class IntervalSet
    • add

      public void add(Interval interval)
      Makes this method accessible and add cache invalidation.
      Overrides:
      add in class IntervalSet
    • tokenNotOmitted

      public boolean tokenNotOmitted(Token token)
      Checks if the given token is covered by this set if it's being used as an omission set. Tokens that are included in one of this interval set's sets and aren't hidden are not printed.
      Parameters:
      token - The token to check
      Returns:
      true if the token should be printed