(name: string, context: ResolutionContext)
| 399 | } |
| 400 | |
| 401 | function resolveModel(name: string, context: ResolutionContext): string | null { |
| 402 | // Try direct file path lookup first (Rails convention: CamelCase -> snake_case.rb) |
| 403 | const snakeName = name.replace(/([A-Z])/g, '_$1').toLowerCase().slice(1); |
| 404 | const possiblePaths = [ |
| 405 | `app/models/${snakeName}.rb`, |
| 406 | `app/models/concerns/${snakeName}.rb`, |
| 407 | ]; |
| 408 | |
| 409 | for (const modelPath of possiblePaths) { |
| 410 | if (context.fileExists(modelPath)) { |
| 411 | const nodes = context.getNodesInFile(modelPath); |
| 412 | const modelNode = nodes.find( |
| 413 | (n) => n.kind === 'class' && n.name === name |
| 414 | ); |
| 415 | if (modelNode) { |
| 416 | return modelNode.id; |
| 417 | } |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | // Fall back to name-based lookup |
| 422 | const candidates = context.getNodesByName(name); |
| 423 | const modelNode = candidates.find( |
| 424 | (n) => n.kind === 'class' && n.filePath.includes('app/models/') |
| 425 | ); |
| 426 | if (modelNode) return modelNode.id; |
| 427 | |
| 428 | return null; |
| 429 | } |
| 430 | |
| 431 | function resolveController(name: string, context: ResolutionContext): string | null { |
| 432 | // Try direct file path lookup first |
no test coverage detected