(code: string, filePath: string)
| 308 | * Extract structure from a single file using tree-sitter |
| 309 | */ |
| 310 | export function extractFileStructure(code: string, filePath: string): FileStructure { |
| 311 | const language = ParserManager.getLanguageForFile(filePath); |
| 312 | if (!language || !ParserManager.isAvailable()) { |
| 313 | return { path: filePath, functions: [], exports: [], imports: [], httpRouteHandlers: [] }; |
| 314 | } |
| 315 | |
| 316 | try { |
| 317 | const manager = ParserManager.get(); |
| 318 | const tree = manager.parse(code, language, filePath); |
| 319 | const result = extractFileStructureFromTree(tree, language, filePath); |
| 320 | tree.delete(); |
| 321 | return toFileStructure(filePath, result); |
| 322 | } catch (error) { |
| 323 | console.warn(`Failed to parse ${filePath}:`, error); |
| 324 | return { path: filePath, functions: [], exports: [], imports: [], httpRouteHandlers: [] }; |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | /** |
| 329 | * Propagate LLM call flags transitively through the call graph. |
no test coverage detected