Class CachingIntervalSet
java.lang.Object
org.antlr.v4.runtime.misc.IntervalSet
io.github.douira.glsl_transformer.print.CachingIntervalSet
- All Implemented Interfaces:
IntSet
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.-
Field Summary
Fields inherited from class org.antlr.v4.runtime.misc.IntervalSet
COMPLETE_CHAR_SET, EMPTY_SET, intervals, readonly -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidAdds the given interval to the set.booleancontains(int el) Copied from ANTLR'sIntervalSet.contains(int)but with an addition of caching.booleantokenNotOmitted(Token token) Checks if the given token is covered by this set if it's being used as an omission set.Methods inherited from class org.antlr.v4.runtime.misc.IntervalSet
add, add, addAll, and, clear, complement, complement, elementName, elementName, equals, get, getIntervals, getMaxElement, getMinElement, hashCode, isNil, isReadonly, of, of, or, or, remove, setReadonly, size, subtract, subtract, toArray, toIntegerList, toList, toSet, toString, toString, toString, toString
-
Constructor Details
-
CachingIntervalSet
public CachingIntervalSet()
-
-
Method Details
-
contains
public boolean contains(int el) Copied from ANTLR'sIntervalSet.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:
containsin interfaceIntSet- Overrides:
containsin classIntervalSet
-
add
Adds the given interval to the set.- Overrides:
addin classIntervalSet- Parameters:
interval- The interval to add to this interval set
-
tokenNotOmitted
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:
trueif the token should be printed
-