Class TokenIndexWithin

java.lang.Object
org.ek9lang.compiler.support.TokenIndexWithin
All Implemented Interfaces:
BiPredicate<Integer, org.antlr.v4.runtime.ParserRuleContext>

public final class TokenIndexWithin extends Object implements BiPredicate<Integer, org.antlr.v4.runtime.ParserRuleContext>
THE "does this token index lie within that parse rule?" - inclusive of the rule's first and last tokens, by token INDEX (so by position in the one token stream, never by line or by text). False for a missing rule, or one without a start or stop token. Use it, never a hand-written getTokenIndex() comparison against a rule's start/stop; a rule inside a rule is its first and its last token both within.

One predicate for what was written four times (no-statics lane S3, 2026-10-29): PropertyInitialiser's declared-in-this-body test, the guard-variable loop write (phase5/GuardVariableReadWhereUnsetOrError), the try resource kept outside its try (phase5/StatementOwnedCloseableCalls) and the method inliner's innermost rule (mcp/oracle/editors/MethodInliner).

  • Constructor Details

    • TokenIndexWithin

      public TokenIndexWithin()
  • Method Details

    • test

      public boolean test(Integer tokenIndex, org.antlr.v4.runtime.ParserRuleContext rule)
      Specified by:
      test in interface BiPredicate<Integer, org.antlr.v4.runtime.ParserRuleContext>