Class LayoutTokens
🔑 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(ParseTree) 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.
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe token types whose positions are synthetic — never the end of anything a reader sees. -
Method Summary
Modifier and TypeMethodDescriptionstatic booleanisLayout(org.antlr.v4.runtime.Token token) Is this a layout token (INDENT / DEDENT / NL / EOF)?static intlastContentLine(org.antlr.v4.runtime.tree.ParseTree node) The 1-based line of the LAST real-content token undernode, or -1 when it holds none.
-
Field Details
-
LAYOUT_TOKENS
-
-
Method Details
-
isLayout
public static boolean isLayout(org.antlr.v4.runtime.Token token) Is this a layout token (INDENT / DEDENT / NL / EOF)? -
lastContentLine
public static int lastContentLine(org.antlr.v4.runtime.tree.ParseTree node) The 1-based line of the LAST real-content token undernode, or -1 when it holds none. Unlikectx.getStop().getLine()this never over-runs onto the trailing DEDENT.
-