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

Function moduleToFilePaths

frontend/src/edge-resolver.ts:40–67  ·  view source on GitHub ↗

* Convert module notation to file path notation * Handles both Python and JS/TS module imports * e.g., "src.db" → ["src/db.py", "src/db.ts", "src/db.js"] * "src.suggestions.engine" → ["src/suggestions/engine.py", ...]

(moduleNotation: string)

Source from the content-addressed store, hash-verified

38 * "src.suggestions.engine" → ["src/suggestions/engine.py", ...]
39 */
40function moduleToFilePaths(moduleNotation: string): string[] {
41 // Split on :: to separate module from function
42 const parts = moduleNotation.split('::');
43 if (parts.length < 2) return [moduleNotation];
44
45 const modulePath = parts[0];
46 const funcAndRest = parts.slice(1).join('::');
47
48 // Check if it looks like module notation (contains dots but not slashes)
49 // and doesn't already have a file extension
50 if (modulePath.includes('.') && !modulePath.includes('/')) {
51 // Check if last segment looks like a file extension
52 const segments = modulePath.split('.');
53 const lastSegment = segments[segments.length - 1];
54 // Check against known extensions (without leading dot)
55 const knownExtensions = SUPPORTED_EXTENSIONS.map(e => e.slice(1));
56 const hasExtension = knownExtensions.includes(lastSegment);
57
58 if (!hasExtension) {
59 // Convert dots to slashes and try multiple extensions
60 const basePath = modulePath.replace(/\./g, '/');
61 const extensions = [...SUPPORTED_EXTENSIONS, ''];
62 return extensions.map(ext => `${basePath}${ext}::${funcAndRest}`);
63 }
64 }
65
66 return [moduleNotation];
67}
68
69/**
70 * Build lookup map from nodes with multiple matching strategies

Callers 1

findMatchingNodeIdFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected