/** * A character-offset range into a template's text, as a half-open interval * `[start, end)`. Framework-neutral on purpose: consumers map offsets to their * own position model (for example the LSP via `TextDocument.positionAt`), which * keeps this package free of editor types and of the UTF-16 column subtlety. */ export interface OffsetRange { /** Start offset, a 0-based character index, inclusive. */ readonly start: number; /** End offset, a 0-based character index, exclusive. */ readonly end: number; } /** * Resolves the character range of a resource's value block inside a synthesized * CloudFormation template. The range covers the value `{ ... }` under * `Resources/`, so `JSON.parse(text.slice(start, end))` returns the * resource object. * * Returns `undefined` when the text is not valid JSON, or when there is no such * resource. */ export declare function resolveResourceRange(templateText: string, logicalId: string): OffsetRange | undefined; /** A resource's block range plus the range of each of its top-level properties. */ export interface ResourceRanges { /** The resource's value block `{ ... }` (value-only, like {@link resolveResourceRange}). */ readonly block: OffsetRange; /** Each top-level property keyed by name, covering the whole `"Key": value` entry. */ readonly properties: Record; } /** * Resolves, in a single parse, a resource's block range and the range of each * of its top-level properties. Property ranges span `"Key": value` so a * navigation lands on the named property. * * Returns `undefined` when the text is not valid JSON or there is no such resource. */ export declare function resolveResourceRanges(templateText: string, logicalId: string): ResourceRanges | undefined; /** * A template parsed once into a queryable range index, so a caller resolving * several resources (for example a hover over a multi-resource construct) pays * the parse cost once instead of per resource. */ export interface TemplateRanges { /** The resource's value-block range, or `undefined` if there is no such resource. */ block(logicalId: string): OffsetRange | undefined; /** The resource's block plus its top-level property ranges, or `undefined` if absent. */ resource(logicalId: string): ResourceRanges | undefined; } /** * Parse a template once into a {@link TemplateRanges} index. Returns `undefined` * when the text is not valid JSON. The single-resource {@link resolveResourceRange} * and {@link resolveResourceRanges} are thin wrappers over this. */ export declare function indexTemplateRanges(templateText: string): TemplateRanges | undefined; /** * The inverse of `resolveResourceRange`: given a character offset into a * template's text, returns the logical id of the resource whose block contains * that offset, for linking a position in the template back to its construct. * * Returns `undefined` when the text is not valid JSON, or when the offset is not * inside any `Resources/` block (for example whitespace, the * `Resources` key, or another top-level section). */ export declare function resolveLogicalIdAtOffset(templateText: string, offset: number): string | undefined;