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 also does caching of the queries if the set has been set to readonly. 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. If the interval set has been marked as readonly, it will return the last hit if the query is the same.
      Specified by:
      contains in interface IntSet
      Overrides:
      contains in class IntervalSet
    • add

      public void add(Interval interval)
      Adds the given interval to the set.
      Overrides:
      add in class IntervalSet
      Parameters:
      interval - The interval to add to this interval set
    • 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