/** * Utilities for extracting source-position info from ANTLR parse-tree * nodes. * * ANTLR tokens carry 1-based line numbers (editor convention) and * 0-based column indices (ANTLR convention). Our `Diagnostic` type uses * the same convention, so these helpers mostly pass values through with * a bit of normalisation. * * Attribute values are a special case: the `STRING` token includes the * surrounding double quotes, but when we want to underline the "bad * thing" for the user it is nicer to point at the inside of the quotes. * `attrValueRange` handles that. */ import type { ParserRuleContext, Token } from 'antlr4ng'; import type { AttrContext } from '../generated/TDCParser.js'; export interface Pos { readonly line: number; readonly column: number; } export interface Range extends Pos { readonly endLine: number; readonly endColumn: number; } /** Position of the first token of a node. Zero-fallback for paranoia. */ export declare function nodePos(node: ParserRuleContext): Pos; /** * Full range covering the node: from the start of the first token to * the end of the last token. For single-line nodes this gives a clean * caret underline; for multi-line ones the formatter only underlines * the first line (which is what a Rust-style error would do anyway). */ export declare function nodeRange(node: ParserRuleContext): Range; /** Position of a raw ANTLR token. */ export declare function tokenPos(t: Token): Pos; /** Range of a raw ANTLR token. */ export declare function tokenRange(t: Token): Range; /** * Range of the attribute VALUE, excluding the surrounding quotes. * This is what callers usually want to underline — the content inside * the quotes — rather than the quotes themselves. * * If the attribute has no value token (malformed), falls back to the * attribute's own range. */ export declare function attrValueRange(attr: AttrContext): Range; /** Range of the attribute NAME token. */ export declare function attrNameRange(attr: AttrContext): Range; //# sourceMappingURL=source-map.d.ts.map