/** * Base extractor interface for language-specific code parsing */ import type Parser from 'tree-sitter'; import type { CodeBlock } from '../../types/models.js'; import type { ExtractionResult } from '../types.js'; /** * Base interface for language-specific extractors */ export interface CodeExtractor { /** * Language this extractor handles */ readonly language: string; /** * Extract code blocks from parsed tree */ extract(tree: Parser.Tree, filePath: string, content: string): CodeBlock[]; /** * Get node types that should be extracted */ getTargetNodeTypes(): string[]; } /** * Abstract base class for extractors */ export declare abstract class BaseExtractor implements CodeExtractor { abstract readonly language: string; /** * Extract code blocks from Tree-sitter tree */ extract(tree: Parser.Tree, filePath: string, content: string): CodeBlock[]; /** * Extract information from a single node */ protected abstract extractNode(node: Parser.SyntaxNode, filePath: string, content: string): ExtractionResult | null; /** * Get target node types for extraction */ abstract getTargetNodeTypes(): string[]; /** * Check if a node should be included in extraction * Override this in subclasses to implement custom filtering */ protected shouldIncludeNode(_node: Parser.SyntaxNode): boolean; /** * Create a CodeBlock from extraction result */ protected createCodeBlock(result: ExtractionResult, filePath: string, _content: string): CodeBlock; /** * Generate unique ID for code block */ protected generateId(filePath: string, line: number): string; /** * Get text of a node */ protected getNodeText(node: Parser.SyntaxNode): string; /** * Get node by field name */ protected getChildByFieldName(node: Parser.SyntaxNode, fieldName: string): Parser.SyntaxNode | null; /** * Get children of a specific type */ protected getChildrenOfType(node: Parser.SyntaxNode, type: string): Parser.SyntaxNode[]; /** * Extract name from identifier node */ protected extractName(node: Parser.SyntaxNode | null): string; /** * Check if node has modifier */ protected hasModifier(node: Parser.SyntaxNode, modifier: string): boolean; /** * Extract parameters from parameter list */ protected extractParameters(node: Parser.SyntaxNode | null): string[]; /** * Extract return type if available */ protected extractReturnType(node: Parser.SyntaxNode | null): string | undefined; /** * Extract comments/docstrings */ protected extractComments(node: Parser.SyntaxNode): string | undefined; /** * Calculate approximate code complexity */ protected calculateComplexity(node: Parser.SyntaxNode): number; } //# sourceMappingURL=base.d.ts.map