@ordojs/dev-tools
Version:
Advanced developer tools for OrdoJS with component inspector, AST explorer, and performance profiling
136 lines (132 loc) • 3.38 kB
TypeScript
import { EventEmitter } from 'events';
import { A as ASTNode } from '../index-D9DTurRB.js';
/**
* @fileoverview OrdoJS Dev Tools - AST Explorer
*
* AST explorer for analyzing and visualizing abstract syntax trees.
*/
/**
* AST explorer for analyzing abstract syntax trees
*/
declare class ASTExplorer extends EventEmitter {
private astNodes;
private isRunning;
private port;
/**
* Create a new ASTExplorer instance
*
* @param port - WebSocket port for AST explorer
*/
constructor(port?: number);
/**
* Start the AST explorer
*/
start(): Promise<void>;
/**
* Stop the AST explorer
*/
stop(): Promise<void>;
/**
* Parse source code and create AST
*
* @param sourceCode - Source code to parse
* @param fileName - File name for the AST
* @returns AST root node
*/
parseSourceCode(sourceCode: string, fileName: string): ASTNode;
/**
* Get AST for a file
*
* @param fileName - File name
* @returns AST node or undefined
*/
getAST(fileName: string): ASTNode | undefined;
/**
* Get all ASTs
*
* @returns Map of all ASTs
*/
getAllASTs(): Map<string, ASTNode>;
/**
* Find nodes by type
*
* @param fileName - File name
* @param nodeType - Node type to search for
* @returns Array of matching nodes
*/
findNodesByType(fileName: string, nodeType: string): ASTNode[];
/**
* Find nodes by value
*
* @param fileName - File name
* @param value - Value to search for
* @returns Array of matching nodes
*/
findNodesByValue(fileName: string, value: string): ASTNode[];
/**
* Get node path from root
*
* @param fileName - File name
* @param targetNode - Target node
* @returns Array of nodes from root to target
*/
getNodePath(fileName: string, targetNode: ASTNode): ASTNode[];
/**
* Get AST statistics
*
* @param fileName - File name
* @returns AST statistics
*/
getASTStats(fileName: string): {
totalNodes: number;
nodeTypes: Record<string, number>;
maxDepth: number;
averageDepth: number;
};
/**
* Clear all ASTs
*/
clearASTs(): void;
/**
* Recursively find nodes by type
*
* @param node - Current node
* @param nodeType - Node type to search for
* @returns Array of matching nodes
*/
private findNodesRecursive;
/**
* Recursively find nodes by value
*
* @param node - Current node
* @param value - Value to search for
* @returns Array of matching nodes
*/
private findNodesByValueRecursive;
/**
* Find path from root to target node
*
* @param node - Current node
* @param targetNode - Target node
* @param path - Current path
* @returns Path to target node or empty array
*/
private findNodePath;
/**
* Calculate AST statistics
*
* @param node - Root node
* @param depth - Current depth
* @returns AST statistics
*/
private calculateASTStats;
/**
* Start WebSocket server for AST explorer communication
*/
private startWebSocketServer;
/**
* Stop WebSocket server
*/
private stopWebSocketServer;
}
export { ASTExplorer };