tree-hugger-js
Version:
A friendly tree-sitter wrapper for JavaScript and TypeScript
58 lines • 1.89 kB
TypeScript
import { SyntaxNode } from 'tree-sitter';
import { NodeWrapper } from './types';
import { Visitor, VisitorFunction } from './visitor';
export declare class TreeNode implements NodeWrapper {
node: SyntaxNode;
sourceCode: string;
parent?: TreeNode | undefined;
private _children?;
constructor(node: SyntaxNode, sourceCode: string, parent?: TreeNode | undefined);
get text(): string;
get type(): string;
get startPosition(): import("tree-sitter").Point;
get endPosition(): import("tree-sitter").Point;
get children(): TreeNode[];
get line(): number;
get column(): number;
get endLine(): number;
get hasError(): boolean;
get name(): string | undefined;
/**
* Extract parameters from function-like nodes (functions, methods, arrow functions)
*/
extractParameters(): string[];
/**
* Check if this function-like node is async
*/
isAsync(): boolean;
/**
* Get the body range of a function or class
*/
getBodyRange(): {
startLine: number;
endLine: number;
} | null;
find(pattern: string): TreeNode | null;
findAll(pattern: string): TreeNode[];
private findNode;
private findAllNodes;
private parsePattern;
functions(): TreeNode[];
classes(): TreeNode[];
imports(): TreeNode[];
variables(): TreeNode[];
comments(): TreeNode[];
exports(): TreeNode[];
jsxComponents(): TreeNode[];
jsxProps(componentName?: string): TreeNode[];
hooks(): TreeNode[];
getParent(type?: string): TreeNode | null;
siblings(): TreeNode[];
ancestors(): TreeNode[];
descendants(type?: string): TreeNode[];
private getAllDescendants;
visit(visitor: Visitor | VisitorFunction): void;
getPath(): TreeNode[];
nodeAt(line: number, column: number): TreeNode | null;
}
//# sourceMappingURL=node-wrapper.d.ts.map