( importPath: string, fromFile: string, language: Language, context: ResolutionContext )
| 449 | } |
| 450 | |
| 451 | function resolveImportPathUncached( |
| 452 | importPath: string, |
| 453 | fromFile: string, |
| 454 | language: Language, |
| 455 | context: ResolutionContext |
| 456 | ): string | null { |
| 457 | // COBOL COPY/EXEC SQL INCLUDE names a copybook member, not a path — the |
| 458 | // compiler searches a library, so we match against indexed file basenames. |
| 459 | // Must run before isExternalImport: a bare member name would otherwise be |
| 460 | // misclassified as an external package. |
| 461 | if (language === 'cobol') { |
| 462 | return resolveCobolCopybook(importPath, fromFile, context); |
| 463 | } |
| 464 | |
| 465 | // Skip external/npm packages — but pass the context so the |
| 466 | // bare-specifier heuristic can consult the project's tsconfig |
| 467 | // alias map first (custom prefixes like `@components/*` would |
| 468 | // otherwise be misclassified as npm). What still looks like a package |
| 469 | // may name a file through the importing app's own config. |
| 470 | if (isExternalImport(importPath, language, context, { fromFile })) { |
| 471 | return resolveFromOwnConfig(importPath, fromFile, language, context); |
| 472 | } |
| 473 | |
| 474 | // Python names modules, not paths: one resolver answers relative and |
| 475 | // absolute specifiers alike, so every caller gets the same answer. |
| 476 | if (language === 'python') { |
| 477 | return resolvePythonModule(importPath, fromFile, context); |
| 478 | } |
| 479 | |
| 480 | const projectRoot = context.getProjectRoot(); |
| 481 | const fromDir = path.dirname(path.join(projectRoot, fromFile)); |
| 482 | |
| 483 | // Handle relative imports |
| 484 | if (importPath.startsWith('.')) { |
| 485 | return resolveRelativeImport(importPath, fromDir, language, context); |
| 486 | } |
| 487 | |
| 488 | // Handle absolute/aliased imports (like @/ or src/) |
| 489 | const aliased = resolveAliasedImport(importPath, projectRoot, language, context, fromFile); |
| 490 | if (aliased) return aliased; |
| 491 | |
| 492 | // C/C++ include directory search: when neither relative nor aliased |
| 493 | // resolution found a match, search -I directories from |
| 494 | // compile_commands.json or heuristic probing. |
| 495 | if (language === 'c' || language === 'cpp') { |
| 496 | return resolveCppIncludePath(importPath, language, context); |
| 497 | } |
| 498 | |
| 499 | return null; |
| 500 | } |
| 501 | |
| 502 | /** |
| 503 | * COBOL copybook lookup: `COPY CVACT01Y` (or `EXEC SQL INCLUDE X`) names a |
no test coverage detected