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

Function resolveCppIncludePath

src/resolution/import-resolver.ts:685–705  ·  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

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