MCPcopy Create free account
hub / github.com/codag-megalith/codag-visualizer / extractFileStructure

Function extractFileStructure

frontend/src/repo-structure.ts:310–326  ·  view source on GitHub ↗
(code: string, filePath: string)

Source from the content-addressed store, hash-verified

308 * Extract structure from a single file using tree-sitter
309 */
310export 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.

Callers 2

updateCrossFileStateFunction · 0.90
extractRepoStructureFunction · 0.85

Calls 7

toFileStructureFunction · 0.85
getLanguageForFileMethod · 0.80
isAvailableMethod · 0.80
parseMethod · 0.80
getMethod · 0.45
deleteMethod · 0.45

Tested by

no test coverage detected