/** * Block-scope tracker for Handlebars for Marketing Cloud Next (MCN). * * Walks a Handlebars AST to collect the local identifiers that block helpers * introduce into their inner body, together with the source range over which * each local is visible: * * - `{{#each items as |item index|}}` — block params (`item`, `index`). * - `{{#each ...}}` / `{{#repeat n}}` — loop data variables (`@index`, * `@first`, `@last`, and `@key` for `each`). * - `{{#with obj as |o|}}` — the context alias when block params are used. * * Consumers (completions, hover, signature help) call * {@link getHandlebarsLocalsAtOffset} to obtain only the locals that are in * scope at the cursor, so block params and loop vars are never offered outside * the block that declares them. * * Mirrors the single-pass tracker pattern used by * {@link ../utils/ampscriptVariableTracker.buildVariableTypeMap} for AMPscript. */ /** The origin of a Handlebars block-local identifier. */ export type HandlebarsLocalKind = 'block-param' | 'loop-var'; /** A single identifier introduced by a block helper. */ export interface HandlebarsLocal { /** The identifier as written in source, e.g. `item` or `@index`. */ name: string; /** Where the identifier originates. */ kind: HandlebarsLocalKind; /** Short human-readable detail, e.g. `block param of #each`. */ detail: string; } /** A lexical scope: a set of locals visible across a half-open offset range. */ export interface HandlebarsScope { /** Inclusive start offset of the block body. */ start: number; /** Exclusive end offset of the block body. */ end: number; /** Locals introduced by the block, visible within `[start, end)`. */ locals: HandlebarsLocal[]; } /** * Build the list of block scopes for a (possibly mixed) document. AMPscript * regions are blanked before parsing so the Handlebars parser does not choke on * `%%[...]%%` / `%%=...=%%`. Offsets in the returned scopes map onto the * original `text` (the sanitizer preserves offsets). * @param text - Full document text. * @returns The block scopes, outermost first in document order. */ export declare function buildHandlebarsScopes(text: string): HandlebarsScope[]; /** * Return the Handlebars block-locals in scope at the given offset. Locals from * nested blocks shadow outer ones by name (inner declaration wins). * @param text - Full document text. * @param offset - Character offset of the cursor. * @returns The in-scope locals, de-duplicated by name. */ export declare function getHandlebarsLocalsAtOffset(text: string, offset: number): HandlebarsLocal[]; //# sourceMappingURL=handlebarsScopeTracker.d.ts.map