sicua
Version:
A tool for analyzing project structure and dependencies
34 lines (33 loc) • 1.33 kB
TypeScript
import ts from "typescript";
export interface VisitorContext {
sourceFile: ts.SourceFile;
typeChecker?: ts.TypeChecker;
}
export type NodeVisitor<T> = (node: ts.Node, context: VisitorContext) => T | undefined;
export type NodePredicate = (node: ts.Node) => boolean;
export declare class NodeVisitors {
/**
* Creates a visitor that collects nodes matching a predicate
*/
static createCollector<T extends ts.Node>(predicate: (node: ts.Node) => node is T): NodeVisitor<T[]>;
/**
* Creates a visitor that transforms nodes
*/
static createTransformer<T extends ts.Node>(predicate: (node: ts.Node) => node is T, transformer: (node: T) => ts.Node): ts.TransformerFactory<ts.Node>;
/**
* Creates a visitor that analyzes dependencies between nodes
*/
static createDependencyAnalyzer(sourceFile: ts.SourceFile): NodeVisitor<Map<string, Set<string>>>;
/**
* Creates a visitor that builds a control flow graph
*/
static createControlFlowAnalyzer(context: VisitorContext): NodeVisitor<Map<ts.Node, Set<ts.Node>>>;
/**
* Helper to add control flow edges
*/
private static addControlFlow;
/**
* Creates a visitor that analyzes scopes
*/
static createScopeAnalyzer(context: VisitorContext): NodeVisitor<Map<ts.Node, Set<string>>>;
}