( importPath: string, fromFile: string, language: Language, context: ResolutionContext )
| 41 | * Resolve an import path to an actual file |
| 42 | */ |
| 43 | export function resolveImportPath( |
| 44 | importPath: string, |
| 45 | fromFile: string, |
| 46 | language: Language, |
| 47 | context: ResolutionContext |
| 48 | ): string | null { |
| 49 | // Skip external/npm packages — but pass the context so the |
| 50 | // bare-specifier heuristic can consult the project's tsconfig |
| 51 | // alias map first (custom prefixes like `@components/*` would |
| 52 | // otherwise be misclassified as npm). |
| 53 | if (isExternalImport(importPath, language, context)) { |
| 54 | return null; |
| 55 | } |
| 56 | |
| 57 | const projectRoot = context.getProjectRoot(); |
| 58 | const fromDir = path.dirname(path.join(projectRoot, fromFile)); |
| 59 | |
| 60 | // Handle relative imports |
| 61 | if (importPath.startsWith('.')) { |
| 62 | return resolveRelativeImport(importPath, fromDir, language, context); |
| 63 | } |
| 64 | |
| 65 | // Handle absolute/aliased imports (like @/ or src/) |
| 66 | const aliased = resolveAliasedImport(importPath, projectRoot, language, context); |
| 67 | if (aliased) return aliased; |
| 68 | |
| 69 | // C/C++ include directory search: when neither relative nor aliased |
| 70 | // resolution found a match, search -I directories from |
| 71 | // compile_commands.json or heuristic probing. |
| 72 | if (language === 'c' || language === 'cpp') { |
| 73 | return resolveCppIncludePath(importPath, language, context); |
| 74 | } |
| 75 | |
| 76 | return null; |
| 77 | } |
| 78 | |
| 79 | /** |
| 80 | * C and C++ standard library header names (without delimiters). |
no test coverage detected