import { type ATN } from "antlr4ng"; /** * What can legally come next at the caret: * - `tokens`: candidate terminal token TYPES (keywords/punctuation/literals) collectable there. * - `rules`: the *preferred* rule indices (name/column/table reference slots) reachable there; * the editor resolves these with schema-aware names instead of enumerating raw tokens. */ export interface Candidates { tokens: Set; rules: Set; } /** The minimal token view the walk needs: each token's antlr type + channel, in source order. Both * antlr's `Token` and our neutral `Token` (src/token/token.ts) satisfy it, so the walk runs over * the document's OWN already-lexed token stream, never a re-parse. */ export interface WalkToken { type: number; channel: number; } /** * Our own ATN candidate-collection walk — a reimplementation of antlr4-c3's * `CodeCompletionCore` (`collectCandidates` / `processRule` / `translateStackToRuleIndex`), * in our own naming/structure, over the antlr4ng ATN API. No `antlr4-c3` dependency. * * The idea: ANTLR compiles each parser rule into an ATN (a state graph). Starting at the entry * rule's start state we DFS the graph, threading a `tokenListIndex` (how many of the real input * tokens before the caret we have consumed) so impossible paths get pruned. At the caret * (`tokenListIndex === caretListIndex`) every terminal transition's label contributes its token * types as candidates — unless the current rule call stack is inside a preferred (name/column) * rule, in which case we record that rule and suppress the raw tokens it subsumes. * * `atn` is the dialect's parser ATN (input-independent, a per-dialect static) and `tokens` is the * document's own lexed token stream up to (at least) the caret; the walk consumes only their `type` * and `channel`, so it reuses the already-parsed tokens rather than re-lexing the source. */ export declare function collectCandidates(atn: ATN, startRuleIndex: number, tokens: readonly WalkToken[], caretTokenIndex: number, preferredRules: Set, ignoredTokens: Set): Candidates;