UNPKG

code-graph-generator

Version:

Generate Json Object of code that can be used to generate code-graphs for JavaScript/TypeScript/Range projects

47 lines (46 loc) 1.88 kB
/** * Gets the starting line number of an AST node. * @param node The AST node * @returns The line number or 0 if not available */ export declare function getStartLine(node: any): number; /** * Counts the number of lines in a text. * @param text The text to count lines in * @returns The number of lines */ export declare function countLines(text: string): number; /** * Extracts function names from an AST node. * @param node The AST node * @returns Array of function names */ export declare function extractFunctionNames(node: any): string[]; /** * Normalizes a file path to use forward slashes. * @param filePath The file path to normalize * @returns Normalized path with forward slashes */ export declare function normalizePath(filePath: string): string; export declare function getCorrectCasePath(basePath: string, filePath: string): Promise<string>; export declare const toPosixPath: typeof normalizePath; /** * Traverses an AST and calls visitor functions for specific node types. * @param node The AST node to traverse * @param visitors Object mapping node types to visitor functions * @param visited Optional Set to prevent circular references */ export declare function lightTraverse(node: any, visitors: Record<string, (node: any) => void>, visited?: Set<any>): void; /** * Builds a map of child nodes to their parent nodes. * @param node The root AST node * @param parent The parent node (null for root) * @returns Map of nodes to their parents */ export declare function buildParentMap(node: any, parent?: any): Map<any, any>; /** * Traverses an AST with parent and grandparent context. * @param ast The AST to traverse * @param visitors Object mapping node types to visitor functions */ export declare function lightTraverseWithParents(ast: any, visitors: Record<string, (node: any, parent: any, grandparent: any) => void>): void;