Class LayoutTokens

java.lang.Object
org.ek9lang.compiler.support.LayoutTokens

public final class LayoutTokens extends Object
THE shared knowledge of EK9's LAYOUT tokens — INDENT / DEDENT / NL / EOF — and the one correction every consumer of a parse-rule's END position needs because of them.

🔑 In an indentation grammar a rule that ends in DEDENT has a stop token belonging to the NEXT construct. The lexer emits the DEDENT at the first token of the following line, so ctx.getStop().getLine() over-runs onto that line: a dynamic function declared on lines 21-22 reports stopping on line 23, the line of the statement AFTER it. Anything that asks "does this construct span line N?" from getStop() therefore claims the next sibling's first line — and when that sibling has no scope of its own (a plain statement), the earlier construct wins the lookup outright. That mis-anchored the cursor-based Lock Fingerprint, data-touch and blast-radius enquiries onto a MutexKey body for the require lock.enter(key) line beneath it.

Use LastContentLine for the true last line — the last real-content token, layout skipped. Consolidated 2026-09-14 from a package-private copy in GenusBlockInserter (which the guard writer already reused) so the line-based scope resolver in assist could share it without a dependency on the editors. Never re-derive a getStop() correction beside this.

This class holds the token set; the questions are IsLayoutToken and LastContentLine - hold one.

  • Field Details

    • LAYOUT_TOKENS

      public static final Set<Integer> LAYOUT_TOKENS
      The token types whose positions are synthetic — never the end of anything a reader sees.