/** * Synchronous facade over tree-sitter LanguageAdapter. * * All public functions assert that tree-sitter parsers have been initialized * (entry points MUST call initParsers() first). An uninitialized call is a * programmer error and throws — the adapterBridge is never meant to recover. * * This module replaces the old TypeScript compiler API utils (astParser.ts, * astUtils.ts) with tree-sitter-powered equivalents that work through the * LanguageAdapter interface. */ import type { Node as TreeSitterNode } from 'web-tree-sitter'; import type { AST, ASTNode } from './types.js'; /** * Parse a file synchronously into an AST. * Returns null on failure (no exceptions for parse errors). */ export declare function parseFile(filePath: string, content: string): AST | null; /** * Walk an AST depth-first, calling visitor for each node. */ export declare function walkAST(root: ASTNode, visitor: (node: ASTNode, depth: number) => void, depth?: number): void; /** * Walk a raw TreeSitterNode depth-first. */ export declare function walkRaw(node: TreeSitterNode, visitor: (node: TreeSitterNode) => void): void; /** * Find all ASTNode matching a predicate. */ export declare function findNodes(ast: ASTNode, predicate: (node: ASTNode) => boolean): ASTNode[]; /** * Find all TreeSitterNode matching a predicate. */ export declare function findRawNodes(node: TreeSitterNode, predicate: (node: TreeSitterNode) => boolean): TreeSitterNode[]; /** * Get the source text for an ASTNode given the full source code. */ export declare function getNodeText(node: ASTNode, sourceCode: string): string; /** * Get a 1-based line and column from an ASTNode's start position. */ /** * Return 1-based line and column for an ASTNode. * * toSourceLocation() already converts tree-sitter 0-based positions to 1-based, * so no additional +1 compensation is needed here. Adding one would produce * 2-based values (a double compensation). */ export declare function getLineAndColumn(node: ASTNode): { line: number; column: number; }; /** * Get line and column from a byte position in source. * This is a fallback for when you don't have an ASTNode. */ export declare function positionToLineColumn(sourceCode: string, position: number): { line: number; column: number; }; export declare function isFunctionNode(node: ASTNode): boolean; export declare function isClassNode(node: ASTNode): boolean; export declare function isImportNode(node: ASTNode): boolean; export declare function isLoopNode(node: ASTNode): boolean; export declare function isConditionalNode(node: ASTNode): boolean; export declare function isVariableNode(node: ASTNode): boolean; /** * Check if an ASTNode has a specific keyword modifier. * In tree-sitter, modifiers appear as anonymous child nodes. */ export declare function hasModifier(node: ASTNode, modifier: string): boolean; /** * Check if a node is exported. */ export declare function isExported(node: ASTNode): boolean; /** * Check if a node is async. */ export declare function isAsync(node: ASTNode): boolean; /** * Get the name of an ASTNode if it has one. * For tree-sitter, looks for a `name` property on the raw node, * or finds the first named child that looks like an identifier. */ export declare function getNodeName(node: ASTNode): string | null; /** * Count parameters of a function-like node. */ export declare function getParameterCount(node: ASTNode): number; /** * Calculate cyclomatic complexity by counting decision points. */ export declare function calculateComplexity(node: ASTNode): number; /** * Get the body text of a function-like node. */ export declare function getFunctionBody(node: ASTNode, sourceCode: string): string | undefined; /** * Extract import info from source content. * Uses tree-sitter directly to find import statements. */ export declare function extractImports(filePath: string, content: string): Array<{ moduleSpecifier: string; importedNames: string[]; isDefaultImport: boolean; isNamespaceImport: boolean; line: number; }>; //# sourceMappingURL=adapterBridge.d.ts.map