UNPKG

sicua

Version:

A tool for analyzing project structure and dependencies

102 lines (101 loc) 3.98 kB
import ts from "typescript"; /** * Traverses AST nodes depth-first */ export declare function traverseAST(node: ts.Node, callback: (node: ts.Node) => void): void; /** * Visits each child of a node */ export declare function visitEachChild(node: ts.Node, visitor: (node: ts.Node) => void): void; /** * Walks all descendant nodes */ export declare function walkDescendants(node: ts.Node, predicate?: (node: ts.Node) => boolean): ts.Node[]; /** * Traverses with context information */ export declare function traverseWithContext<T>(node: ts.Node, visitor: (node: ts.Node, context: T) => void, context: T): void; /** * Visits nodes of specific kind */ export declare function visitNodesOfKind<T extends ts.Node>(node: ts.Node, kind: ts.SyntaxKind, visitor: (node: T) => void): void; /** * Traverses depth-first with early exit */ export declare function traverseDepthFirst(node: ts.Node, visitor: (node: ts.Node) => boolean | void): boolean; /** * Traverses breadth-first */ export declare function traverseBreadthFirst(node: ts.Node, visitor: (node: ts.Node) => void): void; /** * Visits with callback and collects results */ export declare function visitWithCallback<T>(node: ts.Node, callback: (node: ts.Node) => T | undefined): T[]; /** * Builds a path to a node from its ancestors */ export declare function getNodePath(node: ts.Node): ts.Node[]; /** * Gets the containing function-like declaration */ export declare function getContainingFunction(node: ts.Node): ts.FunctionLikeDeclaration | undefined; /** * Gets the containing block scope */ export declare function getContainingBlock(node: ts.Node): ts.Block | undefined; /** * Gets the source file for a node */ export declare function getSourceFileForNode(node: ts.Node, sourceFiles: Map<string, ts.SourceFile>): ts.SourceFile | undefined; /** * Gets the parent of a specific kind */ export declare function getParentOfKind<T extends ts.Node>(node: ts.Node, kind: ts.SyntaxKind): T | undefined; /** * Gets ancestor at a specific level */ export declare function getAncestor(node: ts.Node, level: number): ts.Node | undefined; /** * Navigates to the root node (SourceFile) */ export declare function navigateToRoot(node: ts.Node): ts.SourceFile; /** * Finds sibling nodes */ export declare function findSiblings(node: ts.Node): ts.Node[]; /** * Finds all nodes matching a predicate in a single file */ export declare function findNodes<T extends ts.Node>(sourceFile: ts.SourceFile, predicate: (node: ts.Node) => node is T): T[]; /** * Finds all nodes matching a specific predicate across all source files */ export declare function findNodesInFiles<T extends ts.Node>(sourceFiles: Map<string, ts.SourceFile>, predicate: (node: ts.Node) => node is T): Map<string, T[]>; /** * Gets the nearest parent matching a predicate */ export declare function findNearestParent<T extends ts.Node>(node: ts.Node, predicate: (node: ts.Node) => node is T): T | undefined; /** * Finds all references to an identifier in a single file */ export declare function findReferences(sourceFile: ts.SourceFile, identifier: string): ts.Identifier[]; /** * Finds all references to an identifier across all files */ export declare function findReferencesInFiles(sourceFiles: Map<string, ts.SourceFile>, identifier: string): Map<string, ts.Identifier[]>; /** * Finds nodes across multiple files with source file context */ export declare function findNodesWithContext<T extends ts.Node>(sourceFiles: Map<string, ts.SourceFile>, predicate: (node: ts.Node) => node is T): Array<{ node: T; sourceFile: ts.SourceFile; filePath: string; }>; /** * Finds a component node in the source file by name */ export declare function findComponentNode(node: ts.Node, componentName: string, typeChecker: ts.TypeChecker): ts.Node | undefined; /** * Gets all identifiers used in a node */ export declare function findIdentifiersInFiles(sourceFiles: Map<string, ts.SourceFile>): Map<string, ts.Identifier[]>;