import type { AstNode } from './node.js'; /** Returning `skip` from `enter` leaves that node's children unvisited. */ export type Visit = 'skip' | void; export interface Visitor { readonly enter?: (node: AstNode, parent: AstNode | undefined) => Visit; readonly leave?: (node: AstNode, parent: AstNode | undefined) => void; } /** * Every node, depth first, parents before children and children in source * order. * * `leave` runs for a node whose children were skipped, so a pass that opens * something on the way in and closes it on the way out stays balanced whatever * it skips. A scope left open by a skipped node is the kind of fault that shows * up as a name resolving in the wrong place, three files away from its cause. * * A pass that has to handle every kind should not use this. It should switch on * `node.kind` with no default arm, so that the compiler names the kinds it has * missed; this is for a pass that cares about a few kinds and wants the rest * walked for it. */ export declare function walk(root: AstNode, visitor: Visitor): void; /** * The nodes covering an offset, outermost first, ending at the smallest one. * * This is what an editor asks for and it is one function rather than three, * because hover, completion and signature help each need the node under the * caret and the ancestors above it, and three copies of a descent through the * tree would answer differently at a boundary. * * A span covers its first character and stops before the one after it, and a * span of no length covers nothing, so a caret sitting between two characters * is inside the one on its left: an editor asking about a caret asks about the * offset before it. */ export declare function pathAtOffset(root: AstNode, offset: number): readonly AstNode[]; /** The smallest node covering an offset, or nothing when the offset is outside. */ export declare function nodeAtOffset(root: AstNode, offset: number): AstNode | undefined; //# sourceMappingURL=walk.d.ts.map