MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / resolveHandlerName

Function resolveHandlerName

src/resolution/frameworks/python.ts:164–180  ·  view source on GitHub ↗

* Parse a Django URL handler expression and return the symbol/module to link. * Returns null for shapes we can't confidently link (e.g. lambdas).

(expr: string)

Source from the content-addressed store, hash-verified

162 * Returns null for shapes we can't confidently link (e.g. lambdas).
163 */
164function resolveHandlerName(expr: string): { name: string; kind: 'references' | 'imports' } | null {
165 // include('module.path')
166 const includeMatch = expr.match(/^include\s*\(\s*['"]([^'"]+)['"]/);
167 if (includeMatch) return { name: includeMatch[1]!, kind: 'imports' };
168
169 // Strip trailing .as_view(...) or .as_view()
170 let head = expr.replace(/\.as_view\s*\([^)]*\)\s*$/, '');
171 // Drop any other trailing method call
172 head = head.replace(/\.\w+\s*\([^)]*\)\s*$/, '');
173
174 const dotted = head.split('.').filter(Boolean);
175 if (dotted.length === 0) return null;
176 const last = dotted[dotted.length - 1]!;
177 if (!/^[A-Za-z_][A-Za-z0-9_]*$/.test(last)) return null;
178
179 return { name: last, kind: 'references' };
180}
181
182export const flaskResolver: FrameworkResolver = {
183 name: 'flask',

Callers 1

extractFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected