public final class TokenCoverage extends Object
TSourceToken's position
coverage on the input.
Several pp2 stages walk a TSourceTokenList in offset order
and need to skip tokens that overlap an already-emitted span. The
pattern shows up in:
Pp2TokenStreamBuilder — folding whitespace, skipping
phantom inner tokens emitted by GSP's lexer for shapes like
${name}.SourceSpanLedger — covering every byte exactly once.TokenEquivalence — building the comparable-token
sequence.Centralizing the logic here avoids the predicate drifting across call sites as Phase 2 lands.
Plan reference: §7.3/S9 (the GSP ${name} probe finding).
| Modifier and Type | Method and Description |
|---|---|
static long |
endOffset(TSourceToken token)
Convenience: compute the half-open end offset
(
offset + text.length()) for a token. |
static boolean |
isFullyShadowed(TSourceToken token,
long priorEnd)
True when
token's source range is FULLY contained in an
already-emitted span ending at priorEnd. |
public static boolean isFullyShadowed(TSourceToken token, long priorEnd)
token's source range is FULLY contained in an
already-emitted span ending at priorEnd.
Fully-contained tokens are phantom inner tokens emitted by the
GSP lexer (e.g., the "{" "name" "}" that follow an outer
"${name}" identifier). Skipping them is safe because the
outer token already carries the same bytes.
Partial overlap (start shadowed but end extending past) is NOT fully contained; callers must handle it separately (either throw loudly or continue processing — never silently drop, since that would lose bytes).
token - the candidate token; null is tolerated and
returns false so callers can treat it as
"not shadowed; handle null separately"priorEnd - the source offset where the previously emitted
span ends; pass -1 when nothing has been
emitted yettrue iff token is fully shadowedpublic static long endOffset(TSourceToken token)
offset + text.length()) for a token. Returns the
token's offset when the text is null or empty.