(name: string, context: ResolutionContext)
| 429 | } |
| 430 | |
| 431 | function 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 | |
| 462 | function resolveHelper(name: string, context: ResolutionContext): string | null { |
| 463 | const snakeName = name.replace(/([A-Z])/g, '_$1').toLowerCase().slice(1); |
no test coverage detected