MCPcopy Create free account
hub / github.com/LegacyCodeHQ/clarity-cli / includeBasePathCandidates

Function includeBasePathCandidates

depgraph/languages/cpp/parser_cpp.go:279–305  ·  view source on GitHub ↗
(sourceDir, includePath string)

Source from the content-addressed store, hash-verified

277}
278
279func includeBasePathCandidates(sourceDir, includePath string) []string {
280 candidates := make(map[string]bool)
281 add := func(p string) {
282 candidates[filepath.Clean(p)] = true
283 }
284
285 // Always try source-relative first.
286 add(filepath.Join(sourceDir, includePath))
287
288 // Also try ancestor roots and common include roots.
289 for dir := sourceDir; ; dir = filepath.Dir(dir) {
290 add(filepath.Join(dir, includePath))
291 add(filepath.Join(dir, "include", includePath))
292
293 parent := filepath.Dir(dir)
294 if parent == dir {
295 break
296 }
297 }
298
299 out := make([]string, 0, len(candidates))
300 for p := range candidates {
301 out = append(out, p)
302 }
303 sort.Strings(out)
304 return out
305}

Callers 1

ResolveCppIncludePathFunction · 0.85

Calls 1

addFunction · 0.85

Tested by

no test coverage detected