MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / resolveCppIncludePath

Function resolveCppIncludePath

src/resolution/import-resolver.ts:686–706  ·  view source on GitHub ↗

* Resolve a C/C++ include path by searching include directories. * Called as a fallback after relative and aliased resolution fail.

(
  importPath: string,
  language: Language,
  context: ResolutionContext
)

Source from the content-addressed store, hash-verified

684 * Called as a fallback after relative and aliased resolution fail.
685 */
686function resolveCppIncludePath(
687 importPath: string,
688 language: Language,
689 context: ResolutionContext
690): string | null {
691 const includeDirs = context.getCppIncludeDirs?.() ?? [];
692 const extensions = EXTENSION_RESOLUTION[language] ?? [];
693
694 for (const dir of includeDirs) {
695 const normalizedDir = dir.replace(/\\/g, '/');
696 for (const ext of extensions) {
697 const candidate = normalizedDir + '/' + importPath + ext;
698 if (context.fileExists(candidate)) return candidate;
699 }
700 // Try as-is (already has extension)
701 const candidate = normalizedDir + '/' + importPath;
702 if (context.fileExists(candidate)) return candidate;
703 }
704
705 return null;
706}
707
708/**
709 * Is this reference a PHP include/require PATH (vs a namespace `use` symbol)?

Callers 1

Calls 2

getCppIncludeDirsMethod · 0.80
fileExistsMethod · 0.80

Tested by

no test coverage detected