UNPKG

@wildcard-ai/deepcontext

Version:

Advanced codebase indexing and semantic search MCP server

131 lines 3.81 kB
/** * TreeSitterSymbolExtractor - FULL Tree-sitter AST Implementation * * This is the proper Tree-sitter implementation with real AST parsing, * replacing the regex-based fallback approach with true structural understanding. * * Features: * - Real Tree-sitter parsers for TypeScript/JavaScript * - AST-based scope detection and symbol extraction * - Semantic understanding of code structure * - No regex patterns or manual brace counting */ export interface ExtractedSymbol { name: string; type: 'function' | 'class' | 'interface' | 'type' | 'variable' | 'constant' | 'enum' | 'method'; startLine: number; endLine: number; startColumn: number; endColumn: number; scope: 'local' | 'export' | 'global'; visibility?: 'public' | 'private' | 'protected'; parameters?: string[]; returnType?: string; docstring?: string; } export interface ExtractedImport { module: string; symbols: string[]; isDefault: boolean; isNamespace: boolean; line: number; source: string; } export interface SymbolExtractionResult { symbols: ExtractedSymbol[]; imports: ExtractedImport[]; exports: string[]; docstrings: string[]; scopeGraph: { nodes: any[]; edges: any[]; }; parseErrors: string[]; } export declare class TreeSitterSymbolExtractorFull { private parsers; private initialized; private logger; constructor(); /** * Initialize Tree-sitter parsers with real implementations */ initialize(): Promise<void>; /** * Extract symbols using real Tree-sitter AST parsing with intelligent chunking */ extractSymbols(content: string, language: string, filePath: string): Promise<SymbolExtractionResult>; /** * Parse content directly (for files under 32KB) */ private parseContentDirectly; /** * Parse large content using simple line-based chunking */ private parseContentWithChunking; /** * Fallback: Parse with simple line boundaries */ private parseWithLineBoundaries; /** * CORE: AST Node Traversal with Semantic Understanding */ private traverseASTNode; /** * Process TypeScript/JavaScript AST nodes with semantic understanding */ private processTypeScriptASTNode; /** * CRITICAL: Process variable declarations with AST-based semantic filtering */ private processVariableDeclarationAST; /** * Process Python AST node for symbol extraction */ private processPythonASTNode; private extractPythonFunctionParams; private extractPythonImport; private extractPythonVariableName; private extractPythonDecorators; /** * Helper: Check if we're inside a method/function scope using AST */ private isInMethodScope; /** * Helper: Check if we're inside a class scope (including nested classes) */ private isInClassScope; /** * Helper: Determine if node is exported by checking AST structure */ private isExportedNode; /** * Helper: Get node name from AST structure */ private getNodeName; /** * Helper: Check if variable is semantically meaningful using AST */ private isVariableSemanticalleMeaningful; /** * Helper: Get variable type from AST */ private getVariableTypeFromAST; /** * Helper: Determine scope based on context */ private determineScope; /** * Helper: Process import statements using AST */ private processImportAST; /** * Get extraction statistics */ getStats(): { initialized: boolean; supportedLanguages: string[]; availableParsers: string[]; }; } //# sourceMappingURL=TreeSitterSymbolExtractor.treesitter-based.d.ts.map