tree-hugger-js
Version:
A friendly tree-sitter wrapper for JavaScript and TypeScript
44 lines • 1.68 kB
TypeScript
import { TreeHuggerOptions, FunctionInfo, ClassInfo } from './types';
import { TreeNode } from './node-wrapper';
import { Transform } from './transform';
import { ScopeAnalyzer, Visitor, VisitorFunction } from './visitor';
export declare class TreeHugger {
private parser;
private tree;
private sourceCode;
root: TreeNode;
constructor(sourceCode: string, options?: TreeHuggerOptions);
/**
* Robust rootNode getter with retry mechanism to handle race conditions in CI environments
* Addresses the known issue where tree.rootNode can be undefined in concurrent testing scenarios
*/
private getRootNodeWithRetry;
private findFirstError;
find(pattern: string): TreeNode | null;
findAll(pattern: string): TreeNode[];
functions(): TreeNode[];
classes(): TreeNode[];
imports(): TreeNode[];
variables(): TreeNode[];
comments(): TreeNode[];
exports(): TreeNode[];
jsxComponents(): TreeNode[];
jsxProps(componentName?: string): TreeNode[];
hooks(): TreeNode[];
visit(visitor: Visitor | VisitorFunction): void;
analyzeScopes(): ScopeAnalyzer;
nodeAt(line: number, column: number): TreeNode | null;
/**
* Get detailed function information with parameters and body ranges
*/
getFunctionDetails(): FunctionInfo[];
/**
* Get detailed class information with methods and body ranges
*/
getClassDetails(): ClassInfo[];
transform(): Transform;
}
export declare function parse(filenameOrCode: string, options?: TreeHuggerOptions): TreeHugger;
export { TreeNode } from './node-wrapper';
export * from './types';
//# sourceMappingURL=tree-hugger.d.ts.map