/** * File parsing using tree-sitter * Converts source code into ASTs for analysis */ import type { SyntaxNode } from 'tree-sitter'; import { Language, ParseResult } from './types.js'; export declare class UnsupportedLanguageError extends Error { constructor(language: Language); } export declare class ParseError extends Error { constructor(filePath: string, message: string); } /** * Parse source code with a given language */ export declare function parseSource(source: Buffer | string, language: Language, filePath?: string): Promise; /** * Parse a file from disk */ export declare function parseFile(filePath: string): Promise; /** * Check if a file can be parsed (language is supported) */ export declare function canParseFile(filePath: string): boolean; /** * Try to parse a file, returning null instead of throwing on error */ export declare function tryParseFile(filePath: string): Promise; /** * Pre-order tree traversal callback type */ export type NodeVisitor = (node: SyntaxNode) => void; /** * Walk the AST in pre-order (parent before children) */ export declare function walkTree(node: SyntaxNode, visitor: NodeVisitor): void; /** * Walk the AST with enter/leave callbacks */ export interface TreeWalker { onEnterNode?: (node: SyntaxNode) => void; onLeaveNode?: (node: SyntaxNode) => void; } export declare function walkTreeWithCallbacks(node: SyntaxNode, walker: TreeWalker): void; /** * Get all children with a specific field name */ export declare function childrenWithFieldName(node: SyntaxNode, fieldName: string): SyntaxNode[]; /** * Get child by field name (first match) */ export declare function childWithFieldName(node: SyntaxNode, fieldName: string): SyntaxNode | null; /** * Get all children of a specific type */ export declare function childrenOfType(node: SyntaxNode, type: string): SyntaxNode[]; /** * Get first child of a specific type */ export declare function firstChildOfType(node: SyntaxNode, type: string): SyntaxNode | null; /** * Find first matching child using a predicate */ export declare function findMatchingChild(node: SyntaxNode, predicate: (node: SyntaxNode) => boolean): SyntaxNode | null; /** * Find all nodes matching a predicate (depth-first) */ export declare function findAllNodes(node: SyntaxNode, predicate: (node: SyntaxNode) => boolean): SyntaxNode[]; /** * Get node text content */ export declare function getNodeText(node: SyntaxNode, source: Buffer): string; //# sourceMappingURL=parser.d.ts.map