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

Function resolveController

src/resolution/frameworks/ruby.ts:431–460  ·  view source on GitHub ↗
(name: string, context: ResolutionContext)

Source from the content-addressed store, hash-verified

429}
430
431function resolveController(name: string, context: ResolutionContext): string | null {
432 // Try direct file path lookup first
433 const snakeName = name.replace(/([A-Z])/g, '_$1').toLowerCase().slice(1);
434 const possiblePaths = [
435 `app/controllers/${snakeName}.rb`,
436 `app/controllers/api/${snakeName}.rb`,
437 `app/controllers/api/v1/${snakeName}.rb`,
438 ];
439
440 for (const controllerPath of possiblePaths) {
441 if (context.fileExists(controllerPath)) {
442 const nodes = context.getNodesInFile(controllerPath);
443 const controllerNode = nodes.find(
444 (n) => n.kind === 'class' && n.name === name
445 );
446 if (controllerNode) {
447 return controllerNode.id;
448 }
449 }
450 }
451
452 // Fall back to name-based lookup
453 const candidates = context.getNodesByName(name);
454 const controllerNode = candidates.find(
455 (n) => n.kind === 'class' && n.filePath.includes('controllers/')
456 );
457 if (controllerNode) return controllerNode.id;
458
459 return null;
460}
461
462function resolveHelper(name: string, context: ResolutionContext): string | null {
463 const snakeName = name.replace(/([A-Z])/g, '_$1').toLowerCase().slice(1);

Callers 1

resolveFunction · 0.85

Calls 3

fileExistsMethod · 0.80
getNodesInFileMethod · 0.65
getNodesByNameMethod · 0.65

Tested by

no test coverage detected