The file the `$this->load->view('users/list')` on this line loads: the caller's module's, another module's, or the app's.
(ref: UnresolvedRef, context: ResolutionContext)
| 231 | |
| 232 | /** The file the `$this->load->view('users/list')` on this line loads: the caller's module's, another module's, or the app's. */ |
| 233 | function viewFile(ref: UnresolvedRef, context: ResolutionContext): Node | null { |
| 234 | const line = context.getFileLines?.(ref.filePath)?.[ref.line - 1]; |
| 235 | const view = line ? VIEW_RE.exec(line)?.[1] : undefined; |
| 236 | if (!view) return null; |
| 237 | const file = /\.\w+$/.test(view) ? view : `${view}.php`; |
| 238 | const root = ref.filePath.slice(0, Math.max(ref.filePath.indexOf('application/'), 0)); |
| 239 | const module = MODULE_OF.exec(ref.filePath); |
| 240 | const modules = module ? ref.filePath.slice(0, module.index + module[0].length - module[1]!.length - 1) : `${root}application/modules/`; |
| 241 | const slash = file.indexOf('/'); |
| 242 | const candidates = [ |
| 243 | ...(module ? [`${modules}${module[1]}/views/${file}`] : []), |
| 244 | ...(slash > 0 ? [`${modules}${file.slice(0, slash)}/views/${file.slice(slash + 1)}`] : []), |
| 245 | `${root}application/views/${file}`, |
| 246 | ]; |
| 247 | for (const candidate of candidates) { |
| 248 | const node = context.getNodesInFile(candidate).find((n) => n.kind === 'file'); |
| 249 | if (node) return node; |
| 250 | } |
| 251 | return null; |
| 252 | } |
| 253 | |
| 254 | function aliasesIn(file: string, table: ClassTable, context: ResolutionContext): Map<string, string> { |
| 255 | const known = table.aliases.get(file); |
no test coverage detected