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

Function resolveHandlerName

src/resolution/frameworks/python.ts:163–179  ·  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

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

Callers 1

extractFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected